/*
 * Dashboard styles.
 *
 * Chart colors follow the data-viz reference palette; the single data hue is
 * validated against both surfaces (all six checks pass, light and dark). The
 * brand green is UI-only — buttons and links — and never encodes data.
 */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --deemph: #d7d6d0;
  --good: #006300;
  --accent: #1a7f5a;
  --accent-fg: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #fff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --deemph: #35342f;
    --good: #0ca30c;
    --accent: #3ddc97;
    --accent-fg: #08120d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- chrome ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 0 20px; }
.top .brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.top .spacer { flex: 1; }
.who { color: var(--text-secondary); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--baseline); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.card .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.head { display: flex; align-items: flex-start; gap: 12px; }
.head .spacer { flex: 1; }

/* ---------- filter row: one row above everything it scopes ---------- */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button {
  padding: 8px 14px; border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--accent-fg); }

/* ---------- stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .label { color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }
/* proportional figures — tabular-nums makes large numbers look loose */
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .foot { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }        /* solid hairline, never dashed */
.axis-line { stroke: var(--baseline); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar { fill: var(--series-1); }
.bar-hit { fill: transparent; cursor: pointer; }
.bar-hit:hover + .bar, .bar-hit:focus + .bar { opacity: .82; }
.dlabel { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.empty-note { color: var(--text-muted); font-size: 13px; padding: 28px 0; text-align: center; }

.tip {
  position: fixed; pointer-events: none; z-index: 30; opacity: 0;
  background: var(--text-primary); color: var(--surface-1);
  padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.35;
  transition: opacity .12s; white-space: nowrap;
}
.tip.show { opacity: 1; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.tableview { display: none; }
.tableview.show { display: block; }

/* ---------- upload ---------- */
.drop {
  border: 1.5px dashed var(--baseline); border-radius: 12px; padding: 28px;
  text-align: center; color: var(--text-secondary); cursor: pointer;
}
.drop.over { border-color: var(--accent); color: var(--text-primary); }
.prog { height: 6px; background: var(--deemph); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.prog > i { display: block; height: 100%; width: 0; background: var(--series-1); transition: width .15s; }
.uprow { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-top: 10px; gap: 10px; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 8vh auto; }
.login input {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit; margin-bottom: 10px;
}
.err { color: #d03b3b; font-size: 13px; min-height: 18px; }
.msg { color: var(--good); font-size: 13px; min-height: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%);
  background: var(--text-primary); color: var(--surface-1); padding: 10px 18px;
  border-radius: 999px; font-size: 14px; transition: transform .22s; z-index: 40;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.hide { display: none !important; }
