/* rdpctl web console — operations UI, not a marketing page.
   Dark is the default surface; light is produced by prefers-color-scheme. */

:root {
  --bg:          #0e1116;
  --bg-2:        #131821;
  --surface:     #161c26;
  --surface-2:   #1c2431;
  --surface-3:   #232d3c;
  --border:      #2a3646;
  --border-2:    #384658;
  --text:        #dfe6ef;
  --text-2:      #9fadbf;
  --text-3:      #6f7d8f;
  --accent:      #4c9aff;
  --accent-ink:  #0b1220;
  --ok:          #37c98a;
  --ok-bg:       #0f2a20;
  --warn:        #e8a33d;
  --warn-bg:     #2c2211;
  --bad:         #f2545b;
  --bad-bg:      #2d1418;
  --info:        #9b7bf0;
  --info-bg:     #211b33;
  --shadow:      0 8px 28px rgba(0,0,0,.45);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  --gut: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f4f6f9;
    --bg-2:      #eceff4;
    --surface:   #ffffff;
    --surface-2: #f5f7fa;
    --surface-3: #eaeef4;
    --border:    #d7dee8;
    --border-2:  #c2cddb;
    --text:      #17202c;
    --text-2:    #4d5b6d;
    --text-3:    #75839a;
    --accent:    #1264d4;
    --accent-ink:#ffffff;
    --ok:        #17794a;
    --ok-bg:     #e2f5ec;
    --warn:      #9a6208;
    --warn-bg:   #fdf0d9;
    --bad:       #c4262e;
    --bad-bg:    #fdeaea;
    --info:      #6742c8;
    --info-bg:   #f0eafd;
    --shadow:    0 8px 24px rgba(20,30,45,.14);
  }
}

* { box-sizing: border-box; }

