/* PerfDash — dark-only by design: this renders on a wall TV, never in a
   bright document. Palette roles below follow the validated dark steps. */
:root {
  color-scheme: dark;

  --plane:        #0d0d0d;
  --surface-1:    #141416;
  --surface-2:    #1a1a19;
  --border:       rgba(255,255,255,0.10);
  --grid:         #2c2c2a;
  --baseline:     #383835;

  --ink:          #ffffff;
  --ink-2:        #c3c2b7;
  --ink-muted:    #898781;

  --series-1:     #3987e5;   /* blue  — single-measure magnitude */
  --series-2:     #d95926;   /* orange */
  --series-3:     #199e70;   /* aqua  */

  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --neutral:      #898781;
  --idle:         #383835;

  --r: 10px;
  --gap: clamp(10px, 0.9vw, 18px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(13px, 0.85vw, 18px);
  overflow: hidden;
}
body.scroll { overflow: auto; }

/* ---- shell ---------------------------------------------------------- */
.app { display: flex; flex-direction: column; height: 100vh; padding: var(--gap); gap: var(--gap); }

header.bar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 0 0.2em 0.6em;
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.5em; font-weight: 700; letter-spacing: -0.01em; }
.brand span { color: var(--ink-muted); font-weight: 500; }
.periods { display: flex; gap: 6px; margin-left: 1.2em; }
.pill {
  padding: 0.35em 1em; border-radius: 999px; font-size: 0.95em; font-weight: 600;
  color: var(--ink-2); background: var(--surface-1); border: 1px solid var(--border);
  cursor: pointer;
}
.pill[aria-selected="true"] { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.bar .spacer { flex: 1; }
.clock { font-size: 1.6em; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock small { display: block; font-size: 0.42em; font-weight: 500; color: var(--ink-muted); text-align: right; }
.livedot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 6px; }
.livedot.stale { background: var(--ink-muted); }

/* ---- stat tiles ----------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--gap); }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 0.8em 1em;
}
.tile .k { font-size: 0.82em; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tile .v { font-size: 2.3em; font-weight: 700; line-height: 1.15; margin-top: 0.1em; }
.tile .sub { font-size: 0.82em; color: var(--ink-2); }
.tile.flag .v { color: var(--warning); }

/* ---- panels --------------------------------------------------------- */
.grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: var(--gap); flex: 1; min-height: 0; }
.col { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.panel {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r);
  padding: 0.9em 1.1em; display: flex; flex-direction: column; min-height: 0;
}
.panel > h2 {
  margin: 0 0 0.7em; font-size: 1em; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-2);
  display: flex; align-items: center; gap: 0.5em;
}
.panel > h2 .note { margin-left: auto; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink-muted); }
.panel .body { overflow: hidden; flex: 1; min-height: 0; }

/* ---- leaderboard ---------------------------------------------------- */
/* space-evenly so a light day (3 people) fills the panel the same way a
   full month (10) does, instead of stranding half the panel empty */
.rows { display: flex; flex-direction: column; gap: 0.55em; height: 100%; justify-content: space-evenly; }
.row { display: grid; grid-template-columns: 1.6em 1fr; gap: 0.7em; align-items: center; }
.rank { font-size: 1em; font-weight: 700; color: var(--ink-muted); font-variant-numeric: tabular-nums; text-align: right; }
.who { display: flex; align-items: baseline; gap: 0.5em; margin-bottom: 0.25em; }
.who .nm { font-size: 1.12em; font-weight: 600; }
.who .dp { font-size: 0.82em; color: var(--ink-muted); }
.who .val { margin-left: auto; font-size: 1.05em; font-weight: 700; font-variant-numeric: tabular-nums; }
.who .pct { font-size: 0.85em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.who .mode { font-size: 0.72em; padding: 0.1em 0.5em; border-radius: 4px; border: 1px solid var(--border); color: var(--ink-2); }

/* Stacked productivity bar. 2px surface gap between segments, 4px rounded
   ends anchored to the baseline — per mark spec. */
.stack { display: flex; height: 12px; gap: 2px; }
.stack i { display: block; height: 100%; }
.stack i:first-child { border-radius: 4px 0 0 4px; }
.stack i:last-child  { border-radius: 0 4px 4px 0; }
.seg-p { background: var(--good); }
.seg-n { background: var(--neutral); }
.seg-x { background: var(--critical); }
.seg-i { background: var(--idle); }

.legend { display: flex; gap: 1.1em; font-size: 0.82em; color: var(--ink-2); margin-top: 0.7em; }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.4em; vertical-align: -1px; }

