/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #202035;
  --bg-card: #252540;
  --bg-hover: #2d2d4a;
  --bg-input: #1e1e32;
  --border: #333355;
  --border-light: #2a2a48;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #5f6368;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-dim: rgba(138,180,248,0.15);
  --green: #81c995;
  --green-dim: rgba(129,201,149,0.15);
  --red: #f28b82;
  --red-dim: rgba(242,139,130,0.15);
  --yellow: #fdd663;
  --chart-line: #8ab4f8;
  --chart-fill: rgba(138,180,248,0.15);
  --chart-point-bg: #202035;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Google Sans', 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top Navigation Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-left h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.topbar-center { flex: 1; display: flex; justify-content: center; }

.business-switcher select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 32px 8px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='%239aa0a6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 260px;
}
.business-switcher select:focus {
  outline: none;
  border-color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
  padding: 40px;
}
.empty-icon { margin-bottom: 24px; opacity: 0.6; }
.empty-state h2 {
  font-size: 24px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.empty-state p {
  color: var(--text-muted);
  margin-bottom: 8px;
  font-size: 15px;
}
.empty-steps {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Dashboard Main ── */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Dashboard Header ── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.dash-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-header h2 {
  font-size: 22px;
  font-weight: 400;
}
.back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  transition: all 0.15s;
}
.back-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Date Picker ── */
.date-picker-wrap { position: relative; }

.date-picker-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
}
.date-picker-btn:hover { border-color: var(--accent); }
.date-picker-btn .chevron { transition: transform 0.2s; }
.date-picker-btn.open .chevron { transform: rotate(180deg); }

.date-picker-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  z-index: 50;
  display: none;
  min-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.date-picker-dropdown.open { display: block; }

.date-picker-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.dp-month-btn {
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
}
.dp-month-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dp-month-btn.selected {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}
.dp-month-btn.in-range {
  background: var(--accent-dim);
  color: var(--accent);
}
.dp-month-btn.has-data::after {
  content: '';
  display: block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--green);
  margin: 3px auto 0;
}
.dp-month-btn.no-data { opacity: 0.4; }

.dp-year-label {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0 4px;
  text-align: center;
}

.date-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.dp-btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.dp-cancel { background: var(--bg-input); color: var(--text-secondary); }
.dp-cancel:hover { background: var(--bg-hover); }
.dp-apply { background: var(--accent); color: var(--bg-primary); }
.dp-apply:hover { background: var(--accent-hover); }

/* ── Metric Tabs ── */
.metric-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.metric-tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.metric-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.metric-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Stats Cards ── */
.stats-section {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  flex: 1;
  min-width: 280px;
}

.stat-number {
  font-size: 56px;
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 8px;
}

.stat-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-yoy {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.stat-yoy.positive { color: var(--green); }
.stat-yoy.positive .yoy-arrow { fill: var(--green); }
.stat-yoy.negative { color: var(--red); }
.stat-yoy.negative .yoy-arrow {
  fill: var(--red);
  transform: rotate(180deg) scaleX(-1);
}

/* ── Compare Card ── */
.stat-card.compare {
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 340px;
}
.compare-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}
.compare-period-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
.compare-body {
  display: flex;
  align-items: center;
  gap: 16px;
}
.compare-col { text-align: center; flex: 1; }
.compare-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.compare-value { font-size: 28px; font-weight: 400; }
.compare-arrow { color: var(--text-muted); }
.compare-change {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}
.compare-change .positive { color: var(--green); }
.compare-change .negative { color: var(--red); }
.compare-change .neutral { color: var(--text-muted); }

/* ── Missing comparison data hint ── */
.missing-data-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.missing-data-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--yellow);
}
.missing-data-months {
  font-size: 12px;
  color: var(--text-secondary);
}
.missing-data-tip {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.5;
}
.missing-data-tip strong { color: var(--accent); }

/* ── Compare Toggle ── */
.compare-toggle {
  margin-bottom: 20px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
}
.toggle-label input { display: none; }
.toggle-slider {
  width: 36px; height: 20px;
  background: var(--bg-hover);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  top: 2px; left: 2px;
  transition: all 0.2s;
}
.toggle-label input:checked + .toggle-slider { background: var(--accent-dim); }
.toggle-label input:checked + .toggle-slider::after {
  background: var(--accent);
  transform: translateX(16px);
}

/* ── Chart ── */
.chart-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart-svg {
  width: 100%;
  min-width: 600px;
  height: 320px;
}

