/* Geely Phone Dashboard — design tokens follow the validated reference palette */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;   /* categorical slot 1, blue    */
  --s2: #eb6834;   /* slot 2, orange              */
  --s3: #1baf7a;   /* slot 3, aqua                */
  --s4: #eda100;   /* slot 4, yellow              */
  --s5: #e87ba4;   /* slot 5, magenta             */
  --s6: #008300;   /* slot 6, green               */
  --s7: #4a3aa7;   /* slot 7, violet              */
  --s8: #e34948;   /* slot 8, red                 */
  --seq: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-text: #006300;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
    --seq: #3987e5;
    --good-text: #0ca30c;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --s7: #9085e9;
  --s8: #e66767;
  --seq: #3987e5;
  --good-text: #0ca30c;
  --accent: #3987e5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); }

/* ---------- header ---------- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand h1 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); }
.brand-divider { width: 1px; height: 20px; background: var(--baseline); }
/* the official SVG is white-filled: invert to black on light surfaces */
.brand-logo { height: 22px; width: auto; display: block; filter: invert(1); }
.login-logo { height: 44px; width: auto; display: block; margin: 0 auto 20px; filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .brand-logo,
  :root:where(:not([data-theme="light"])) .login-logo { filter: none; }
}
:root[data-theme="dark"] .brand-logo,
:root[data-theme="dark"] .login-logo { filter: none; }
.brand .sub { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--border); background: transparent; color: var(--ink-2);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px;
}
.iconbtn:hover { background: var(--grid); }

/* ---------- filters ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 22px 0;
}
.range-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
}
.chip:hover { border-color: var(--baseline); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.filters .custom { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; }
.filters input[type="date"], .filters select, .filters input[type="search"] {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 5px 8px; font-size: 12.5px; font-family: inherit;
}
.freshness { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- layout: sidebar + main ---------- */
.shell { display: flex; min-height: calc(100vh - 57px); }
.sidebar {
  width: 198px; flex: 0 0 auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 10px;
}
.nav-title {
  color: var(--muted); font-size: 10.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.09em; padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; color: var(--ink-2); font: inherit;
  font-size: 13.5px; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  text-align: left; margin-bottom: 2px;
}
.nav-item:hover { background: var(--grid); }
.nav-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--ink); font-weight: 650;
}
.nav-ico { font-size: 15px; width: 20px; text-align: center; }
.main-col { flex: 1; min-width: 0; }
.wrap { padding: 14px 22px 40px; max-width: 1220px; }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto; display: flex; gap: 4px; align-items: center;
    padding: 8px 12px; border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .nav-title { display: none; }
  .nav-item { width: auto; white-space: nowrap; margin-bottom: 0; }
}

/* topic chips in call log */
.topic-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 8px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap;
  margin-right: 4px;
}
.topic-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.remark { color: var(--muted); font-size: 11.5px; margin-top: 2px; max-width: 340px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px;
}
.tile .label { color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.tile .hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 980px) { .grid2 { grid-template-columns: 3fr 2fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; overflow: hidden;
}
.card h2 { font-size: 13.5px; font-weight: 650; margin-bottom: 2px; }
.card .subtitle { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.card .scroller { overflow-x: auto; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 4px; }
.legend .item { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

svg text { font-family: inherit; }
.axis-label { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--muted); font-weight: 550; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 9px; font-size: 12px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--ink-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.answered { color: var(--good-text); }
.pill.answered .dot { background: var(--good); }
.pill.missed { color: var(--critical); }
.pill.missed .dot { background: var(--critical); }
.pill.after_hours .dot { background: var(--muted); }
.pill.abandoned .dot { background: var(--warning); }
.pill.no_answer .dot { background: var(--muted); }

.dir-ico { font-size: 13px; }

/* ---------- call log controls ---------- */
.logbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.logbar .grow { flex: 1; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.btn:hover { border-color: var(--baseline); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 12.5px; }

/* ---------- tooltip ---------- */
#tooltip {
  position: fixed; pointer-events: none; z-index: 50; display: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); max-width: 260px;
}
#tooltip .t-title { font-weight: 650; margin-bottom: 3px; }
#tooltip .t-row { display: flex; gap: 8px; justify-content: space-between; }
#tooltip .t-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--page); padding: 20px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 380px; padding: 34px 32px;
}
.login-card .logo { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.login-card .logo-sub { color: var(--muted); font-size: 13px; margin: 4px 0 24px; }
.login-card label { display: block; color: var(--ink-2); font-size: 12.5px; margin-bottom: 6px; }
.login-card input {
  width: 100%; border: 1px solid var(--border); background: var(--page); color: var(--ink);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; font-family: inherit;
  letter-spacing: 0.08em;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-card button {
  width: 100%; margin-top: 16px; background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 11px; font-size: 14.5px; font-weight: 650; cursor: pointer;
  font-family: inherit;
}
.login-card .err { color: var(--critical); font-size: 12.5px; margin-top: 10px; min-height: 18px; }
.login-card .foot { color: var(--muted); font-size: 11.5px; margin-top: 22px; text-align: center; }

.footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 18px 0 30px; }
.hidden { display: none !important; }
