/* Jarvis console. House shell after Rapple OS: navy masthead, Georgia title in SilverLion ice-blue, one-line sub,
   Refresh, "Figures as at". Dense operator screens: figures in one band, tables, one primary action per item.
   Mobile first (394px), sidebar from 900px. No inline styles (CSP). */

:root {
  --navy: #0B1628; --navy-2: #14243C; --ice: #8EC5FF; --ice-deep: #245F9E; --ice-soft: #E3F0FE;
  --bg: #F3F5F8; --panel: #FFFFFF; --panel-2: #F7F9FB; --line: #E0E5EC; --line-2: #CDD5DF;
  --text: #111925; --muted: #566273; --soft: #7C8796;
  --ok: #1F6B3A; --ok-bg: #E2F1E7; --warn: #7A5A0C; --warn-bg: #FBF0D2; --bad: #A33A2E; --bad-bg: #FBE6E2; --info: #245F9E; --info-bg: #E3F0FE;
  --r: 10px; --tab-h: 62px; --side-w: 232px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09101B; --panel: #101A2A; --panel-2: #0D1624; --line: #1F2D43; --line-2: #2B3C57;
    --text: #E6ECF4; --muted: #9DAABD; --soft: #7D8BA0; --ice-deep: #8EC5FF; --ice-soft: #13253D;
    --ok: #8FD1A4; --ok-bg: #12291B; --warn: #E8C877; --warn-bg: #2A2312; --bad: #F0A195; --bad-bg: #2E1714; --info: #9FCBFA; --info-bg: #13253D;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 .7em; }
code { font: 12.5px var(--mono); background: var(--panel-2); border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; word-break: break-all; }
.small { font-size: 13px; } .muted, .meta { color: var(--muted); } .meta { font-size: 12.5px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 14px; }
.lead { color: var(--muted); max-width: 70ch; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ice); color: var(--navy); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--ice-deep); outline-offset: 2px; border-radius: 6px; }
.ic { flex: 0 0 auto; vertical-align: middle; }
.inline { display: inline; margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 9px; border: 1px solid transparent;
  font: 600 14px/1.1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-primary { background: var(--ice-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: var(--navy); } }
.btn-primary:hover { filter: brightness(1.07); }
.btn-mast { background: var(--ice); color: var(--navy); }
.btn-quiet { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn-quiet:hover { background: var(--panel-2); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; color: var(--ice-deep); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.layout { min-height: 100vh; }
.main { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px); min-width: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 14px 16px 0; }
.back { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px 0; font-weight: 600; font-size: 13.5px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }

.mast { background: var(--navy); color: #fff; margin-top: 8px; border-bottom: 3px solid var(--ice); }
.mast-in { max-width: 1240px; margin: 0 auto; padding: 16px 16px 16px; }
.mast-row { display: flex; gap: 14px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.mast h1 { font-family: var(--serif); color: var(--ice); font-size: 27px; letter-spacing: -.01em; margin: 0 0 4px; overflow-wrap: anywhere; }
.mast .sub { color: #C9D6E6; margin: 0 0 8px; max-width: 76ch; font-size: 14px; }
.asat { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 12.5px; color: #93A4BB; flex-wrap: wrap; }
.refresh { display: inline-flex; align-items: center; gap: 5px; color: #fff; text-decoration: none; font-weight: 600; border: 1px solid #2E4566; border-radius: 7px; padding: 4px 9px; }
.refresh:hover { border-color: var(--ice); }
.mast-action .btn-mast { min-height: 42px; }

/* sidebar (desktop) and tab bar (phones) */
.side { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; background: var(--navy); border-top: 1px solid #22385A; padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tab-h); color: #9FB2CB; text-decoration: none; font-size: 11.5px; font-weight: 600; position: relative; }
.tabbar a.on { color: var(--ice); }
.tabbar a.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--ice); border-radius: 0 0 3px 3px; }
.badge { display: inline-block; min-width: 19px; padding: 1px 6px; border-radius: 10px; background: var(--ice); color: var(--navy); font: 700 11px/17px var(--sans); text-align: center; }
.badge-bad { background: #F0A195; color: #3A0D07; }
.tabbar .badge { position: absolute; top: 7px; left: calc(50% + 6px); }

@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); background: var(--navy); padding: 16px 12px; gap: 2px; z-index: 40; overflow-y: auto; }
  .side-brand { display: flex; align-items: center; gap: 10px; color: var(--ice); text-decoration: none; font: 22px var(--serif); padding: 4px 10px 18px; }
  .side a:not(.side-brand) { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #B7C6DA; text-decoration: none; font-weight: 600; font-size: 14px; }
  .side a:not(.side-brand):hover { background: var(--navy-2); color: #fff; }
  .side a.on { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 var(--ice); }
  .side a .badge { margin-left: auto; }
  .side-out { margin-top: auto; }
  .side-out button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: #93A4BB; padding: 9px 10px; font: 600 13.5px var(--sans); cursor: pointer; border-radius: 8px; }
  .side-out button:hover { background: var(--navy-2); color: #fff; }
  .main { margin-left: var(--side-w); padding-bottom: 40px; }
  .tabbar { display: none; }
  .mast { margin-top: 0; }
  .mast-in, .wrap { padding-left: 28px; padding-right: 28px; }
  .back { padding-left: 28px; }
  .mast h1 { font-size: 32px; }
}

/* ---------- figures band ---------- */
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 14px; overflow: hidden; }
.fig { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; text-decoration: none; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
.fig:nth-child(2n) { border-right: 0; }
a.fig:hover { background: var(--panel-2); }
.fig-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.fig-v { font: 26px/1.15 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.fig-s { font-size: 12px; color: var(--soft); }
.fig-acc { box-shadow: inset 0 -3px 0 var(--ice-deep); } .fig-acc .fig-v { color: var(--ice-deep); }
.fig-bad { box-shadow: inset 0 -3px 0 var(--bad); } .fig-bad .fig-v { color: var(--bad); }
.fig-warn .fig-v { color: var(--warn); }
@media (min-width: 700px) { .figs { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } .fig { border-bottom: 0; border-right: 1px solid var(--line); } .fig:nth-child(2n) { border-right: 1px solid var(--line); } .fig:last-child { border-right: 0; } }
.meter { display: block; width: 100%; max-width: 160px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
@media (max-width: 699px) { .figs > .fig:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.meter i { display: block; height: 100%; background: var(--ice-deep); }
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}
.w55{width:55%}.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%;background:var(--bad)}.w95{width:95%;background:var(--bad)}.w100{width:100%;background:var(--bad)}

/* ---------- panels, rows, tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 14px; min-width: 0; }
.panel.pad, .pad { padding: 14px 16px; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 16px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h2 { margin: 0; }
.grid-2 { display: grid; gap: 0 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; text-decoration: none; min-height: 52px; }
.row:hover { background: var(--panel-2); }
.row strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row-go { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; color: var(--ice-deep); white-space: nowrap; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td a { text-decoration: none; } .tbl td a:hover { text-decoration: underline; }
.tbl .meta { display: block; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.err { display: block; color: var(--bad); font-size: 12.5px; }
@media (max-width: 699px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 8px 14px; border-bottom: 1px solid var(--line); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td { border: 0; padding: 2px 0; display: flex; gap: 10px; }
  .tbl td::before { content: attr(data-l); flex: 0 0 84px; font-size: 11.5px; font-weight: 700; color: var(--soft); padding-top: 2px; }
  .tbl td > * { min-width: 0; }
  .tbl .num { text-align: left; }
}
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.5; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-info { background: var(--info-bg); color: var(--info); }
.pill-bad { background: var(--bad-bg); color: var(--bad); } .pill-neutral { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill-acc { background: var(--navy); color: var(--ice); }

.seg { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.seg a { flex: 0 0 auto; padding: 7px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 13px; color: var(--muted); border: 1px solid var(--line); background: var(--panel); }
.seg a.on { background: var(--navy); color: var(--ice); border-color: var(--navy); }
.seg-n { font-weight: 700; opacity: .75; margin-left: 2px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 16px; font-size: 13px; }
.pager a, .pg-dis { display: inline-flex; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.pager a { border: 1px solid var(--line-2); background: var(--panel); } .pg-dis { color: var(--soft); } .pg-info { color: var(--muted); }

.empty { padding: 22px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r); margin: 0 0 14px; font-size: 13.5px; }
.note-warn { background: var(--warn-bg); color: var(--warn); } .note-info { background: var(--info-bg); color: var(--info); } .note-bad { background: var(--bad-bg); color: var(--bad); }
.note strong { color: inherit; }
.flash { padding: 10px 14px; border-radius: 9px; margin: 0 0 12px; font-weight: 600; font-size: 13.5px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); } .flash-bad { background: var(--bad-bg); color: var(--bad); } .flash-info { background: var(--info-bg); color: var(--info); }

pre.code, pre.draft, pre.digest { margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 460px; overflow: auto; }
pre.draft { font: 14px/1.55 var(--sans); }
pre.digest { border: 0; border-radius: 0 0 var(--r) var(--r); margin: 0; }
.prose { max-width: 80ch; line-height: 1.6; overflow-wrap: anywhere; }
.dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 5px 12px; margin: 8px 0; font-size: 13.5px; }
.dl dt { color: var(--muted); font-weight: 600; } .dl dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { margin: 0; padding-left: 18px; }

/* ---------- approvals ---------- */
.appr { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ice-deep); border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; }
.appr-h { display: flex; gap: 12px; align-items: flex-start; }
.appr-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: var(--ice); flex: 0 0 auto; }
.appr-kind { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; overflow-wrap: anywhere; }
.appr h2 { font-size: 19px; margin: 0 0 3px; overflow-wrap: anywhere; } .appr h2 a { text-decoration: none; }
.appr-form { margin-top: 10px; }
.appr-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.appr-actions .btn-primary { min-height: 46px; }
@media (max-width: 520px) { .appr-actions .btn-primary { width: 100%; white-space: normal; text-align: left; } }
details.reject, details.more { margin-top: 10px; border-top: 1px dashed var(--line-2); padding-top: 8px; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
details[open] summary { margin-bottom: 8px; }
.add-lesson summary { font-size: 14px; color: var(--text); }

/* ---------- agents ---------- */
.agent { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; }
.agent.is-off { opacity: .66; }
.agent-h { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.agent-h h2 { margin: 0; }
.agent-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; flex-wrap: wrap; }
.switch { width: 48px; height: 28px; border-radius: 14px; border: 0; background: var(--line-2); position: relative; cursor: pointer; flex: 0 0 auto; }
.switch span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.23,1,.32,1); }
.switch[aria-checked="true"] { background: var(--ice-deep); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* ---------- knowledge ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 5px 5px 5px 12px; margin: 0 0 12px; color: var(--muted); }
.search input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; font: 15px var(--sans); color: var(--text); padding: 8px 2px; }
.search input:focus { outline: none; }
.kn { list-style: none; margin: 0 0 12px; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.kn li + li { border-top: 1px solid var(--line); }
.kn a { display: block; padding: 11px 16px; text-decoration: none; }
.kn a:hover { background: var(--panel-2); }
.kn-top { display: flex; gap: 8px; align-items: baseline; }
.kn-top strong { font-weight: 600; overflow-wrap: anywhere; }
.kn-ex { display: block; color: var(--muted); font-size: 13px; margin: 2px 0; overflow-wrap: anywhere; }

/* ---------- forms and sign-in ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select { font: 15px/1.45 var(--sans); color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; width: 100%; font-weight: 400; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--ice-deep); outline: 2px solid var(--ice-soft); }
body.plain { background: var(--navy); }
.auth { max-width: 420px; margin: 0 auto; padding: 48px 16px; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--ice); font: 26px var(--serif); margin-bottom: 18px; }
.auth-card { background: var(--panel); border-radius: 12px; padding: 22px 20px; }
.auth-card h1 { font-size: 24px; color: var(--text); }
.auth-foot { color: #7F93AE; font-size: 12px; margin-top: 16px; }
