/* Token Burn dashboard layout + components. The theme color variables (light +
   dark via prefers-color-scheme) live in themes.css, generated from themes/<id>.json
   by themes.py — load it before this file (see index.html). */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  font-variant-numeric: var(--num);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 48px; }

/* masthead -------------------------------------------------------------- */
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding-bottom: 16px;
  border-bottom: var(--border-width) solid var(--stroke);
}
.title { display: flex; align-items: center; gap: 10px; }

/* 8-bit burning flame — a small canvas running the DOOM fire effect (see
   flame.js). The backing store is the low-res heat grid; CSS upscales it with
   pixelated rendering so the pixels stay crisp and chunky. */
.flame {
  display: block;
  width: 36px;
  height: 52px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
h1 { font-size: 26px; font-weight: 800; letter-spacing: .5px; margin: 0; text-transform: var(--ut); }
.masthead-meta { text-align: right; line-height: 1.3; }
.combined { display: block; font-size: 20px; font-weight: 800; color: var(--accent); }
.generated { font-size: 12px; color: var(--faint); }

/* controls -------------------------------------------------------------- */
.controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 18px 0 22px;
}
.seg {
  display: inline-flex; background: var(--panel); border: var(--border-width) solid var(--stroke);
  border-radius: calc(9px * var(--radius-scale)); padding: 3px; gap: 2px;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px;
  border-radius: calc(7px * var(--radius-scale)); cursor: pointer;
  text-transform: var(--ut); transition: background .12s, color .12s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--text); color: var(--bg); }
.toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted); user-select: none;
  padding: 6px 12px; border: var(--border-width) solid var(--stroke);
  border-radius: calc(9px * var(--radius-scale)); background: var(--panel);
}
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.toggle[hidden] { display: none; }

/* tiles ----------------------------------------------------------------- */
.tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px;
}
.tile {
  background: var(--panel); border: var(--border-width) solid var(--stroke);
  border-radius: calc(12px * var(--radius-scale)); padding: 14px 16px; min-height: 78px;
}
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.tile .v small { font-size: 14px; font-weight: 700; color: var(--muted); }
.tile .k { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile .x { font-size: 11px; color: var(--faint); margin-top: 2px; }
.tile.accent .v { color: var(--accent); }

/* panels ---------------------------------------------------------------- */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.panel {
  background: var(--panel-2); border: var(--border-width) solid var(--stroke);
  border-radius: calc(14px * var(--radius-scale)); padding: 16px 18px; box-shadow: var(--shadow);
}
.panel-wide { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 14px; font-weight: 700; margin: 0; letter-spacing: .2px; text-transform: var(--ut); }
.panel-sub { font-size: 11.5px; color: var(--faint); }

/* heatmap --------------------------------------------------------------- */
.heatmap-scroll { overflow-x: auto; padding-bottom: 4px; }
.heatmap { display: grid; grid-auto-flow: column; grid-auto-columns: 13px; grid-template-rows: auto repeat(7, 13px); gap: 3px; width: max-content; }
.heatmap .mlabel { font-size: 10px; color: var(--faint); height: 14px; white-space: nowrap; overflow: visible; }
.heatmap .cell { width: 13px; height: 13px; border-radius: calc(3px * var(--radius-scale)); background: var(--empty); }
.cell.lvl-1 { background: var(--l1); } .cell.lvl-2 { background: var(--l2); }
.cell.lvl-3 { background: var(--l3); } .cell.lvl-4 { background: var(--l4); }
.cell.sub { box-shadow: inset 0 0 0 1.5px var(--accent); }
.legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 12px; font-size: 11px; color: var(--muted); }
.legend .cell { width: 12px; height: 12px; border-radius: calc(3px * var(--radius-scale)); }

/* hours histogram ------------------------------------------------------- */
.hours { display: grid; grid-template-columns: repeat(24, 1fr); align-items: end; gap: 2px; height: 130px; }
.hours .hb { background: var(--bar); border-radius: calc(2px * var(--radius-scale)) calc(2px * var(--radius-scale)) 0 0; min-height: 2px; opacity: .8; transition: opacity .12s; }
.hours .hb.peak { opacity: 1; }
.hours .hb:hover { opacity: 1; }
.hours-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: 4px; font-size: 9px; color: var(--faint); }

/* daily bar chart ------------------------------------------------------- */
.barchart { display: flex; align-items: flex-end; gap: 2px; height: 150px; overflow-x: auto; }
.barchart .bar { flex: 1 0 6px; background: var(--bar); border-radius: calc(2px * var(--radius-scale)) calc(2px * var(--radius-scale)) 0 0; min-height: 1px; opacity: .8; }
.barchart .bar:hover { opacity: 1; }
.barchart .bar .subseg { display: block; width: 100%; background: var(--text); opacity: .35; border-radius: 0 0 calc(2px * var(--radius-scale)) calc(2px * var(--radius-scale)); }

/* models ---------------------------------------------------------------- */
.model-list { display: flex; flex-direction: column; gap: 14px; }
.model-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 14px; }
.model-row .name { font-weight: 700; font-size: 13px; }
.model-row .name small { display: block; font-weight: 500; font-size: 11px; color: var(--faint); }
.model-row .track { background: var(--panel); border-radius: calc(6px * var(--radius-scale)); height: 22px; overflow: hidden; display: flex; }
.model-row .seg-in { background: var(--bar); }
.model-row .seg-out { background: var(--l2); }
.model-row .seg-bar { background: var(--bar); }
.model-row .vals { text-align: right; font-size: 13px; font-weight: 700; min-width: 92px; }
.model-row .vals small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.model-group-label { font-size: 11px; font-weight: 700; letter-spacing: .4px; color: var(--faint); text-transform: uppercase; margin-top: 6px; }
.io-key { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }
.io-key i { width: 9px; height: 9px; border-radius: calc(2px * var(--radius-scale)); display: inline-block; }
.io-key i + i { margin-left: 6px; }
.io-key .sw-in { background: var(--bar); }
.io-key .sw-out { background: var(--l2); }

/* footer + tooltip ------------------------------------------------------ */
.foot {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  margin-top: 30px; padding-top: 16px; border-top: var(--border-width) solid var(--stroke);
  font-size: 12px; color: var(--faint);
}
.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.4;
  padding: 6px 9px; border-radius: calc(7px * var(--radius-scale)); box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: 240px; transform: translate(-50%, calc(-100% - 10px));
}
.tooltip b { font-weight: 700; }

/* responsive ------------------------------------------------------------ */
@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .model-row { grid-template-columns: 110px 1fr; }
  .model-row .vals { grid-column: 2; text-align: left; }
}
