/* ChartMate licensing dashboard.
   Design tokens follow the dataviz-skill structure: full light palette on :root,
   dark redefined under both the OS media query and the explicit toggle, so the
   in-page theme switch wins both ways. Chart colors are the validated reference
   palette (categorical slots 1–3 all-pairs safe; sequential blue; fixed status
   colors paired with labels, never color alone). */

:root {
  color-scheme: light;
  /* surfaces + ink */
  --bg: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --border: #e3e2de;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a8983;
  /* brand chrome (product accent — charts use series tokens, not this) */
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #0f766e14;
  /* validated chart palette */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-400: #3987e5;
  --seq-550: #1c5cab;
  /* status — reserved, always with a label */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110;
    --surface-1: #1a1a19;
    --surface-2: #222221;
    --border: #33332f;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8a897f;
    --accent: #14b8a6;
    --accent-ink: #06211e;
    --accent-soft: #14b8a622;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface-1: #1a1a19;
  --surface-2: #222221;
  --border: #33332f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8a897f;
  --accent: #14b8a6;
  --accent-ink: #06211e;
  --accent-soft: #14b8a622;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Chrome ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; }
.brand .tile {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
}
.brand .sub { font-weight: 500; color: var(--text-muted); font-size: 13px; }
.topbar { flex-wrap: wrap; }
.topbar nav { display: flex; gap: 2px; margin-left: 8px; }
.topbar nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--text-secondary);
  font-weight: 550; font-size: 14px;
}
.topbar nav a:hover { background: var(--accent-soft); text-decoration: none; }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { flex: 1; }
.iconbtn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center;
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }

main { max-width: 1060px; margin: 0 auto; padding: 20px 16px 80px; }

/* ── Cards & layout ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card h2 + .hint { margin-top: 0; }
.hint { color: var(--text-secondary); font-size: 13px; margin: 4px 0 12px; }
.hint.tight { margin-bottom: 4px; }
.grid { display: grid; gap: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 640px) { main { padding: 14px 10px 70px; } .card { padding: 14px; } }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */
.tile-stat {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.tile-stat .k { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.tile-stat .l { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ── Pills (status always carries a label — never color alone) ──────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px 2px 7px;
  border: 1px solid var(--border); color: var(--text-secondary); background: var(--surface-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.pill.active   { color: var(--status-good); }   .pill.active::before   { background: var(--status-good); }
.pill.suspended{ color: #a06a00; }              .pill.suspended::before{ background: var(--status-warning); }
.pill.blocked  { color: var(--status-serious); }.pill.blocked::before  { background: var(--status-serious); }
.pill.revoked  { color: var(--status-critical); }.pill.revoked::before { background: var(--status-critical); }
.pill.site     { color: var(--accent); }        .pill.site::before     { background: var(--accent); }
.pill.seat     { color: var(--series-1); }      .pill.seat::before     { background: var(--series-1); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
  border-radius: 9px; padding: 7px 14px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--status-critical); }
.btn.danger:hover { border-color: var(--status-critical); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 12px; border-radius: 9px; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin: 10px 0 4px; }
.formrow { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.formrow > div { flex: 1; min-width: 130px; }

/* ── Tables (scroll inside the card on phones) ──────────────────────────── */
.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 650; padding: 6px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rowname { font-weight: 600; }
.rowsub { font-size: 12px; color: var(--text-muted); }

/* ── Bars (single-hue sequential; thin marks, rounded data end, tooltip) ── */
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 64px; gap: 10px; align-items: center; padding: 5px 0; }
.bar-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--border) 45%, transparent); position: relative; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--seq-400); min-width: 2px; }
.bar-val { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-secondary); text-align: right; }

/* ── Key reveal ─────────────────────────────────────────────────────────── */
.keybox {
  font: 600 16px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--accent-soft); border: 1px dashed var(--accent);
  padding: 12px 14px; border-radius: 10px; text-align: center; letter-spacing: .04em;
  user-select: all; word-break: break-all;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 50;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); width: 100%; max-width: 440px; padding: 20px;
  max-height: 90dvh; overflow-y: auto;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: var(--bg);
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  z-index: 60; box-shadow: var(--shadow); max-width: 90vw;
}

/* ── Activity feed ──────────────────────────────────────────────────────── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.feed li:last-child { border-bottom: none; }
.feed .when { color: var(--text-muted); font-size: 12px; white-space: nowrap; min-width: 82px; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 82dvh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 14px; }
details.firsttime { margin-top: 14px; }
details.firsttime summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13.5px; }

.empty { color: var(--text-muted); font-size: 13.5px; padding: 14px 0; text-align: center; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.section-h h2 { margin: 0; font-size: 16px; }
.warnbox {
  border: 1px solid color-mix(in srgb, var(--status-warning) 55%, var(--border));
  background: color-mix(in srgb, var(--status-warning) 9%, var(--surface-1));
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0;
}
