/* Kernalin app — shares the marketing site's monochrome tokens and its
   data-theme / localStorage('theme') switch, so the choice carries across. */
:root {
  --bg: #050506; --bg-soft: #0a0a0b; --surface: #0e0e10; --surface-2: #151517; --surface-3: #1c1c1f;
  --ink: #f4f4f5; --ink-muted: #a6a6ac; --ink-dim: #8a8a92; --ink-faint: #48484f;   /* dim text 5.6:1 on surface (AA) */
  --ol: 255 255 255;
  --border: rgb(var(--ol) / .08); --border-strong: rgb(var(--ol) / .16);
  --btn-bg: #f4f4f5; --btn-ink: #0b0b0d;
  --heat-lo: #1a1a1d; --heat-hi: #ff7a3d;   /* cool to hot: hotspots read as hot */
  --bad: #f2716b; --warn: #e5b45a; --good: #7fd49b;
  --hw1: #8ab4ff; --hw2: #7fd49b; --hw3: #e5b45a; --hw4: #f2716b; --hw5: #c59bff; --hw6: #62d0d6;
  --bad-bg: rgb(242 113 107 / .12); --warn-bg: rgb(229 180 90 / .12); --good-bg: rgb(127 212 155 / .1);
  --on-bad: #1a0605;                         /* text on a --bad fill: dark on light red (7:1) */
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #fcfcfd; --bg-soft: #f5f6f8; --surface: #ffffff; --surface-2: #f8f8fa; --surface-3: #f0f1f4;
  --ink: #0d0d11; --ink-muted: #4f4f58; --ink-dim: #696973; --ink-faint: #a5a6ae;   /* dim text 5.4:1 on white (AA) */
  --ol: 15 17 22;
  --border: rgb(var(--ol) / .1); --border-strong: rgb(var(--ol) / .2);
  --btn-bg: #0d0d11; --btn-ink: #ffffff;
  --heat-lo: #f0f1f4; --heat-hi: #c2410c;
  --bad: #c2362f; --warn: #9a6a0c; --good: #1f7a42;
  --hw1: #2f62c9; --hw2: #1f7a42; --hw3: #9a6a0c; --hw4: #c2362f; --hw5: #7446c7; --hw6: #1b8a91;
  --bad-bg: rgb(194 54 47 / .09); --warn-bg: rgb(154 106 12 / .1); --good-bg: rgb(31 122 66 / .09);
  --on-bad: #ffffff;                         /* white on dark red (5.3:1) */
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-family: "Space Grotesk", "Inter", system-ui, sans-serif; letter-spacing: -0.02em; margin: 0; }
.mono, code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; }
.muted { color: var(--ink-muted); } .dim { color: var(--ink-dim); }
.rw-why { color: var(--ink); margin-top: 4px; max-width: 60ch; }   /* the model's own explanation of a rewrite */

/* ---- shared controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--btn-bg); color: var(--btn-ink); font: 500 14px "Inter", sans-serif;
  text-decoration: none; transition: opacity .15s;
}
.btn:hover { opacity: .88; } .btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink-muted); border: 1px solid var(--border-strong); height: 34px; padding: 0 14px; font-size: 13px; }
.btn-ghost:hover { color: var(--ink); opacity: 1; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--ink-muted); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }
.theme-sun { display: none; } [data-theme="light"] .theme-sun { display: block; } [data-theme="light"] .theme-moon { display: none; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-muted); }
.field input {
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink); font: 14px "Inter", sans-serif; outline: none;
}
.field input:focus { border-color: var(--ink-muted); }
/* A visible keyboard focus ring everywhere (WCAG 2.4.7); mouse clicks don't show it. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.field input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
select {
  height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink); font: 13px "Inter", sans-serif;
}
.field input.invalid { border-color: var(--bad); }
.ferr { font-size: 12.5px; color: var(--bad); min-height: 0; }
.ferr:empty { display: none; }
.ferr.good { color: var(--good); }
.pw { position: relative; }
.pw input { width: 100%; padding-right: 46px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-dim); cursor: pointer;
}
.pw-eye:hover { color: var(--ink); background: rgb(var(--ol) / .05); }
.pw-eye svg { width: 18px; height: 18px; }
.pw-eye .eye-off, .pw-eye[aria-pressed="true"] .eye-on { display: none; }
.pw-eye[aria-pressed="true"] .eye-off { display: block; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.meter i { height: 4px; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.meter[data-level="1"] i.on { background: var(--bad); }
.meter[data-level="2"] i.on { background: var(--warn); }
.meter[data-level="3"] i.on { background: var(--good); opacity: .75; }
.meter[data-level="4"] i.on { background: var(--good); }
.meter-row { font-size: 12px; color: var(--ink-dim); }
.rules { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12.5px; color: var(--ink-dim); }
.rules li { display: flex; align-items: center; gap: 6px; }
.rules li::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border-strong);
}
.rules li.ok { color: var(--ink-muted); }
.rules li.ok::before {
  border-color: var(--good); background: var(--good);
  -webkit-mask: none;
  box-shadow: inset 0 0 0 2.5px var(--surface);
}
.capslock { font-size: 12.5px; color: var(--warn); margin: -6px 0 12px; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; background: var(--bad-bg); color: var(--bad); }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo svg { width: 28px; height: 28px; }
.logo span { font: 600 17px "Space Grotesk", sans-serif; letter-spacing: -0.02em; }

/* Tile K mark, same as the marketing site: solid tiles form the K, the other
   three sit at low opacity; everything is currentColor so it follows the theme. */
