/* SIGHT VR admin dashboard — tokens follow the data-viz reference palette. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f3f0;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6; /* blue  — single-series default, CNC */
  --series-2: #eb6834; /* orange — Milling */
  --series-3: #1baf7a; /* aqua  — Cobot */
  --series-1-soft: #cde2fb;
  --series-1-ink: #104281;
  --good: #006300;
  --bad: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px -16px rgba(11, 11, 11, 0.2);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-1-soft: #184f95;
    --series-1-ink: #cde2fb;
    --good: #0ca30c;
    --bad: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-1-soft: #184f95;
  --series-1-ink: #cde2fb;
  --good: #0ca30c;
  --bad: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- gate ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.gate-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.gate-card h1 { font-size: 20px; }
.gate-card p { color: var(--text-2); }
.gate-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--series-1);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 5px 4px;
  background:
    linear-gradient(90deg, transparent 0, transparent 100%);
  border-bottom: 2px solid #fff; border-left: 2px solid #fff; border-right: 2px solid #fff;
  border-radius: 0 0 3px 3px;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); background: var(--series-1); }
.btn-small { padding: 6px 10px; font-size: 13px; }
.btn-link { border: 0; background: none; color: var(--series-1); padding: 0; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); min-width: 200px; padding: 4px; display: grid;
}
.menu-list button {
  text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.menu-list button:hover { background: var(--surface-2); }

/* ---------- app frame ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.tab {
  border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--text-2);
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-email { color: var(--muted); font-size: 13px; }

.filters {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px 0;
}
.filter { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.filter select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.data-stamp { margin-left: auto; color: var(--muted); font-size: 12px; }

.main { padding: 16px; display: grid; gap: 16px; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; }
.view { display: grid; gap: 16px; }
.foot { padding: 12px 16px 24px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.span-all { grid-column: 1 / -1; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

/* stat tile */
.kpi { display: grid; gap: 4px; }
.kpi .label { color: var(--text-2); font-size: 13px; }
.kpi .value { font-size: 30px; font-weight: 600; line-height: 1.1; }
.kpi .hint { color: var(--muted); font-size: 12px; }

/* machine card */
.machine-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: 1px; margin-right: 6px; }
.stat-list { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.stat-list dt { color: var(--text-2); margin: 0; }
.stat-list dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* meter */
.meter { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.meter .track { flex: 1; height: 6px; border-radius: 3px; background: var(--series-1-soft); overflow: hidden; }
.meter .fill { height: 100%; background: var(--series-1); border-radius: 3px; }
.meter .num { font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; font-size: 13px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-width: 100%; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; vertical-align: middle;
}
table.data th { color: var(--text-2); font-weight: 500; position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td:first-child { white-space: normal; min-width: 140px; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .dir { color: var(--muted); font-size: 11px; margin-left: 4px; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
table.data tr.is-selected td { background: color-mix(in srgb, var(--series-1) 10%, var(--surface)); }
table.data th.group { text-align: center; border-bottom: 0; color: var(--muted); font-size: 12px; padding-bottom: 0; }
table.data th.group-l, table.data td.group-l { border-left: 1px solid var(--grid); }
.sub-cell { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.dim { color: var(--muted); }
.search {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-width: 220px;
}

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .cat { fill: var(--text-2); font-size: 12px; }
.chart .cat-head { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .val { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .bar.s1 { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .bar.s3 { fill: var(--series-3); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { filter: brightness(1.12); }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .area { fill: var(--series-1); opacity: 0.1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.toggle button { border: 0; background: none; padding: 3px 9px; font-size: 12px; cursor: pointer; color: var(--text-2); }
.toggle button.is-active { background: var(--surface-2); color: var(--text); }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--text); color: var(--page);
  padding: 6px 9px; border-radius: 7px; font-size: 12px; line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); max-width: 260px;
}
.tooltip b { font-weight: 600; }

/* learner detail */
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.detail-head .id { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--text-2); }
.pill.done { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); }

@media (max-width: 700px) {
  .main { padding: 12px; }
  .kpi .value { font-size: 24px; }
  .topbar { gap: 10px; }
}