/* A class that sets `display` outranks the UA agent's [hidden] rule, so #boot and #shell would
   stay on screen after being hidden. Everything in this app toggles visibility with el.hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  overflow-x: hidden;
}
body { overscroll-behavior-y: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }

h1,h2,h3,h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 17px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }
p  { margin: 0 0 .6em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }

code, .mono, pre { font-family: var(--mono); font-size: 12px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot-mark { font: 600 22px var(--mono); letter-spacing: .08em; color: var(--accent); text-align: center; }
.boot-msg { margin-top: 8px; color: var(--text-3); text-align: center; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--gut);
  height: 44px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 10px; height: 10px; border-radius: 2px; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.brand-text { font-family: var(--mono); font-size: 13px; }

.navtoggle { display: none; }

.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 5px 9px; border-radius: var(--r); color: var(--text-2);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.conn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  border-radius: 999px; padding: 3px 9px 3px 7px; cursor: pointer; font: inherit;
}
.conn:hover { border-color: var(--border-2); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.conn[data-state="open"] .conn-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.conn[data-state="connecting"] .conn-dot,
.conn[data-state="authenticating"] .conn-dot,
.conn[data-state="reconnecting"] .conn-dot { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.conn[data-state="failed"] .conn-dot { background: var(--bad); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.conn-text { font-size: 11px; letter-spacing: .02em; text-transform: uppercase; }

.usermenu { position: relative; }
.usermenu-btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r); padding: 4px 8px;
}
.usermenu-btn .role { color: var(--text-3); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.usermenu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column;
}
.usermenu-pop a, .usermenu-pop button {
  text-align: left; background: none; border: 0; color: var(--text); font: inherit;
  padding: 6px 8px; border-radius: 4px; cursor: pointer;
}
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--surface-3); text-decoration: none; }

.banners { display: flex; flex-direction: column; }
.banner {
  padding: 7px var(--gut); font-size: 12px; display: flex; gap: 10px; align-items: center;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.banner strong { font-weight: 600; }
.banner-bad  { background: var(--bad-bg);  color: var(--bad); }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-info { background: var(--info-bg); color: var(--info); }
.banner .spacer { flex: 1; }

.view { flex: 1; padding: var(--gut); max-width: 1680px; width: 100%; margin: 0 auto; }
.view:focus { outline: none; }

/* ---------- page furniture ---------- */
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px; margin-bottom: 12px;
}
.card.pad0 { padding: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .spacer { flex: 1; }
.card-head h2 { font-size: 13px; }

.grid { display: grid; gap: 12px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.small { font-size: 11px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.strong { font-weight: 600; }
.empty { color: var(--text-3); padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: var(--r); }
.err-box { background: var(--bad-bg); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  border-radius: var(--r); padding: 8px 10px; margin-bottom: 10px; word-break: break-word; }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; align-items: baseline; margin: 0; }
.kv dt { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-word; }

.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 10px; }
.stat .label { color: var(--text-3); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font: 600 20px/1.1 var(--mono); margin-top: 3px; word-break: break-word; }
.stat .value.sm { font-size: 15px; }
.stat .foot { color: var(--text-3); font-size: 11px; margin-top: 2px; }
.stat.ok   .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.bad  .value { color: var(--bad); }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--r);
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  padding: 5px 10px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); background: var(--bad); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.btn-sm { padding: 3px 7px; font-size: 12px; }
.btn-xs { padding: 1px 6px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em; min-width: 0; }
label.field > .hint { text-transform: none; letter-spacing: 0; color: var(--text-3); font-size: 11px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 5px 7px; min-width: 0; width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input.invalid, textarea.invalid { border-color: var(--bad); }
input[type=search] { min-width: 130px; }
.check { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0;
  font-size: 12px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.inline-form { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 10px; margin: 0 0 10px; min-width: 0; }
legend { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 0 5px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-3); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.mono, th.mono { font-family: var(--mono); }
td.num { text-align: right; font-family: var(--mono); }

/* ---------- badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 1px 8px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pill-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.pill-bad  { background: var(--bad-bg);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.pill-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.pill-mute { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge {
  display: inline-block; min-width: 16px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; text-align: center;
}
.badge-warn { background: var(--warn); color: #201400; }

.tag { font-family: var(--mono); font-size: 11px; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 5px; color: var(--text-2); }

/* ---------- panel state badge: LIVE / DYING / BLIND ---------- */
.panelstate {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r);
  padding: 2px 8px; font-weight: 700; font-size: 11px; letter-spacing: .09em;
  border: 1px solid transparent; text-transform: uppercase;
}
.panelstate .ps-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.panelstate .ps-sub { font-weight: 500; letter-spacing: 0; text-transform: none; opacity: .85; font-family: var(--mono); }
.panelstate[data-state="live"]  { background: var(--ok-bg);   color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.panelstate[data-state="dying"] { background: var(--bad-bg);  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.panelstate[data-state="dying"] .ps-dot { animation: pulse .9s ease-in-out infinite; }
.panelstate[data-state="blind"] { background: var(--warn-bg); color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 55%, transparent);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px,
    color-mix(in srgb, var(--warn) 12%, transparent) 6px 12px); }
.panelstate[data-state="unknown"] { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.scope-weak {
  display: inline-flex; align-items: center; gap: 5px; background: var(--warn-bg); color: var(--warn);
  border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent); border-radius: var(--r);
  padding: 2px 7px; font-size: 11px; font-weight: 600;
}

/* ---------- agent cards ---------- */
.agentcard { display: flex; flex-direction: column; gap: 9px; }
.agentcard .ac-top { display: flex; align-items: flex-start; gap: 8px; }
.agentcard .ac-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.agentcard .ac-host { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.agentcard .ac-run { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 8px; }
.agentcard .ac-run.dying { border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: var(--bad-bg); }
.agentcard .ac-run.blind { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-bg); }
.agentcard .ac-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; }
.statedot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.statedot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.statedot.offline { background: var(--bad); }
.statedot.disabled { background: var(--text-3); }
.statedot.tombstoned { background: var(--text-3); opacity: .5; }

