/* Drive dashboard — calm dark UI, one accent, light theme mirrors it. */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090e1a;
  --glow-1: rgba(57, 135, 229, 0.16);
  --glow-2: rgba(27, 175, 122, 0.07);
  --surface: #10172a;
  --surface-2: #151e34;
  --surface-3: #1b2640;
  --raise: rgba(255, 255, 255, 0.025);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #eef2f9;
  --text-2: #a9b3c6;
  --muted: #7a849a;
  --grid: rgba(255, 255, 255, 0.06);
  --axis: rgba(255, 255, 255, 0.16);
  --accent: #3987e5;
  --accent-2: #6aa8f2;
  --accent-soft: rgba(57, 135, 229, 0.14);
  --accent-rgb: 57, 135, 229;
  --accent-ink: #ffffff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --good: #0ca30c;
  --good-text: #3ccf5a;
  --good-soft: rgba(12, 163, 12, 0.14);
  --warn: #fab219;
  --warn-soft: rgba(250, 178, 25, 0.14);
  --bad: #d03b3b;
  --bad-text: #f07a7a;
  --bad-soft: rgba(208, 59, 59, 0.16);
  --topbar: rgba(9, 14, 26, 0.72);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.18);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --glow-1: rgba(42, 120, 214, 0.10);
  --glow-2: rgba(27, 175, 122, 0.05);
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #edf1f7;
  --raise: rgba(11, 18, 32, 0.015);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text: #0e1526;
  --text-2: #4a5468;
  --muted: #6b7489;
  --grid: rgba(15, 23, 42, 0.07);
  --axis: rgba(15, 23, 42, 0.2);
  --accent: #2a78d6;
  --accent-2: #4a90e2;
  --accent-soft: rgba(42, 120, 214, 0.1);
  --accent-rgb: 42, 120, 214;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good-text: #006300;
  --good-soft: rgba(12, 163, 12, 0.1);
  --warn: #c98500;
  --warn-soft: rgba(250, 178, 25, 0.16);
  --bad-text: #b42323;
  --bad-soft: rgba(208, 59, 59, 0.1);
  --topbar: rgba(244, 246, 250, 0.78);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.05);
  --shadow-pop: 0 18px 48px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(900px 480px at 8% -8%, var(--glow-1), transparent 70%),
    radial-gradient(700px 420px at 100% 0%, var(--glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin-top: 12px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- buttons & controls ---------- */
.btn, .control {
  appearance: none; font: inherit; font-weight: 500; color: var(--text);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; cursor: pointer;
  border-radius: 10px; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn { border: 1px solid transparent; background: transparent; padding: 7px 11px; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { padding: 7px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.control {
  height: 38px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow);
}
.control:hover { border-color: var(--border-strong); }
.control svg { color: var(--muted); }
.control .chev { width: 14px; height: 14px; }
.control-icon { width: 38px; padding: 0; justify-content: center; }
.control-icon.is-spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented {
  display: inline-flex; height: 38px; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.segmented button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500;
  padding: 0 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface-3); color: var(--text); }
.segmented button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--topbar); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; gap: 11px; align-items: center; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, #4c96ee, #2a63c4); color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: 0.4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 6px 16px rgba(42, 120, 214, 0.35);
}
.logo-lg { width: 48px; height: 48px; border-radius: 14px; font-size: 16px; }
.brand-title { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.live {
  display: inline-flex; align-items: center; gap: 7px; margin-right: 8px; font-size: 12px; color: var(--text-2);
  padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
}
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.is-ok .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); animation: pulse 2.4s ease-out infinite; }
.live.is-warn .dot { background: var(--warn); }
.live.is-error .dot { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.45); } 70%, 100% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .live .dot, .control-icon.is-spinning svg { animation: none !important; } }

