/* conneX Data Hub - industrial HMI ("AIm Ice") + VT220 amber.
   Tokens from aim-codex-web/tokens/themes.json (industrial, vt220). */

@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap;
  src: url("vendor/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap;
  src: url("vendor/fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }

:root, [data-theme="industrial"] {
  --bg: #0a0e14; --bg-raised: #0f1620; --bg-sunken: #060910; --bg-rail: #11192399;
  --fg: #c7d0db; --fg-dim: #838f9e; --fg-faint: #5a6b7e; --fg-bright: #eef3f8;
  --accent: #38bdf8; --accent-2: #f59e0b; --accent-ink: #02121c;
  --line: #243240; --line-bright: #55687e; --grid: #131c27; --selection-bg: #38bdf833;
  --ok: #1fb455; --warn: #ca8a04; --crit: #f04545; --idle: #8a96a4; --info: #5a94f7;
  --s1: #38bdf8; --s2: #f59e0b; --s3: #1fb455; --s4: #a78bfa; --s5: #f472b6; --s6: #f04545; --s7: #94a3b8;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --font-prose: system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
[data-theme="vt220"] {
  --bg: #0c0a05; --bg-raised: #14110a; --bg-sunken: #080603; --bg-rail: #14110a99;
  --fg: #ffb000; --fg-dim: #c08400; --fg-faint: #8a6000; --fg-bright: #ffd070;
  --accent: #ffb000; --accent-2: #ff8c2a; --accent-ink: #0c0a05;
  --line: #4a3300; --line-bright: #946600; --grid: #140e00; --selection-bg: #ffb00033;
  --ok: #2fbf66; --warn: #d99a00; --crit: #ff5a5a; --idle: #9a8a55; --info: #5a94f7;
  --s1: #ffb000; --s2: #ff8c2a; --s3: #2fbf66; --s4: #ffd070; --s5: #5a94f7; --s6: #ff5a5a; --s7: #c08400;
  --font-prose: var(--font-mono);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--font-prose); }
::selection { background: var(--selection-bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--fg-bright); font-weight: 600; line-height: 1.15; }
h1 { font-size: 26px; margin: 4px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.mono, code, td, th, .stat .v, .label, nav a, button, .btn, input, select { font-family: var(--font-mono); }
.label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-dim); }
.dim { color: var(--fg-dim); } .faint { color: var(--fg-faint); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .crit { color: var(--crit); }

/* header + nav */
header.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg-sunken);
  border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 6px 16px;
}
.brand { font-family: var(--font-mono); font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-bright); font-size: 15px; white-space: nowrap; margin-right: 8px; }
.brand b { color: var(--accent); font-weight: 600; }
.brand:hover { text-decoration: none; }
nav.main { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
nav.main a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--fg-dim); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; border-bottom: 2px solid transparent; }
nav.main a:hover { color: var(--fg-bright); text-decoration: none; }
nav.main a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tools { display: flex; gap: 6px; align-items: center; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
footer { padding: 24px 16px; color: var(--fg-faint); font: 12px var(--font-mono); text-align: center; }

/* panels */
.panel { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 2px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--bg-raised); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 12px; min-width: 0; }
.stat .v { font-size: 28px; color: var(--fg-bright); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .v.small { font-size: 16px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { font: 12px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); padding-top: 3px; }
dl.kv dd { margin: 0; font-family: var(--font-mono); color: var(--fg-bright); overflow-wrap: anywhere; }

/* badges */
.badge { display: inline-block; font: 600 12px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border: 1px solid currentColor; border-radius: 2px; vertical-align: middle; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.crit { color: var(--crit); }
.badge.idle { color: var(--idle); } .badge.info { color: var(--info); }
.badge.solid-crit { background: var(--crit); color: #fff; border-color: var(--crit); }

/* buttons + forms */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 2px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--selection-bg); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 12px; }
input, select { min-height: 44px; padding: 0 10px; font-size: 15px; background: var(--bg-sunken); color: var(--fg-bright);
  border: 1px solid var(--line-bright); border-radius: 2px; max-width: 100%; }
input[type=checkbox] { min-height: 0; width: 22px; height: 22px; accent-color: var(--accent); }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
form.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
form.filters label { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* tables */
.tablebar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 8px; }
.tablebar input { flex: 1 1 200px; min-height: 38px; }
.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); background: var(--bg-sunken); }
.tablewrap.short { max-height: 420px; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: var(--bg-raised); color: var(--fg-dim); text-align: left;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 10px;
  border-bottom: 1px solid var(--line-bright); cursor: pointer; white-space: nowrap; user-select: none; }
table.data th.sorted-asc::after { content: " \25B2"; color: var(--accent); }
table.data th.sorted-desc::after { content: " \25BC"; color: var(--accent); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; max-width: 420px; overflow-wrap: anywhere; }
table.data tr:hover td { background: var(--bg-rail); }
table.data td.num { text-align: right; white-space: nowrap; }
table.data td.json { color: var(--fg-dim); font-size: 12px; }
.count { font: 12px var(--font-mono); color: var(--fg-faint); }

/* charts */
.chart { width: 100%; min-height: 260px; }
.chartbox { background: var(--bg-sunken); border: 1px solid var(--line); padding: 8px; margin-bottom: 12px; min-width: 0; }
.chartbox .label { margin: 2px 4px 6px; }
.uplot, .uplot * { font-family: var(--font-mono) !important; }
.u-legend { color: var(--fg); font-size: 13px !important; }
.u-legend th { font-weight: 400; }
.u-select { background: var(--selection-bg) !important; }

/* timeline */
ul.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
ul.timeline li { position: relative; padding: 4px 0 12px 16px; }
ul.timeline li::before { content: ""; position: absolute; left: -7px; top: 10px; width: 8px; height: 8px;
  background: var(--bg); border: 2px solid var(--accent); }
ul.timeline li.modification::before { border-color: var(--accent-2); }
ul.timeline .when { font: 12px var(--font-mono); color: var(--fg-dim); }

/* drop zone */
.drop { border: 2px dashed var(--line-bright); padding: 32px 16px; text-align: center; background: var(--bg-sunken); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--selection-bg); }
.results { padding-left: 18px; }
.results li { font-family: var(--font-mono); font-size: 14px; margin: 6px 0; overflow-wrap: anywhere; }

/* photos */
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photos img { width: 120px; height: 120px; object-fit: cover; border: 1px solid var(--line); background: var(--bg-sunken); }
.trialcard { border-top: 1px solid var(--line); padding: 12px 0; }
.score { font: 600 22px var(--font-mono); color: var(--fg-bright); }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
  body { font-size: 15px; }
  main { padding: 12px 16px; }
  header.top { padding: 4px 8px 0; justify-content: space-between; }
  header.top .brand { order: 1; }
  header.top .tools { order: 2; }
  nav.main { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  nav.main::-webkit-scrollbar { display: none; }
  nav.main a { padding: 0 10px; font-size: 12px; white-space: nowrap; flex: none; }
  .grid { grid-template-columns: 1fr; }
  .stat .v { font-size: 22px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .tablewrap { max-height: 60vh; }
}

/* phones */
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 4px 2px 0; }
form.inline .btn, form.inline button { white-space: nowrap; flex: none; }
.enrol-row { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.enrol .qr svg { width: 220px; height: 220px; display: block; background: #fff; padding: 6px; }
.code-big { font-size: 28px; letter-spacing: .12em; font-weight: 700; }
td.actions { white-space: nowrap; }
