/*
 * tower dashboard — one dark page: cameras, gears, felt ops, chip.
 */

:root {
  color-scheme: dark;
  --ground: #05080a;
  --surface: #0a1014;
  --surface-2: #0e161b;
  --rule: #16242b;
  --rule-2: #22363f;
  --ink: #d2dcdf;
  --dim-ink: #6a7f86;
  --faint: #3b4c53;
  --accent: #7fd4ff;
  --ok: #45e08c;
  --ok-dim: #1f6b43;
  --ok-deep: #123b27;
  --warn: #f2b53a;
  --warn-dim: #3d2d0c;
  --fault: #ff5a5a;
  --fault-dim: #3f1414;
  --idle: #4a5a60;
  --none: #121b20;
  --mono: "JetBrains Mono", "JetBrainsMono Nerd Font", ui-monospace, "Cascadia Mono", "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 13px/1.45 var(--mono);
  font-variant-numeric: tabular-nums;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgb(127 212 255 / 0.018) 3px),
    radial-gradient(ellipse at 30% -10%, rgb(69 224 140 / 0.05), transparent 60%),
    var(--ground);
}
body.is-zoomed { overflow: hidden; }
::selection { background: var(--ok); color: var(--ground); }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--ok); }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.k { color: var(--dim-ink); font-size: 11px; letter-spacing: 0.04em; }
.spacer { flex: 1; }
.pos { color: var(--ok); }
.neg { color: var(--fault); }

.wrap { display: grid; gap: 12px; max-width: 3400px; margin: 0 auto; padding-inline: 16px; padding-block: 12px 24px; }