/* SVG chart styles */
.chart-svg .grid-line {
  stroke: var(--border-light);
  stroke-dasharray: 3, 3;
}
.chart-svg .axis-line { stroke: var(--border); }
.chart-svg .axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: 'Google Sans', 'Segoe UI', Roboto, sans-serif;
}
.chart-svg .y-label {
  fill: var(--text-secondary);
  font-size: 11px;
  font-family: 'Google Sans', 'Segoe UI', Roboto, sans-serif;
}
.chart-svg .y-label-bg {
  fill: var(--bg-card);
  rx: 10;
}
.chart-svg .chart-area { fill: var(--chart-fill); }
.chart-svg .chart-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 2;
}
.chart-svg .chart-point {
  fill: var(--chart-point-bg);
  stroke: var(--chart-line);
  stroke-width: 2;
}
.chart-svg .chart-point:hover {
  r: 8;
  stroke-width: 3;
}
.chart-svg .chart-line-derived {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 2;
  stroke-dasharray: 8, 4;
  opacity: 0.65;
}
.chart-svg .chart-point-derived {
  fill: var(--chart-point-bg);
  stroke: var(--yellow);
  stroke-width: 2;
}
.chart-svg .compare-line {
  fill: none;
  stroke: var(--yellow);
  stroke-width: 2;
  stroke-dasharray: 6, 4;
}
.chart-svg .compare-point {
  fill: var(--chart-point-bg);
  stroke: var(--yellow);
  stroke-width: 2;
}
.chart-svg .compare-area {
  fill: rgba(253, 214, 99, 0.08);
}
.chart-svg .tooltip-bg {
  fill: #303040;
  rx: 6;
  stroke: var(--border);
}
.chart-svg .tooltip-text {
  fill: var(--text-primary);
  font-size: 12px;
  font-family: 'Google Sans', 'Segoe UI', Roboto, sans-serif;
}

.chart-no-data {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Coverage Grid ── */
.coverage-section {
  margin-bottom: 24px;
}
.coverage-section h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 6px;
}
.coverage-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
}

.cov-cell {
  aspect-ratio: 1.8;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.cov-cell:hover { border-color: var(--accent); transform: scale(1.05); }
.cov-cell.has-data {
  background: var(--green-dim);
  color: var(--green);
}
.cov-cell.derived-data {
  background: rgba(253,214,99,0.12);
  color: var(--yellow);
  border-style: dashed;
  border-color: rgba(253,214,99,0.35);
}
.cov-cell.no-data {
  background: var(--bg-card);
  color: var(--text-muted);
}
.cov-cell.current {
  border-color: var(--accent);
}
.cov-month { font-weight: 600; font-size: 11px; }
.cov-year { font-size: 9px; opacity: 0.7; }

/* ── Data Table ── */
.table-section {
  margin-bottom: 24px;
}
.table-section h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
}
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
td { font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.td-bar {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}
.td-bar-derived {
  background: var(--yellow);
  opacity: 0.6;
}

/* ── Derived / estimated data badge ── */
.derived-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(253,214,99,0.15);
  border: 1px solid rgba(253,214,99,0.4);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  letter-spacing: 0.03em;
  cursor: help;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Business Switcher Enhancements ── */
.business-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Date Picker Presets ── */
.dp-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.dp-preset-btn {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.dp-preset-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }

/* ── Date Picker Hint ── */
.dp-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 10px;
  text-align: center;
}
.dp-hint strong { color: var(--accent); }

/* ── Date Picker scroll ── */
.date-picker-months {
  max-height: 280px;
  overflow-y: auto;
}
.date-picker-months::-webkit-scrollbar { width: 6px; }
.date-picker-months::-webkit-scrollbar-track { background: var(--bg-input); border-radius: 3px; }
.date-picker-months::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.dp-clear { background: var(--bg-input); color: var(--text-muted); margin-right: auto; }
.dp-clear:hover { background: var(--red-dim); color: var(--red); }

/* ── Date picker larger dropdown ── */
.date-picker-dropdown { min-width: 480px; }

/* ── Business Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}
.modal-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.modal-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-muted); }
.modal-footer {
  display: flex;
  align-items: center;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.modal-delete-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--red);
  cursor: pointer;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}
.modal-delete-btn:hover { background: var(--red); color: #fff; }

/* ── Sync Status ── */
.sync-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.sync-status {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.sync-status.up-to-date { color: var(--green); }
.sync-status.outdated   { color: var(--yellow); }
.sync-btn { border: none !important; }
.sync-btn:hover { background: var(--bg-hover) !important; }
.sync-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Compare Bar ── */
.compare-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.compare-modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cmp-mode-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.cmp-mode-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cmp-mode-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}
.compare-month-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.compare-month-select:focus { outline: none; border-color: var(--accent); }