.kn-mark .kn-t { fill: currentColor; transform-box: fill-box; transform-origin: center; }
.kn-mark .kn-off { opacity: 0.14; }
@keyframes kn-ripple-on { 0%, 100% { transform: scale(1); } 40% { transform: scale(0.74); } }
@keyframes kn-ripple-off { 0%, 100% { opacity: 0.14; } 40% { opacity: 0.55; } }
.kn-mark.kn-ripple .kn-t { animation: kn-ripple-on 0.42s ease-in-out both; animation-delay: calc(var(--d) * 45ms); }
.kn-mark.kn-ripple .kn-off { animation-name: kn-ripple-off; }
/* Loader: the tile wave runs continuously while a view is loading. */
@keyframes kn-busy { 0%, 100% { opacity: 0.14; transform: scale(0.8); } 35% { opacity: 1; transform: scale(1); } }
.kn-mark.kn-busy .kn-t { animation: kn-busy 1.1s ease-in-out infinite; animation-delay: calc(var(--d) * 110ms); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form .field input, .form .field select { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink); font: 14px "Inter", sans-serif; }
.form .field input[type=checkbox], .form .field input[type=radio] { height: auto; width: 16px; padding: 0; margin: 0; accent-color: var(--ink); }
fieldset.field { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.field legend, .form .field label { font-size: 13px; color: var(--ink-muted); padding: 0; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--ink-dim); }
.checks { display: grid; gap: 8px; font-size: 14px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--ink-muted); background: rgb(var(--ol) / .03); }
.choice input { margin-top: 3px !important; }
.choice > span { display: grid; gap: 2px; font-size: 14px; }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; }
.winners { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.winner { display: grid; gap: 2px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; min-width: 130px; }
@media (max-width: 760px) { .form-grid, .choices { grid-template-columns: 1fr; } }
.heatlist { display: grid; gap: 4px; }
.hl-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.hl-row:hover { background: rgb(var(--ol) / .04); }
.hl-row.sel { background: rgb(var(--ol) / .07); outline: 1px solid var(--border-strong); }
.hl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.hl-bar { height: 14px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hl-bar i { display: block; height: 100%; border-radius: 4px; }
.hl-val { font-size: 12px; min-width: 64px; text-align: right; }
@media (max-width: 760px) { .hl-row { grid-template-columns: 1fr auto; } .hl-bar { grid-column: 1 / -1; grid-row: 2; } }
.nav a .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: var(--on-bad); font-size: 11px; line-height: 18px; text-align: center; }
.rc { margin: 0 0 12px; }
.rc-strip { border-top: 0; padding-top: 0; color: var(--ink-muted); }
.muted-card { opacity: .72; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--btn-bg); color: var(--btn-ink); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgb(0 0 0 / .3); }
tr.sel-row td { background: rgb(var(--ol) / .05); }
.checkline { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-muted); margin: 4px 0 8px; }
.checkline input { margin-top: 3px; accent-color: var(--ink); }
.recs li, .kv dd, .rc { overflow-wrap: anywhere; }
.recs { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); margin: 2px 2px 0 0; }
.grid-2.tight { gap: 18px; }
.ranked { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.limiters { margin: 0; padding-left: 18px; display: grid; gap: 4px; } .limiters .small { overflow-wrap: anywhere; }
.prose { font-size: 14.5px; line-height: 1.65; max-width: 75ch; }
.drop {
  display: grid; justify-items: center; gap: 6px; padding: 34px 18px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--ink-muted); background: rgb(var(--ol) / .03); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }   /* hidden but focusable */
