/* =============================================================================
   DASHWOO — Shared Design System
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  --bg:          #0d0f14;
  --surface:     #13161e;
  --surface2:    #1a1e28;
  --surface3:    #202532;
  --border:      #252a38;
  --border2:     #2e3449;

  --accent:      #4f9eff;
  --accent-dim:  rgba(79,158,255,0.12);
  --accent2:     #7c3aed;
  --accent2-dim: rgba(124,58,237,0.12);

  --green:       #22c55e;
  --green-dim:   rgba(34,197,94,0.12);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,0.12);
  --orange:      #f59e0b;
  --orange-dim:  rgba(245,158,11,0.12);

  --text:        #e8ecf4;
  --text-1:      #e8ecf4;
  --text-2:      #a8b3cf;
  --muted:       #6b7494;

  --sidebar-w:   224px;
  --header-h:    60px;
  --content-max: 1440px;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Light Mode ─────────────────────────────────────────── */
html[data-theme="light"] {
  --bg:          #f0f2f7;
  --surface:     #ffffff;
  --surface2:    #f4f6fb;
  --surface3:    #e8ecf5;
  --border:      #dde2ef;
  --border2:     #cdd4e8;

  --accent-dim:  rgba(79,158,255,0.10);
  --accent2-dim: rgba(124,58,237,0.10);

  --green-dim:   rgba(34,197,94,0.10);
  --red-dim:     rgba(239,68,68,0.10);
  --orange-dim:  rgba(245,158,11,0.10);

  --text:        #111827;
  --text-1:      #111827;
  --text-2:      #4b5568;
  --muted:       #9ca3b0;

  --shadow:    0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Base ──────────────────────────────────────────────── */
body {
  font-family: 'Syne', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ─────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Brand */
.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-name {
  font-size: 16px; font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
  line-height: 1.2;
}
.brand-sub {
  font-size: 9.5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.04em;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.nav-section {}
.nav-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-ico {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s;
}
.nav-item:hover .nav-ico { color: var(--text-2); }
.nav-badge {
  margin-left: auto;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px; font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
}

.live-nav-badge {
  background: var(--red-dim);
  color: var(--red);
  animation: live-pulse 1.4s ease-in-out infinite;
}

/* Store badge in sidebar */
.sidebar-store {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.store-pill {
  display: flex; align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
}
.store-pill-btn {
  width: 100%; cursor: pointer; text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.store-pill-btn:hover { background: var(--surface3); border-color: var(--border2); }
.store-chevron {
  margin-left: auto; flex-shrink: 0; color: var(--muted);
  transition: transform 0.2s;
}
.store-pill-btn[aria-expanded="true"] .store-chevron { transform: rotate(180deg); }

.store-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.store-dot.ok  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.store-dot.err { background: var(--red); }
.store-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600;
}

/* ── Store Switcher Dropdown ────────────────────────────── */
.store-switch-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px; right: 12px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
}
.store-switch-menu.open { display: block; }
.store-switch-label {
  font-size: 10px; font-weight: 700;
  color: var(--muted);
  padding: 9px 12px 4px;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.store-switch-opt {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 12px; font-family: inherit;
  text-align: left; transition: background 0.12s;
}
.store-switch-opt:hover:not(:disabled) { background: var(--surface3); }
.store-switch-opt.active { color: var(--text); font-weight: 600; }
.store-switch-opt:disabled { opacity: 0.5; cursor: default; }
.store-switch-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-switch-check { color: var(--green); font-size: 12px; font-weight: 700; flex-shrink: 0; }
.store-switch-sep { height: 1px; background: var(--border); margin: 4px 0; }
.store-switch-manage {
  display: block; padding: 8px 12px 10px;
  font-size: 11px; color: var(--muted);
  transition: color 0.12s;
}
.store-switch-manage:hover { color: var(--accent); }


/* ═══════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top Header ────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  gap: 12px;
}
.header-left {
  display: flex; align-items: center;
  gap: 12px;
  min-width: 0;
}
.page-title {
  font-size: 17px; font-weight: 800;
  letter-spacing: -0.4px;
  white-space: nowrap;
}
.page-title .title-muted {
  font-weight: 400; color: var(--muted);
  font-size: 14px; margin-left: 6px;
}
.header-right {
  display: flex; align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Date Range Picker */
.date-picker {
  position: relative;
}
.date-trigger {
  display: flex; align-items: center;
  gap: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.date-trigger:hover { border-color: var(--accent); color: var(--text); }
.date-trigger svg { color: var(--muted); flex-shrink: 0; }
.date-trigger .chevron { color: var(--muted); }

.date-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
  z-index: 300;
  min-width: 280px;
  box-shadow: var(--shadow);
  display: none;
}
.date-dropdown.open { display: block; }
.date-opt {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-bottom: 1px solid var(--border);
}
.date-opt:last-child { border-bottom: none; }
.date-opt:hover { background: var(--surface3); color: var(--text); }
.date-opt.sel { color: var(--accent); background: var(--accent-dim); }

/* Custom range separator + option */
.date-sep { height: 1px; background: var(--border); }
.date-opt-custom {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
}
.date-opt-custom svg { flex-shrink: 0; opacity: 0.6; }

/* Inline custom range panel */
.custom-range-panel {
  display: none;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.custom-range-panel.open { display: block; }
.custom-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.custom-range-field { display: flex; flex-direction: column; gap: 4px; }
.custom-range-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted);
}
.custom-date-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: 11.5px;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  width: 100%;
  outline: none;
  color-scheme: dark;
}
.custom-date-input:focus { border-color: var(--accent); }
.custom-range-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none;
  border-radius: var(--r-sm);
  padding: 7px;
  font-size: 12.5px; font-weight: 700;
  font-family: 'Syne', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
}
.custom-range-btn:hover { opacity: 0.85; }

/* Icon Button */
.btn-icon {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
.btn-icon.spinning svg { animation: spin 1s linear infinite; }
.btn-icon.notif-active { color: var(--accent); border-color: var(--accent-dim); }

/* ── Page Body ─────────────────────────────────────────── */
.page-body {
  flex: 1;
  padding: 24px;
  max-width: var(--content-max);
  width: 100%;
}


/* ═══════════════════════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0; transition: opacity 0.2s;
}
.kpi-card:hover { border-color: var(--border2); }
.kpi-card:hover::after { opacity: 1; }

.kpi-label {
  display: flex; align-items: center;
  gap: 7px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}
.kpi-ico { font-size: 13px; }

.kpi-value {
  font-size: 28px; font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1;
  margin-bottom: 10px;
  min-height: 28px;
}

.kpi-footer {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.kpi-change {
  display: inline-flex; align-items: center;
  gap: 3px;
  font-size: 11.5px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
}
.kpi-change.up   { background: var(--green-dim);  color: var(--green); }
.kpi-change.down { background: var(--red-dim);    color: var(--red); }
.kpi-change.flat { background: var(--surface2);   color: var(--muted); }
.kpi-vs { font-size: 12px; color: var(--muted); }

.kpi-sub {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
  display: flex; gap: 14px;
}
.kpi-sub-item { display: flex; align-items: center; gap: 5px; }
.kpi-sub-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.kpi-sub-dot.new    { background: var(--accent); }
.kpi-sub-dot.repeat { background: var(--accent2); }


/* ═══════════════════════════════════════════════════════
   WIDGET SHELL
   ═══════════════════════════════════════════════════════ */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.widget-head {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.widget-title {
  font-size: 13px; font-weight: 700;
  color: var(--text); letter-spacing: -0.2px;
}
.widget-sub {
  font-size: 11px; color: var(--muted);
  margin-top: 2px;
  font-family: 'DM Mono', monospace;
}
.widget-body { padding: 20px; }
.widget-body.np { padding: 0; }


/* ═══════════════════════════════════════════════════════
   CHART METRIC TOGGLE
   ═══════════════════════════════════════════════════════ */
.chart-metric-toggle {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
  flex-shrink: 0;
}
.chart-metric-pill {
  background: none; border: none;
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Syne', sans-serif;
  white-space: nowrap;
  line-height: 1.4;
}
.chart-metric-pill:hover,
.heatmap-metric-pill:hover  { color: var(--text); background: var(--surface3); }
.chart-metric-pill.active,
.heatmap-metric-pill.active { background: var(--accent-dim); color: var(--accent); }
.chart-view-pill {
  background: none; border: none;
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Syne', sans-serif;
  white-space: nowrap;
  line-height: 1.4;
}
.chart-view-pill:hover  { color: var(--text); background: var(--surface3); }
.chart-view-pill.active { background: var(--surface3); color: var(--text); }
.heatmap-metric-pill {
  background: none; border: none;
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Syne', sans-serif;
  white-space: nowrap;
  line-height: 1.4;
}


/* ═══════════════════════════════════════════════════════
   ORDER STATUS BREAKDOWN
   ═══════════════════════════════════════════════════════ */
.status-breakdown-wrap { margin-bottom: 16px; min-height: 0; }
.status-breakdown {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.status-label {
  font-size: 12px; color: var(--text-2); font-weight: 500;
}
.status-count {
  font-size: 11px; font-weight: 700;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}


/* ═══════════════════════════════════════════════════════
   CHARTS ROW
   ═══════════════════════════════════════════════════════ */
.widgets-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  margin-bottom: 20px;
}
.widget-right-col { display: flex; flex-direction: column; gap: 14px; }
.chart-wrap { position: relative; height: 260px; }


/* ═══════════════════════════════════════════════════════
   PAYMENT METHODS
   ═══════════════════════════════════════════════════════ */
.pay-list { display: flex; flex-direction: column; }
.pay-item {
  display: flex; align-items: center;
  gap: 10px; padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.pay-item:last-child { border-bottom: none; }
.pay-item:hover { background: var(--surface2); }
.pay-icon {
  width: 30px; height: 30px;
  background: var(--surface2); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.pay-name { flex: 1; font-size: 12.5px; font-weight: 500; color: var(--text); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-bar-wrap { width: 52px; height: 3px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.pay-bar { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.6s ease; }
.pay-amount { font-size: 12px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; text-align: right; min-width: 64px; }


/* ═══════════════════════════════════════════════════════
   TOP COUNTRIES
   ═══════════════════════════════════════════════════════ */
.country-list { display: flex; flex-direction: column; }
.country-item {
  display: flex; align-items: center;
  gap: 10px; padding: 9px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.country-item:last-child { border-bottom: none; }
.country-item:hover { background: var(--surface2); }
.country-rank { width: 18px; text-align: center; font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; flex-shrink: 0; }
.country-flag { font-size: 18px; flex-shrink: 0; line-height: 1; }
.country-name { flex: 1; font-size: 12.5px; font-weight: 500; color: var(--text); }
.country-amount { font-size: 12px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; }


/* ═══════════════════════════════════════════════════════
   TOP PRODUCTS TABLE
   ═══════════════════════════════════════════════════════ */
.products-wrap { margin-bottom: 20px; }
.products-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  margin-bottom: 20px;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  padding: 9px 16px;
  text-align: left;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.tbl th:first-child { padding-left: 20px; }
.tbl th:last-child  { padding-right: 20px; text-align: right; }
.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.tbl td:first-child { padding-left: 20px; }
.tbl td:last-child  { padding-right: 20px; text-align: right; font-family: 'DM Mono', monospace; font-weight: 600; }
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr:hover { background: var(--surface2); }
.tbl tbody tr:last-child td { border-bottom: none; }

.prod-name-cell { display: flex; align-items: center; gap: 10px; }
.prod-rank {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface3); color: var(--muted);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: 'DM Mono', monospace;
}
.prod-rank.top-3 { background: var(--accent-dim); color: var(--accent); }
.prod-orders { color: var(--text-2); font-family: 'DM Mono', monospace; }


/* ═══════════════════════════════════════════════════════
   EMPTY / NOT-CONNECTED STATE
   ═══════════════════════════════════════════════════════ */
.state-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 24px;
  text-align: center; gap: 14px;
}
.state-icon { font-size: 52px; opacity: 0.35; line-height: 1; }
.state-title { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.state-text { font-size: 13.5px; color: var(--muted); max-width: 340px; line-height: 1.7; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none;
  padding: 10px 22px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 700;
  font-family: 'Syne', sans-serif;
  cursor: pointer; transition: opacity 0.2s;
  text-decoration: none;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface2);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 9px 20px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  font-family: 'Syne', sans-serif;
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }


/* ═══════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════ */

/* ── Tabs ─────────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 4px;
  width: fit-content;
}
.stab {
  background: none; border: none;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: calc(var(--r-lg) - 3px);
  font-size: 13px; font-weight: 600;
  font-family: 'Syne', sans-serif;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.stab:hover { color: var(--text); }
.stab.active { background: var(--surface3); color: var(--text); }
.stab-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Panel + section card ─────────────────────────────── */
.stab-panel { display: flex; flex-direction: column; gap: 20px; max-width: 680px; }
.stab-panel.hidden { display: none; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.settings-card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.settings-card-title { font-size: 13.5px; font-weight: 700; }
.settings-card-desc  { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ── Settings rows ────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; min-width: 0; }
.settings-row-title { font-size: 13px; font-weight: 600; }
.settings-row-desc  { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.settings-row-ctrl  { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }

/* ── Toggle switch ────────────────────────────────────── */
.toggle-wrap { display: inline-flex; align-items: center; cursor: pointer; position: relative; }
.toggle-input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.toggle-slider {
  position: relative;
  width: 42px; height: 24px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-input:checked + .toggle-slider::after {
  transform: translateX(18px);
  background: #fff;
}

/* ── Pref select ──────────────────────────────────────── */
.pref-select {
  appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 32px 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 160px;
  transition: border-color 0.15s;
}
.pref-select:focus { outline: none; border-color: var(--accent); }
.pref-select option { background: var(--surface2); }

/* ── Danger zone ──────────────────────────────────────── */
.settings-card.danger { border-color: rgba(239,68,68,0.4); }
.settings-card.danger .settings-card-head { border-bottom-color: rgba(239,68,68,0.2); }
.settings-card.danger .settings-card-title { color: var(--red); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.35);
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 600;
  font-family: 'Syne', sans-serif;
  cursor: pointer; transition: all 0.15s;
}
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ── Account inline input rows ───────────────────────── */
.settings-input-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.settings-input-row .form-input { flex: 1; min-width: 180px; }
.settings-row-status { font-size: 12px; margin-top: 6px; }
.settings-row-status.ok  { color: var(--green); }
.settings-row-status.err { color: var(--red); }

/* ── Info card (stores tab) ───────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 680px;
}
.settings-aside {}
.settings-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
}
.settings-info-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.settings-info-text { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.settings-info-text code { font-family: 'DM Mono', monospace; background: var(--surface2); padding: 1px 5px; border-radius: 3px; color: var(--accent); font-size: 11px; }
.settings-steps { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.settings-steps li { display: flex; gap: 10px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.step-num { width: 20px; height: 20px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: 'DM Mono', monospace; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.form-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.form-head-title { font-size: 14px; font-weight: 700; }
.form-head-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.form-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px; font-family: 'Syne', sans-serif;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }
.form-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.form-hint a { color: var(--accent); }
.form-divider { height: 1px; background: var(--border); margin: 4px 0; }
.form-actions { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.form-status { flex: 1; font-size: 12px; }
.form-status.ok  { color: var(--green); }
.form-status.err { color: var(--red); }

.store-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.store-list-head { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.store-list-body { display: flex; flex-direction: column; }
.store-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.store-list-item:last-child { border-bottom: none; }
.store-list-item:hover { background: var(--surface2); }
.sli-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sli-dot.ok  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.sli-dot.err { background: var(--red); }
.sli-name { flex: 1; font-size: 13px; font-weight: 600; }
.sli-url  { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }
.sli-remove { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: var(--r-sm); font-size: 11px; transition: all 0.15s; }
.sli-remove:hover { color: var(--red); background: var(--red-dim); }
.store-list-empty { padding: 28px 20px; text-align: center; font-size: 12.5px; color: var(--muted); }


/* ═══════════════════════════════════════════════════════
   SKELETON / LOADING
   ═══════════════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skel {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface3) 50%, var(--border) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: 4px;
  color: transparent !important;
  pointer-events: none;
  display: inline-block;
}
.skel-text { height: 14px; border-radius: 3px; }
.skel-val  { height: 28px; width: 120px; border-radius: 4px; }
.skel-chip { height: 20px; width: 60px; border-radius: 20px; }

/* Error banner */
.error-banner {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--r);
  padding: 12px 16px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; color: var(--red);
  margin-bottom: 20px;
}
.error-banner svg { flex-shrink: 0; margin-top: 1px; }


/* ═══════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-up   { animation: fadeUp 0.3s ease both; }
.fade-up-1 { animation-delay: 0.04s; }
.fade-up-2 { animation-delay: 0.08s; }
.fade-up-3 { animation-delay: 0.12s; }
.fade-up-4 { animation-delay: 0.16s; }
.fade-up-5 { animation-delay: 0.20s; }

/* ── Scrollbars ────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════════════════════════════════
   INBOX INSIGHTS PAGE
   ═══════════════════════════════════════════════════════ */

/* Settings panel */
.inbox-settings-panel { margin-bottom: 24px; }

/* ── Profile picker (empty state) ───────────────────── */
.profile-picker {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 0 20px;
}
.pp-header { text-align: center; margin-bottom: 28px; }
.pp-title  { font-size: 18px; font-weight: 700; color: var(--text-1); margin-bottom: 6px; }
.pp-sub    { font-size: 13px; color: var(--muted); }
.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.profile-card {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 24px 16px 20px;
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.profile-card:hover {
  border-color: var(--accent);
  background: var(--surface3);
  transform: translateY(-2px);
}
.profile-card.pc-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface2));
}
.pc-icon   { font-size: 26px; margin-bottom: 10px; }
.pc-name   { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.pc-detail { font-size: 12px; color: var(--muted); line-height: 1.5; word-break: break-all; }
.pc-host   { opacity: 0.65; font-size: 11px; }
.pc-unconfigured { font-style: italic; }
.pc-check  {
  position: absolute;
  top: 10px; right: 12px;
  font-size: 12px; font-weight: 700;
  color: var(--accent);
}
.profile-card.pc-add {
  border-style: dashed;
  color: var(--muted);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 140px;
}
.profile-card.pc-add:hover { color: var(--accent); border-color: var(--accent); }
.pc-add-icon { margin-bottom: 8px; }
.pp-footer { text-align: center; }

/* Profile selector bar */
.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.profile-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.profile-select {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  cursor: pointer;
}
#profile-delete-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* AI provider toggle */
.ai-provider-toggle {
  display: flex; gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px;
}
.ai-provider-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: none; border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Syne', sans-serif;
}
.ai-provider-btn:hover { color: var(--text); background: var(--surface3); }
.ai-provider-btn.active { background: var(--accent-dim); color: var(--accent); }
.ai-provider-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Loading state */
.inbox-spinner { margin-bottom: 16px; }

/* Report header bar */
.report-header {
  display: flex; align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 20px;
  margin-bottom: 14px;
  gap: 12px;
}
.report-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-meta-item { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.report-meta-sep { color: var(--border2); font-size: 12px; }
.report-model {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* Two-column grid for report sections */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

/* Top issues list */
.issue-item {
  display: flex; align-items: flex-start;
  gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.issue-item:last-child { border-bottom: none; }
.issue-item:hover { background: var(--surface2); }
.issue-rank {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface3); color: var(--muted);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: 'DM Mono', monospace;
  margin-top: 1px;
}
.issue-body { flex: 1; min-width: 0; }
.issue-category { font-size: 13px; font-weight: 600; color: var(--text); }
.issue-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.issue-count {
  font-size: 13px; font-weight: 700;
  color: var(--text-2); font-family: 'DM Mono', monospace;
  flex-shrink: 0;
}

/* Category breakdown bars */
.category-row {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 12px;
}
.category-row:last-child { margin-bottom: 0; }
.category-name { font-size: 12px; color: var(--text-2); width: 130px; flex-shrink: 0; }
.category-bar-wrap { flex: 1; height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.category-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; transition: width 0.5s ease; }
.category-pct { font-size: 11px; font-weight: 600; color: var(--muted); font-family: 'DM Mono', monospace; width: 32px; text-align: right; flex-shrink: 0; }

/* Trend list */
.trend-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; }
.trend-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; color: var(--text-2); line-height: 1.6;
}
.trend-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 7px;
}

/* Example complaint cards */
.example-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.example-card:last-child { margin-bottom: 0; }
.example-category {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); margin-bottom: 6px;
}
.example-quote {
  font-size: 13px; color: var(--text-2);
  font-style: italic; line-height: 1.6;
  margin: 0; padding: 0;
  border-left: 2px solid var(--accent-dim);
  padding-left: 10px;
}

/* Priority items */
.priority-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.priority-item:last-child { border-bottom: none; }
.priority-item:hover { background: var(--surface2); }
.priority-item.priority-high   { border-left-color: var(--red);    }
.priority-item.priority-medium { border-left-color: var(--orange); }
.priority-item.priority-low    { border-left-color: var(--muted);  }
.priority-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.priority-badge {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 2px 8px; border-radius: 20px;
  font-family: 'DM Mono', monospace;
}
.priority-badge-high   { background: var(--red-dim);    color: var(--red);    }
.priority-badge-medium { background: var(--orange-dim); color: var(--orange); }
.priority-badge-low    { background: var(--surface3);   color: var(--muted);  }
.priority-effort { font-size: 11px; color: var(--muted); margin-left: auto; }
.priority-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.priority-desc  { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* Responsive: collapse report grid on smaller screens */
@media (max-width: 960px) {
  .report-grid { grid-template-columns: 1fr; }
}


/* ── Recent Orders Feed ─────────────────────────────────── */
.order-feed-wrap { margin-bottom: 14px; }

/* Filter toolbar */
.feed-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.feed-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  flex: 1;
}
.feed-pill {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.feed-pill:hover { border-color: var(--accent); color: var(--accent); }
.feed-pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.feed-search {
  width: 200px;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.feed-search::placeholder { color: var(--muted); }
.feed-search:focus { border-color: var(--accent); }

/* Pagination */
.feed-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.feed-page-btn {
  padding: 5px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.feed-page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.feed-page-btn:disabled { opacity: 0.35; cursor: default; }
.feed-page-info { font-size: 12.5px; color: var(--muted); }

/* Live indicator dot */
.feed-live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
  animation: feed-breathe 2.5s ease-in-out infinite;
}
@keyframes feed-breathe {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50%      { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}
.feed-live-dot.feed-pulse {
  animation: feed-pop 0.6s ease-out;
}
@keyframes feed-pop {
  0%   { transform: scale(1); background: var(--accent); }
  50%  { transform: scale(1.6); background: var(--accent); }
  100% { transform: scale(1); background: var(--green); }
}

/* Table rows */
.feed-row { transition: background 0.12s; }
.feed-row:hover { background: var(--surface2); }
.feed-id    { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-customer { font-size: 13px; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-items { font-size: 12px; color: var(--text-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-more  { font-size: 11px; color: var(--muted); background: var(--surface3); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
.feed-method { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.feed-coupon-cell { white-space: nowrap; }
.feed-coupon { display: inline-block; font-size: 11px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--accent2); background: var(--accent2-dim); border-radius: 4px; padding: 2px 6px; letter-spacing: .3px; }
.feed-no-coupon { font-size: 12px; color: var(--muted); }
.feed-date  { font-size: 12px; color: var(--text-2); white-space: nowrap; display: flex; flex-direction: column; gap: 1px; }
.feed-time  { font-size: 11px; color: var(--muted); }
.feed-total { font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500; text-align: right; white-space: nowrap; }

/* Status badges */
.order-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.status-completed  { background: var(--green-dim);   color: var(--green); }
.status-processing { background: var(--accent-dim);  color: var(--accent); }
.status-on-hold    { background: var(--orange-dim);  color: var(--orange); }
.status-pending    { background: var(--surface3);    color: var(--muted); }
.status-cancelled  { background: var(--red-dim);     color: var(--red); }
.status-refunded   { background: var(--red-dim);     color: var(--red); }
.status-failed     { background: var(--red-dim);     color: var(--red); }
.status-other      { background: var(--surface3);    color: var(--muted); }

/* Hide some columns on tablet */
@media (max-width: 860px) {
  .feed-method, .tbl th:nth-child(4) { display: none; }
}
/* Hide more columns on mobile */
@media (max-width: 600px) {
  .feed-items, .tbl th:nth-child(3),
  .feed-date,  .tbl th:nth-child(6) { display: none; }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1200px) {
  .widgets-row { grid-template-columns: 1fr; }
  .widget-right-col { flex-direction: row; }
  .widget-right-col .widget { flex: 1; }
  .products-row { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .widget-right-col { flex-direction: column; }
}
/* ── Hamburger button (hidden on desktop) ──────────────── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-1);
  flex-shrink: 0;
  margin-right: 10px;
}

/* ── Sidebar backdrop (mobile overlay) ─────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
}

@media (max-width: 680px) {
  :root { --sidebar-w: 0px; }
  .main { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Hamburger visible on mobile */
  .hamburger-btn { display: flex; }

  /* Sidebar hidden off-screen by default */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }

  /* Slide in when app has .sidebar-open */
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .sidebar-backdrop { display: block; }
}

/* ── Sales Heatmap ─────────────────────────────────────── */
.heatmap-wrap { margin-bottom: 24px; }

.heatmap-container {
  overflow-x: auto;
  padding: 4px 20px 20px;
}

/* ── Grid layout: 1 label col + 24 hour cols ── */
.heatmap-grid {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(0, 1fr));
  gap: 3px;
  min-width: 580px;
}

.hm-corner { /* top-left spacer */ }

.hm-hour-label {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-align: center;
  padding-bottom: 5px;
  white-space: nowrap;
}

.hm-day-label {
  font-size: 11px;
  color: var(--text-2);
  font-family: 'DM Mono', monospace;
  display: flex;
  align-items: center;
  padding-right: 4px;
  white-space: nowrap;
}

.hm-cell {
  height: 26px;
  border-radius: 3px;
  cursor: default;
  transition: filter 0.12s, outline 0.12s;
}
.hm-cell:hover {
  filter: brightness(1.25);
  outline: 1.5px solid rgba(79,158,255,0.55);
  outline-offset: 1px;
}

/* ── Legend ─────────────────────────────────────────────── */
.hm-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  justify-content: flex-end;
  padding-right: 2px;
}
.hm-legend-label {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.hm-legend-scale {
  display: flex;
  gap: 3px;
}
.hm-legend-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

/* ── Skeleton ────────────────────────────────────────────── */
.hm-skel-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 12px;
}
.hm-skel-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hm-skel-label {
  width: 28px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}
.hm-skel-bar {
  flex: 1;
  height: 26px;
  border-radius: 4px;
}

/* =============================================================================
   LIVE VIEW
   ============================================================================= */

/* ── Top KPI bar ─────────────────────────────────────────── */
.lv-kpi-bar {
  display: grid;
  grid-template-columns: auto 1px repeat(4, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.lv-kpi-sep {
  width: 1px;
  background: var(--border);
  align-self: stretch;
}
.lv-kpi-card {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.lv-kpi-card:last-child { border-right: none; }
.lv-kpi-locked {
  background: var(--surface2);
  opacity: 0.75;
}
.lv-kpi-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
  white-space: nowrap;
}
.lv-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}
.lv-kpi-sub {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.lv-kpi-note {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Live KPI privacy mode ───────────────────────────────── */
.lv-kpi-bar.lv-privacy .lv-kpi-value,
.lv-kpi-bar.lv-privacy .lv-kpi-sub {
  filter: blur(8px);
  user-select: none;
  transition: filter 0.2s ease;
}

/* ── Dashboard privacy mode ──────────────────────── */
.dashboard-privacy .kpi-value,
.dashboard-privacy .kpi-footer,
.dashboard-privacy .kpi-vs,
.dashboard-privacy .meta-ads-kpi-value,
.dashboard-privacy .meta-ads-kpi-sub,
.dashboard-privacy .pay-amount,
.dashboard-privacy .country-amount,
.dashboard-privacy #products-body td:last-child,
.dashboard-privacy .lprod-rev,
.dashboard-privacy #order-feed-body td:last-child {
  filter: blur(8px);
  user-select: none;
  transition: filter 0.2s ease;
}
.lv-kpi-bar .lv-kpi-value,
.lv-kpi-bar .lv-kpi-sub {
  transition: filter 0.2s ease;
}

/* ── Live badge ──────────────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: 20px;
  padding: 3px 8px 3px 6px;
  margin-left: 10px;
  vertical-align: middle;
  line-height: 1;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.65); }
}
.live-updated {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-right: 4px;
}

/* ── KPI sub text ────────────────────────────────────────── */
.kpi-sub-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
  font-family: 'DM Mono', monospace;
}

/* ── Live layout grids ───────────────────────────────────── */

/* Shopify-style: left stat panel + right map */
.live-shopify-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
.live-left-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Compact stat card (left panel) */
.live-stat-card { padding: 0; }
.lsc-body { padding: 0 16px 12px; }

/* Full-width feed below the grid */
.live-feed-widget { margin-bottom: 0; }
#activity-feed {
  overflow-y: auto;
  max-height: 380px;
  padding: 0 16px 8px;
}
#activity-feed::-webkit-scrollbar { width: 3px; }
#activity-feed::-webkit-scrollbar-track { background: transparent; }
#activity-feed::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── World map ───────────────────────────────────────────── */
.live-map-widget { display: flex; flex-direction: column; }
.live-map-body { padding: 0 0 4px; flex: 1; }
#world-map { height: 420px; width: 100%; }
.jvm-tooltip {
  background: var(--surface3) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  font-family: 'Syne', sans-serif !important;
  font-size: 12px !important;
  box-shadow: var(--shadow-sm) !important;
  padding: 5px 10px !important;
}

/* ── Activity feed ───────────────────────────────────────── */
.live-activity-widget { display: flex; flex-direction: column; }
.live-activity-widget .widget-head { flex-shrink: 0; }
#activity-feed {
  overflow-y: auto;
  max-height: 380px;
  padding: 4px 16px 8px;
}
#activity-feed::-webkit-scrollbar { width: 3px; }
#activity-feed::-webkit-scrollbar-track { background: transparent; }
#activity-feed::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-item.new { animation: act-flash 2.5s ease forwards; }
@keyframes act-flash {
  0%   { background: rgba(34,197,94,0.14); }
  70%  { background: rgba(34,197,94,0.06); }
  100% { background: transparent; }
}
.act-flag { font-size: 18px; flex-shrink: 0; width: 26px; text-align: center; }
.act-info  { min-width: 84px; flex-shrink: 0; }
.act-name  {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 84px;
}
.act-loc   {
  font-size: 10px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 84px;
}
.act-product {
  flex: 1; font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.act-more {
  font-size: 10px; background: var(--surface3); color: var(--muted);
  border-radius: 3px; padding: 1px 4px; margin-left: 3px;
}
.act-right  { flex-shrink: 0; text-align: right; }
.act-total  { font-size: 12px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text); }
.act-meta   { display: flex; gap: 5px; align-items: center; justify-content: flex-end; margin-top: 2px; }
.act-status { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.act-time   { font-size: 10px; color: var(--muted); font-family: 'DM Mono', monospace; }

/* ── Status bars ─────────────────────────────────────────── */
.sbi-item { margin-bottom: 12px; }
.sbi-item:last-child { margin-bottom: 0; }
.sbi-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.sbi-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sbi-label { font-size: 13px; color: var(--text-2); flex: 1; }
.sbi-count { font-size: 13px; font-family: 'DM Mono', monospace; font-weight: 600; color: var(--text); }
.sbi-track { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.sbi-fill  { height: 100%; border-radius: 2px; opacity: 0.8; transition: width 0.4s ease; }

/* ── Country bars ────────────────────────────────────────── */
.cbi-item { margin-bottom: 10px; }
.cbi-item:last-child { margin-bottom: 0; }
.cbi-head  { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cbi-flag  { font-size: 13px; flex-shrink: 0; }
.cbi-name  { font-size: 12px; color: var(--text-2); flex: 1; }
.cbi-rev   { font-size: 11px; font-family: 'DM Mono', monospace; color: var(--text); }
.cbi-count {
  font-size: 10px; color: var(--muted); background: var(--surface3);
  border-radius: 4px; padding: 1px 5px; font-family: 'DM Mono', monospace;
}
.cbi-track { height: 3px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.cbi-fill  { height: 100%; background: var(--accent); border-radius: 2px; opacity: 0.7; transition: width 0.4s ease; }

/* ── Today badge ─────────────────────────────────────────── */
.live-today-badge {
  font-size: 11px; color: var(--muted); background: var(--surface3);
  border-radius: 12px; padding: 3px 9px; white-space: nowrap; flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────── */
.live-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--green); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--r);
  box-shadow: var(--shadow); z-index: 9999;
  transform: translateY(72px); opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  pointer-events: none;
}
.live-toast.show { transform: translateY(0); opacity: 1; }

/* ── Empty states ────────────────────────────────────────── */
.live-empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Top products (left panel) ───────────────────────────── */
.lprod-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.lprod-item:last-child { border-bottom: none; }
.lprod-name { font-size: 12px; color: var(--text-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lprod-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lprod-qty   { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }
.lprod-rev   { font-size: 12px; font-weight: 700; font-family: 'DM Mono', monospace; color: var(--text); }

/* ── lsc-title-note ──────────────────────────────────────── */
.lsc-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 16px 8px;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lsc-title-note {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

/* ── Last Hour section ───────────────────────────────────── */
.lh-row {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
}
.lh-stat {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  border-right: 1px solid var(--border);
}
.lh-stat:last-child { border-right: none; }
.lh-val {
  font-size: 16px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  color: var(--text);
  line-height: 1.2;
}
.lh-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.lh-flags {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--muted);
  padding: 4px 0 2px;
  text-align: center;
}

/* ── Right column ────────────────────────────────────────── */
.live-right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ── Hourly chart ────────────────────────────────────────── */
.lv-hourly {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 80px;
}
.lv-hour-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
  min-width: 0;
}
.lv-hour-col:hover .lv-hour-bar { opacity: 1; }
.lv-hour-col.current .lv-hour-bar { background: var(--accent); opacity: 1; }
.lv-hour-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}
.lv-hour-bar {
  width: 100%;
  min-height: 2px;
  background: var(--accent-dim);
  border-radius: 2px 2px 0 0;
  opacity: 0.7;
  transition: height 0.3s ease, opacity 0.2s;
}
.lv-hour-col.current .lv-hour-bar { background: var(--accent); }
.lv-hour-label {
  font-size: 8px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  height: 12px;
  line-height: 12px;
}

/* ── Hourly toggle ───────────────────────────────────────── */
.lv-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.lv-toggle-btn {
  background: none;
  border: none;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lv-toggle-btn.active {
  background: var(--surface3);
  color: var(--text);
}

/* ── Customer Behavior ───────────────────────────────────── */
.cbeh-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.cbeh-row:last-child { border-bottom: none; }
.cbeh-row-sm { padding: 5px 0; }
.cbeh-label { font-size: 13px; color: var(--text2); white-space: nowrap; min-width: 90px; }
.cbeh-bar-wrap { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.cbeh-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.cbeh-val { font-size: 15px; font-weight: 700; min-width: 24px; text-align: right; }
.cbeh-row-sm .cbeh-val { font-size: 12px; font-weight: 500; }
.cbeh-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ── Visitor Pages ───────────────────────────────────────── */
.live-visitors-widget { margin-bottom: 0; }
.vp-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.vp-item:last-child { border-bottom: none; }
.vp-flag  { font-size: 20px; width: 26px; flex-shrink: 0; text-align: center; }
.vp-info  { flex: 1; min-width: 0; }
.vp-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vp-path  {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vp-tag   {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px; flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .lv-kpi-bar { grid-template-columns: auto 1px repeat(4, 1fr); }
}
@media (max-width: 1100px) {
  .live-shopify-grid { grid-template-columns: 260px 1fr; }
}
@media (max-width: 960px) {
  .lv-kpi-bar { grid-template-columns: 1fr 1fr; }
  .lv-kpi-sep { display: none; }
  .lv-kpi-card { border-right: none; border-bottom: 1px solid var(--border); }
  .lv-kpi-card:last-child { border-bottom: none; }
  /* Locked visitors card spans full width */
  .lv-kpi-locked { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .live-shopify-grid { grid-template-columns: 1fr; }
  #world-map { height: 280px; }
}
@media (max-width: 680px) {
  .lv-kpi-bar { grid-template-columns: 1fr 1fr; }
  .lv-kpi-value { font-size: 18px; }
  .lv-kpi-card { padding: 12px 14px; }
  .act-product { display: none; }
  /* Live badge in header */
  .live-badge { font-size: 9px; padding: 2px 6px; }
  /* Updated text shorter on mobile */
  .live-updated { display: none; }
}

/* ── Tracking tab ────────────────────────────────────────── */
.trk-step-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--surface3);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.trk-code-block {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.trk-code-block pre {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
  padding: 14px 16px;
  padding-right: 90px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
  margin: 0;
}
.trk-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.trk-copy-btn:hover { background: var(--border2); }
.lv-kpi-dim { opacity: 0.4; }

/* ═══════════════════════════════════════ META SPY ══ */

/* Toolbar */
.spy-toolbar { margin-bottom: 16px; }
.spy-toolbar.widget,
.spy-toolbar.widget .widget-body { overflow: visible; }
.spy-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.spy-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.spy-filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.spy-filter-sep { width: 1px; height: 18px; background: var(--border); }
.spy-search {
  flex: 1;
  min-width: 180px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.spy-search:focus { border-color: var(--accent); }
/* Country custom dropdown */
.spy-country-wrap { position: relative; }
.spy-country-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  min-width: 160px;
}
.spy-country-btn:hover { border-color: var(--border2); }
.spy-country-wrap.open .spy-country-btn { border-color: var(--accent); background: var(--surface); }
.spy-country-chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.spy-country-wrap.open .spy-country-chevron { transform: rotate(180deg); }
.spy-country-drop {
  position: fixed;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 9999;
  overflow: hidden;
  display: none;
}
.spy-country-drop.open { display: block; }
.spy-country-search-wrap {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border);
}
.spy-country-search {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}
.spy-country-search:focus { border-color: var(--accent); }
.spy-country-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.spy-country-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  width: 100%;
}
.spy-country-opt:hover { background: var(--surface2); }
.spy-country-opt.active { background: var(--accent-dim); color: var(--accent); }
.spy-country-opt-flag { font-size: 16px; line-height: 1; width: 20px; }
.spy-country-opt-name { flex: 1; }
.spy-country-opt-code { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }

.spy-pill-group { display: flex; gap: 4px; }

/* Filter rows spacing */
.spy-filter-row--gap { margin-top: 10px; }

/* Date custom inputs */
.spy-date-custom {
  display: none;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
}
.spy-date-input {
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  color-scheme: dark;
}
.spy-date-input:focus { border-color: var(--accent); }
html[data-theme="light"] .spy-date-input { color-scheme: light; }
.spy-date-sep { color: var(--muted); font-size: 13px; }

/* Recent searches */
.spy-recent { margin-bottom: 20px; }
.spy-recent-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.spy-recent-list { display: flex; flex-wrap: wrap; gap: 6px; }
.spy-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.spy-recent-item:hover { border-color: var(--accent); background: var(--surface2); }
.spy-recent-q { font-weight: 600; }
.spy-recent-meta { color: var(--muted); font-size: 11px; }

/* Info card */
.spy-info-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-top: 8px;
}
.spy-info-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  background: var(--accent-dim);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.spy-info-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  padding-top: 8px;
}
.spy-info-text strong { color: var(--text); }

/* Responsive */
@media (max-width: 680px) {
  .spy-search-row { flex-direction: column; align-items: stretch; }
  .spy-select { width: 100%; }
  .spy-pill-group { flex-wrap: wrap; }
  .spy-filter-row { gap: 8px; }
  .spy-filter-sep { display: none; }
}

/* Setup banner — keep for reference */
.spy-setup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  overflow: hidden;
}
.spy-setup-inner {
  display: flex;
  gap: 20px;
  padding: 24px;
}
.spy-setup-icon {
  width: 52px; height: 52px;
  flex-shrink: 0;
  background: var(--accent-dim);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.spy-setup-content { flex: 1; min-width: 0; }
.spy-setup-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.spy-setup-sub { font-size: 13px; color: var(--text-2); margin-bottom: 16px; line-height: 1.5; }
.spy-setup-sub code, .spy-token-hint code {
  font-family: 'DM Mono', monospace;
  font-size: 11.5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent);
}
.spy-steps {
  margin: 0 0 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.spy-steps li { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.spy-steps li strong { color: var(--text); }
.spy-setup-note {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface2);
  border-left: 3px solid var(--orange);
  padding: 8px 12px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-bottom: 16px;
  line-height: 1.5;
}
.spy-setup-token-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.spy-setup-input { flex: 1; font-size: 12.5px; }

/* Toolbar */
.spy-toolbar { margin-bottom: 20px; }
.spy-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.spy-search {
  flex: 1;
  min-width: 180px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.spy-search:focus { border-color: var(--accent); }
.spy-select {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.spy-select:focus { border-color: var(--accent); }
.spy-pill-group { display: flex; gap: 4px; }

/* Results header */
.spy-results-header {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  font-weight: 600;
}

/* Error banner */
.spy-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
}
.spy-error svg { flex-shrink: 0; }
.spy-error-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0.7;
}
.spy-error-close:hover { opacity: 1; }

/* Ad grid */
.spy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

/* Ad card */
.spy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.spy-card:hover {
  border-color: var(--border2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.spy-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 0;
}
.spy-platforms { display: flex; gap: 5px; }
.spy-platform-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}
.spy-plat-facebook  { background: rgba(24,119,242,0.15); color: #4f9eff; border: 1px solid rgba(24,119,242,0.25); }
.spy-plat-instagram { background: rgba(214,41,118,0.12); color: #e1306c; border: 1px solid rgba(214,41,118,0.25); }
.spy-plat-messenger { background: rgba(0,153,255,0.12);  color: #00b4ff; border: 1px solid rgba(0,153,255,0.25); }
.spy-plat-audience_network { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.spy-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.spy-status-active   { color: var(--green);  background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.2); }
.spy-status-inactive { color: var(--muted);  background: var(--surface2);      border: 1px solid var(--border); }
.spy-muted { color: var(--muted); font-size: 12px; }

.spy-card-body { padding: 12px 14px; flex: 1; }
.spy-page-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spy-funding {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spy-ad-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.spy-ad-body {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spy-ad-body--empty { color: var(--muted); font-style: italic; }

.spy-card-meta {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.spy-meta-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spy-meta-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.spy-meta-val { font-size: 12px; color: var(--text-2); font-weight: 500; }
.spy-mono { font-family: 'DM Mono', monospace; }

.spy-card-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.spy-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
}
.spy-view-btn:hover { background: var(--surface3); border-color: var(--accent); color: var(--accent); }

/* Skeleton */
.spy-skeleton {
  min-height: 260px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.spy-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: spy-shimmer 1.4s ease-in-out infinite;
}
@keyframes spy-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* Empty state */
.spy-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--muted);
  gap: 12px;
  text-align: center;
}
.spy-empty-title { font-size: 15px; font-weight: 700; color: var(--text-2); }
.spy-empty-sub   { font-size: 13px; max-width: 360px; line-height: 1.5; }

/* Pagination */
.spy-pagination { display: flex; justify-content: center; padding: 8px 0 24px; }

/* Token modal */
.spy-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.spy-modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  margin: 0 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.spy-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.spy-modal-title { font-size: 14px; font-weight: 700; }
.spy-modal-body  { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.spy-token-hint  { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.spy-modal-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* Responsive */
@media (max-width: 1100px) { .spy-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px)  {
  .spy-grid { grid-template-columns: 1fr; }
  .spy-search-row { flex-direction: column; align-items: stretch; }
  .spy-select { width: 100%; }
  .spy-pill-group { flex-wrap: wrap; }
  .spy-setup-inner { flex-direction: column; }
}

/* ── Meta Ads ROI Widget ─────────────────────────────── */
.meta-ads-widget { margin-bottom: 24px; }
.meta-ads-widget .widget-body { padding: 0; }

/* Not-connected state — compact horizontal row */
.meta-ads-setup {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.meta-ads-setup-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, #1877F2, #0a5cbf);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.meta-ads-setup-text { flex: 1; min-width: 0; }
.meta-ads-setup-title { font-size: 13px; font-weight: 700; color: var(--text); }
.meta-ads-setup-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meta-ads-connect-btn { flex-shrink: 0; }

.meta-ads-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.meta-ads-kpi {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}
.meta-ads-kpi:last-child { border-right: none; }
.meta-ads-kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.meta-ads-kpi-value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.2; }
.meta-ads-kpi-sub   { font-size: 12px; color: var(--muted); margin-top: 3px; }
.meta-ads-positive  { color: var(--green) !important; }
.meta-ads-negative  { color: var(--red) !important; }

.meta-ads-fb-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; font-size: 12px; color: var(--muted);
}
.meta-cost-type-btn {
  padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface2); border: 1.5px solid var(--border2); color: var(--text-2);
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.meta-cost-type-btn:hover { border-color: var(--accent); color: var(--accent); }
.meta-cost-type-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.meta-ads-disconnect {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: var(--muted); font-family: inherit;
  padding: 2px 6px; border-radius: 4px;
}
.meta-ads-disconnect:hover { color: var(--red); background: var(--red-dim); }

.meta-ads-error {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; font-size: 13px; color: var(--orange);
  background: var(--orange-dim);
}

/* Setup modal */
.meta-ads-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.meta-ads-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
}
.meta-ads-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.meta-ads-modal-title { font-size: 15px; font-weight: 700; }
.meta-ads-modal-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 16px; padding: 4px 8px; border-radius: 4px;
}
.meta-ads-modal-close:hover { background: var(--surface2); }
.meta-ads-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.meta-ads-modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.meta-ads-modal-step {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; background: var(--surface2);
  border-radius: var(--r-sm); border: 1px solid var(--border);
}
.meta-ads-modal-step-num {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

@media (max-width: 680px) {
  .meta-ads-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-ads-kpi:nth-child(2) { border-right: none; }
}
