/* LLM Dashboard — a quiet instrument panel over two live model catalogues.
   Design language borrowed from the FB-ElecRate energy observatory: ink
   surfaces, tabular numerals, semantic accents, no decorative chrome. */
:root {
  color-scheme: dark;
  --bg: #0b1119;
  --panel: #121c28;
  --panel-hi: #182433;
  --panel-hi2: #1e2c3d;
  --line: #2a394a;
  --line-soft: #202d3c;
  --ink: #e9eff4;
  --muted: #a3b3c4;
  --quiet: #8192a6;
  --accent: #b7e6d6;
  --accent-ink: #0f2a24;
  --nous: #b7e6d6;
  --openrouter: #a9c9eb;
  --free: #72d9a0;
  --cheap: #f5c65a;
  --warn: #ffd18b;
  --bad: #f58e81;
  --radius: 12px;
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button,
select,
input[type="search"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-hi);
  color: var(--ink);
  padding: 8px 13px;
}
button {
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s;
}
button:hover,
select:hover {
  background: var(--panel-hi2);
  border-color: #516a81;
}
button[aria-pressed="true"] {
  background: #25473f;
  border-color: #72c7ac;
  color: #dbfff2;
}
.badge {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.micro {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}
.dim {
  color: var(--quiet);
}
.eyebrow {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.15em;
  color: var(--muted);
}
a {
  color: inherit;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 21px;
  letter-spacing: -0.025em;
  font-weight: 550;
}
h2 {
  font-size: 19px;
  letter-spacing: -0.02em;
  font-weight: 550;
}
h3 {
  font-size: 15px;
  font-weight: 550;
  letter-spacing: -0.01em;
}
strong,
time,
output,
td,
th {
  font-variant-numeric: tabular-nums;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.skip {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100;
  background: var(--accent);
  color: #000;
  padding: 15px;
}
.skip:focus {
  top: 12px;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 16px 26px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  /* Keep the last control clear of a vertical scrollbar on narrow windows. */
  padding-right: max(26px, calc(100vw - 100% + 8px));
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 260px;
}
.brand a {
  text-decoration: none;
}
.brand .mark {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.15em;
  color: var(--muted);
}
.brand h1 {
  font-size: 19px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stamp {
  text-align: right;
}

/* Anchor nav: sits between the brand and the actions, collapses out of the
   way rather than wrapping to a second line on narrow windows. */
.anchors {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.anchors a {
  text-decoration: none;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.anchors a:hover {
  color: var(--ink);
  border-color: #516a81;
  background: var(--panel-hi);
}
.anchors a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ layout */
main {
  padding: 20px 26px 60px;
  max-width: 1680px;
  margin: 0 auto;
}
.loading,
.error {
  padding: 40px 0;
  color: var(--muted);
}
.error {
  color: var(--bad);
}

/* ------------------------------------------------------------------- stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.stat .value {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.stat .label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.stat.accent .value {
  color: var(--accent);
}
.stat.free .value {
  color: var(--free);
}

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-head .titles {
  min-width: 240px;
}
.panel-head h2 {
  margin-top: 2px;
}
.panel-body {
  padding: 16px 18px;
}
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.seg button {
  border: 0;
  border-radius: 0;
  min-height: 38px;
  padding: 7px 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.seg button + button {
  border-left: 1px solid var(--line);
}
.seg button[aria-pressed="true"] {
  background: #25473f;
  color: #dbfff2;
}
input[type="search"] {
  min-width: 210px;
  flex: 1 1 210px;
  max-width: 320px;
}

/* ------------------------------------------------------------------ tables */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-hi);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover {
  color: var(--ink);
}
/* An interactive heading must look interactive, including on keyboard focus. */
thead th:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  color: var(--ink);
}
thead th.sorted {
  color: var(--accent);
}
thead th .arrow {
  color: var(--accent);
  margin-left: 4px;
  font-size: 9px;
}
tbody td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
tbody tr:hover {
  background: var(--panel-hi);
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}
.model-cell {
  min-width: 210px;
}
.model-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.model-id {
  font-size: 11px;
  color: var(--quiet);
  word-break: break-all;
}
/* ---------------------------------------------------------------- tooltip */
/* A real element, not the native title attribute. The desktop wrapper renders
   the help cursor but suppresses the browser's own tooltip, so a title-only
   label looks broken: you get the question mark and no explanation. */
.tip {
  position: fixed;
  z-index: 60;
  max-width: 290px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #2c3b49;
  background: #131c26;
  color: #d7e2ec;
  font: 400 12px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.tip.on {
  opacity: 1;
}
.tip b {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font: 600 10px/1.4 inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* Positioned entirely through the inline `top` set by showTip(); no class
   toggles `top` to auto, which would leave a stale value in effect. */

@media (prefers-reduced-motion: reduce) {
  .tip {
    transition: none;
  }
}

/* "Last 30 days" trigger in the changelog panel header. */
.panel-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
}
button.ghost {
  font: 600 11px/1 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 32px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
button.ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--panel-hi);
}
button.ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Rollup line at the top of the 30-day dialog. */
.log-summary {
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.log-summary-line {
  font-size: 12px;
  color: var(--muted);
}
#history .dlg-body {
  max-height: min(66vh, 620px);
}

/* "Handles" chips: same visual language as "Good at" labels so both columns
   read the same way and behave the same way on hover. */
.handles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.handle {
  font-size: 10.5px;
  color: #9fd6cc;
  background: #12252b;
  border: 1px solid #1e3b42;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}
.handle.has-help {
  cursor: help;
  border-bottom: 1px dotted #4d7d78;
}
.handle.has-help:hover {
  color: #d6f2ec;
  border-color: var(--accent);
}
.handle.no-help {
  opacity: 0.65;
  border-style: dashed;
}
.handles-cell {
  max-width: 220px;
}
/* Ranking badge: interactive, so it must look interactive and explain itself. */
.rank-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel-hi2);
  color: var(--muted);
  font: 500 10px/1.7 inherit;
  cursor: help;
  white-space: nowrap;
}
.rank-badge:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.strengths {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.strengths span {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--panel-hi2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 1px 6px;
}
/* A label with an explanation invites a hover; one without is visibly inert,
   so a missing definition is obvious rather than silent. */
.strength.has-help {
  cursor: help;
  border-bottom: 1px dotted var(--quiet);
}
.strength.has-help:hover {
  color: var(--ink);
  border-color: var(--accent);
}
.strength.no-help {
  opacity: 0.65;
  border-style: dashed;
}
.model-link {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.model-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.model-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pop-cell .score {
  min-width: 66px;
}
.score-cell {
  min-width: 96px;
}
.score {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score .bar {
  flex: 1;
  height: 5px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
  min-width: 38px;
}
.score .bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.score.derived .bar i {
  background: var(--quiet);
}
.score .num {
  font-weight: 600;
  min-width: 22px;
}
.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill.nous {
  color: var(--nous);
  border-color: #2f5a51;
  background: #16262a;
}
.pill.openrouter {
  color: var(--openrouter);
  border-color: #2f4763;
  background: #16202c;
}
.pill.free {
  color: var(--free);
  border-color: #2c5c46;
  background: #14261f;
}
.pill.cheapest {
  color: #0f2a24;
  background: var(--cheap);
  border-color: var(--cheap);
}
.pill.tight {
  color: var(--warn);
  border-color: #5c4a2a;
}
.pill.well {
  color: var(--accent);
  border-color: #2f5a51;
}
.pill.roomy {
  color: var(--free);
  border-color: #2c5c46;
}
.pill.new {
  color: var(--free);
  border-color: #2c5c46;
}
.pill.gone {
  color: var(--bad);
  border-color: #6b3b36;
}
.pill.moved {
  color: var(--warn);
  border-color: #5c4a2a;
}
.price-cell {
  min-width: 128px;
}
.price-cell .alt {
  font-size: 11px;
  color: var(--quiet);
  margin-top: 3px;
}
.free-price {
  color: var(--free);
  font-weight: 600;
}
.fit {
  cursor: help;
  border-bottom: 1px dotted var(--line);
}

/* --------------------------------------------------------- hermes ranking */
/* Suite cells read "score" over "cost per task", so the number that ranks the
   board stays dominant and the cost reads as an annotation. */
.suite-cell {
  min-width: 72px;
}
.suite-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.suite-cost {
  font-size: 11px;
  color: var(--quiet);
  margin-top: 2px;
  white-space: nowrap;
}
.suite-cost.raw,
.suite-cost.raw:hover {
  cursor: help;
  color: var(--muted);
}
.task-cost {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cheapest-cell {
  min-width: 128px;
}
.cheapest-cell .suite-cost {
  color: var(--muted);
  margin-top: 3px;
}
.prov {
  color: var(--warn);
  cursor: help;
  margin-left: 1px;
}

/* --------------------------------------------------------------- changelog */
.log-day {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--panel-hi);
}
.log-day h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}
.log-group {
  margin-top: 9px;
}
.log-group > .eyebrow {
  margin-bottom: 5px;
}
.log-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.log-item .nm {
  font-weight: 600;
}
.log-item .why {
  color: var(--muted);
  font-size: 12.5px;
}
.log-empty {
  color: var(--quiet);
  padding: 6px 0;
}
.delta {
  font-size: 12px;
  white-space: nowrap;
}
.delta.down {
  color: var(--free);
}
.delta.up {
  color: var(--bad);
}
.note {
  background: var(--panel-hi);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--warn);
  border-radius: 7px;
  padding: 11px 13px;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 16px;
}
.note strong {
  color: var(--ink);
}
footer {
  border-top: 1px solid var(--line-soft);
  padding: 18px 26px 34px;
  color: var(--quiet);
  font-size: 12px;
  max-width: 1680px;
  margin: 0 auto;
}
footer a {
  color: var(--muted);
}

/* ------------------------------------------------------------------ dialog */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  max-width: 620px;
  width: calc(100% - 32px);
  padding: 0;
}
dialog::backdrop {
  background: rgb(4 8 13 / 0.72);
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.dlg-body {
  padding: 16px 18px 20px;
  max-height: 68vh;
  overflow-y: auto;
}
.dlg-body dt {
  font-size: 11px;
  color: var(--muted);
  margin-top: 11px;
}
.dlg-body dd {
  margin: 2px 0 0;
}

@media (max-width: 720px) {
  main {
    padding: 16px 14px 50px;
  }
  .topbar {
    padding: 13px 14px 11px;
  }
  .stamp {
    text-align: left;
  }
  .model-cell {
    min-width: 170px;
  }
}