/* ---------- page ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 28px 28px 48px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 6px; }
.hero-title { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }

.period { position: relative; }
.period-menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40; width: 280px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px;
}
.period-presets button {
  display: flex; width: 100%; align-items: center; justify-content: space-between; appearance: none; border: 0;
  background: transparent; color: var(--text); font: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left;
}
.period-presets button:hover { background: var(--surface-2); }
.period-presets .check { font-weight: 800; font-size: 15px; color: var(--accent); visibility: hidden; }
.period-presets button[aria-checked="true"] .check { visibility: visible; }
.period-custom { border-top: 1px solid var(--border); margin-top: 6px; padding: 10px 6px 4px; display: grid; gap: 8px; }
.period-custom label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.period-custom input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 5px 8px; font: inherit; }

.alert {
  display: flex; gap: 10px; align-items: baseline; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 10px; font-size: 13px; color: var(--text-2);
}
.alert::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; transform: translateY(-1px); }
.alert.is-error::before { background: var(--bad); }
.alert strong { color: var(--text); white-space: nowrap; font-weight: 600; }

#main { transition: opacity 0.2s; }
#main.is-loading { opacity: 0.55; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px 18px 14px; box-shadow: var(--shadow); min-width: 0; overflow: hidden;
}
.tile-top { display: flex; align-items: center; gap: 9px; }
.tile-icon {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-2);
}
.tile-icon svg { width: 15px; height: 15px; }
.tile-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.tile-value { font-size: 27px; font-weight: 650; letter-spacing: -0.02em; margin: 12px 0 6px; overflow-wrap: anywhere; line-height: 1.15; }
.tile-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); min-height: 22px; }
.tile .spark { display: block; width: 100%; height: 34px; margin-top: 10px; overflow: visible; }
.tile .spark-empty { height: 34px; margin-top: 10px; }
.delta {
  display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.delta.is-good { color: var(--good-text); background: var(--good-soft); }
.delta.is-bad { color: var(--bad-text); background: var(--bad-soft); }

/* ---------- checks ---------- */
.check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
.check {
  display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.ring { width: 44px; height: 44px; flex: none; }
.ring svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: var(--muted); transition: stroke-dashoffset 0.4s; }
.ring.ok .bar { stroke: var(--good); }
.ring.warn .bar { stroke: var(--warn); }
.ring.bad .bar { stroke: var(--bad); }
.ring-icon { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.ring-icon.ok { color: var(--good-text); background: var(--good-soft); }
.ring-icon.warn { color: var(--warn); background: var(--warn-soft); }
.ring-icon svg { width: 20px; height: 20px; }
.check-body { min-width: 0; }
.check-label { font-size: 12.5px; color: var(--text-2); }
.check-value { font-size: 17px; font-weight: 650; margin: 1px 0; font-variant-numeric: tabular-nums; }
.check-sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.status-tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); }
.status-tag.ok { color: var(--good-text); background: var(--good-soft); }
.status-tag.warn { color: var(--warn); background: var(--warn-soft); }
.status-tag.bad { color: var(--bad-text); background: var(--bad-soft); }

