:root {
  --bg: #0a0f1a;
  --surface: #111827;
  --surface-2: #182132;
  --border: #1f2937;
  --border-light: #374151;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --text-1: #f9fafb;
  --text-2: #9ca3af;
  --text-3: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 700px at 50% -200px, #1e293b 0%, var(--bg) 50%);
  color: var(--text-1);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.app-shell {
  width: min(1100px, 92vw);
  margin: 18px auto 96px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  font-size: clamp(1.3rem, 2.2vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.status-pill {
  border: 1px solid var(--border-light);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.78rem;
  white-space: nowrap;
}

.page-content {
  display: grid;
  gap: 14px;
}

.panel {
  background: linear-gradient(180deg, rgba(24, 33, 50, 0.86), rgba(17, 24, 39, 0.96));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.stack-md {
  display: grid;
  gap: 14px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two-col {
  grid-template-columns: 1fr;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
}

.field-hint {
  color: var(--text-3);
  font-size: 0.76rem;
  margin: 0;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: #0c1320;
  color: var(--text-1);
  padding: 0.74rem 0.85rem;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border-light);
  background: #0c1320;
  color: var(--text-2);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text-1);
}

.chip.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--accent);
  color: #c7d2fe;
}

.auto-detected-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.13);
}

.collapsible-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  background: transparent;
  color: var(--text-2);
  border: 0;
  padding: 0;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.collapsible-trigger .icon {
  transition: transform 0.2s ease;
}

.collapsible-trigger.open .icon {
  transform: rotate(180deg);
}

.collapsible-content {
  display: none;
}

.collapsible-content.open {
  display: block;
}

.metrics-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-input {
  display: grid;
  gap: 6px;
}

.metric-input label {
  font-size: 0.78rem;
  color: var(--text-2);
}

.btn-primary,
.btn-secondary {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: #0c1320;
  color: var(--text-2);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-1);
}

.btn-full {
  width: 100%;
}

.posts-list,
.insight-list,
.followups-list {
  display: grid;
  gap: 8px;
}

.post-item {
  border: 1px solid var(--border);
  background: #0d1525;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.post-item-info {
  display: grid;
  gap: 2px;
}

.post-item-date {
  font-size: 0.82rem;
  font-weight: 600;
}

.post-item-details {
  font-size: 0.74rem;
  color: var(--text-2);
}

.post-item-er {
  font-size: 0.82rem;
  font-weight: 700;
}

.post-item-er.good {
  color: var(--success);
}

.post-item-er.warning {
  color: var(--warning);
}

.post-item-er.bad {
  color: var(--danger);
}

