:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7684;
  --line: #e4e8ee;
  --blue: #2563eb;
  --blue-soft: #dbe7fe;
  --orange: #f59e0b;
  --green: #16a34a;
  --green-soft: #e8f6ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber-soft: #fff6e0;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
/* the hidden attribute must win over display rules (e.g. the filter labels' flex) */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 22px; margin: 4px 0 2px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 10px; }
.muted { color: var(--muted); }
button, input, select {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px;
}
/* example text in an empty field: clearly lighter than what is typed */
input::placeholder, textarea::placeholder { color: #a7b0bc; opacity: 1; }
button { cursor: pointer; }
button:hover { border-color: var(--blue); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.link { border: none; background: none; color: var(--muted); padding: 6px 4px; }
button.link:hover { color: var(--text); }

/* header */
.top {
  display: flex; align-items: center; gap: 0 24px; flex-wrap: wrap;
  padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; padding: 14px 0; }
/* tabs wrap onto a second line on narrow windows: none is ever hidden */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; flex: 1 1 420px; min-width: 0; }
.tabs a {
  padding: 14px 10px 12px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent; font-weight: 500;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
.account { display: flex; align-items: center; gap: 4px; margin-left: auto; }
a.link { color: var(--muted); text-decoration: none; padding: 6px 4px; font-size: 15px; }
a.link:hover { color: var(--text); }
.logout { margin: 0; }

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  max-width: 1200px; margin: 16px auto 0; padding: 0 20px;
}
.filters label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 40px; }
.page { display: none; }
.page.active { display: block; }
.status { padding: 10px 14px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); }
.status.error { border-color: var(--red); color: var(--red); background: var(--red-soft); }

/* number tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 14px; }
.tile .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile.good { border-left: 4px solid var(--green); }
.tile.bad { border-left: 4px solid var(--red); }
.tile.warn { border-left: 4px solid var(--orange); }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; min-width: 0;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.chart { position: relative; height: 280px; }
.chart.short { height: 220px; }
.chart .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* number tiles inside a card */
.tiles.flat { margin-bottom: 0; }
.tiles.flat .tile { background: var(--bg); }
#co-unpriced { margin-bottom: 18px; }

/* cost history: per day / per month */
.toggle { display: inline-flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.toggle button.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

/* GPU prices */
.price-form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.price-form h3 { grid-column: 1 / -1; font-size: 15px; margin: 0; }
.price-form label { display: grid; gap: 4px; color: var(--muted); font-size: 14px; }
.price-form .wide, .price-form .ask, .price-form .actions, .price-form .error { grid-column: 1 / -1; }
.price-form .error { margin: 0; }
.price-form .ask { background: var(--amber-soft); border: 1px solid var(--orange); border-radius: 8px; padding: 10px 14px; }
.price-form .ask p { margin: 0 0 8px; color: var(--text); }
.price-form .ask label { max-width: 240px; }
.price-form .actions { display: flex; gap: 8px; align-items: center; }
.small { font-size: 12px; }
td.row-actions { text-align: right; }
button.link.danger { color: var(--red); }

/* engine status banner */
.banner { border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; border: 1px solid var(--line); }
.banner .title { font-size: 20px; font-weight: 700; }
.banner .sub { color: var(--muted); margin-top: 2px; }
.banner.good { background: var(--green-soft); border-color: var(--green); }
.banner.good .title { color: var(--green); }
.banner.bad { background: var(--red-soft); border-color: var(--red); }
.banner.bad .title { color: var(--red); }
.banner.warn { background: var(--amber-soft); border-color: var(--orange); }

/* needs attention */
ul.attention { list-style: none; margin: 0; padding: 0; }
ul.attention li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
ul.attention li:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; transform: translateY(1px); }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--orange); }
.dot.bad { background: var(--red); }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 180px; }
td .reason { font-weight: 500; }
td .reason.total { font-weight: 700; }
.lead-in { margin: 0 0 12px; }
.wait-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 0 24px; margin-bottom: 12px; }
h3.sub-title { font-size: 14px; margin: 16px 0 6px; }
h3.sub-title:first-of-type { margin-top: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f0f5ff; }
.up { color: var(--green); }
.down { color: var(--red); }

/* lookup */
.search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; align-items: center; }
.search input { flex: 1 1 260px; min-width: 0; padding: 9px 12px; }
.search select { padding: 8px 10px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.pager .muted { margin-right: auto; font-size: 14px; }
.pager button:disabled { opacity: 0.4; cursor: default; }
pre.json {
  max-height: 380px; overflow: auto; background: var(--bg); padding: 12px; border-radius: 8px;
  font-size: 12px; border: 1px solid var(--line);
}
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 14px; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
.error { color: var(--red); }

/* recording detail: why */
.explain { margin: 6px 0 16px; }
.explain h3 { font-size: 15px; margin: 18px 0 8px; }
.explain h3:first-child { margin-top: 4px; }
.explain .table-wrap { max-width: 640px; }
.small-banner { padding: 12px 14px; margin: 12px 0; }
.small-banner .title { font-size: 15px; }
ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin: 4px 0; }

/* login */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card form { display: grid; gap: 14px; margin-top: 18px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); }
.login-card button { background: var(--blue); color: #fff; border-color: var(--blue); padding: 9px; }
.login-card .back { color: var(--muted); text-decoration: none; font-size: 14px; }
.login-card .back:hover { color: var(--text); }
.login-card p.ok { color: var(--green); background: var(--green-soft); padding: 8px 10px; border-radius: 8px; }
.login-card p.error { background: var(--red-soft); padding: 8px 10px; border-radius: 8px; }

/* play button (recordings, reviews) */
.play { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.play button.link { color: var(--blue); padding: 2px 4px; }
.detail-actions { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; }
.detail-actions > button.link { color: var(--blue); padding: 2px 4px; }
.attempts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.attempts strong { font-size: 1.05em; }
.attempts button.link { color: var(--blue); padding: 2px 4px; }
.warn-text { color: #b45309; }
.warn-text:empty { display: none; }

/* reviews */
.reviewer { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 12px; }
.reviewer input { width: 180px; }
.set-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.set-card { display: grid; gap: 6px; align-content: start; margin: 0; }
.set-card button { justify-self: start; margin-top: 4px; }
.review { max-width: 720px; text-align: center; }
.review-word { font-size: 40px; font-weight: 700; margin: 18px 0 12px; overflow-wrap: anywhere; }
button.big { font-size: 18px; padding: 10px 28px; margin-bottom: 8px; }
.verdicts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0 10px; }
.verdicts button { min-width: 140px; padding: 9px 12px; }
.verdicts button.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); font-weight: 600; }
.review input { width: 100%; max-width: 480px; margin-bottom: 12px; }
.review .actions { display: flex; justify-content: center; gap: 8px; }

@media (max-width: 640px) {
  .top { padding: 0 16px; }
  .filters, main { padding-left: 16px; padding-right: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile .value { font-size: 22px; }
  .review-word { font-size: 30px; }
  .verdicts button { min-width: 0; flex: 1 1 40%; }
}