/* ---- attention ------------------------------------------------------ */
.att { display: flex; flex-direction: column; gap: 0.55em; }
.att .item {
  display: grid; grid-template-columns: auto 1fr; gap: 0.7em; align-items: start;
  padding: 0.6em 0.7em; border-radius: 8px;
  background: color-mix(in oklab, var(--critical) 12%, transparent);
  border-left: 3px solid var(--critical);
}
.att .item.warn { background: color-mix(in oklab, var(--warning) 10%, transparent); border-left-color: var(--warning); }
.att .item.info { background: rgba(255,255,255,0.03); border-left-color: var(--ink-muted); }
.att .icon { font-size: 1.05em; line-height: 1.3; }
.att .nm { font-weight: 700; font-size: 1.05em; }
.att .why { font-size: 0.88em; color: var(--ink-2); }
.empty { color: var(--ink-muted); font-size: 0.95em; padding: 0.6em 0; }

/* ---- AI ------------------------------------------------------------- */
.ai { font-size: 1.05em; line-height: 1.5; color: var(--ink); white-space: pre-wrap; overflow: auto; }
.ai.placeholder { color: var(--ink-muted); }

/* ---- charts --------------------------------------------------------- */
.chart { width: 100%; height: 100%; display: block; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--baseline); stroke-width: 1; }
.chart text { fill: var(--ink-muted); font-size: 11px; }
.chart text.val { fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart rect.bar { fill: var(--series-1); rx: 4; }
.chart rect.hit { fill: transparent; cursor: pointer; }

.apps { display: flex; flex-direction: column; gap: 0.45em; }
.apps .a { display: grid; grid-template-columns: 8.5em 1fr auto; gap: 0.6em; align-items: center; font-size: 0.95em; }
.apps .a .nm { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apps .a .track { background: rgba(255,255,255,0.06); border-radius: 4px; height: 10px; }
.apps .a .track i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
.apps .a .v { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---- tooltip -------------------------------------------------------- */
.tip {
  position: fixed; pointer-events: none; z-index: 50; opacity: 0; transition: opacity .12s;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5em 0.7em; font-size: 0.9em; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.tip.on { opacity: 1; }
.tip .t { font-weight: 700; margin-bottom: 0.2em; }
.tip .r { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---- admin ---------------------------------------------------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 1.05em; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--ink-muted); font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
input, select, textarea, button {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
button { cursor: pointer; font-weight: 600; }
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
button.primary:disabled { opacity: .5; cursor: default; }
.muted { color: var(--ink-muted); }
.warnbox { border-left: 3px solid var(--warning); background: color-mix(in oklab, var(--warning) 10%, transparent); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .95em; }
.rowflex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
nav.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
nav.tabs a { padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--ink-2); background: var(--surface-1); border: 1px solid var(--border); }
nav.tabs a.on { background: var(--series-1); border-color: var(--series-1); color: #fff; }

/* no-agent row: attendance exists but no activity data to judge */
.who .muted-val { color: var(--ink-muted); font-weight: 600; font-size: 0.92em; }
.noagent {
  font-size: 0.82em; color: var(--ink-muted); font-style: italic;
  padding: 2px 0 1px; border-left: 2px solid var(--baseline); padding-left: 8px;
}

/* AI panel: clamp to the panel instead of spilling out of it */
.ai {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 9;
  line-clamp: 9; overflow: hidden;
}