.period-selector {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.period-btn {
  border: 1px solid var(--border-light);
  background: #0c1320;
  color: var(--text-2);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.42rem 0.72rem;
  cursor: pointer;
}

.period-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  border: 1px solid var(--border);
  background: #0d1525;
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.metric-label {
  color: var(--text-2);
  font-size: 0.76rem;
  font-weight: 600;
}

.metric-value {
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1;
}

.metric-value.accent {
  background: linear-gradient(120deg, #a5b4fc, #f9a8d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 120px) 1fr minmax(54px, 70px);
  gap: 8px;
  align-items: center;
}

.bar-label {
  font-size: 0.78rem;
  color: var(--text-2);
}

.bar-track {
  height: 18px;
  border-radius: 999px;
  background: #0b1220;
  position: relative;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bar-fill.total {
  opacity: 0.38;
}

.bar-fill.active {
  opacity: 0.88;
}

.bar-value {
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-1);
  font-weight: 600;
}

.legend {
  display: inline-flex;
  gap: 12px;
  color: var(--text-2);
  font-size: 0.74rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.total {
  background: #7c83ff;
  opacity: 0.42;
}

.legend-dot.active {
  background: #7c83ff;
}

.recommendations {
  display: grid;
  gap: 8px;
}

.rec-item {
  border: 1px solid var(--border);
  background: #0d1525;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.83rem;
  color: var(--text-1);
}

.two-col {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.growth-section {
  display: grid;
  gap: 10px;
}

.growth-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #0d1525;
}

.growth-group h4 {
  margin: 0 0 8px;
  color: var(--text-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.growth-item {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}

.growth-item:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.growth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.growth-name {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: capitalize;
}

.growth-count {
  color: var(--text-3);
  font-size: 0.72rem;
}

.growth-points {
  display: grid;
  gap: 5px;
}

.growth-point {
  display: grid;
  grid-template-columns: 34px 1fr 64px 56px;
  align-items: center;
  gap: 7px;
}

.growth-hours,
.growth-views,
.growth-change {
  font-size: 0.72rem;
}

.growth-hours,
.growth-change {
  color: var(--text-2);
}

.growth-bar-wrapper {
  height: 12px;
  border-radius: 999px;
  background: #0b1220;
  overflow: hidden;
}

.growth-bar {
  height: 100%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.growth-views {
  text-align: right;
  color: var(--text-1);
}

.growth-change.positive {
  color: var(--success);
}

.growth-change.neutral {
  color: var(--warning);
}

.growth-change.stagnant {
  color: var(--danger);
}

.growth-verdict {
  margin-top: 6px;
  font-size: 0.73rem;
  font-weight: 700;
}

.verdict-good {
  color: var(--success);
}

.verdict-neutral {
  color: var(--warning);
}

.verdict-bad {
  color: var(--danger);
}

.empty-growth,
.empty-state {
  border: 1px dashed var(--border-light);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  color: var(--text-2);
}

.empty-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
}

.empty-text {
  margin: 0;
  font-size: 0.84rem;
}

.follow-up-card {
  border: 1px solid var(--border);
  background: #0d1525;
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.follow-up-card.overdue {
  border-color: rgba(239, 68, 68, 0.65);
}

.follow-up-card.today {
  border-color: rgba(245, 158, 11, 0.65);
}

.follow-up-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.follow-up-hours {
  font-size: 0.74rem;
  color: var(--text-2);
  font-weight: 700;
}

.follow-up-date {
  color: var(--text-3);
  font-size: 0.72rem;
}

.urgency-badge {
  font-size: 0.66rem;
  border-radius: 999px;
  padding: 3px 7px;
  border: 1px solid;
}

.urgency-badge.overdue {
  color: #fda4af;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

.urgency-badge.today {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.follow-up-post-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.format-pill,
.pillar-pill,
.platform-pill {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  color: var(--text-2);
}

.follow-up-description {
  margin: 0;
  color: var(--text-1);
  font-size: 0.84rem;
}

.post-url {
  font-size: 0.76rem;
  color: #a5b4fc;
}

.post-url:hover {
  text-decoration: underline;
}

.follow-up-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.follow-up-actions {
  display: flex;
  gap: 8px;
}

.insight-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.84rem;
}

.insight-item.success {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}

.insight-item.warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}

.insight-item.info {
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.08);
}

.muted-text {
  color: var(--text-2);
  font-size: 0.86rem;
  line-height: 1.45;
  margin-top: 0;
}

.active-stats {
  display: grid;
  gap: 8px;
}

.pillar-stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #0d1525;
}

.pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pillar-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.pillar-ratio {
  font-size: 0.74rem;
  font-weight: 700;
}

.pillar-ratio.high {
  color: var(--success);
}

.pillar-ratio.medium {
  color: var(--warning);
}

.pillar-ratio.low {
  color: var(--danger);
}

.pillar-bar {
  height: 8px;
  background: #0b1220;
  border-radius: 999px;
  overflow: hidden;
}

.pillar-bar-active {
  height: 100%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.pillar-details {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  color: var(--text-2);
  font-size: 0.74rem;
}

.plan-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.plan-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  background: #0d1525;
  border-radius: 10px;
  padding: 9px;
}

.plan-number {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.plan-content {
  font-size: 0.84rem;
  color: var(--text-1);
}

.export-panel {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.month-selector {
  display: grid;
  gap: 6px;
}

.month-selector label {
  font-size: 0.74rem;
  color: var(--text-2);
}

.month-selector.compact {
  min-width: 170px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: min(1100px, 92vw);
  background: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 30;
}

.nav-item {
  position: relative;
  padding: 10px 6px;
  display: grid;
  place-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 12px;
}

.nav-item.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.18);
}

.nav-item .icon {
  width: 17px;
  height: 17px;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 18px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #111827;
  color: #fff;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, #111827 0%, #1f2937 50%, #111827 100%);
  background-size: 220% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
}

.skeleton-row {
  height: 40px;
}

.skeleton-card {
  height: 140px;
}

@keyframes skeleton {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -20% 0;
  }
}

.error-message {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.84rem;
}

@media (min-width: 768px) {
  .app-shell {
    margin-top: 26px;
    margin-bottom: 110px;
  }

  .panel {
    padding: 18px;
  }

  .form-grid.two-col,
  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-grid,
  .follow-up-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stats-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .period-selector {
    width: 100%;
  }

  .period-btn {
    flex: 1;
    text-align: center;
  }

  .stats-grid.three {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .bar-label,
  .bar-value {
    font-size: 0.75rem;
    text-align: left;
  }

  .growth-point {
    grid-template-columns: 36px 1fr 56px;
  }

  .growth-change {
    display: none;
  }

  .export-panel {
    flex-direction: column;
  }
}
