:root {
  --bg: #080c18;
  --panel: #12182c;
  --panel-2: #181f36;
  --line: #2c3658;
  --text: #eef2ff;
  --muted: #b4c0dc;
  --accent: #3ee0b2;
  --accent-dim: #1a4f42;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --warn: #e4c36a;
  --bad: #f07180;
  --ok: #3ee0b2;
  --info: #7ea8ff;
  --long: #3ee0b2;
  --short: #f0909c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --radius-lg: 12px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --touch: 40px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1100px 520px at 8% -12%, #1b2748, transparent),
    radial-gradient(800px 400px at 100% 0%, #15241c, transparent),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--accent);
  color: #06281e;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.skip:focus {
  left: 8px;
  box-shadow: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.top-brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: .04em;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.tag { margin: 0; color: var(--muted); font-size: .85rem; }
.nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
}
.nav a {
  color: var(--muted);
  padding: 8px 12px;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
}
.nav a:hover { text-decoration: none; color: var(--text); background: var(--panel-2); }
.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill, .badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .75rem;
  letter-spacing: .02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.badge.off {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.kill {
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
}
.kill.on { background: var(--bad); color: #14040a; border-color: var(--bad); }
.banner {
  background: #3a1520;
  color: #ffd0d6;
  padding: 8px 16px;
  font-size: .9rem;
  border-bottom: 1px solid #5a2430;
}
main { padding: 16px 16px 40px; max-width: 1280px; margin: 0 auto; }
body[data-page="channel"] main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body[data-page="channel"] .crumb,
body[data-page="channel"] .hero,
body[data-page="channel"] .subnav { margin-bottom: 0; }
.hero {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-start;
}
.hero-compact { margin-bottom: 12px; }
h1 {
  margin: 0 0 4px;
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  letter-spacing: -0.02em;
  font-weight: 700;
  line-height: 1.25;
}
h2 {
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: none;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}
p { color: var(--muted); line-height: 1.5; margin: 0 0 8px; }

.status-box {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  max-width: 360px;
  display: grid;
  gap: 8px;
}
.status-link { font-weight: 600; }

.stats, .kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}
.stat-card, .kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  gap: 2px;
}
.stat-card.hero-stat, .kpi.hero {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.stat-label, .kpi-label {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
}
.stat-card strong, .kpi-value {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums slashed-zero;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.kpi.hero .kpi-value { color: var(--accent); font-size: 1.7rem; }
.stat-sub, .kpi-sub { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.kpi-spark { height: 32px; width: 100%; display: block; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: inherit;
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
a.card { transition: border-color .12s; }
.card.channel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .12s, opacity .12s;
}
.card.channel.dim,
.card.channel.disabled {
  opacity: 1;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--warn) 35%, var(--line));
  background: color-mix(in srgb, var(--warn) 6%, var(--panel));
}
.card.channel header { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.card.channel h3 { margin: 0; font-size: 1.02rem; }
.card.channel h3 a { color: inherit; text-decoration: none; }
.card.channel h3 a:hover { color: var(--accent); }
.card.channel dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0; }
.card.channel dt { color: var(--muted); font-size: .75rem; }
.card.channel dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.channel-status {
  margin: 0;
  font-size: .85rem;
  color: var(--ok);
  font-weight: 600;
}
.channel-status.warn { color: var(--warn); }
.channel-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}
.channel-card-actions .ghost,
.channel-card-actions button {
  flex: 1 1 auto;
  min-height: var(--touch);
}
.callout.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  color: var(--text);
}
.split { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-top: 24px; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .top { position: static; }
  .tag { display: none; }
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.hint { color: var(--muted); font-size: .8rem; }
.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  scrollbar-gutter: stable;
}
.feed-tall { max-height: 420px; }
.ev {
  background: var(--panel);
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  display: grid;
  gap: 2px;
}
.ev.ok { border-color: var(--ok); }
.ev.warn { border-color: var(--warn); }
.ev.error { border-color: var(--bad); }
.ev.info { border-color: var(--info); }
.when { color: var(--muted); font-size: .75rem; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 16px;
  border-radius: 8px;
  background: transparent;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  scrollbar-gutter: stable;
  max-height: 480px;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.mono { font-variant-numeric: tabular-nums slashed-zero; font-family: var(--font-mono); font-size: .84rem; }
.muted { color: var(--muted); }
.side { font-weight: 700; font-size: .78rem; letter-spacing: .02em; }
.side.long { color: var(--long); }
.side.short { color: var(--short); }
.status {
  font-size: .75rem;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}
.status.filled::before, .status.submitted::before { background: var(--ok); }
.status.killed::before, .status.closed::before { background: var(--muted); }
.status.error::before, .status.rejected::before { background: var(--bad); }
button, .ghost {
  background: var(--accent);
  color: #06281e;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  min-height: var(--touch);
  font-weight: 600;
  cursor: pointer;
  font: inherit;
}
button:disabled, .ghost:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost, .ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.danger, .danger { background: var(--bad); color: #14040a; }
button.tiny {
  padding: 4px 10px;
  font-size: .78rem;
  border-radius: 8px;
  min-height: 32px;
}
.danger-text,
button.danger-text,
a.danger-text {
  background: transparent !important;
  color: #ffb4bc !important;
  border: 1px solid color-mix(in srgb, var(--bad) 65%, var(--line)) !important;
}
button.danger-text:hover:not(:disabled),
.danger-text:hover:not(:disabled),
a.danger-text:hover {
  background: color-mix(in srgb, var(--bad) 14%, transparent) !important;
  color: #ffe0e4 !important;
  border-color: var(--bad) !important;
  text-decoration: none;
}
button.danger-text:disabled,
.danger-text:disabled {
  opacity: 1;
  color: color-mix(in srgb, #ffb4bc 45%, var(--muted)) !important;
  border-color: color-mix(in srgb, var(--bad) 28%, var(--line)) !important;
  cursor: not-allowed;
}
.filters, .toolbar-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 32px;
  font-size: .8rem;
  cursor: pointer;
  font-weight: 500;
}
.chip.on, .chip[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: var(--accent-soft);
}
.channel-hero { align-items: center; }
.channel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
}
.channel-meta code {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
a.ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  justify-content: center;
}
a.ghost:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.risk-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 6px;
  align-items: stretch;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 0;
}
.field > label {
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: flex-end;
}
.field-help {
  margin: 0;
  font-weight: 400;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
  min-height: 2.7em;
}
.field-wide {
  grid-column: 1 / -1;
}
.field-wide textarea {
  min-height: 88px;
  height: auto;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
}
.stat-sub a {
  color: var(--accent);
  text-decoration: none;
}
.stat-sub a:hover { text-decoration: underline; }
@supports (grid-template-rows: subgrid) {
  .risk-form .field {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    row-gap: 6px;
    padding: 4px 0 20px;
  }
  .risk-form .field > label,
  .risk-form .field-help { min-height: 0; }
}
.login-form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
}
textarea, input[type=file], input[type=number], input[type=text], input[type=password], input[type=search], select {
  width: 100%;
  background: #0d1324;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: var(--touch);
  height: var(--touch);
  font: inherit;
  line-height: 1.25;
}
.field input[type=number] { font-variant-numeric: tabular-nums; }
select {
  appearance: none;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 3px), calc(100% - 8px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
textarea { min-height: 8rem; height: auto; }
input[type=file] { height: auto; padding: 8px; }
.try form { display: grid; gap: 4px; max-width: 640px; }
.try .field { padding: 8px 0; }
.try .field > label { min-height: 0; }
.check { color: var(--muted); display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 8px 0; }
.check input { width: auto; min-height: 20px; height: auto; }
.callout {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: .88rem;
}
.callout.quiet { background: transparent; color: var(--muted); }
.settings .section-head {
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) {
  .risk-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .risk-form { grid-template-columns: 1fr; }
  .risk-form .field {
    display: flex;
    flex-direction: column;
    grid-row: auto;
    padding: 8px 0;
  }
  .field > label { min-height: 0; }
  .field-help { min-height: 0; }
}
.samples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.samples > .card { background: var(--panel-2); }
.sample-when { margin: 0 0 8px; }
.sample pre { white-space: pre-wrap; font-size: .82rem; color: var(--muted); font-family: var(--font-mono); }
.sample img { width: 100%; border-radius: 8px; }
.sample .ok-line,
.sample .fail-line { margin-bottom: 8px; }
.sample-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 2px;
}
.ok-line { color: var(--ok); }
.fail-line { color: var(--bad); }
.stat { color: var(--text); }
.crumb {
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: .88rem;
}
.subnav {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 52px;
  z-index: 15;
  padding: 8px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.subnav a {
  color: var(--muted);
  padding: 6px 10px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
}
.subnav a:hover { text-decoration: none; background: var(--panel-2); color: var(--text); }
.subnav a[aria-current="location"] {
  color: var(--accent);
  background: var(--accent-soft);
}
@media (max-width: 860px) {
  .subnav { top: 0; }
}
.try-out {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 3rem;
}
.try-out.empty { color: var(--muted); border-style: dashed; background: transparent; }
.parsed-card { display: grid; gap: 8px; }
.parsed-card header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.parsed-card dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 0; }
.parsed-card dt { color: var(--muted); font-size: .75rem; }
.parsed-card dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.parsed-card pre { margin: 0; color: var(--muted); font-size: .8rem; white-space: pre-wrap; }
.toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
  z-index: 40;
  width: min(360px, calc(100vw - 24px));
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: .9rem;
}
.toast.ok { border-color: var(--ok); }
.toast.warn { border-color: var(--warn); }
.toast.error { border-color: var(--bad); }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 16, 0.72);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal-card p { color: var(--text); margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.logout { margin: 0; }
.login-page main { display: grid; place-items: center; min-height: 100vh; }
.login-box { max-width: 420px; width: min(420px, 100%); }
.brand-mark {
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent);
  margin: 0 0 8px;
}
.login-box h1 { margin-top: 0; }
.login-form { display: grid; gap: 12px; }
.err { color: var(--bad); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 0;
}
.toolbar-label { color: var(--muted); font-size: .78rem; font-weight: 600; }
.toolbar-end { margin-left: auto; }
.toolbar-group select { width: auto; min-width: 140px; }
.channels-filter { margin-bottom: 12px; }
.widget-panel { margin-bottom: 16px; }
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.widget-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 500;
  color: var(--text);
}
.widget-grid input { width: auto; min-height: 20px; }
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card canvas { width: 100%; height: 220px; display: block; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .toolbar-end { margin-left: 0; }
}
.chart-table { margin-top: 8px; color: var(--muted); font-size: .8rem; }
.search-label { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--muted); }
.search-label input { width: min(240px, 100%); min-height: 36px; }
.progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  min-width: 140px;
}
.progress-svg { width: 100%; height: 10px; display: block; }
.progress-bg { fill: var(--line); }
.progress-fg { fill: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.progress-mk { fill: var(--text); }
.kbd-hint { font-size: .8rem; }
kbd {
  font-family: var(--font-mono);
  font-size: .75rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--text);
  background: var(--panel-2);
}
.help-list { margin: 0 0 16px; padding-left: 16px; color: var(--text); }
.help-list li { margin: 4px 0; }
.sortable { cursor: pointer; }
.sortable:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a.card, tbody tr { transition: none; }
}
@media (max-width: 640px) {
  main { padding: 12px 12px 32px; }
  .nav a { padding: 8px 10px; }
}