/* ---------- controls ---------- */
.btn, .felt-actions button, .menu-list button, .felt-launch-form input[type=submit], .felt-funding-dialog input[type=submit], .felt-funding-dialog button {
  border: 1px solid var(--rule-2); background: var(--surface-2); padding: 3px 9px; font-size: 11px; line-height: 1.4; color: var(--ink);
}
.btn:hover:not(:disabled), .felt-actions button:hover:not(:disabled), .felt-launch-form input[type=submit]:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn--go, .felt-launch-form input[type=submit] { border-color: var(--ok-dim); color: var(--ok); }
.btn--danger:hover:not(:disabled), .is-danger:hover:not(:disabled) { border-color: var(--fault) !important; color: var(--fault) !important; }
.btn:disabled, .felt-actions button:disabled, .menu-list button:disabled, input[type=submit]:disabled { opacity: 0.35; }
.btns { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; }
.button_to { display: inline; margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--dim-ink); font-size: 11px; }
.linkish:hover { color: var(--accent); }
input[type=text], input[type=number], input[type=password], select {
  background: var(--ground); border: 1px solid var(--rule-2); padding: 4px 6px; min-width: 0;
}
.seg { display: inline-flex; border: 1px solid var(--rule-2); }
.seg button { background: none; border: 0; padding: 2px 9px; font-size: 11px; color: var(--dim-ink); }
.seg button + button { border-left: 1px solid var(--rule-2); }
.seg button:hover { color: var(--accent); }
kbd { font: 11px var(--mono); color: var(--faint); border: 1px solid var(--rule-2); padding: 0 5px; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot--warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.dot--fault { background: var(--fault); box-shadow: 0 0 8px var(--fault); animation: pulse 1s infinite; }
.dot--idle { background: var(--idle); box-shadow: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
.st { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- top bar ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px;
  padding: 8px 14px; border: 1px solid var(--rule); background: var(--surface);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
}
.brand { font-size: 24px; font-weight: 500; line-height: 1; letter-spacing: 0.06em; color: var(--ok); text-shadow: 0 0 12px rgb(69 224 140 / 0.35); }
.brand a { color: inherit; text-decoration: none; }
.brand::before { content: "▮ "; font-size: 15px; vertical-align: 3px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim-ink); letter-spacing: 0.08em; text-transform: uppercase; }
.live .dot { background: var(--ok); }
.live.is-down { color: var(--fault); }
.live.is-down .dot { background: var(--fault); box-shadow: 0 0 8px var(--fault); animation: pulse 1s infinite; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; }
.stat { display: inline-flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.stat b { font-weight: 500; }
.stat .k { text-transform: uppercase; }
.meter { display: inline-block; width: 42px; height: 5px; background: var(--none); position: relative; vertical-align: 1px; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--ok); }
.meter.is-warn i { background: var(--warn); }
.clock { font-size: 18px; line-height: 1; }
.acct { display: flex; gap: 12px; align-items: center; font-size: 11px; }
.acct a { color: var(--dim-ink); text-decoration: none; }
.acct a:hover { color: var(--accent); }

/* chips with hover popovers (weather, atm) */
.chip-pop { position: relative; }
.chipbtn { display: inline-flex; gap: 8px; align-items: baseline; border: 1px solid var(--rule-2); background: var(--surface-2); padding: 3px 10px; }
.chipbtn:hover { border-color: var(--accent); }
.chipbtn b { color: var(--ok); font-size: 17px; font-weight: 500; line-height: 1; }
.chipbtn .k { text-transform: uppercase; }
.chipbtn.is-fault { border-color: var(--fault); }
.chipbtn.is-muted b { color: var(--dim-ink); }
.pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 300px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--rule-2); padding: 12px 14px; box-shadow: 0 12px 40px #000c;
  display: none; z-index: 30;
}
/* :focus-visible, not :focus-within: a mouse click focuses the button and would pin the popover open. */
.chip-pop:has(:focus-visible) .pop, .chip-pop.is-open .pop { display: block; }
/* Touch screens keep :hover after a tap, so only real hover devices open on hover. */
@media (hover: hover) { .chip-pop:hover .pop { display: block; } }
/* Bridge the 6px gap so the pointer can travel from chip to popover without it closing. */
.pop::before { content: ""; position: absolute; left: 0; right: 0; top: -7px; height: 7px; }
.pop h3 { margin-bottom: 8px; font-size: 11px; font-weight: 400; color: var(--dim-ink); display: flex; justify-content: space-between; gap: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.pop .big { font-size: 32px; line-height: 1; color: var(--ok); }
.pop .big small { font-size: 16px; color: var(--dim-ink); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 10px 0 0; }
.kv dt { color: var(--dim-ink); }
.kv dd { margin: 0; text-align: right; }
.kv--recent { border-top: 1px solid var(--rule); padding-top: 8px; }
.warn-text { margin-top: 8px; color: var(--fault); font-size: 11px; overflow-wrap: anywhere; }
.wi { width: 18px; height: 18px; display: block; }
.wic { display: inline-flex; align-items: center; gap: 6px; align-self: center; }
.wic--sun { color: var(--warn); }
.wic--cloud { color: var(--dim-ink); }
.wic--rain { color: var(--accent); }
.pop--wx { width: 470px; }
.wdays { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wday { display: grid; gap: 5px; align-content: start; padding: 4px 12px; border-left: 1px solid var(--rule); }
.wday:first-child { border-left: 0; padding-left: 0; }
.wday .t { font-size: 28px; line-height: 1; }
.wday .t small { font-size: 15px; color: var(--dim-ink); }
.wday .r { font-size: 11px; color: var(--dim-ink); display: grid; gap: 3px; }
.wday .r.is-wet { color: var(--accent); }
.wday .wi { width: 24px; height: 24px; }
.rbar { display: block; height: 4px; background: var(--none); }
.rbar i { display: block; height: 100%; background: currentColor; }

/* ---------- panels & grid ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 3fr) minmax(400px, 1fr); align-items: start; }
.main, .rail { display: grid; gap: 12px; min-width: 0; align-content: start; }
.panel { border: 1px solid var(--rule); background: var(--surface); min-width: 0; }
.ph { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 12px; border-bottom: 1px solid var(--rule); min-height: 34px; }
.ph h2 { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; color: var(--dim-ink); }
.ph h2::before { content: "// "; color: var(--faint); }
.ph .meta { margin-left: auto; color: var(--faint); font-size: 11px; }
.pb { padding: 12px; display: grid; gap: 10px; }

/* ---------- cameras ---------- */
.cams { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: dense; gap: 6px; padding: 6px; }
/* 3bs main is the featured camera: a 2x2 tile, with the other eight filling a 4x3 block. */
.cam[data-camera-id="bar-main"] { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
.cam { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border: 1px solid var(--rule); overflow: hidden; display: block; }
.cam-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam:hover { border-color: var(--accent); }
/* Name, still age and refresh sit together bottom-left; the overlay itself lets clicks through to zoom. */
.cam .ov { position: absolute; inset: auto 0 0 0; display: flex; align-items: center; gap: 6px; padding: 16px 8px 5px; font-size: 11px; background: linear-gradient(transparent, #000c); text-align: left; pointer-events: none; }
.cam-refresh { pointer-events: auto; flex: none; box-sizing: border-box; width: 14px; height: 14px; aspect-ratio: 1; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--ok-dim); border-radius: 50%; background: rgb(0 0 0 / 0.55); color: var(--ok); }
.cam-refresh svg { width: 9px; height: 9px; display: block; }
.cam-refresh:hover { border-color: var(--ok); box-shadow: 0 0 6px rgb(69 224 140 / 0.5); }
.cam-refresh.is-refreshing { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cam .ov .n { color: #fff; margin-right: 6px; }
.cam .ov .a { color: var(--ok); }
.cam.is-stale { border-color: var(--warn); }
.cam.is-stale .ov .a { color: var(--warn); }
.cam.is-dead { border-color: var(--fault); }
.cam.is-dead .ov .a { color: var(--fault); }
.cam.is-dead img { filter: grayscale(1) brightness(0.4); }
.cam-missing { display: grid; place-items: center; height: 100%; color: var(--fault); font-size: 11px; }
.cam.is-fresh::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--ok); pointer-events: none; animation: flash 0.8s ease-out forwards; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

.zoom { position: fixed; inset: 0; z-index: 40; background: rgb(2 4 5 / 0.96); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px)); }
.zh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.zh h2 { font-size: 22px; font-weight: 500; }
.rec { display: inline-flex; gap: 6px; align-items: center; color: var(--fault); font-size: 11px; letter-spacing: 0.12em; }
.rec .dot { background: var(--fault); box-shadow: 0 0 8px var(--fault); animation: pulse 1s infinite; }
/* Zoom badge states: amber while connecting, green once video is playing. */
.rec--connecting { color: var(--warn); }
.rec--connecting .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulse 0.6s infinite; }
.rec--live { color: var(--ok); }
.rec--live .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2s infinite; }
.rec--stills { color: var(--accent); }
.rec--stills .dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: none; }
.rec--paused { color: var(--dim-ink); }
.rec--paused .dot { background: var(--idle); box-shadow: none; animation: none; }
.hint { color: var(--faint); font-size: 11px; }
.zstage { min-height: 0; display: grid; place-items: center; }
.zstage { position: relative; }
.zstage img, .zstage video { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--rule-2); background: #000; }
.zstage video { width: 100%; height: 100%; }
.zresume { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 16px; font-size: 13px; }
.zthumbs { display: flex; gap: 6px; overflow-x: auto; justify-content: center; }
.zthumbs button { flex: none; width: 110px; aspect-ratio: 16 / 9; padding: 0; border: 1px solid var(--rule); background: #000; }
.zthumbs button.is-on { border-color: var(--accent); }
.zthumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- gears ---------- */
.verdict { cursor: pointer; user-select: none; }
.verdict .word { font-size: 17px; font-weight: 500; letter-spacing: 0.08em; }
.verdict--ok .word { color: var(--ok); text-shadow: 0 0 10px rgb(69 224 140 / 0.3); }
.verdict--warn .word { color: var(--warn); }
.verdict--fault .word { color: var(--fault); text-shadow: 0 0 10px rgb(255 90 90 / 0.35); }
.verdict .count { color: var(--ink); font-weight: 500; }
.verdict--fault .count { color: var(--fault); }
.faults { list-style: none; margin: 0; padding: 0; }
.faults li { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: baseline; padding: 6px 12px; border-bottom: 1px solid var(--rule); background: var(--fault-dim); }
.faults li.fault--warn { background: var(--warn-dim); }
.faults .m { color: var(--dim-ink); grid-column: 2 / 4; font-size: 11px; overflow-wrap: anywhere; }
.lamps { padding: 8px 12px 12px; display: grid; gap: 10px; }
.grp h3 { margin-bottom: 4px; font-size: 10px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.16em; display: flex; justify-content: space-between; }
.grp h3 .is-down { color: var(--fault); }
.row, .axis { display: grid; grid-template-columns: 10px minmax(9ch, 19ch) 7ch minmax(0, 1fr); gap: 8px; align-items: center; }
.row { padding: 1px 0; }
.row:hover, .row:focus { background: var(--surface-2); outline: none; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ag { color: var(--dim-ink); font-size: 11px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row--fault .nm { color: var(--fault); }
.row--warn .nm { color: var(--warn); }
.row--idle .nm { color: var(--dim-ink); }
.hist { display: grid; grid-template-columns: repeat(48, minmax(0, 1fr)); gap: 1px; height: 10px; }
.hist i { background: var(--none); }
.hist .h--ok { background: var(--ok-dim); }
.hist .h--warn { background: var(--warn); }
.hist .h--fault { background: var(--fault); }
.hist i:last-child.h--ok { background: var(--ok); }
.axis { font-size: 10px; color: var(--faint); }
.axis > span:last-child { display: flex; justify-content: space-between; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-2); border: 1px solid var(--rule-2); padding: 8px 10px; font-size: 11px; max-width: 360px; box-shadow: 0 8px 30px #000c; }
.tip b { display: block; font-weight: 500; margin-bottom: 4px; }
.tip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.tip dt { color: var(--faint); }
.tip dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- chip console ---------- */
.chat-bar { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 12px; min-height: 34px; background: var(--surface); border: 0; text-align: left; }
.chat-bar:hover { background: var(--surface-2); }
.chat-t { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ok); }
.chat-t::before { content: "› "; }
.chat-prev { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--dim-ink); font-size: 12px; }
.chat.is-open .chat-prev { visibility: hidden; }
.unread { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.command-status { color: var(--faint); font-size: 11px; white-space: nowrap; }
.chat .term { height: 0; overflow: hidden; transition: height 0.25s ease; display: flex; flex-direction: column; }
.chat.is-open .term { height: 340px; border-top: 1px solid var(--rule); }
.log-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.log { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 10px 12px; display: grid; align-content: start; gap: 6px; font-size: 12px; }
.log li { white-space: pre-wrap; overflow-wrap: anywhere; }
.command-line--user { color: var(--accent); }
.command-line--user::before { content: "you› "; color: var(--faint); }
.command-line--assistant::before { content: "chip› "; color: var(--faint); }
.command-line--status { color: var(--faint); font-size: 11px; }
.command-line[data-status="pending"]::after, .command-line[data-status="delivered"]::after { content: " …"; color: var(--faint); }
.prompt { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--rule); padding: 8px 12px; margin: 0; }
.prompt label { color: var(--ok); }
.prompt input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; caret-color: var(--ok); padding: 2px 0; }
.lampwrap { max-height: 3000px; overflow: hidden; transition: max-height 0.3s ease; }
.rail.is-chatting .lampwrap { max-height: 0; }