.drop { position: relative; }
.drop:focus-within { border-color: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; }
.drop strong { font-weight: 600; }
.uploads { display: grid; gap: 12px; margin-top: 14px; }
.uploads:empty { display: none; }
.upload-row { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }
.upload-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink-muted); transition: width .15s; }
.progress.ok i { background: var(--good); } .progress.bad i { background: var(--bad); }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issues li { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.issues .badge { flex: none; }
.log {
  margin: 0; padding: 14px 18px; max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.55 "JetBrains Mono", ui-monospace, monospace; color: var(--ink-muted); background: var(--surface-2);
}
.log.code { max-height: 560px; color: var(--ink); }
.bad-text { color: var(--bad); }
.log .d-add { color: var(--good); background: var(--good-bg); }
.log .d-del { color: var(--bad); background: var(--bad-bg); }
.log.small { max-height: 260px; border-radius: 10px; margin-top: 6px; }
.loading { display: flex; align-items: center; gap: 12px; }
.loading .kn-mark { width: 26px; height: 26px; color: var(--ink-muted); }
@media (prefers-reduced-motion: reduce) {
  .kn-mark .kn-t { animation: none !important; }
}

/* ---- auth pages ---- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; }
.auth-card {
  align-self: start;
  width: min(420px, calc(100vw - 32px)); margin: 5vh auto 40px; padding: 32px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface);
  box-shadow: 0 30px 80px -40px rgb(0 0 0 / .5);
}
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-muted); margin: 0 0 24px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--ink-muted); font-size: 13px; }
.auth-foot a { color: var(--ink); }
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse at top, #000 20%, transparent 70%);
}

/* ---- app shell ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 24px; background: var(--bg-soft); }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--ink-muted); text-decoration: none; font-size: 13.5px;
}
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { color: var(--ink); background: rgb(var(--ol) / .04); }
.nav a.active { color: var(--ink); background: rgb(var(--ol) / .07); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--ink-dim); display: grid; gap: 8px; }
.side-foot .ws { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { padding: 40px 28px; display: grid; gap: 8px; justify-items: start; max-width: 60ch; }
.empty-state h2 { font-size: 17px; }
.empty-state p { margin: 0; color: var(--ink-muted); }
.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); }
.side-foot .row { display: flex; gap: 8px; align-items: center; }
.main { min-width: 0; padding: 28px 32px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--ink-muted); }
.banner { border: 1px dashed var(--border-strong); border-radius: 12px; padding: 10px 14px; color: var(--ink-muted); font-size: 13px; margin-bottom: 20px; }
.banner code { color: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.tile { border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; background: var(--surface); }
.tile .k { font-size: 12.5px; color: var(--ink-muted); }
.tile .v { font: 600 28px/1.2 "Space Grotesk", sans-serif; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }

.card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); margin-bottom: 18px; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.card-body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--ink-dim); font-size: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: rgb(var(--ol) / .03); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nw { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border-strong); color: var(--ink-muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge.good { color: var(--good); background: var(--good-bg); border-color: transparent; }
.badge.plain::before { display: none; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--ink-muted); border-radius: 99px; }
.barcell { display: flex; align-items: center; gap: 10px; }
.barcell span { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* heatmap */
.heat { display: grid; gap: 4px; }
.heat .h { font-size: 12px; color: var(--ink-dim); padding: 4px 6px; align-self: center; }
.heat .rh { text-align: right; color: var(--ink-muted); font-weight: 500; }
.heat .ch { text-align: center; }
.hc {
  min-height: 52px; border-radius: 8px; border: 0; cursor: pointer; display: grid; place-items: center;
  font: 500 12.5px "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; transition: transform .08s;
}
.hc:hover { transform: scale(1.03); }
.hc.sel { outline: 2px solid var(--ink); outline-offset: 2px; }
.hc.na { background: var(--surface-3); color: var(--ink-dim); cursor: default; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); margin-top: 14px; }
.legend .ramp { width: 140px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--heat-lo), var(--heat-hi)); border: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--ink-dim); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--border-strong); } .chart .grid { stroke: var(--border); }
.chart .line { stroke: var(--ink); fill: none; stroke-width: 2; }
.chart .band { fill: rgb(var(--ol) / .08); }
.chart text { fill: var(--ink-dim); font: 11px "Inter", sans-serif; }
.chart .pt { fill: var(--ink); }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-muted); text-decoration: none; font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--ink); }
.empty { padding: 36px 18px; text-align: center; color: var(--ink-muted); }
.anom-msg { color: var(--ink-muted); font-size: 12.5px; max-width: 520px; }
.caps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.cap { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; }
.loading { color: var(--ink-dim); padding: 40px 0; }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  /* minmax(0, 1fr): a plain 1fr can't shrink below the one-row nav, which then
     widened every page to ~1600px on a phone; the nav scrolls inside instead. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border); min-width: 0; }
  .nav { grid-auto-flow: column; overflow-x: auto; min-width: 0; scrollbar-width: thin; }
  .nav a span { white-space: nowrap; }
  .side-foot { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
  th, td { padding: 10px 12px; }
  .auth-card { padding: 24px; margin-top: 2vh; }
  .rules { grid-template-columns: 1fr; }
}

.btn.btn-danger { background: var(--bad); color: var(--on-bad); border-color: transparent; }
.side-foot a.who { display: block; text-decoration: none; }
.side-foot a.who:hover { color: var(--ink); }

/* Projects (story 2.1) */
.form .field textarea { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; resize: vertical; min-height: 96px; }
.form .field textarea:focus { border-color: var(--ink-muted); }
.ferr { color: var(--bad); font-size: 12.5px; min-height: 1em; }
.meta-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; margin-bottom: 8px; }
.meta-row input { height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; min-width: 0; }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.btn.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.inline-form select, .inline-field select { height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; max-width: 100%; }
.inline-field { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.inline-field label { font-size: 13px; color: var(--ink-muted); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.people li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.prose { white-space: pre-wrap; max-width: 70ch; margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 52ch; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg a { padding: 6px 12px; font-size: 13px; color: var(--ink-muted); text-decoration: none; }
.seg a.on { background: var(--surface-2, var(--border)); color: var(--ink); }
.tile .v.small { font-size: 22px; }
@media (max-width: 640px) { .meta-row { grid-template-columns: 1fr; } }
.form-grid > .field { align-content: start; }
.field > .btn, fieldset.field > .btn { justify-self: start; }

/* Workspaces (story 1.2) */
.ws-pick { display: grid; gap: 6px; min-width: 0; }
.ws-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ws-top label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-dim); }
.ws-top a { font-size: 12px; color: var(--ink-muted); text-decoration: none; }
.ws-top a:hover, .ws-top a.active { color: var(--ink); text-decoration: underline; }
.ws-pick select { width: 100%; min-width: 0; height: 34px; font-weight: 600; color: var(--ink); }
.invite-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.invite-grid .field { align-content: start; }
.invite-grid .btn { height: 40px; }
.copy-row { display: flex; gap: 8px; margin: 8px 0; }
.copy-row input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-size: 12px; }
#inv-result { display: grid; gap: 4px; color: var(--ink); }
.auth-card .banner { color: var(--ink); }
.auth-card .hint { font-size: 13px; color: var(--ink-muted); margin: 0 0 16px; }
.auth-card .btn + .auth-foot { margin-top: 14px; }
.auth-card a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
@media (max-width: 760px) { .invite-grid { grid-template-columns: 1fr; } }
.danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.danger-zone p { margin: 0; }
.field input[readonly] { opacity: .7; cursor: not-allowed; }
/* Email verification and reset (story 1.1) */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row a { font-size: 12.5px; color: var(--ink-muted); }
.label-row a:hover { color: var(--ink); }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; font-weight: 600; }
.linklike:disabled { opacity: .6; cursor: default; text-decoration: none; }
#resend-msg { margin-top: 6px; }
.auth-card .btn-ghost { width: 100%; }