/* ---------- log stream ---------- */
.logstream { display: flex; flex-direction: column; min-height: 0; }
.logstream-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 7px 9px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r) var(--r) 0 0; }
.logstream-bar .spacer { flex: 1; }
.logbody {
  height: min(60vh, 620px); overflow: auto; background: var(--bg); padding: 6px 0;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; border-radius: 0 0 var(--r) var(--r);
}
.logbody.tall { height: min(78vh, 900px); }
.logline { display: flex; gap: 8px; padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.logline:hover { background: var(--surface-2); }
.logline .ln { color: var(--text-3); flex: none; min-width: 52px; text-align: right; user-select: none; font-size: 11px; }
.logline .lt { color: var(--text-3); flex: none; user-select: none; font-size: 11px; }
.logline .lm { flex: 1; min-width: 0; }
.logline.s-stderr .lm { color: var(--warn); }
.logline.s-shim   .lm { color: var(--info); }
.logline.l-error  .lm { color: var(--bad); }
.logline.l-warn   .lm { color: var(--warn); }
.logline.l-debug  .lm { color: var(--text-3); }
.logline.partial .lm::after { content: "\2590"; color: var(--accent); opacity: .8; }
.logline mark { background: color-mix(in srgb, var(--accent) 45%, transparent); color: inherit; border-radius: 2px; }
.logline.hit { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.loggap {
  margin: 4px 10px; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  background: var(--warn-bg); color: var(--warn);
  border: 1px dashed color-mix(in srgb, var(--warn) 60%, transparent);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.loggap .gap-rule { flex: 1; height: 1px; background: currentColor; opacity: .4; min-width: 20px; }
.pinbtn[data-pinned="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- prompt renderer ---------- */
.prompt-card { border-left: 3px solid var(--accent); }
.prompt-card.urgent { border-left-color: var(--bad); }
.prompt-text {
  font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 8px 10px; white-space: pre-wrap; word-break: break-word;
}
.prompt-ctx { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r);
  padding: 6px 9px; font-family: var(--mono); font-size: 11px; color: var(--text-2); max-height: 130px; overflow: auto; }
.prompt-ctx div { white-space: pre-wrap; word-break: break-word; }
.choice-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.choice {
  border: 1px solid var(--border-2); background: var(--surface-2); border-radius: var(--r);
  padding: 6px 12px; cursor: pointer; font-family: var(--mono); font-size: 12px;
}
.choice[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.secret-note { color: var(--warn); font-size: 11px; display: flex; gap: 5px; align-items: center; }
.countdown { font-family: var(--mono); font-weight: 600; }
.countdown.soon { color: var(--warn); }
.countdown.now  { color: var(--bad); }
.keyset { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-family: var(--mono); font-size: 11px; }
.keyset .tier { color: var(--text-3); }

/* ---------- kill evidence ---------- */
.evidence { border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); border-radius: var(--r); overflow: hidden; }
.evidence.shadow { border-color: var(--info); }
.evidence-head { background: var(--bad-bg); color: var(--bad); padding: 8px 10px; display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap; }
.evidence.shadow .evidence-head { background: var(--info-bg); color: var(--info); }
.evidence-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.expr {
  font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 7px 9px; white-space: pre-wrap; word-break: break-word;
}
.metric-age { font-size: 11px; }
.metric-age.stale { color: var(--bad); font-weight: 600; }
.metric-age.fresh { color: var(--ok); }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; max-width: 100%; }
.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); margin-top: 4px; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.spark { display: block; max-width: 100%; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--text-2); padding: 6px 10px; }
.tabs button:hover { background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- toasts & modal ---------- */
.toasts { position: fixed; right: 12px; bottom: 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px;
  max-width: min(400px, calc(100vw - 24px)); }
.toast { background: var(--surface); border: 1px solid var(--border-2); border-left-width: 3px; border-radius: var(--r);
  box-shadow: var(--shadow); padding: 9px 11px; display: flex; gap: 9px; align-items: flex-start; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 600; }
.toast .t-msg { color: var(--text-2); font-size: 12px; word-break: break-word; }
.toast .t-close { background: none; border: 0; color: var(--text-3); padding: 0 2px; }
.toast.ok   { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad  { border-left-color: var(--bad); }
.toast.info { border-left-color: var(--accent); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,12,.62); z-index: 70; display: grid;
  place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: var(--shadow);
  width: min(720px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(1040px, 100%); }
.modal-head { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-foot { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px;
  justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.danger-confirm { background: var(--bad-bg); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  border-radius: var(--r); padding: 10px; color: var(--text); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; box-shadow: var(--shadow); }
.login h1 { font-family: var(--mono); font-size: 18px; margin-bottom: 2px; }
.login .sub { color: var(--text-3); margin-bottom: 16px; font-size: 12px; }
.login .col { gap: 11px; }

/* ---------- liveness ---------- */
.liverow { display: grid;
  grid-template-columns: minmax(230px, 1.4fr) minmax(150px, .9fr) minmax(190px, 1.2fr) minmax(210px, 1.3fr);
  gap: 12px; align-items: start; padding: 11px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); margin-bottom: 10px; }
.liverow.dying { border-color: color-mix(in srgb, var(--bad) 60%, transparent); box-shadow: inset 3px 0 0 var(--bad); }
.liverow.blind { border-color: color-mix(in srgb, var(--warn) 60%, transparent); box-shadow: inset 3px 0 0 var(--warn); }
.liverow.live  { box-shadow: inset 3px 0 0 var(--ok); }
.bignum { font: 700 26px/1 var(--mono); }
.bignum.ok { color: var(--ok); } .bignum.warn { color: var(--warn); } .bignum.bad { color: var(--bad); }
.rulechip { border: 1px solid var(--border); border-radius: var(--r); padding: 7px 8px; background: var(--surface-2); }
.rulechip + .rulechip { margin-top: 6px; }
.breachdots { display: inline-flex; gap: 3px; vertical-align: -1px; }
.breachdots i { width: 8px; height: 8px; border-radius: 2px; background: var(--surface-3);
  border: 1px solid var(--border-2); display: block; }
.breachdots i.on { background: var(--bad); border-color: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); }
.legend .item { display: flex; gap: 6px; align-items: center; }

/* ---------- dropzone ---------- */
.dropzone { border: 2px dashed var(--border-2); border-radius: var(--r); padding: 22px; text-align: center;
  color: var(--text-2); background: var(--surface-2); }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); color: var(--text); }