/* ── AI Insights Section ── */
.insights-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.insights-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.insights-title h3 {
  font-size: 16px;
  font-weight: 500;
}
.insights-badge {
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.insight-card {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border-left: 3px solid transparent;
  background: var(--bg-secondary);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.insight-card.positive { border-left-color: var(--green); }
.insight-card.warning  { border-left-color: var(--yellow); }
.insight-card.info     { border-left-color: var(--accent); }
.insight-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.insight-icon { font-size: 18px; line-height: 1; }
.insight-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.insight-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.insight-action {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}
.insights-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
  grid-column: 1/-1;
}

/* ── Performance Funnel Card ── */
.funnel-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.funnel-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.funnel-step {
  display: flex;
  align-items: center;
  gap: 12px;
}
.funnel-step-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.funnel-step-info {
  min-width: 280px;
  flex-shrink: 0;
}
.funnel-step-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.funnel-step-rate {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.funnel-step-bar-wrap {
  flex: 1;
  height: 10px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
}
.funnel-step-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
  min-width: 3px;
}
.funnel-step-value {
  font-size: 18px;
  font-weight: 600;
  min-width: 80px;
  text-align: right;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .funnel-step-info { min-width: 160px; }
}

/* ── Discovery Section (Platform + Search Terms) ── */
.discovery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 860px) { .discovery-grid { grid-template-columns: 1fr; } }

.discovery-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}
.discovery-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.discovery-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Platform bars */
.platform-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.platform-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.platform-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 160px;
}
.platform-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}
.platform-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.platform-count {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 54px;
  text-align: right;
}
.platform-pct {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}

/* Search term rows */
.term-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}
.term-row:last-child { border-bottom: none; }
.term-rank {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 18px;
  text-align: right;
}
.term-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}
.term-bar-wrap {
  width: 80px;
  height: 5px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.term-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.term-count {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}
.discovery-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
}

/* ── Sync Help Modal Steps ── */
.sync-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.sync-step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  margin-top: 1px;
}
.sync-step strong { color: var(--text-primary); }

/* ── Cloud Sync Button ── */
.cloud-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.cloud-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}
.cloud-btn.connected {
  color: var(--green);
  border-color: rgba(129,201,149,0.4);
  background: var(--green-dim);
}
.cloud-btn.syncing svg {
  animation: spin 1s linear infinite;
}

/* ── Cloud Sync Modal ── */
.cloud-modal { width: 540px; max-width: calc(100vw - 40px); }

.cloud-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.cloud-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.cloud-status-banner.ok      { background: var(--green-dim); border-color: rgba(129,201,149,0.3); color: var(--green); }
.cloud-status-banner.error   { background: var(--red-dim);   border-color: rgba(242,139,130,0.3); color: var(--red); }
.cloud-status-banner.warning { background: rgba(253,214,99,0.1); border-color: rgba(253,214,99,0.3); color: var(--yellow); }

.cloud-info-box {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.cloud-info-box strong { color: var(--text-primary); display: block; margin-bottom: 6px; }
.cloud-info-box ul { padding-left: 16px; }
.cloud-info-box li { margin-bottom: 3px; }
.cloud-info-box code {
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent);
}

.cloud-key-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cloud-key-wrap .modal-input { flex: 1; }
.cloud-eye-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.cloud-eye-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.cloud-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  user-select: none;
}
.cloud-toggle-row input { display: none; }

/* Test connection result */
.cloud-test-result {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
}
.cloud-test-result.ok    { background: var(--green-dim); color: var(--green); border: 1px solid rgba(129,201,149,0.3); }
.cloud-test-result.error { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(242,139,130,0.3); }

.cloud-server-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cloud-stat-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.cloud-stat-chip strong { color: var(--text-primary); display: block; font-size: 18px; font-weight: 400; }

.cloud-modal-footer {
  display: flex;
  align-items: center;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.cloud-test-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}
.cloud-test-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.cloud-test-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cloud-pull-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid rgba(138,180,248,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}
.cloud-pull-btn:hover { background: var(--accent); color: var(--bg-primary); }
.cloud-pull-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sync status in the topbar (shown when a business is selected) */
.server-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  margin-right: 4px;
  flex-shrink: 0;
}
.server-sync-dot.ok      { background: var(--green); }
.server-sync-dot.syncing { background: var(--yellow); animation: pulse 1s ease-in-out infinite; }
.server-sync-dot.error   { background: var(--red); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Report Button ── */
.report-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bg-primary);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.report-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 10px rgba(138,180,248,0.35);
  transform: translateY(-1px);
}
.report-btn:active {
  opacity: 0.85;
  transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .topbar-center { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .business-switcher select { min-width: 100%; }
  .dashboard { padding: 16px; }
  .stat-number { font-size: 40px; }
  .date-picker-dropdown { min-width: 320px; right: -60px; }
  .date-picker-months { grid-template-columns: repeat(3, 1fr); }
  .coverage-grid { grid-template-columns: repeat(6, 1fr); }
  .metric-tabs { gap: 0; }
  .metric-tab { padding: 10px 14px; font-size: 13px; }
}