/* ---------- felt ---------- */
.felt .ph .seg { margin-left: 4px; }
.felt[data-range="24h"] [data-range-button="24h"], .felt[data-range="1w"] [data-range-button="1w"], .felt[data-range="all"] [data-range-button="all"] { background: var(--surface-2); color: var(--accent); }
.felt .by-range { display: none; }
.felt[data-range="24h"] .by-range[data-range="24h"], .felt[data-range="1w"] .by-range[data-range="1w"], .felt[data-range="all"] .by-range[data-range="all"] { display: inline; }
.felt[data-range="24h"] .pd-chart[data-range="24h"], .felt[data-range="1w"] .pd-chart[data-range="1w"], .felt[data-range="all"] .pd-chart[data-range="all"] { display: block; }
.felt[data-range="24h"] .range-label::after { content: "24h"; }
.felt[data-range="1w"] .range-label::after { content: "1w"; }
.felt[data-range="all"] .range-label::after { content: "∞"; }
.felt.felt-display-stale .felt-live { opacity: 0.55; }
.felt-alert, .flash-alert { color: var(--fault); padding: 6px 12px; font-size: 12px; }
.felt-feedback { color: var(--accent); padding: 6px 12px; font-size: 12px; border-bottom: 1px solid var(--rule); }
.felt-feedback.felt-alert { color: var(--fault); }
.felt-muted { color: var(--dim-ink); font-size: 11px; padding: 6px 12px; max-width: 110ch; }
.felt-server { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 6px 12px; border-bottom: 1px solid var(--rule); }
.felt-server .felt-actions { display: flex; }
.felt-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0; border-bottom: 1px solid var(--rule); }
.felt-top .cell { padding: 10px 12px; border-right: 1px solid var(--rule); display: grid; gap: 4px; align-content: start; }
.felt-top .cell:last-child { border-right: 0; }
.felt-top dt { text-transform: uppercase; }
.felt-top dd { margin: 0; font-size: 22px; line-height: 1; }
.felt-top dd small { font-size: 14px; color: var(--dim-ink); }
.felt-launch { display: none; padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.felt.is-launching .felt-launch { display: block; }
.felt-launch-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.felt-launch-form label { display: grid; gap: 3px; font-size: 10px; color: var(--dim-ink); text-transform: uppercase; letter-spacing: 0.08em; }
.felt-launch-form input[type=number] { width: 13ch; }
.felt-launch-name { display: flex; gap: 4px; }
.felt-random { border: 1px solid var(--rule-2); background: var(--ground); padding: 0 8px; }
.felt-seatmap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.felt-seatmap h3 { font-size: 11px; font-weight: 400; color: var(--dim-ink); text-transform: uppercase; letter-spacing: 0.1em; display: flex; gap: 8px; align-items: baseline; }
.seats { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.seat { width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 10px; font-style: normal; border: 1px solid var(--rule-2); color: var(--ground); cursor: default; }
.seat--bot { background: var(--accent); border-color: var(--accent); }
.seat--human { background: var(--ok); border-color: var(--ok); }
.seat--open { background: var(--fault-dim); border-color: var(--fault); color: var(--fault); box-shadow: 0 0 6px rgb(255 90 90 / 0.35); }
.seat.is-out { opacity: 0.45; }
.seat-legend { display: inline-flex; align-items: center; gap: 5px; }
.seat-legend .seat { width: 10px; height: 10px; }
.seat-legend .open-count { color: var(--fault); margin-left: 6px; }
.felt-table-wrap { overflow-x: auto; }
.felt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.felt-table th, .felt-table td { padding: 5px 10px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; font-weight: 400; }
.felt-table th:first-child, .felt-table td:first-child { text-align: left; }
.felt-table thead th { color: var(--faint); font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; }
.felt-table tbody tr:hover { background: var(--surface-2); }
.felt-table .strat { color: var(--dim-ink); font-size: 11px; }
.bot-row { cursor: pointer; }
.bot-row.is-open { background: var(--surface-2); }
.bot-detail { display: none; }
.bot-detail.is-open { display: table-row; }
.bot-detail td { padding: 0; text-align: left; white-space: normal; background: var(--surface-2); }
.pd { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; padding: 10px 12px 12px; }
.pd-chart { display: none; min-width: 0; }
.pd .kv { margin: 0; }
.spark { width: 70px; height: 16px; vertical-align: middle; overflow: visible; }
.chart { width: 100%; height: auto; max-height: 160px; display: block; }
.spark .line, .chart .line { fill: none; stroke-width: 1.3; vector-effect: non-scaling-stroke; }
.chart--up .line { stroke: var(--ok); }
.chart--down .line { stroke: var(--fault); }
.chart .area { opacity: 0.12; }
.chart--up .area, .chart--up .end { fill: var(--ok); }
.chart--down .area, .chart--down .end { fill: var(--fault); }
.spark .zero, .chart .zero { stroke: var(--faint); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--rule); vector-effect: non-scaling-stroke; }
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; display: grid; min-width: 150px; background: var(--surface); border: 1px solid var(--rule-2); box-shadow: 0 10px 30px #000c; }
.menu-list .button_to, .menu-list > button { display: block; }
.menu-list button { width: 100%; text-align: left; border: 0 !important; border-bottom: 1px solid var(--rule) !important; background: none; padding: 6px 10px; }
.menu-list button:hover:not(:disabled) { color: var(--accent); background: var(--surface-2); }
.felt-archived, .felt-pending, .felt-gold { border-top: 1px solid var(--rule); }
.felt-archived summary { cursor: pointer; padding: 8px 12px; color: var(--dim-ink); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.felt-pending h3, .felt-gold h3 { padding: 8px 12px 0; color: var(--dim-ink); font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.1em; }
.felt-operations { margin: 4px 0 8px; padding: 0 12px 0 28px; color: var(--warn); font-size: 12px; }
.felt-gold a { display: inline-block; padding: 4px 12px 0; font-size: 12px; }
.felt-funding-dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--rule-2); padding: 16px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px #000; }
.felt-funding-dialog::backdrop { background: rgb(0 0 0 / 0.7); }
.felt-funding-dialog h3 { margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.felt-funding-dialog .felt-muted, .felt-funding-dialog .felt-alert { padding: 0 0 8px; }
.felt-funding-dialog form { display: grid; gap: 6px; }
.felt-funding-dialog label { color: var(--dim-ink); font-size: 11px; }
.felt-funding-dialog .felt-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding-inline: 16px; }
.login-card { width: min(360px, 100%); padding: 20px; display: grid; gap: 14px; }
.login-card-header { color: var(--dim-ink); font-size: 12px; }
.terminal-kicker { color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; }
.terminal-form { display: grid; gap: 8px; }
.terminal-form input[type=text], .terminal-form input[type=password] { width: 100%; padding: 7px 8px; }
.login-submit { border: 1px solid var(--ok-dim); background: var(--surface-2); color: var(--ok); padding: 6px; }
.flash-notice { color: var(--accent); font-size: 12px; }

/* ---------- desktop: whole dashboard above the fold ---------- */
@media (min-width: 1101px) and (min-height: 760px) {
  body.controller-dashboard { height: 100vh; overflow: hidden; }
  body.controller-dashboard .wrap { height: 100vh; grid-template-rows: auto minmax(0, 1fr); }
  .grid { min-height: 0; align-items: stretch; }
  .main, .rail { min-height: 0; display: flex; flex-direction: column; }
  .campanel { flex: none; }
  .cams { max-width: calc((100vh - 400px) * 64 / 27); margin-inline: auto; width: 100%; }
  .felt { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
  .felt-scroll { flex: 1 1 0; min-height: 0; overflow: auto; }
  .gears { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; transition: flex-grow 0.3s ease; }
  .lampwrap { flex: 1 1 0; min-height: 0; max-height: none; overflow: auto; transition: none; }
  .rail.is-chatting .gears { flex-grow: 0; flex-basis: auto; }
  .rail.is-chatting .lampwrap { flex: 0 0 0; }
  .chat { flex: none; display: flex; flex-direction: column; min-height: 0; transition: flex-grow 0.3s ease; }
  .chat.is-open { flex: 1 1 0; }
  .chat.is-open .term { height: auto; flex: 1 1 0; min-height: 0; }
}

/* ---------- narrower screens ---------- */
/* Laptop widths (1080p at 125-150% scaling): keep the top bar on one line. */
@media (max-width: 1600px) {
  .bar { gap: 6px 14px; }
  .stats { gap: 4px 12px; }
  .meter { width: 32px; }
  .opt-wide { display: none !important; }
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  /* One column: cameras, then gears and chip, then felt. */
  .main, .rail { display: contents; }
  .campanel { order: 1; }
  .gears { order: 2; }
  .chat { order: 3; }
  .felt { order: 4; }
}
@media (max-width: 900px) {
  .cams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pd { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 10px; gap: 10px; }
  .bar { gap: 6px 14px; padding: 8px 10px; position: static; }
  .opt { display: none !important; }
  .brand { font-size: 20px; }
  .pop { position: fixed; left: 10px; right: 10px; top: 64px; width: auto; }
  .wday { padding: 4px 8px; }
  .wday .t { font-size: 20px; }
  .row, .axis { grid-template-columns: 10px minmax(0, 1fr) 7ch 96px; }
  .hist { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .hist i:nth-child(-n+36) { display: none; }
  .zthumbs { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