/* Audit log and permissions (story 10.1) */
.filters { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.filters .inline-field { margin: 0; }
.filters select { max-width: 220px; }
table.perm td.c, table.perm th.c { text-align: center; width: 84px; }
.yes { color: var(--good); font-weight: 600; }
td.small, .small { font-size: 12px; }
/* Alerting (story 9.1) */
.threshold-row { gap: 10px 16px; }
.threshold-row input[type=number] { width: 90px; height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; }
.inline-field span { font-size: 13px; color: var(--ink-muted); }
fieldset.checks { border: 0; padding: 0; margin: 0; }
fieldset.checks legend { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; padding: 0; }

/* Schedules (story 8.2) */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

/* Hardware comparison (story 4.2) */
.bars { display: grid; gap: 14px; }
.bar-group { display: grid; gap: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.bar-fill { display: block; height: 12px; border-radius: 4px; min-width: 2px; }
.bar-val { font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hw-tiles .k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr.group-start td { border-top: 2px solid var(--border-strong); }
table.pick td:first-child, table.pick td:nth-child(2) { width: 70px; }

/* Live GPUs (story 7.1) */
.runner-card .card-head h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.devs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-top: 14px; }
.dev { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.dev-head { display: flex; justify-content: space-between; gap: 8px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.meter-cell .k { font-size: 12px; color: var(--ink-muted); }
.meter-cell .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.meter-bar { height: 6px; border-radius: 99px; background: rgb(var(--ol) / .08); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--good); transition: width .4s ease; }
.meter-bar.warm i { background: var(--warn); }
.meter-bar.hot i { background: var(--bad); }
.sparks { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.spark svg { width: 100%; height: 44px; display: block; }
.spark-line { fill: none; stroke: var(--hw1); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-fill { fill: var(--hw1); opacity: .12; }
.procs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.active { border: 1px dashed var(--border-strong); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.active.idle { border-style: solid; border-color: var(--border); }
.active-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Costs (story 6.1) */
.insights { list-style: none; margin: 0; padding: 0; }
.insights li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--border); }
.insights li:first-child { border-top: 0; }
.insights .saving { flex: none; align-self: center; }
.daybars { display: flex; gap: 6px; align-items: flex-end; height: 150px; overflow-x: auto; }
.daybar { display: grid; grid-template-rows: 1fr auto; gap: 4px; min-width: 26px; flex: 1; height: 100%; text-align: center; }
.daybar-col { display: flex; flex-direction: column-reverse; height: 100%; border-radius: 4px; overflow: hidden; background: rgb(var(--ol) / .04); }
.daybar-col i, .sw { display: block; }
.daybar-col i.busy, .sw.busy { background: var(--hw1); }
.daybar-col i.idle, .sw.idle { background: var(--warn); }
.legend-row { display: flex; gap: 14px; margin-top: 8px; color: var(--ink-muted); }
.legend-row .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tok-form { display: inline-flex; gap: 6px; }
.tok-form input { width: 76px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; }
@media (max-width: 760px) { .insights li { flex-direction: column; } }

/* Utilization (story 6.2) */
.heat-list { display: grid; gap: 22px; }
.uheat { display: grid; gap: 3px; overflow-x: auto; }
.uh-row { display: grid; grid-template-columns: 64px repeat(24, minmax(10px, 1fr)); gap: 3px; align-items: center; min-width: 360px; }
.uh-row i { display: block; height: 16px; border-radius: 3px; }
.uh-axis i { height: auto; font-style: normal; font-size: 10px; color: var(--ink-dim); }
.uh-ramp { display: inline-block; width: 120px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--hw2) 8%, var(--surface)), var(--hw2)); }

/* Cost spikes (story 9.2) */
.cost-alert { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; margin-top: 12px; }
.cost-alert.muted-card { opacity: .65; }

/* Warp divergence (story 3.2) */
.kname { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.hint-row td { padding-top: 0; border-top: 0; }
.hints { margin: 0 0 6px; padding-left: 18px; color: var(--ink-muted); font-size: 13px; display: grid; gap: 4px; }
#ncu-cmd { white-space: pre-wrap; word-break: break-all; }

/* SSO (story 10.2) */
.sso-sp { display: grid; gap: 4px; color: var(--ink); }
.sso-sp code, .txtv { word-break: break-all; }
#ssof textarea { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: 12px "JetBrains Mono", monospace; }
#sso-dom { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; min-width: 200px; }

/* Repositories (story 2.3) */
.gh-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.gh-who { font-weight: 600; margin-bottom: 2px; }
.gh-who .badge { margin-left: 6px; }
.h-sm { font-size: 15px; margin: 0 0 6px; }
#lf #lr { width: 100%; margin-top: 8px; font-family: var(--mono, ui-monospace, monospace); font-size: 13px; }
#lf #lr option { padding: 3px 6px; }
#lf fieldset .check { margin-top: 6px; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, max-content)); gap: 12px 32px; align-items: start; margin: 8px 0 14px 26px; }
.sub-grid .mini > span { display: block; font-size: 12px; color: var(--ink-muted); margin-bottom: 6px; }
.form .sub-grid .mini > input, .form .sub-grid .mini > select { width: 100%; min-width: 120px; }
#lf #lr { height: auto; padding: 6px; }
#lhist td { vertical-align: top; }

/* Environment: where jobs run */
.places { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.place { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.place-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.place p { margin: 0; font-size: 13px; }
@media (max-width: 900px) { .places { grid-template-columns: 1fr; } }
details.fold > summary { cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2::before { content: "▸ "; color: var(--ink-dim); }
details.fold[open] > summary h2::before { content: "▾ "; }
details.fold:not([open]) > summary { border-bottom: 0; }
h3.sub { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; }
details.raw > summary { cursor: pointer; }

/* Re-authentication prompt for destructive actions (SEC-66). */
dialog.reauth { border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--ink);
  padding: 20px 22px; width: calc(100% - 32px); max-width: 420px; }
dialog.reauth::backdrop { background: rgb(0 0 0 / .5); }
dialog.reauth h2 { margin: 0 0 8px; font-size: 17px; }

/* QA hotfix (KRN-12..15): narrow windows and phones. These rules only decide what
   gives way when a page doesn't fit; wide layouts keep their look. */
/* KRN-12: a select with long option text shrinks to its row instead of running out of the card. */
.inline-field select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
/* KRN-12: run ids never break at their hyphens; the table scrolls in its card instead. */
table.pick td.mono a { white-space: nowrap; }
@media (max-width: 560px) {
  table.pick td:first-child, table.pick td:nth-child(2) { width: auto; }   /* room for the hardware name */
}
/* KRN-13: the heatmap grid is as wide as its cells, so its .table-wrap scrolls the whole
   grid (it used to stop 9px short and clip the last column), with room for the
   selected cell's outline. */
.table-wrap > .heat { width: max-content; min-width: 100%; }
.table-wrap:has(> .heat) { padding: 4px; margin: -4px; }
/* KRN-14: channel actions wrap inside their cell, and a webhook URL can break anywhere,
   so the table fits a narrow window instead of pushing the buttons off screen. */
tr[data-channel] td:last-child { white-space: normal; padding-top: 9px; padding-bottom: 9px; }   /* + 2px margins = the usual row */
tr[data-channel] td:last-child .btn { margin: 2px 0; }
tr[data-channel] td:nth-child(2) { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  tr[data-channel] td:last-child { padding-top: 8px; padding-bottom: 8px; }   /* cells are 10px here */
}
@media (max-width: 560px) {
  /* On a phone each channel is a block: name, target, then its controls. */
  .table-wrap table:has(> tbody > tr[data-channel]) > thead { display: none; }
  tr[data-channel] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  tr[data-channel]:last-child { border-bottom: 0; }
  tr[data-channel] td { display: block; padding: 0; border: 0; }
  tr[data-channel] td:first-child, tr[data-channel] td:nth-child(2) { flex-basis: 100%; }
  tr[data-channel] td:last-child { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }
  tr[data-channel] td:last-child .btn { margin: 0; }
}
/* KRN-15: a long hardware name (CPU model strings) takes at most two lines, ending in
   an ellipsis when squeezed; the full name is in the title. */
.hwname { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-width: 9ch; }
/* KRN-15: with the sidebar beside a narrow page (~880px), the runs table (Overview,
   Benchmarks) gives way instead of pushing Status off screen: headers and the start
   time may wrap, and cells are a little tighter. */
@media (min-width: 800px) and (max-width: 1000px) {
  table:has(> tbody > tr[data-href^="#/benchmarks/"]) :is(th, td.nw) { white-space: normal; }
  table:has(> tbody > tr[data-href^="#/benchmarks/"]) :is(th, td) { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 760px) {
  .nav { padding-bottom: 6px; }       /* mobile nav strip: its scrollbar no longer sits on the links */
}