/* ---------- cards ---------- */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }
.split > .card { margin-top: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 20px 22px; margin-top: 14px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.card-head p { margin-top: 2px; font-size: 12.5px; }

.tabs, .chips { display: flex; gap: 2px; flex-wrap: wrap; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.tab, .chip {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 7px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.tab:hover, .chip:hover { color: var(--text); }
.tab[aria-selected="true"], .chip.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.chip .count { color: var(--muted); margin-left: 5px; font-variant-numeric: tabular-nums; }

.chart-meta { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-summary { display: flex; gap: 28px; flex-wrap: wrap; }
.chart-summary div { font-size: 12px; color: var(--muted); }
.chart-summary strong { display: block; font-size: 19px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-wrap { position: relative; height: 290px; }

/* ---------- funnel ---------- */
.funnel { display: grid; gap: 4px; }
.funnel-step { display: grid; gap: 6px; }
.funnel-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.funnel-label { font-weight: 500; color: var(--text-2); font-size: 13px; }
.funnel-num { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.funnel-num small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.funnel-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s; min-width: 0; }
.funnel-cv { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 4px 0 6px 2px; font-variant-numeric: tabular-nums; }
.funnel-cv svg { width: 12px; height: 12px; }
.funnel-foot { font-size: 12px; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- daily table (collapsible) ---------- */
.daily-details summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; }
.daily-details summary::-webkit-details-marker { display: none; }
.daily-details summary > span { display: flex; flex-direction: column; gap: 2px; }
.daily-details summary .muted { font-size: 12.5px; }
.daily-details summary .chev { width: 18px; height: 18px; color: var(--muted); transition: transform 0.2s; }
.daily-details[open] summary .chev { transform: rotate(180deg); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th {
  text-align: right; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  padding: 9px 12px; background: var(--surface-2); white-space: nowrap; border-bottom: 1px solid var(--border);
}
.table th:first-child { border-radius: 10px 0 0 10px; text-align: left; }
.table th:last-child { border-radius: 0 10px 10px 0; }
.table td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td:first-child { text-align: left; }
.table td.wrap { white-space: normal; min-width: 220px; text-align: left; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table-click tbody tr { cursor: pointer; transition: background 0.12s; }
.table-click tbody tr:hover td { background: var(--raise); }
.table tr.sub td { color: var(--text-2); font-size: 12.5px; background: var(--raise); }
.table tr.sub td:first-child { padding-left: 34px; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.table .dim { color: var(--muted); opacity: 0.6; }
.meter { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.meter-track { width: 54px; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-bar { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.obj-name { font-weight: 550; display: flex; align-items: center; gap: 6px; }
.obj-name svg { width: 14px; height: 14px; color: var(--muted); transition: transform 0.15s; }
tr[aria-expanded="true"] .obj-name svg { transform: rotate(90deg); }
.obj-meta { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2);
  padding: 2px 9px 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.pill.active { color: var(--good-text); background: var(--good-soft); border-color: transparent; }
.pill.active::before { background: var(--good); }
.pill.paused::before { background: var(--warn); }

/* ---------- creatives ---------- */
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.creative {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; overflow: hidden; cursor: pointer;
  text-align: left; color: inherit; font: inherit; padding: 0; display: flex; flex-direction: column;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.creative:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.creative-thumb { aspect-ratio: 1 / 1; background: var(--surface-3); position: relative; overflow: hidden; }
.creative-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s; }
.creative:hover .creative-thumb img { transform: scale(1.03); }
.creative-thumb::after { content: ""; position: absolute; inset: auto 0 0 0; height: 45%; background: linear-gradient(to top, rgba(6, 10, 20, 0.72), transparent); pointer-events: none; }
.creative-thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.thumb-cpl { position: absolute; left: 10px; bottom: 9px; z-index: 1; color: #fff; font-size: 12px; }
.thumb-cpl strong { font-size: 17px; font-weight: 650; margin-right: 4px; }
.badge {
  position: absolute; top: 9px; left: 9px; z-index: 1; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: rgba(6, 10, 20, 0.66); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.badge.win { background: rgba(12, 163, 12, 0.85); border-color: transparent; }
.badge.status { left: auto; right: 9px; display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.badge.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #9aa3b5; }
.badge.status.active::before { background: #2fd05a; }
.badge.status.paused::before { background: #fab219; }
.badge.exp { background: rgba(208, 59, 59, 0.85); border-color: transparent; }
.creative-body { padding: 11px 12px 12px; display: grid; gap: 9px; }
.creative-name { font-weight: 600; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.creative-camp { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.creative-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 9px; border-top: 1px solid var(--border); }
.creative-stats div { font-size: 11px; color: var(--muted); }
.creative-stats strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.empty-block { color: var(--muted); text-align: center; padding: 36px 10px; border: 1px dashed var(--border-strong); border-radius: 14px; grid-column: 1 / -1; }

.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mini-stats div { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.mini-stats strong { display: block; font-size: 19px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

.footer { margin-top: 22px; font-size: 12px; text-align: center; color: var(--muted); display: grid; gap: 2px; }

/* ---------- modal ---------- */
.modal {
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border: 1px solid var(--border-strong);
  border-radius: 20px; background: var(--surface); color: var(--text); padding: 0; overflow: auto; box-shadow: var(--shadow-pop);
}
.modal::backdrop { background: rgba(4, 7, 14, 0.6); backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px 22px; }
.modal-body h3 { font-size: 14px; margin: 20px 0 4px; }
.modal-grid { display: grid; grid-template-columns: 230px 1fr; gap: 20px; }
.modal-grid img { width: 100%; border-radius: 14px; display: block; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kv div { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.kv strong { display: block; font-size: 14.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.creative-text { white-space: pre-wrap; color: var(--text-2); font-size: 13px; margin-top: 12px; line-height: 1.55; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 30px 28px 28px; display: grid; gap: 18px; box-shadow: var(--shadow-pop);
}
.login-title { font-size: 21px; margin-bottom: 4px; }
.field { display: grid; gap: 7px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.field input {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 11px; padding: 11px 13px; font: inherit; font-size: 15px; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { color: var(--bad-text); font-size: 13px; margin: -8px 0 -6px; min-height: 18px; }

/* ---------- summary (hero) ---------- */
.summary {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 0;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.10), transparent 55%), var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.summary-text { padding: 22px 26px; }
.insight { font-size: 18px; line-height: 1.6; color: var(--text-2); max-width: 70ch; text-wrap: pretty; }
.insight strong { color: var(--text); font-weight: 600; }
.hero-metric { padding: 22px 26px 18px; border-left: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; }
.hero-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.hero-value { font-size: 40px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; margin: 8px 0; font-variant-numeric: tabular-nums; }
.money .unit { font-size: 0.62em; font-weight: 550; color: var(--text-2); margin: 0 0.06em; letter-spacing: 0; }
.tile-value .money .unit { font-size: 0.66em; }
.spark-lg { display: block; width: 100%; height: 44px; margin-top: 12px; overflow: visible; }
.spark-lg-empty { height: 12px; }

/* ---------- summary highlights ---------- */
.hl-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 16px; }
.hl {
  display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: inherit; cursor: pointer;
  padding: 10px 12px 10px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s; min-width: 0;
}
.hl:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.hl-thumb { width: 46px; height: 46px; border-radius: 10px; overflow: hidden; flex: none; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); position: relative; }
.hl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hl-thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.hl-body { display: grid; gap: 1px; min-width: 0; }
.hl-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.hl.best .hl-label { color: var(--good-text); }
.hl.idle .hl-label { color: var(--bad-text); }
.hl-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-camp { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.hl-meta { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hl-meta strong { color: var(--text); font-weight: 600; }

/* ---------- ratio strip ---------- */
.ratio-strip { margin-top: 14px; }
.ratio-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); padding: 0; margin-top: 0; }
.ratio { padding: 14px 18px; border-left: 1px solid var(--border); display: grid; gap: 4px; align-content: start; justify-items: start; }
.ratio:first-child { border-left: 0; }
.ratio-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.ratio-value { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.connect { margin-top: 0; }

/* ---------- empty states ---------- */
.empty-state { display: flex; gap: 14px; align-items: flex-start; padding: 6px 2px; }
.empty-state strong { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 3px; }
.empty-state p { color: var(--muted); font-size: 13px; max-width: 62ch; margin-bottom: 10px; }
.empty-state p:last-child { margin-bottom: 0; }
.empty-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-2); }
.empty-icon svg { width: 20px; height: 20px; }

/* ---------- signals ---------- */
.split-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 14px; }
.signals { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.signal { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.signal strong { font-size: 13.5px; font-weight: 600; }
.signal p { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.signal-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.signal-icon svg { width: 16px; height: 16px; }
.signal.bad .signal-icon { background: var(--bad-soft); color: var(--bad-text); }
.signal.warn .signal-icon { background: var(--warn-soft); color: var(--warn); }
.signal.good .signal-icon { background: var(--good-soft); color: var(--good-text); }
.signal.info .signal-icon { background: var(--accent-soft); color: var(--accent-2); }
.signal.calm { background: transparent; border-style: dashed; }

/* ---------- plan ---------- */
.plan { display: grid; gap: 14px; }
.plan-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.plan-label { font-weight: 500; color: var(--text-2); }
.plan-nums { color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-nums strong { color: var(--text); font-weight: 650; font-size: 15px; }
.plan-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); margin: 7px 0 6px; }
.plan-bar { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); max-width: 100%; transition: width 0.4s; }
.plan-row.warn .plan-bar { background: var(--warn); }
.plan-row.bad .plan-bar { background: var(--bad); }
.plan-row.ok .plan-bar { background: var(--good); }
.plan-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--text); opacity: 0.55; transform: translateX(-1px); }
.plan-goal { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }
.plan-foot { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.plan-row.is-empty .plan-top { color: var(--muted); }
.plan-form { display: grid; gap: 12px; max-width: 420px; }

/* ---------- funnel cost ---------- */
.funnel-cost { margin-left: 8px; font-size: 11.5px; color: var(--muted); font-weight: 400; }

/* ---------- heatmap ---------- */
.heatmap { overflow-x: auto; }
.heat-grid { display: grid; grid-template-columns: 28px repeat(24, minmax(16px, 1fr)); gap: 3px; min-width: 560px; }
.heat-hour { font-size: 10.5px; color: var(--muted); text-align: left; padding-bottom: 2px; font-variant-numeric: tabular-nums; }
.heat-day { font-size: 11.5px; color: var(--muted); align-self: center; }
.heat-cell { height: 20px; border-radius: 4px; background: var(--surface-2); transition: outline-color 0.1s; outline: 1px solid transparent; }
.heat-cell:hover { outline-color: var(--text-2); }
.heat-legend { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.heat-legend span { margin: 0 4px; }
.heat-legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; background: rgba(var(--accent-rgb), 0.15); }
.heat-legend i:nth-of-type(2) { background: rgba(var(--accent-rgb), 0.35); }
.heat-legend i:nth-of-type(3) { background: rgba(var(--accent-rgb), 0.55); }
.heat-legend i:nth-of-type(4) { background: rgba(var(--accent-rgb), 0.78); }
.heat-legend i:nth-of-type(5) { background: rgba(var(--accent-rgb), 1); }

/* ---------- misc additions ---------- */
.head-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.badge.tired { background: rgba(201, 133, 0, 0.88); border-color: transparent; }
.legend i.dashed { height: 0; border-top: 2px dashed; background: none !important; }
.chart-summary strong .delta { font-size: 11px; vertical-align: middle; margin-left: 4px; }
.segmented button[data-view] { min-width: 34px; font-weight: 600; }

body.no-crm [data-crm-only] { display: none !important; }
body.sales-mode [data-pipeline-only] { display: none !important; }

/* ---------- sales breakdown ---------- */
.bd { display: grid; gap: 4px; }
.bd-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; text-align: left; font: inherit; color: inherit; background: transparent; border: 0; width: 100%;
}
.bd-row:hover { background: var(--surface-2); }
.bd-label { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-num { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bd-num small { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.bd-track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bd-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bd-meta { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bd-more { font-size: 12px; color: var(--muted); padding: 6px 10px; }

/* ---------- TV mode ---------- */
body.tv .filters, body.tv #alerts, body.tv .daily-card, body.tv #creatives-card, body.tv #attr-card,
body.tv #campaigns-card, body.tv #checks, body.tv .footer, body.tv #pdf-btn, body.tv #logout-btn,
body.tv #plan-edit, body.tv .hero .muted { display: none !important; }
body.tv .page, body.tv .topbar-inner { max-width: 1760px; }
body.tv .hero-title { font-size: 34px; }
body.tv .insight { font-size: 20px; }
body.tv .hero-value { font-size: 56px; }
body.tv .tile-value { font-size: 36px; }
body.tv .ratio-value { font-size: 24px; }
body.tv .chart-wrap { height: 340px; }
body.tv .topbar { position: static; }

/* ---------- loading screen: sunset → sunrise over the road ---------- */
.loader { position: fixed; inset: 0; z-index: 100; background: #050816; overflow: hidden; transition: opacity 0.6s ease, visibility 0.6s; }
.loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.sky-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; stroke: none; fill: none; }
.sky-scene .road-shine { opacity: 0.6; }
.sky-scene .sky-dawn { animation: sky-dawn 9s ease-in-out infinite; }
.sky-scene .sky-day { animation: sky-day 9s ease-in-out infinite; }
.sky-scene .stars { animation: stars 9s ease-in-out infinite; }
.sky-scene .stars circle { fill: #fff; animation: twinkle 2.6s ease-in-out infinite alternate; }
.sky-scene .sun { animation: sun 9s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
.sky-scene .hglow { animation: hglow 9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.sky-scene .road-edge { stroke: rgba(255, 255, 255, 0.28); stroke-width: 3; fill: none; }
.sky-scene .lane { stroke: #fff; stroke-width: 7; stroke-dasharray: 34 30; fill: none; animation: lane-run 0.9s linear infinite; }

.loader-copy {
  position: absolute; left: 50%; bottom: max(7vh, 40px); transform: translateX(-50%);
  display: grid; justify-items: center; gap: 6px; text-align: center; width: min(420px, calc(100% - 32px)); z-index: 1; isolation: isolate;
}
.loader-copy::before {
  content: ""; position: absolute; inset: -28px -60px -20px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(5, 8, 22, 0.7), rgba(5, 8, 22, 0));
}
.loader-brand { font-size: 18px; font-weight: 650; color: #fff; letter-spacing: -0.01em; margin-top: 6px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); }
.loader-text { font-size: 14.5px; color: rgba(255, 255, 255, 0.78); min-height: 22px; transition: opacity 0.3s; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.loader-text.is-swap { opacity: 0; }

/* one 9s day: dusk → night → dawn → day → dusk */
@keyframes sun {
  0% { transform: translateY(-60px); }
  22% { transform: translateY(170px); }
  32% { transform: translateY(170px); }
  56% { transform: translateY(-300px); }
  76% { transform: translateY(-300px); }
  100% { transform: translateY(-60px); }
}
@keyframes sky-dawn { 0% { opacity: 0.95; } 22% { opacity: 0.15; } 32% { opacity: 0.15; } 44% { opacity: 1; } 60% { opacity: 0.25; } 76% { opacity: 0.25; } 92% { opacity: 1; } 100% { opacity: 0.95; } }
@keyframes sky-day { 0% { opacity: 0; } 32% { opacity: 0; } 58% { opacity: 0.95; } 76% { opacity: 0.95; } 100% { opacity: 0; } }
@keyframes stars { 0% { opacity: 0.2; } 20% { opacity: 1; } 34% { opacity: 1; } 46% { opacity: 0; } 92% { opacity: 0; } 100% { opacity: 0.2; } }
@keyframes hglow { 0% { opacity: 1; } 22% { opacity: 0.1; } 32% { opacity: 0.2; } 44% { opacity: 1; } 60% { opacity: 0.35; } 76% { opacity: 0.35; } 92% { opacity: 1; } 100% { opacity: 1; } }
@keyframes twinkle { from { opacity: 0.35; } to { opacity: 1; } }
@keyframes lane-run { to { stroke-dashoffset: -64; } }

/* thin "route" bar with a tiny car while data refreshes */
.route { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.route.is-on { opacity: 1; background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.5), transparent); }
.route-car {
  position: absolute; top: -5px; left: 0; width: 22px; height: 11px; border-radius: 5px 7px 3px 3px;
  background: linear-gradient(180deg, #5aa2f0, #2a63c4); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6);
}
.route-car::before, .route-car::after { content: ""; position: absolute; bottom: -3px; width: 6px; height: 6px; border-radius: 50%; background: #1a1f2b; }
.route-car::before { left: 3px; }
.route-car::after { right: 3px; }
.route.is-on .route-car { animation: drive 1.6s ease-in-out infinite; }
@keyframes drive { 0% { transform: translateX(-30px); } 100% { transform: translateX(calc(100vw + 30px)); } }

@media (prefers-reduced-motion: reduce) {
  .sky-scene *, .route-car { animation: none !important; }
  .sky-scene .sun { transform: translateY(-40px); }
  .sky-scene .stars { opacity: 0.2; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .split, .split-even { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .hero-metric { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 1080px) {
  .kpi-grid, .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 16px; }
  .brand-sub, .hide-sm, .live-text { display: none; }
  .live { padding: 6px; margin-right: 2px; }
  .page { padding: 20px 16px 36px; }
  .hero-title { font-size: 22px; }
  .kpi-grid, .check-grid { gap: 10px; }
  .check-grid { grid-template-columns: 1fr; }
  .tile { padding: 13px 13px 11px; }
  .tile-value { font-size: 20px; margin-top: 10px; }
  .tile-icon { display: none; }
  .card { padding: 16px; border-radius: 16px; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-wrap { height: 230px; }
  .summary-text, .hero-metric { padding: 18px; }
  .insight { font-size: 15px; }
  .hero-value { font-size: 32px; }
  .ratio-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratio { border-left: 0; border-top: 1px solid var(--border); }
  .ratio:nth-child(-n+2) { border-top: 0; }
  .ratio:nth-child(even) { border-left: 1px solid var(--border); }
  .heat-legend { display: none; }
  .creative-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .creative-body { padding: 9px 10px 10px; }
  .creative-stats { grid-template-columns: repeat(2, 1fr); }
  .thumb-cpl strong { font-size: 15px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  .segmented button { padding: 0 9px; }
}

/* ---------- print / PDF ---------- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f6f8fc; --surface-3: #edf1f7; --border: #e3e7ee; --border-strong: #cfd5df;
    --text: #0e1526; --text-2: #4a5468; --muted: #6b7489; --grid: #e7eaf0; --series-1: #2a78d6; --series-2: #eb6834;
    --good-text: #006300; --bad-text: #b42323; --accent-soft: rgba(42, 120, 214, 0.1); --shadow: none;
  }
  body { background: #fff; }
  .topbar, .filters, .alert, .chips, .tabs, #plan-edit { display: none !important; }
  .summary { background: #fff; }
  .page { max-width: none; padding: 0; }
  .card, .tile, .check { box-shadow: none; break-inside: avoid; }
  .split { grid-template-columns: 1fr; }
  .creative-grid { grid-template-columns: repeat(4, 1fr); }
  .table-scroll { overflow: visible; }
  .daily-details > *:not(summary) { display: block; }
}
