@font-face {
  font-family: "Inter";
  src: url("fonts/Inter.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Italic.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: block;
}

:root {
  --sb: #0B1917;
  --sb-2: #122522;
  --sb-hover: #16302C;
  --accent: #0D9488;
  --accent-2: #2DD4BF;
  --accent-d: #0F766E;
  --accent-soft: #CCFBF1;
  --bg: #F1F5F3;
  --card: #FFFFFF;
  --line: #E1E8E5;
  --line-2: #D0DAD6;
  --text: #10211E;
  --muted: #5A6C68;
  --muted-2: #8A9B97;
  --success: #059669;
  --success-bg: #ECFDF5;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --warn: #D97706;
  --warn-bg: #FFFBEB;
  --info: #0284C7;
  --info-bg: #F0F9FF;
  --shadow: 0 1px 2px rgba(16, 33, 30, 0.05), 0 4px 10px rgba(16, 33, 30, 0.04);
  --r: 12px;
  --sbw: 232px;
  --th: 56px;
  --fh: 32px;
  --google: #4285F4;
  --chatgpt: #7C5CFC;
  --direct: #64748B;
  --social: #E11D48;
  --other: #94A3B8;
  --amber: #F59E0B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 1600px;
  height: 1000px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { display: flex; }
button, input { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ——— Sidebar ——— */
.sidebar {
  width: var(--sbw);
  flex: 0 0 var(--sbw);
  height: 1000px;
  background: linear-gradient(180deg, #0C1C1A 0%, #0B1917 60%, #0A1514 100%);
  color: #C5D6D2;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, #2DD4BF, #0F766E);
  display: grid; place-items: center;
  box-shadow: 0 0 0 3px rgba(13,148,136,.22), 0 6px 14px rgba(13,148,136,.28);
  flex: 0 0 32px;
}
.brand-name { font-weight: 700; font-size: 14.5px; color: #F4FFFC; letter-spacing: -0.03em; line-height: 1.15; }
.brand-sub { font-weight: 500; font-size: 10.5px; color: #7E9B96; letter-spacing: 0.04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: #B4C8C4; text-decoration: none; font-weight: 520; font-size: 13px;
}
.nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 18px; }
.nav a.active {
  background: linear-gradient(90deg, rgba(13,148,136,.28), rgba(13,148,136,.12));
  color: #F3FFFC;
  box-shadow: inset 0 0 0 1px rgba(45,212,191,.22);
}
.nav a.active svg { stroke: #5EEAD4; }
.nav .section-label {
  font-size: 10px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: #6D8682; padding: 16px 10px 6px;
}

.sb-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.06); }
.sb-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px; padding: 8px 9px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52,211,153,.18); flex: 0 0 7px; }
.sb-badge .t1 { font-size: 11.5px; font-weight: 600; color: #E8F5F2; line-height: 1.2; }
.sb-badge .t2 { font-size: 10px; color: #7E9B96; }

/* ——— Main ——— */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 1000px; }
.topbar {
  height: var(--th); flex: 0 0 var(--th);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.page-kicker { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 1px; }
.spacer { flex: 1; }

.ctrl {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 11px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 9px;
  font-size: 12.5px; font-weight: 550; color: var(--text);
  box-shadow: 0 1px 1px rgba(16,33,30,.03);
  white-space: nowrap;
}
.ctrl svg { width: 15px; height: 15px; stroke: var(--muted); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ctrl .chev { width: 13px; height: 13px; margin-left: 2px; }
.ctrl .site-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.content {
  flex: 1; padding: 16px 20px 12px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; overflow: hidden;
}
.footer {
  height: var(--fh); flex: 0 0 var(--fh);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  background: #F7FAF8;
  color: var(--muted); font-size: 11px; font-weight: 500;
}
.footer strong { color: var(--muted); font-weight: 650; }

/* ——— Cards / grid ——— */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 0; min-height: 0;
}
.card h3 {
  font-size: 12.5px; font-weight: 650; color: var(--text);
  letter-spacing: -0.01em;
}
.card .sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.row { display: flex; gap: 12px; min-height: 0; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.kpi { padding: 12px 14px 11px; display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 11px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kpi .value { font-size: 20px; font-weight: 730; letter-spacing: -0.04em; line-height: 1.2; margin-top: 4px; color: var(--text); }
.kpi .hint { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; }
.delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10.5px; font-weight: 700; letter-spacing: -0.01em;
  padding: 1px 6px; border-radius: 999px; line-height: 16px;
}
.delta.up { background: var(--success-bg); color: var(--success); }
.delta.down { background: var(--danger-bg); color: var(--danger); }
.delta.flat { background: #F3F4F6; color: var(--muted); }
.delta.warn { background: var(--warn-bg); color: var(--warn); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left; font-size: 10.5px; font-weight: 650;
  color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0 8px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 7px 8px; border-bottom: 1px solid #F0F4F2; vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.mono, .mono { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sku { color: var(--muted-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: #F0F5F3; color: #3F5A55; white-space: nowrap;
}

/* Chart helpers */
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.leg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 550; }
.sw { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 8px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

/* Toggle */
.toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--success-bg); color: var(--success);
  border: 1px solid #A7F3D0; border-radius: 999px;
  padding: 4px 10px 4px 6px; font-size: 11.5px; font-weight: 650;
}
.toggle .knob {
  width: 28px; height: 16px; border-radius: 99px; background: var(--success); position: relative;
}
.toggle .knob::after {
  content: ""; position: absolute; top: 2px; right: 2px;
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
}

/* Bars */
.bar-row { display: grid; grid-template-columns: 148px 1fr 86px; gap: 8px; align-items: center; margin: 0 0 9px; }
.bar-row .nm { font-size: 12px; font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 10px; background: #EAF1EE; border-radius: 99px; overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #0F766E, #2DD4BF); }
.bar-row .amt { font-size: 12px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

/* Dark theme (Live) */
body.theme-dark { background: #0A1211; color: #E7F3F0; }
body.theme-dark .topbar {
  background: #10211E; border-bottom-color: #1C3330; color: #E7F3F0;
}
body.theme-dark .page-title { color: #F4FFFC; }
body.theme-dark .page-kicker { color: #8AA8A2; }
body.theme-dark .ctrl {
  background: #16302C; border-color: #234842; color: #E7F3F0;
  box-shadow: none;
}
body.theme-dark .ctrl svg { stroke: #8AA8A2; }
body.theme-dark .content { background: #0C1615; }
body.theme-dark .footer { background: #0A1211; border-top-color: #1C3330; color: #7E9B96; }
body.theme-dark .card {
  background: #12211F; border-color: #1E3632;
  box-shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 20px rgba(0,0,0,.22);
}
body.theme-dark .card h3 { color: #F0FAF7; }
body.theme-dark .card .sub, body.theme-dark .hint, body.theme-dark .kpi .hint { color: #7E9B96; }
body.theme-dark .kpi .label { color: #8AA8A2; }
body.theme-dark .kpi .value { color: #F4FFFC; }
body.theme-dark th { color: #8AA8A2; border-bottom-color: #1E3632; }
body.theme-dark td { color: #E7F3F0; border-bottom-color: #1A302C; }
body.theme-dark .sku { color: #6D8682; }
body.theme-dark .pill { background: #1A3330; color: #B7D0CB; }
body.theme-dark .track { background: #1A302C; }

/* Pulse */
.pulse {
  width: 10px; height: 10px; border-radius: 50%; background: #34D399;
  box-shadow: 0 0 0 0 rgba(52,211,153,.55);
  position: relative;
}
.pulse::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid rgba(52,211,153,.45);
}

/* Site segmented switcher */
.sites {
  display: flex; align-items: center;
  height: 34px; padding: 3px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 9px;
  box-shadow: 0 1px 1px rgba(16,33,30,.03);
}
.sites span {
  display: flex; align-items: center; height: 28px;
  padding: 0 10px; border-radius: 7px;
  font-size: 12px; font-weight: 580; color: var(--muted);
  white-space: nowrap;
}
.sites span.on {
  background: #0D9488; color: #F4FFFC; font-weight: 680;
  box-shadow: 0 1px 2px rgba(15,118,110,.35);
}
body.theme-dark .sites { background: #16302C; border-color: #234842; box-shadow: none; }
body.theme-dark .sites span { color: #8AA8A2; }
body.theme-dark .sites span.on { background: #0D9488; color: #F4FFFC; }

.qty-box { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.qty-box h4 { font-size: 11.5px; font-weight: 650; margin-bottom: 8px; }
.qty-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 3px 0; }
.qty-row .q { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty-row .n { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stack-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.stack-bar > i { display: block; height: 100%; }
/* Screen-specific layout */
.kpis { flex: 0 0 auto; }
.grow { flex: 1 1 auto; min-height: 0; }
.chart-wrap { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; }
.chart-wrap svg.plot { width: 100%; height: 100%; flex: 1; min-height: 0; }
.donut-box { display: flex; align-items: center; gap: 18px; flex: 1; min-height: 0; }
.donut-box svg { flex: 0 0 auto; }
.donut-center { font-size: 20px; font-weight: 730; letter-spacing: -0.04em; }
.donut-center span { display: block; font-size: 11px; font-weight: 550; color: var(--muted); letter-spacing: 0; margin-top: 1px; }
.ch-list { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 0; }
.ch-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: start; }
.ch-item .nm { font-size: 12.5px; font-weight: 620; white-space: nowrap; }
.ch-item .meta { font-size: 11px; color: var(--muted); }
.ch-item .val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.2; }
.ch-item .val small { display: block; font-size: 10.5px; font-weight: 550; color: var(--muted); }

/* comparison */
.cmp { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.cmp-card { position: relative; overflow: hidden; }
.cmp-label { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cmp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.cmp-pair .lbl { font-size: 11px; color: var(--muted); }
.cmp-pair .v { font-size: 22px; font-weight: 730; letter-spacing: -0.04em; line-height: 1.15; }
.vs { font-size: 10.5px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; }
.note { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* abandoned panel */
.abandon { display: grid; grid-template-columns: 1.1fr 1.3fr 1fr; gap: 16px; align-items: stretch; }
.abandon .big { font-size: 28px; font-weight: 740; letter-spacing: -0.045em; line-height: 1.1; }
.opportunity {
  background: linear-gradient(180deg, #ECFDF5 0%, #F0FDFA 100%);
  border: 1px solid #A7F3D0; border-radius: 10px; padding: 12px 14px;
}
.opportunity h4 { font-size: 12px; font-weight: 700; color: #047857; margin-bottom: 4px; }
.opportunity p { font-size: 11.5px; color: #065F46; line-height: 1.45; }
.opp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.opp-grid div { background: #fff; border-radius: 8px; padding: 8px 10px; border: 1px solid #D1FAE5; }
.opp-grid .k { font-size: 10.5px; color: #047857; font-weight: 600; }
.opp-grid .v { font-size: 16px; font-weight: 730; letter-spacing: -0.03em; color: #064E3B; }

/* traffic banner */
.banner {
  display: flex; align-items: center; gap: 14px;
  background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 12px;
  padding: 9px 14px; font-size: 12px; color: #92400E;
}
.banner strong { color: #78350F; }
.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 12px; min-height: 0; }
.device-row { display: flex; align-items: center; gap: 10px; margin: 0 0 11px; }
.device-row .nm { width: 92px; font-size: 12.5px; font-weight: 600; flex: 0 0 92px; }
.device-row .track { flex: 1; height: 11px; }
.device-row .meta { width: 148px; text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); flex: 0 0 148px; }
.device-row .meta b { color: var(--text); font-weight: 700; }

.buyer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.buyer {
  background: #F6FAF8; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.buyer .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.buyer .v { font-size: 26px; font-weight: 740; letter-spacing: -0.045em; margin: 4px 0 2px; }
.buyer .s { font-size: 11.5px; color: var(--muted); }

/* Live */
.live-kpis { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr; gap: 12px; }
.live-hero .value { font-size: 42px; font-weight: 760; letter-spacing: -0.05em; display: flex; align-items: center; gap: 12px; }
.live-hero .label { font-size: 12px; }
.feed { display: flex; flex-direction: column; gap: 0; overflow: hidden; }
.feed-row {
  display: grid; grid-template-columns: 62px 1fr 72px 70px;
  gap: 8px; align-items: center;
  padding: 7.5px 2px; border-bottom: 1px solid #1A302C;
  font-size: 12px;
}
.feed-row:last-child { border-bottom: 0; }
.feed-row .ago { color: #7E9B96; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.feed-row .prod { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .loc { color: #8AA8A2; font-size: 11px; }
.feed-row .amt { font-weight: 720; font-variant-numeric: tabular-nums; text-align: right; color: #5EEAD4; }
.funnel { display: flex; flex-direction: column; gap: 8px; justify-content: center; flex: 1; }
.fun-step { display: grid; grid-template-columns: 108px 1fr 92px; gap: 10px; align-items: center; }
.fun-step .nm { font-size: 12px; font-weight: 600; }
.fun-bar { height: 26px; background: #1A302C; border-radius: 7px; overflow: hidden; position: relative; }
.fun-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #0F766E, #2DD4BF);
  border-radius: 7px;
}
.fun-step .cnt { text-align: right; font-weight: 720; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.fun-step .rate { display: block; font-size: 10.5px; font-weight: 550; color: #7E9B96; }
.alerts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 10px; padding: 11px 12px; border: 1px solid;
}
.alert .tag { font-size: 10px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 2px; }
.alert .ttl { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.alert .desc { font-size: 11.5px; line-height: 1.4; margin-top: 2px; opacity: .88; }
.alert.warn { background: rgba(217,119,6,.1); border-color: rgba(245,158,11,.35); color: #FDE68A; }
.alert.warn .tag { color: #FBBF24; }
.alert.info { background: rgba(13,148,136,.12); border-color: rgba(45,212,191,.28); color: #A7F3D0; }
.alert.info .tag { color: #5EEAD4; }
body.theme-dark .delta.up { background: rgba(5,150,105,.22); color: #6EE7B7; }
body.theme-dark .delta.down { background: rgba(220,38,38,.22); color: #FCA5A5; }
body.theme-dark .buyer { background: #16302C; border-color: #1E3632; }
body.theme-dark .opportunity { background: rgba(13,148,136,.12); border-color: rgba(45,212,191,.28); }
body.theme-dark .opportunity h4 { color: #5EEAD4; }
body.theme-dark .opportunity p { color: #A7F3D0; }

.ch-table td, .ch-table th { padding-top: 8px; padding-bottom: 8px; }
.rank { width: 18px; height: 18px; border-radius: 6px; background: #F0F5F3; color: #3F5A55; font-size: 10px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; }
.rank.gold { background: #ECFDF5; color: #047857; }

/* ——— App overrides (responsive, interactive) ——— */
html, body { width: auto; height: auto; min-height: 100vh; overflow: auto; }
.sidebar { height: 100vh; position: sticky; top: 0; }
.main { height: auto; min-height: 100vh; }
.content { overflow: visible; flex: 1 0 auto; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.grid2e { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 1100px) { .grid2, .grid2e, .grid3, .live-kpis, .abandon { grid-template-columns: 1fr; } .sidebar { display: none; } }
.ctrl select, .ctrl input { border: 0; background: transparent; font: inherit; color: inherit; outline: none; }
.ctrl input[type=date] { width: 120px; }
.sites span { cursor: pointer; user-select: none; }
.toggle { cursor: pointer; user-select: none; }
.toggle.off { background: #F1F5F3; color: var(--muted); border-color: var(--line-2); }
.toggle.off .knob { background: #B7C5C1; }
.toggle.off .knob::after { right: auto; left: 2px; }
.nav a { cursor: pointer; }
.loading { opacity: .55; transition: opacity .2s; }
.err { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; border-radius: 10px; padding: 10px 14px; }
.plotsvg { width: 100%; height: 260px; display: block; }
.spark { width: 100%; height: 120px; display: block; }
.logout { margin-top: 10px; display: block; color: #7E9B96; font-size: 11px; text-decoration: none; }
.logout:hover { color: #E8F5F2; }
table { width: 100%; }
.empty { color: var(--muted); font-size: 12px; padding: 8px 0; }
td.mono, td.r { white-space: nowrap; }
body.theme-dark .bar-row .nm, body.theme-dark .bar-row .amt { color: #E7F3F0; }
body.theme-dark .empty { color: #8AA8A2; }
.sidebar { align-self: flex-start; }