/* ---------- misc ---------- */
.copyrow { display: flex; gap: 6px; align-items: stretch; }
.copyrow input { font-family: var(--mono); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 12px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline li.bad::before  { background: var(--bad); }
.timeline li.warn::before { background: var(--warn); }
.timeline li.ok::before   { background: var(--ok); }
.timeline .tl-when { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
details > summary { cursor: pointer; color: var(--text-2); }
details[open] > summary { margin-bottom: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- narrow windows ---------- */
@media (max-width: 900px) {
  .liverow { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  :root { --gut: 10px; }
  .navtoggle { display: inline-flex; }
  .nav {
    position: absolute; top: 44px; left: 0; right: 0; flex-direction: column; overflow: visible;
    background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 6px; gap: 2px; z-index: 29;
  }
  .nav[hidden] { display: none; }
  .brand-text { display: none; }
  .liverow { grid-template-columns: 1fr; }
  .grid-cards { grid-template-columns: 1fr; }
  .logbody { height: 58vh; }
  .logline .lt { display: none; }
  .toasts { left: 12px; right: 12px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; }
}

/* ---------- additions the components need ---------- */

/* Gap markers carry a tone: mute = evicted from this browser (recoverable), warn = dropped in
   transit, bad = missing on the hub. The default .loggap above is the warn case. */
.loggap.mute { background: var(--surface-2); color: var(--text-3);
  border-color: color-mix(in srgb, var(--text-3) 45%, transparent); }
.loggap.bad  { background: var(--bad-bg); color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 60%, transparent); }

th.num { text-align: right; }
td.bad { color: var(--bad); font-weight: 600; }

ul, ol { margin: 0 0 .6em; padding-left: 18px; }
li { margin: 0 0 .2em; }

/* A modal body is a flex column, so a bare grid inside it needs to be told to fill the row. */
.modal-body > .grid, .modal-body > .form-grid, .modal-body > .tablewrap { width: 100%; }

/* Long identifiers (sha256, run ids, enrolment one-liners) must wrap rather than widen the page. */
.kv dd, .expr, .copyrow input, .copyrow textarea { overflow-wrap: anywhere; }
.copyrow textarea { resize: vertical; }

/* Keyboard focus must be visible on every interactive surface, not only on inputs. */
:where(a, button, .btn, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}
