/* AI Server control console.
   The visual language is a control-panel schedule, not a dashboard: state first,
   dense rows, unambiguous safe/isolated colouring, no decoration that is not
   carrying information.
   Type is local on purpose. Bahnschrift is Windows' DIN-derived industrial face,
   which is what panel legends are actually set in -- and an admin console must
   still render when the network it administers is down, so nothing is fetched. */

:root {
  --field:   #E8EAE6;  /* RAL 7035, the colour of the enclosure itself */
  --panel:   #F4F5F2;
  --ink:     #1B1F1D;
  --ink-dim: #5C635E;
  --rule:    #C3C8C1;
  --live:    #2E6F4E;  /* energised */
  --cut:     #A4331F;  /* isolated: the e-stop red */
  --warn:    #8A6516;
  --legend: 'Bahnschrift', 'DIN Alternate', 'Segoe UI', system-ui, sans-serif;
  --body:   'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:   'Cascadia Mono', Consolas, 'SF Mono', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --field: #14171A; --panel: #1C2024; --ink: #E6E9E5; --ink-dim: #9AA39C;
    --rule: #333A3C; --live: #5FBF8C; --cut: #E07A62; --warn: #D6A43A;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- sign in ---------- */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.gate__card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: 28px;
}

.gate__mark { width: 26px; height: 26px; background: var(--ink); position: relative; margin-bottom: 18px; }
.gate__mark::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 9px; height: 9px; border-radius: 50%; background: var(--live);
}

.gate__title { font-family: var(--legend); font-size: 27px; font-weight: 600; letter-spacing: .01em; margin: 0; }
.gate__sub { color: var(--ink-dim); margin: 6px 0 22px; font-size: 14px; }
.gate__err { color: var(--cut); font-size: 14px; margin: 14px 0 0; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-family: var(--legend); font-size: 13px; color: var(--ink-dim); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--field); border: 1px solid var(--rule); border-radius: 0;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.btn:focus-visible, .tab:focus-visible, .row__toggle:focus-visible {
  outline: 2px solid var(--live); outline-offset: 2px;
}

/* The QR keeps a white field whatever the theme: inverting it, or tinting the
   background, stops many scanners reading it. */
.enrol__qr { background: #fff; border: 1px solid var(--rule); padding: 10px;
  margin-bottom: 18px; display: flex; justify-content: center; }
.enrol__qr svg { display: block; width: 100%; height: auto; max-width: 260px; image-rendering: pixelated; }
.enrol__or { margin-top: 0; margin-bottom: 8px; }

.linkish { display: block; margin: 14px 0 0; padding: 0; background: none; border: 0;
  color: var(--ink-dim); font: inherit; font-size: 13.5px; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--ink); }

/* ---------- buttons ---------- */

