:root {
  --ink: #14181f; --ink-2: #3a424d; --muted: #5a6472; --line: #dde1e7; --line-2: #edeff2;
  --bg: #f4f6f9; --panel: #fff; --soft: #f8f9fb;
  --accent: #1f5fd1; --accent-ink: #174aa6; --accent-soft: #e8effc;
  --err: #b42318; --err-soft: #fef0ee; --err-line: #f3c4be;
  --warn: #b54708; --warn-ink: #8a3b00; --warn-soft: #fff6e6; --warn-line: #f5d9a8;
  --ok: #1e7a45; --ok-ink: #1e6b3e; --ok-soft: #ecf8f0;
  --gold: #b7791f; --gold-soft: #fff4dc;
  --mono: ui-monospace, 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, Inter, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid #c9cfd8; background: #fff; color: var(--ink); font: 600 13px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); color: #fff; }
.btn.danger { color: var(--err); border-color: var(--err-line); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .chip:focus-visible, .tab:focus-visible { outline: 3px solid #9cbcf5; outline-offset: 1px; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url], input[type=search], input:not([type]), select, textarea {
  min-height: 34px; border: 1px solid #c9cfd8; border-radius: 6px; padding: 0 8px; font: 13px inherit; font-family: inherit; background: #fff; color: var(--ink); width: 100%;
}
input.mono, .mono input { font-family: var(--mono); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

/* chips, pills */
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid #c9cfd8; background: #fff; color: var(--ink-2); font: 500 12px inherit; font-family: inherit; cursor: pointer; }
.chip[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill.gold { background: var(--gold-soft); color: #7a4d0b; }
.tag { font-size: 11px; color: var(--muted); }

/* layout shell */
.topbar { background: var(--ink); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 0 20px; min-height: 56px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; }
.brand:hover { color: #fff; text-decoration: none; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1 1 auto; }
.nav a { color: #c5cbd3; font-weight: 500; padding: 17px 10px 15px; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav a.active { color: #fff; font-weight: 600; border-bottom-color: #7fa8f5; }
.me { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #c5cbd3; flex-wrap: wrap; }
.me strong { color: #fff; }
.me .btn { background: transparent; color: #fff; border-color: #5a6472; min-height: 32px; }
.online { display: inline-flex; align-items: center; gap: 6px; }
.online::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #3fb97a; }
.page { max-width: 1320px; margin: 0 auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel.tight { padding: 12px; }
.panel h2 + * { margin-top: 10px; }
.grid { display: grid; gap: 14px; }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* stat cards */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 26px; line-height: 1.1; }
.progress { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }
.progress.ok > div { background: var(--ok); }

/* scenario cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.weekly { border: 2px solid var(--gold); }
.card.done { border-color: #b9e0c8; }
.card.locked { background: #f7f8fa; }
.card.locked h3, .card.locked p, .card.locked .tag { color: var(--ink-2); opacity: .75; }
.btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.card h3 { font-size: 15px; }
.card p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.stars { display: inline-flex; gap: 1px; }
.star { width: 16px; height: 16px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px 9px; font: 600 13px inherit; font-family: inherit; color: var(--muted); cursor: pointer; }
.tab[aria-selected=true] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab .pill { margin-left: 4px; }

/* feed */
.feed { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow: auto; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--accent); }
.feed-item time { font-size: 11px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; color: var(--ink-2); font-weight: 600; background: var(--bg); padding: 8px 10px; }
td { padding: 8px 10px; border-top: 1px solid var(--line-2); vertical-align: middle; }
tr.me-row td { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.place { font-weight: 700; width: 44px; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.podium > div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.podium .p1 { border: 2px solid var(--gold); padding-top: 22px; }
.medal { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.matrix td, .matrix th { padding: 4px; text-align: center; }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); height: 110px; white-space: nowrap; font-weight: 500; }
.cell { display: inline-block; min-width: 34px; padding: 3px 2px; border-radius: 4px; font: 600 11px var(--mono); }
.cell.s3 { background: #c9ecd6; color: #135c33; } .cell.s2 { background: #e2f3e8; color: #1e6b3e; } .cell.s1 { background: #f0f7f2; color: #3a6b4c; }
.cell.none { color: #c3c9d1; }

/* lab */
.lab { display: grid; grid-template-columns: minmax(260px, 310px) minmax(0, 1fr) minmax(330px, 420px); gap: 14px; padding: 14px; align-items: start; max-width: 1800px; margin: 0 auto; }
.lab.wide { grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); }
.lab.wide > .right { display: none; }
.lab.nobrief { grid-template-columns: minmax(0, 1fr) minmax(330px, 420px); }
.lab.nobrief.wide { grid-template-columns: minmax(0, 1fr); }
.lab.nobrief > .left { display: none; }
.briefbtn[aria-pressed=true] { background: var(--accent-soft); border-color: #b9cdf3; color: var(--accent-ink); }
@media (max-width: 1200px) { .lab { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); } .lab > .right { grid-column: 1 / -1; } }
@media (max-width: 820px) { .lab { grid-template-columns: 1fr; } }
.labbar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: 56px; z-index: 15; }
.labbar h1 { font-size: 17px; }
.timer { font: 600 13px var(--mono); color: var(--ink-2); background: var(--bg); padding: 6px 10px; border-radius: 6px; }
.ticket { background: var(--bg); border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.obj { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; padding: 6px 0; }
.obj .dot { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: -1px; }
.obj.pass .dot { background: var(--ok); color: #fff; }
.obj.fail .dot { border: 2px solid #9aa3af; }
.obj .detail { display: block; font-size: 12px; color: var(--muted); }
.hint { background: var(--gold-soft); border: 1px solid #f0d9a6; border-radius: 8px; padding: 10px; font-size: 13px; line-height: 1.5; }
.mapwrap { background: var(--soft); background-image: radial-gradient(#dde1e7 1px, transparent 1px); background-size: 20px 20px; border-radius: 10px; overflow: auto; border: 1px solid var(--line); touch-action: none; }
.mapwrap { max-height: 600px; }
.mapwrap svg { display: block; height: auto; user-select: none; margin: 0 auto; }
.maptools { position: sticky; left: 0; top: 0; display: flex; gap: 4px; padding: 6px; z-index: 2; width: max-content; }
.maptools .btn { background: #fff; min-height: 28px; min-width: 30px; padding: 0 8px; }
.node rect.box { fill: #fff; stroke: #9aa3af; stroke-width: 1.5; }
.node.sel rect.box { stroke: var(--accent); stroke-width: 2.5; }
.node.err rect.box { stroke: var(--err); fill: #fffbfa; stroke-width: 2; }
.node.warn rect.box { stroke: var(--warn); fill: #fffcf5; stroke-width: 2; }
.node rect.ring { fill: none; stroke: none; }
.node.sel rect.ring { stroke: #d6e3fa; stroke-width: 6; }
.node:focus { outline: none; } .node:focus-visible rect.ring { stroke: #9cbcf5; stroke-width: 4; }
.node text { font-family: system-ui, sans-serif; }
.node .nm { font-size: 13px; font-weight: 600; fill: var(--ink); }
.node .sub { font-size: 11px; fill: var(--muted); font-family: var(--mono); }
.node { cursor: grab; }
.link { stroke: #9aa3af; stroke-width: 2; }
.link.down { stroke: var(--err); stroke-dasharray: 6 4; }
.link.wifi { stroke: #7fa8f5; stroke-dasharray: 3 4; }
.link.wifi.down { stroke: var(--err); }
.plabel { font: 10px var(--mono); fill: var(--muted); }
.issues { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.issue { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; line-height: 1.4; background: #fff; text-align: left; font-family: inherit; cursor: pointer; width: 100%; color: var(--ink); }
.issue.error { border-color: var(--err-line); background: #fffbfa; }
.issue.warn { border-color: var(--warn-line); background: #fffcf5; }
.sev { flex: none; font-size: 10px; font-weight: 700; color: #fff; border-radius: 4px; padding: 2px 5px; }
.sev.error { background: var(--err); } .sev.warn { background: var(--warn); } .sev.info { background: var(--muted); }
.insp h2 { font-size: 17px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-word; }
.status { padding: 10px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.status.ok { background: var(--ok-soft); color: var(--ok-ink); }
.status.err { background: var(--err-soft); color: #8a1c12; }
.status.warn { background: var(--warn-soft); color: var(--warn-ink); }
.ports { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 520px; }
.prow { display: grid; grid-template-columns: 30px minmax(64px, 1fr) 78px 48px minmax(96px, 1.2fr) 24px; gap: 6px; align-items: center; padding: 6px 8px; border-top: 1px solid var(--line-2); font-size: 12px; }
.prow.head { background: var(--bg); font-weight: 600; color: var(--ink-2); border-top: 0; position: sticky; top: 0; z-index: 1; }
.prow.bad { background: var(--err-soft); }
.prow input, .prow select { min-height: 28px; font-size: 12px; padding: 0 5px; }
.prow .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rules { min-width: 760px; }
.rrow { display: grid; grid-template-columns: 30px minmax(110px, 1.4fr) 90px 90px minmax(90px, 1fr) minmax(90px, 1fr) 90px 82px 34px 92px; gap: 6px; align-items: center; padding: 6px 8px; border-top: 1px solid var(--line-2); font-size: 12px; }
.rrow.head { background: var(--bg); font-weight: 600; color: var(--ink-2); border-top: 0; }
.rrow.flag { background: var(--err-soft); box-shadow: inset 4px 0 0 var(--err); }
.rrow.off { opacity: .55; }
.rrow input, .rrow select { min-height: 28px; font-size: 12px; padding: 0 5px; }
.rrow.implicit { color: var(--muted); font-style: italic; }
.ifrow { display: grid; grid-template-columns: 60px minmax(80px, 1fr) 110px minmax(110px, 1fr) 60px 70px minmax(110px, 1fr) minmax(110px, 1fr) minmax(100px, 1fr) 34px; gap: 6px; align-items: center; padding: 6px 8px; border-top: 1px solid var(--line-2); font-size: 12px; min-width: 980px; }
.ifrow.head { background: var(--bg); font-weight: 600; color: var(--ink-2); border-top: 0; }
.ifrow input, .ifrow select { min-height: 28px; font-size: 12px; padding: 0 5px; }
.hops { display: flex; flex-direction: column; }
.hopx { display: flex; gap: 12px; }
.hopx .rail { display: flex; flex-direction: column; align-items: center; }
.hopx .num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 12px inherit; flex: none; }
.hopx .num.pass { background: var(--ok-soft); color: var(--ok-ink); }
.hopx .num.fail { background: var(--err); color: #fff; }
.hopx .num.info { background: var(--accent-soft); color: var(--accent-ink); }
.hopx .line { width: 2px; flex: 1; background: var(--line); min-height: 10px; }
.hopx .body { padding-bottom: 14px; flex: 1; min-width: 0; }
.hopx .body strong { font-size: 13.5px; display: block; }
.hopx .body span { font: 12px var(--mono); color: var(--ink-2); word-break: break-word; }
.verdict { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.verdict.delivered { background: var(--ok-soft); color: var(--ok-ink); border: 1px solid #b9e0c8; }
.verdict.blocked { background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.verdict.failed { background: var(--err-soft); color: #8a1c12; border: 1px solid var(--err-line); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 24, 31, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; max-width: 560px; width: 100%; max-height: 92vh; overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.modal.win { border-top: 6px solid var(--ok); }
.big-score { font-size: 46px; font-weight: 800; line-height: 1; color: var(--ok-ink); }
.lines { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.lines div { display: flex; justify-content: space-between; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; background: #fff; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.badge .ico { width: 44px; height: 44px; border-radius: 50%; background: var(--gold-soft); color: #7a4d0b; display: flex; align-items: center; justify-content: center; }
.badge b { font-size: 13px; } .badge span { font-size: 11.5px; color: var(--muted); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 14px; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 12px; opacity: .9; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(620px) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: 360px; }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); animation: pop .25s ease-out; }
.toast b { color: #ffd88a; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* auth */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; padding: 32px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.auth-card p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.ms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; border-radius: 8px; background: #2f2f2f; color: #fff; font-weight: 600; font-size: 15px; }
.ms-btn:hover { background: #111; color: #fff; text-decoration: none; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.inline select { width: auto; min-width: 110px; }

@media (max-width: 820px) {
  .topbar { position: static; gap: 8px; padding: 0 12px; }
  .nav a { padding: 12px 8px 10px; }
  .me { width: 100%; padding-bottom: 8px; gap: 8px; }
  .me > span:nth-child(3) { display: none; }
  .labbar { position: static; padding: 10px 12px; }
  .lab, .lab.nobrief, .lab.wide, .lab.nobrief.wide { grid-template-columns: 1fr; padding: 10px; }
  .lab.nobrief > .left { display: flex; }
  .lab.wide > .right { display: block; }
  .briefbtn { display: none; }
  .page { padding: 10px; }
  .podium { grid-template-columns: 1fr; }
  .board-grid { grid-template-columns: 1fr !important; }
}

/* nav extras */
.nav-dot { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: #7fa8f5; color: var(--ink); font-size: 10px; font-weight: 700; vertical-align: 1px; }
.nav-dot.live { background: #f04438; color: #fff; letter-spacing: .04em; }
.menu-btn { display: none; }
.topbar .menu-btn { background: transparent; color: #fff; border-color: #5a6472; min-height: 32px; }

/* banners on the scenario library */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid #b9cdf3; background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; }
.banner:hover { text-decoration: none; color: var(--accent-ink); filter: brightness(.98); }
.banner.live { border: 2px solid #f04438; background: #fff4f2; color: #7a1d14; }
.banner.live:hover { color: #7a1d14; }
.banner.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn-ink); }
.banner.warn:hover { color: var(--warn-ink); }

/* admin center */
.admin { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 56px); }
.admin-nav { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 8px 24px; display: flex; flex-direction: column; gap: 1px; position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto; }
.admin-nav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.admin-nav a:hover { background: var(--soft); text-decoration: none; color: var(--ink); }
.admin-nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.admin-body { padding: 18px 22px 40px; max-width: 1280px; min-width: 0; }
.perm-matrix th { position: sticky; top: 0; background: var(--panel); z-index: 1; text-align: center; vertical-align: bottom; font-size: 12px; }
.perm-matrix td { padding: 6px 10px; }
.perm-matrix tbody tr:hover td { background: var(--soft); }
.perm-matrix .perm-name { min-width: 260px; position: sticky; left: 0; background: var(--panel); z-index: 2; }
.perm-matrix tbody tr:hover td.perm-name { background: var(--soft); }

@media (max-width: 960px) {
  .admin { grid-template-columns: 1fr; }
  .admin-nav { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  .admin-nav .section-title { display: none; }
  .admin-nav a { white-space: nowrap; flex: none; }
  .admin-body { padding: 12px; }
  .perm-matrix .perm-name { min-width: 150px; max-width: 170px; box-shadow: 1px 0 0 var(--line); }
}
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; margin-left: auto; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; }
  .nav.open { display: flex; }
  .nav a { border-bottom: 0; border-left: 3px solid transparent; }
  .nav a.active { border-left-color: #7fa8f5; }
  .banner { flex-wrap: wrap; }
}

/* setup wizard */
.install-page { min-height: 100vh; margin: 0; background: var(--ink); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.install-card { background: #fff; border-radius: 16px; padding: 28px 32px; max-width: 640px; width: 100%; display: flex; flex-direction: column; gap: 18px; box-sizing: border-box; }
.install-card h2 { margin: 0; font-size: 18px; }
.install-card p { margin: 0; line-height: 1.55; }
.install-card input[type="text"], .install-card input[type="url"], .install-card input[type="password"], .install-card input[type="number"], .install-card textarea { width: 100%; box-sizing: border-box; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--soft); }
.steps li span { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: 11px; }
.steps li.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.steps li.on span { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.past span { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice { flex: 1 1 220px; display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; }
.choice span { display: flex; flex-direction: column; gap: 2px; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
table.summary { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.summary th, table.summary td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; word-break: break-word; }
table.summary th { color: var(--ink-2); font-weight: 500; }
.done-mark { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; background: var(--ok); align-items: center; justify-content: center; }
.copyable { background: var(--soft); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
@media (max-width: 600px) { .install-page { padding: 12px 8px; } .install-card { padding: 20px 16px; } }
.status:not(.ok):not(.err):not(.warn) { background: var(--soft); color: var(--ink); }
/* updates */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; cursor: pointer; color: var(--ink-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dropzone.disabled { opacity: .55; cursor: not-allowed; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: inherit; }
.update-notes { white-space: pre-wrap; font-size: 13px; line-height: 1.55; background: var(--soft); border-radius: 8px; padding: 10px 12px; max-height: 260px; overflow: auto; }
.update-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.update-steps li { display: flex; align-items: center; gap: 10px; }
.update-steps .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--ok-soft); color: var(--ok-ink); font-weight: 700; font-size: 12px; flex: none; }
.update-steps li.current { font-weight: 600; }
.update-steps li.current .dot { background: var(--accent-soft); }
.update-steps li.failed .dot { background: var(--err-soft); color: var(--err); }
.spin { width: 12px; height: 12px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: nl-spin .8s linear infinite; }
@keyframes nl-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* ---------------------------------------------------------------- server-run labs (labs.js) */
.lab2 { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(300px, 380px); gap: 14px; padding: 14px; align-items: start; max-width: 1800px; margin: 0 auto; }
.lab2.nobrief { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.lab2.notools { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
.lab2.nobrief.notools { grid-template-columns: minmax(0, 1fr); }
.lab2 > aside.right { position: sticky; top: 124px; max-height: calc(100vh - 140px); overflow: auto; }
@media (max-width: 1200px) { .lab2, .lab2.nobrief { grid-template-columns: minmax(240px, 290px) minmax(0, 1fr); } .lab2.nobrief { grid-template-columns: minmax(0, 1fr); } .lab2 > aside.right { grid-column: 1 / -1; position: static; max-height: none; } }
@media (max-width: 820px) { .lab2, .lab2.nobrief, .lab2.notools, .lab2.nobrief.notools { grid-template-columns: 1fr; padding: 10px; } }
.console { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 980px) { .console { grid-template-columns: 1fr; } .cnav { flex-direction: row !important; overflow-x: auto; } .cnav-item { white-space: nowrap; } }
.lab2:not(.nobrief):not(.notools) .console { grid-template-columns: 1fr; }
.lab2:not(.nobrief):not(.notools) .cnav { flex-direction: row; flex-wrap: wrap; position: static; }
.lab2:not(.nobrief):not(.notools) .cnav-item { padding: 6px 10px; }
.cnav { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; position: sticky; top: 124px; }
.cnav-item { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; font: 500 13px inherit; font-family: inherit; color: var(--ink-2); cursor: pointer; }
.cnav-item:hover { background: var(--soft); }
.cnav-item[aria-current=page] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.ilist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.irow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-top: 1px solid var(--line-2); background: #fff; text-align: left; font: 13px inherit; font-family: inherit; color: var(--ink); cursor: pointer; }
.irow:first-child { border-top: 0; }
.irow:hover { background: var(--soft); }
.ico-lg { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; }
.form > .field:has(.ltable), .form > .field:has(.chips), .form > .fhead, .form > .checklist, .form > .field:has(textarea), .form > .ro:has(.rotext), .form > .ro:has(.rolist) { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); padding-top: 18px; }
.field.check.compact { padding-top: 0; justify-content: center; }
.flabel { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.fhead { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 4px; }
.roval { font-size: 13px; color: var(--ink); padding: 7px 0; overflow-wrap: anywhere; }
.rotext { font-size: 13px; color: var(--ink); white-space: pre-wrap; background: var(--soft); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; line-height: 1.55; overflow-wrap: anywhere; }
.rolist { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; background: var(--line-2); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; color: var(--ink); }
.tagchip button { border: 0; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); }
.tagchip button:hover { background: #d9dde3; color: var(--err); }
.addsel { width: auto !important; min-width: 150px; max-width: 260px; min-height: 28px !important; font-size: 12px !important; }
.addtag { width: 200px !important; min-height: 28px !important; font-size: 12px !important; }
.checklist { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 14px; }
.checklist legend { margin-bottom: 6px; }
.checklist .check { align-items: flex-start; line-height: 1.35; }
.checklist .check input { margin-top: 1px; flex: none; }
.ltable { width: 100%; border-collapse: collapse; font-size: 12px; }
.ltable th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ltable td { padding: 4px 6px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.ltable td input, .ltable td select { min-height: 30px; font-size: 12px; }
.ltable .w-xs { min-width: 88px; width: 88px; } .ltable .w-sm { min-width: 150px; } .ltable .w-md { min-width: 170px; } .ltable .w-lg { min-width: 300px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 600px) { .tgrid { grid-template-columns: 1fr; } }
.issues { border-color: var(--warn-line); background: var(--warn-soft); gap: 6px; }
.issues.has-err { border-color: var(--err-line); background: var(--err-soft); }
.issue { font-size: 12.5px; padding-left: 24px; position: relative; line-height: 1.45; }
.issue::before { content: '•'; position: absolute; left: 10px; }
.issue.error { color: var(--err); }
.issue.warning, .issue.info { color: var(--warn-ink); }
.toolcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; gap: 8px; }
.out { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 8px 10px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.out.bad { border-left-color: var(--err); }
.osum { font-size: 13px; font-weight: 600; }
.olines { margin: 0; font: 11.5px/1.5 var(--mono); white-space: pre-wrap; color: var(--ink-2); background: var(--soft); border-radius: 6px; padding: 8px; max-height: 320px; overflow: auto; }
.drill2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .drill2 { grid-template-columns: 1fr; } }
.alertcard { border-left: 4px solid var(--err); }
.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; line-height: 1.45; }
.tl:first-child { border-top: 0; }
.tl-t { flex: none; width: 118px; color: var(--muted); padding-top: 2px; }
.ctx { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.tcard.first { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.debrief { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.debrief summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.cattabs { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) { .cattabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding-bottom: 4px; scroll-snap-type: x proximity; } .cattab { flex: 0 0 auto; scroll-snap-align: start; } }
.cattab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: 600 13px inherit; font-family: inherit; color: var(--ink-2); }
.cattab[aria-selected=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.cattab .pill { font-weight: 600; }

/* Email analysis drill */
.mailview { border-left: 4px solid var(--accent); }
.extbanner { background: var(--warn-soft); color: var(--warn-ink); border-radius: 6px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; }
.mailsubj { margin: 2px 0 0; font-size: 17px; }
.mailhead { display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 8px; font-size: 13.5px; word-break: break-word; }
.mailbody { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.maillink { color: #1a56c4; text-decoration: underline; font-size: 13px; cursor: help; word-break: break-all; }
/* Insurance questionnaire */
.qrow { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qrow:last-of-type { border-bottom: 0; }
@media (max-width: 600px) { .qrow { flex-direction: column; align-items: stretch; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: 0 0 auto; }
.segbtn { border: 0; background: #fff; padding: 6px 12px; font: 600 12.5px inherit; font-family: inherit; color: var(--ink-2); cursor: pointer; }
.segbtn + .segbtn { border-left: 1px solid var(--line); }
.segbtn.on { background: var(--accent-soft); color: var(--accent-ink); }
.segbtn:disabled { cursor: default; opacity: .7; }
/* Incident tabletop */
.ttround { border-left: 4px solid var(--accent); }
.ttopt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13.5px; line-height: 1.45; background: #fff; }
.ttopt.on { border-color: var(--accent); background: var(--accent-soft); }
.ttopt input { margin-top: 3px; }
.ttletter { font-weight: 700; color: var(--accent-ink); min-width: 14px; }
/* Client communication */
.example { background: var(--soft); border-radius: 8px; padding: 10px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.bulkbar { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; }