.btn {
  font-family: var(--legend); font-size: 14px; letter-spacing: .01em;
  padding: 8px 15px; border: 1px solid var(--ink); background: transparent;
  color: var(--ink); cursor: pointer; border-radius: 0;
}
.btn:hover { background: var(--ink); color: var(--panel); }
.btn--go { background: var(--ink); color: var(--panel); }
.btn--go:hover { background: var(--live); border-color: var(--live); color: #fff; }
.btn--cut { border-color: var(--cut); color: var(--cut); }
.btn--cut:hover { background: var(--cut); border-color: var(--cut); color: #fff; }
.btn--quiet { border-color: var(--rule); color: var(--ink-dim); }
.btn--quiet:hover { background: var(--rule); color: var(--ink); }
.btn--sm { padding: 4px 10px; font-size: 13px; }

/* ---------- top bar ---------- */

.bar {
  display: flex; align-items: center; gap: 18px;
  background: var(--ink); color: var(--panel); padding: 0 20px; height: 54px;
}
.bar__mark { width: 16px; height: 16px; background: var(--live); flex: none; }
.bar__name { font-family: var(--legend); font-size: 18px; font-weight: 600; }
.bar__nav { display: flex; gap: 2px; margin-left: 14px; flex: 1; }
.tab {
  font-family: var(--legend); font-size: 15px; background: transparent; border: 0;
  color: #9AA39C; padding: 6px 13px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--panel); }
.tab.is-on { color: var(--panel); border-bottom-color: var(--live); }
.bar__who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #9AA39C; }
.bar__who .btn { border-color: #444B46; color: #9AA39C; }
.bar__who .btn:hover { background: #444B46; color: var(--panel); }

/* ---------- status strip: the annunciator ---------- */

.strip { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--rule); background: var(--panel); }
.stat { padding: 13px 20px; border-right: 1px solid var(--rule); min-width: 132px; }
.stat__n { font-family: var(--legend); font-size: 25px; font-weight: 600; line-height: 1.1; }
.stat__k { font-size: 12.5px; color: var(--ink-dim); }
.stat--cut .stat__n { color: var(--cut); }
.stat--live .stat__n { color: var(--live); }

/* ---------- layout ---------- */

.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 20px 72px; }
.view__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.view__head h2 { font-family: var(--legend); font-size: 22px; font-weight: 600; margin: 0 0 2px; }
.view__note { color: var(--ink-dim); font-size: 14px; margin: 0 0 18px; max-width: 68ch; }

/* ---------- the register ---------- */

.register { border: 1px solid var(--rule); background: var(--panel); }
.register__empty { padding: 26px 18px; color: var(--ink-dim); }

.row { border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row__main { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 14px; align-items: center; padding: 11px 16px; }

/* Filled lamp = reachable right now. Hollow = cut off. */
.lamp { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--live); background: var(--live); }
.lamp--cut { border-color: var(--cut); background: transparent; }
.lamp--warn { border-color: var(--warn); background: var(--warn); }

.row__name { font-family: var(--legend); font-size: 16px; }
.row__meta { color: var(--ink-dim); font-size: 13px; }
.row__scopes { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; border: 1px solid var(--rule); padding: 1px 7px; color: var(--ink-dim); }
.row__toggle { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font-family: var(--legend); font-size: 13px; }

.row__grants { padding: 0 16px 14px 48px; }
.grant { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px dashed var(--rule); font-size: 14px; }
.grant__eff { font-family: var(--legend); font-size: 13px; padding: 0 7px; border: 1px solid; }
.grant__eff--allow { color: var(--live); border-color: var(--live); }
.grant__eff--deny  { color: var(--cut);  border-color: var(--cut); }
.grant__kind { color: var(--ink-dim); font-size: 13px; min-width: 56px; }
.grant__pat { font-family: var(--mono); font-size: 13px; }
.grant__none { color: var(--ink-dim); font-size: 13.5px; padding: 7px 0; border-top: 1px dashed var(--rule); }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-family: var(--legend); font-weight: 500; font-size: 13px;
  color: var(--ink-dim); padding: 9px 16px; border-bottom: 1px solid var(--rule);
}
.tbl td { padding: 8px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.tbl .bad { color: var(--cut); }
.tbl .ok { color: var(--live); }
.path { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); word-break: break-all; }

/* ---------- dialog ---------- */

.dlg { border: 1px solid var(--rule); border-top: 3px solid var(--ink); background: var(--panel);
  color: var(--ink); padding: 24px; width: min(460px, 94vw); }
.dlg::backdrop { background: rgba(10,12,11,.5); }
.dlg h3 { font-family: var(--legend); font-size: 20px; font-weight: 600; margin: 0 0 14px; }
.dlg__row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dlg__note { color: var(--ink-dim); font-size: 13.5px; margin: 0 0 14px; }

/* A minted token is shown exactly once. It should feel like a one-time event,
   not another field on a form. */
.token { font-family: var(--mono); font-size: 13px; word-break: break-all;
  background: var(--field); border: 1px solid var(--live); border-left: 4px solid var(--live); padding: 12px; }
.token--warn { border-color: var(--warn); border-left-color: var(--warn); }

@media (max-width: 720px) {
  .bar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .bar__nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .row__main { grid-template-columns: 18px 1fr; row-gap: 6px; }
  .row__scopes, .row__toggle { grid-column: 2; }
  .wrap { padding: 18px 14px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
