/* The console's foundations and its one component set (platform/STANDARD: page header, section heading, table, buttons,
   form field, sheet, empty state, toast, badge, note). Every size, weight, radius and colour is a token (tokens.css). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: var(--f-body); color: var(--ink); background: var(--canvas);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
/* native radios and checkboxes ignore border-radius: they keep the system focus ring, which follows their shape */
input[type="radio"]:focus-visible, input[type="checkbox"]:focus-visible { box-shadow: none; outline: revert; outline-offset: 2px; }
/* inside a choice card the card carries the ring (rounded like the card) */
.choice input:focus-visible { outline: none; }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.ph-d, .sec-d, .note p, .aside, .hint, .toast { text-wrap: pretty; }
.num, td.n, .tnum { font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: var(--fs-small); }
b, strong { font-weight: var(--w-semibold); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 48px 1fr; height: 100vh; }
.top {
  grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-3) 0 var(--s-3);
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-2); border-radius: var(--r-s); color: var(--ink); }
.brand:hover { text-decoration: none; background: var(--hover); }
.crumb-sep { color: var(--ink-4); padding: 0 2px; }
.switch {
  display: flex; align-items: center; gap: var(--s-2); height: var(--h-md); padding: 0 var(--s-2); border: 0; background: none; border-radius: var(--r-s);
  font-weight: var(--w-medium); white-space: nowrap;
}
.switch:hover { background: var(--hover); }
.switch .i { color: var(--ink-3); width: 14px; height: 14px; }
.search {
  flex: 1; max-width: 560px; margin: 0 auto; height: var(--h-md); display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3);
  border: 1px solid var(--line); background: var(--canvas); border-radius: var(--r-m); color: var(--ink-3); text-align: left;
}
.search:hover { border-color: var(--line-2); }
.search span { flex: 1; }
kbd {
  font: var(--f-micro); color: var(--ink-3); padding: 3px 5px; border-radius: var(--r-xs); border: 1px solid var(--line-2);
  background: var(--panel); min-width: 18px; text-align: center; display: inline-block;
}
.top-r { display: flex; align-items: center; gap: 2px; }
.ibtn {
  width: var(--h-md); height: var(--h-md); display: grid; place-items: center; border: 0; background: none; border-radius: var(--r-s); color: var(--ink-2);
  position: relative; flex: none;
}
.ibtn:hover { background: var(--hover); color: var(--ink); }
.ibtn[aria-pressed="true"] { background: var(--press); color: var(--ink); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: var(--f-micro); font-weight: var(--w-semibold); color: var(--on-color); flex: none; }
.avatar.sys { background: var(--sunk); color: var(--ink-2); }
.avatar.sys .i { width: 14px; height: 14px; }
.avatar.di { background: var(--ultra); }
.avatar.di .i { width: 14px; height: 14px; }
.menu-btn { display: none; }

/* nav */
.nav {
  background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: var(--s-3) var(--s-2) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-4); scrollbar-width: thin;
}
.nav-group h3 { margin: 0 0 var(--s-1); padding: 0 var(--s-3); font: var(--f-label); color: var(--ink-3); }
.nav a {
  display: flex; align-items: center; gap: var(--s-2); height: var(--h-md); padding: 0 var(--s-3); border-radius: var(--r-s); color: var(--ink-2);
  position: relative; font-weight: var(--w-medium);
}
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sel); color: var(--ink); font-weight: var(--w-semibold); }
.nav a[aria-current="page"] .i { color: var(--accent); }
.nav a .i { color: var(--ink-3); }
.nav-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: var(--s-3); }
.credit-chip { display: block; margin: 0 2px var(--s-2); padding: var(--s-3); border-radius: var(--r-m); background: var(--canvas); border: 1px solid var(--line); color: var(--ink); }
.credit-chip:hover { text-decoration: none; border-color: var(--line-2); }
.credit-chip b { font-weight: var(--w-semibold); font-variant-numeric: tabular-nums; }
.credit-chip small { display: block; color: var(--ink-3); font-size: var(--fs-small); margin-top: 2px; }
.meter { height: 4px; border-radius: 2px; background: var(--c1-wash); margin-top: var(--s-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.meter.warn { background: var(--warn-wash); } .meter.warn i { background: var(--warn); }
.meter.bad { background: var(--bad-wash); } .meter.bad i { background: var(--bad); }

@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }

/* main */
.main { overflow-y: auto; overflow-x: hidden; position: relative; scroll-behavior: smooth; }
.page { padding: var(--s-6) var(--s-8) 64px; max-width: 1280px; margin: 0 auto; }
.banner {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-8); border-bottom: 1px solid var(--line);
}
.banner.bad { background: var(--bad-wash); }
.banner.warn { background: var(--warn-wash); }
.banner .i { flex: none; }
.banner.bad .i { color: var(--bad-ink); } .banner.warn .i { color: var(--warn-ink); }
.banner p { margin: 0; flex: 1; }
.banner .btns { display: flex; gap: var(--s-2); }

/* 1. page header: a title and ONE description line */
.ph { display: flex; align-items: flex-end; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.ph-t { flex: 1; min-width: 260px; }
.ph h1 { font: var(--f-title); letter-spacing: var(--track-title); margin: 0; }
.ph-t > p, .ph-d { margin: var(--s-1) 0 0; color: var(--ink-2); max-width: 100ch; } /* one line at 1440: the description is a single sentence */
.ph-a { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }

/* 2. section heading: a title, an optional one-statement description, optional actions */
.sec-h, .panel-h { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4) 0; min-height: 40px; }
.sec-h .sec-t { flex: 1; min-width: 0; }
.sec-h > .btn.sm, .sec-h > .gated > .btn.sm, .panel-h > .btn.sm { margin: -2px 0; }
/* a ghost action's label ends at the content's edge (its padding hangs into the panel's), as text beside it does */
.sec-h > .btn.ghost { margin-right: calc(-1 * var(--s-3)); }
.sec-title, .panel-h h2 { margin: 0; font: var(--f-heading); flex: 1; }
.sec-d { margin: 2px 0 0; color: var(--ink-2); max-width: 72ch; }
.sec-h.bare { padding: 0; min-height: 0; margin-bottom: var(--s-3); }
.panel-h .sub { color: var(--ink-3); font-weight: var(--w-regular); margin-left: var(--s-2); }
/* a sub-label inside a sheet, popover or form group (never all caps) */
.label { font: var(--f-label); color: var(--ink-3); margin: 0 0 var(--s-2); }

/* 4. buttons: md 32, sm 28, lg 44 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: var(--h-md); padding: 0 var(--s-3); border-radius: var(--r-s); font-weight: var(--w-medium);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--btn); border-color: transparent; color: var(--on-btn); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14); }
.btn.primary:hover { background: var(--btn-hover); }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.danger { color: var(--bad-ink); }
.btn.danger-fill { background: var(--btn-danger); border-color: transparent; color: var(--on-color); }
.btn.danger-fill:hover { filter: brightness(.95); }
.btn.sm { height: var(--h-sm); padding: 0 var(--s-3); }
.btn.lg { height: var(--h-lg); padding: 0 var(--s-5); font-size: var(--fs-heading); justify-content: center; border-radius: var(--r-m); }
.btn .i { width: 15px; height: 15px; }
.btn kbd { margin-left: var(--s-1); background: transparent; }
.btn.primary kbd { color: rgba(255, 255, 255, .8); border-color: rgba(255, 255, 255, .3); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[disabled]:active, .btn[aria-disabled="true"]:active { transform: none; }
.btn[aria-disabled="true"]:hover { background: var(--panel); }
.btn.primary[aria-disabled="true"]:hover { background: var(--btn); }
.btn.busy { pointer-events: none; opacity: .7; }
.gated { display: inline-flex; cursor: not-allowed; border-radius: var(--r-s); }
.gated:focus-visible { box-shadow: var(--focus); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-m); background: var(--sunk); gap: 2px; }
.seg button { border: 0; background: none; height: calc(var(--h-sm) - 4px); padding: 0 var(--s-3); border-radius: var(--r-s); color: var(--ink-2); font-weight: var(--w-medium); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgba(35, 31, 43, .12), 0 0 0 .5px var(--line-2); }

/* 5. form field: label, input, one-statement hint, error */
.field { display: flex; flex-direction: column; gap: var(--gap-label); }
fieldset.field, fieldset.fs, fieldset.choices { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend, fieldset.fs legend { padding: 0; margin-bottom: var(--gap-label); }
.field label, .field legend, .lbl { font: var(--f-label); color: var(--ink-2); }
.input, select.input, textarea.input {
  height: var(--h-md); padding: 0 var(--s-3); border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--panel); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh-body); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input.sm { height: var(--h-sm); padding: 0 28px 0 var(--s-3); width: auto; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6.2 3.5 3.5 3.5-3.5' fill='none' stroke='%238A849A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; padding-right: 28px; }
.hint { font: var(--f-small); color: var(--ink-3); }
.field-err { font: var(--f-small); color: var(--bad-ink); }
.field-err:empty { display: none; }
.form { display: flex; flex-direction: column; gap: var(--s-4); }
.modal > .form { gap: 0; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.form .note, .modal .note { margin: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.check { display: flex; align-items: flex-start; gap: var(--s-2); cursor: pointer; }
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 15px; height: 15px; }
.check span small { display: block; color: var(--ink-3); font-size: var(--fs-small); }
.choices { display: grid; gap: var(--s-2); }
.choice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--line-2); border-radius: var(--r-m); cursor: pointer; background: var(--panel); }
.choice:hover { border-color: var(--ink-4); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); }
.choice b { font-weight: var(--w-semibold); display: block; }
.choices .choice { font: var(--f-body); color: var(--ink); } /* the same card inside a .field (whose labels are small) and outside one */
.choice small { display: block; font: var(--f-small); color: var(--ink-3); }
.choice:has(input:checked) small { color: var(--ink-2); }
.toggle { width: 30px; height: 18px; border-radius: 9px; background: var(--line-2); border: 0; position: relative; padding: 0; flex: none; transition: background .2s var(--ease); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .22s var(--rise); }
.toggle[aria-checked="true"] { background: var(--good); }
.toggle[aria-checked="true"]::after { transform: translateX(12px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: var(--s-1); height: 26px; padding: 0 6px 0 var(--s-3); border-radius: var(--r-pill); background: var(--sunk); font-size: var(--fs-small); }
.chip button { border: 0; background: none; color: var(--ink-3); width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; padding: 0; }
.chip button:hover { background: var(--press); color: var(--ink); }
.chip .i { width: 12px; height: 12px; }

/* panels and layout */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); }
.panel-b { padding: var(--s-3) var(--s-4) var(--s-4); }
.panel-b > p:not(.aside) { margin: 0; }
.grid { display: grid; gap: var(--s-4); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-2); }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.mt { margin-top: var(--s-3); }

/* stat strip: one panel, divided by hairlines */
.stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.stat { padding: var(--s-4) var(--s-4) var(--s-3); border-left: 1px solid var(--line); min-width: 0; text-align: left; background: none; border-top: 0; border-right: 0; border-bottom: 0; display: block; color: inherit; }
a.stat { text-decoration: none; }
a.stat:hover, button.stat:hover { background: var(--hover); text-decoration: none; }
.stat:first-child { border-left: 0; border-radius: var(--r-l) 0 0 var(--r-l); }
.stat:last-child { border-radius: 0 var(--r-l) var(--r-l) 0; }
.stat-l { font-size: var(--fs-small); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat-l .i { width: 14px; height: 14px; color: var(--ink-3); }
.stat-v { font: var(--f-figure); letter-spacing: -.02em; margin-top: var(--s-1); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-v small { font-size: var(--fs-body); font-weight: var(--w-medium); color: var(--ink-3); margin-left: 3px; letter-spacing: 0; }
/* a figure nothing measures: a dash at the figure's size; the caption says why */
.stat-v.none { color: var(--ink-4); }
.stat-d { font-size: var(--fs-small); color: var(--ink-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; }

/* 3. table: head small 500; rows 40, or 52 with a sub-line */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font: var(--f-label); color: var(--ink-3); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 0 var(--s-3); height: 40px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl.rows-2 td { height: 52px; }
.tbl tr:last-child td, .tbl tr:last-child th { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: var(--s-4); }
.tbl th:last-child, .tbl td:last-child { padding-right: var(--s-4); }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.n { font-variant-numeric: normal; } /* a column head is words: tabular figures would widen its hyphens */
.tbl tbody tr[data-open] { cursor: pointer; }
.tbl tbody tr[data-open]:hover td { background: var(--hover); }
.tbl tbody tr.sel td { background: var(--sel); }
.tbl tbody tr:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.tbl .id { font-family: var(--mono); font-size: var(--fs-small); color: var(--ink-2); }
.tbl .strong { font-weight: var(--w-semibold); }
.cell-sub { font-size: var(--fs-small); color: var(--ink-3); }
.tbl td .cell-sub { display: block; }
.trunc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr.fresh td { animation: rowin .32s var(--rise), fresh 1.8s var(--ease); }
@keyframes fresh { from { background: var(--accent-wash); } to { background: transparent; } }
@keyframes rowin { from { opacity: 0; transform: translateY(-6px); } }
.tbl tbody tr.leaving td { animation: rowout .24s var(--ease) forwards; }
@keyframes rowout { to { opacity: 0; transform: translateX(14px); } }

/* status in a table: a dot and a word, never colour alone */
.st { display: inline-flex; align-items: center; gap: 5px; font: var(--f-label); white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: none; }
.st.good::before { background: var(--good); }
.st.bad::before { background: var(--bad); border-radius: 2px; transform: rotate(45deg); width: 6px; height: 6px; }
.st.warn::before { background: var(--warn); border-radius: 1px; width: 7px; height: 7px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.st.wait::before, .st.live::before { background: var(--accent); }
.st.live::before { animation: breathe 1.6s var(--ease) infinite; }
.st.off::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-4); }

/* 9. badge: a pill, 20 high */
.badge { display: inline-flex; align-items: center; gap: var(--s-1); height: 20px; padding: 0 var(--s-2); border-radius: var(--r-pill); font: var(--f-label); background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.badge.code { font-family: var(--mono); font-weight: var(--w-medium); border-radius: var(--r-xs); padding: 0 6px; }
.badge.accent { background: var(--accent-wash); color: var(--accent-ink); }
/* AA text on the green wash. Kept out of tokens.css, which the sign-in screens bundle (acul/build.mjs). */
:root { --good-ink: light-dark(#0F6E49, #3FB984); }
.badge.good { background: var(--good-wash); color: var(--good-ink); }
.badge.warn { background: var(--warn-wash); color: var(--warn-ink); }
.badge.bad { background: var(--bad-wash); color: var(--bad-ink); }
.badge .i { width: 12px; height: 12px; }
/* legacy names, retired by the page groups: .tag and .code-pill render as the badge */
.tag { display: inline-flex; align-items: center; gap: var(--s-1); height: 20px; padding: 0 var(--s-2); border-radius: var(--r-pill); font: var(--f-label); background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.tag.accent { background: var(--accent-wash); color: var(--accent-ink); }
.code-pill { display: inline-flex; align-items: center; height: 20px; font: var(--f-label); font-family: var(--mono); padding: 0 6px; border-radius: var(--r-xs); background: var(--sunk); color: var(--ink-2); }
.code-pill.bad { background: var(--bad-wash); color: var(--bad-ink); }
.code-pill.warn { background: var(--warn-wash); color: var(--warn-ink); }
.code-pill.good { background: var(--good-wash); color: var(--good-ink); }
.swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }

/* 10. note: a boxed statement with an icon; aside: an unboxed one */
.note { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-m); background: var(--accent-wash); color: var(--ink); margin: 0 0 var(--s-4); }
.note > .i { flex: none; margin-top: 1px; color: var(--accent-ink); }
.note > p, .note > div { margin: 0; flex: 1; min-width: 0; }
.note .btn { flex: none; }
.note.plain { background: var(--sunk); color: var(--ink-2); }
.note.plain > .i { color: var(--ink-3); }
.note.warn { background: var(--warn-wash); }
.note.warn > .i { color: var(--warn-ink); }
.note.bad { background: var(--bad-wash); color: var(--bad-ink); }
.note.bad > .i { color: var(--bad-ink); }
.note[hidden] { display: none; }
/* a long message shown in place (say.js): the note with its close button */
.note.in-place { padding-right: var(--s-2); }
.note.in-place .note-x { width: var(--h-sm); height: var(--h-sm); margin: -4px 0; color: inherit; }
.note.in-place .note-x:hover { background: var(--hover); color: inherit; }
.aside { display: flex; gap: var(--s-2); align-items: flex-start; margin: var(--s-3) 2px 0; font: var(--f-small); color: var(--ink-2); }
.aside > .i { flex: none; width: 14px; height: 14px; margin-top: 2px; color: var(--ink-3); }
.aside a, .note a:not(.btn) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-4); }
.tabs button, .tabs a {
  border: 0; background: none; height: 36px; padding: 0 var(--s-3); color: var(--ink-2); font-weight: var(--w-medium); position: relative; display: inline-flex; align-items: center; gap: 6px;
}
.tabs button:hover, .tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs [aria-selected="true"] { color: var(--ink); }
.tabs [aria-selected="true"]::after { content: ""; position: absolute; left: var(--s-2); right: var(--s-2); bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
/* a strip that scrolls sideways fades on each side with more to show (cue.js sets cue-l / cue-r) */
.cue-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.tabs.cue-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent); }
.tabs.cue-l.cue-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent); }

/* code */
.code {
  font: var(--f-code); background: var(--code-bg); border-radius: var(--r-m); padding: var(--s-3) var(--s-4); margin: 0; overflow-x: auto;
  color: var(--ink); white-space: pre; tab-size: 2;
}
.code .k { color: var(--c3); } .code .s { color: var(--good); } .code .c { color: var(--ink-3); } .code .p { color: var(--accent-ink); } .code .n { color: var(--c2); }
.secret { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3); border-radius: var(--r-m); background: var(--sunk); font: var(--f-code); }
.secret > span { flex: 1; min-width: 0; overflow-wrap: anywhere; } /* shown once: the whole value, wrapped, never cut */
.secret .btn { font: var(--f-body); font-weight: var(--w-medium); }

/* lead statement, in the serif */
.say { font: var(--f-lead); color: var(--ink); margin: 0; max-width: 66ch; }
.say b { font-weight: var(--w-semibold); }

/* 7. empty state: icon, title, one statement, an optional action */
.empty { text-align: center; padding: var(--s-10) var(--s-6); color: var(--ink-2); display: flex; flex-direction: column; align-items: center; }
.empty-ic { width: 40px; height: 40px; border-radius: var(--r-l); display: grid; place-items: center; background: var(--accent-wash); color: var(--accent-ink); margin-bottom: var(--s-4); }
.empty-ic .i { width: 20px; height: 20px; }
.empty-ic.bad { background: var(--bad-wash); color: var(--bad-ink); }
.empty h3 { font: var(--f-title-s); color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0; max-width: 52ch; text-wrap: pretty; }
.empty-a { margin-top: var(--s-4); display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; }
.empty-a [hidden] { display: none; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .ax { font: var(--fs-micro) var(--sans); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .gl { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-small); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* 6. sheet (inspector) */
.sheet {
  position: fixed; top: 48px; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); box-shadow: var(--shadow-sheet);
  z-index: 30; transform: translateX(104%); display: flex; flex-direction: column;
  visibility: hidden; transition: transform .32s var(--ease), visibility 0s linear .32s;
}
.sheet.on { transform: none; visibility: visible; transition: transform .32s var(--ease), visibility 0s; }
.sheet-h { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.sheet-h .t { flex: 1; min-width: 0; }
.sheet-h h2 { margin: 0; font: var(--f-title-s); }
.sheet-h .id { font: var(--f-small); font-family: var(--mono); color: var(--ink-3); }
.sheet-h .sub { font: var(--f-small); color: var(--ink-3); } /* a person's email: the body face, as in tables and dialogs */
.sheet-b { overflow-y: auto; padding: var(--s-5) var(--s-5) var(--s-10); flex: 1; }
.sheet-sec { margin-top: var(--s-5); }
.sheet-sec h3 { font: var(--f-label); color: var(--ink-3); margin: 0 0 var(--s-2); }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: var(--s-2) var(--s-3); margin: 0; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* modal + palette */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; transition: opacity .16s var(--ease); }
.scrim.on { opacity: 1; }
.pal {
  position: fixed; left: 50%; top: 14vh; width: min(660px, calc(100vw - 24px)); transform: translateX(-50%) scale(.98); opacity: 0;
  background: var(--raised); border-radius: var(--r-l); box-shadow: var(--shadow-pop); z-index: 41; overflow: hidden;
  transition: transform .18s var(--rise), opacity .14s var(--ease);
}
.pal.on { transform: translateX(-50%) scale(1); opacity: 1; }
.pal-in { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); height: 52px; border-bottom: 1px solid var(--line); }
.pal-in input { flex: 1; min-width: 0; border: 0; background: none; font-size: var(--fs-lead); outline: none; height: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.pal-in input::placeholder { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.pal-in input:focus-visible, .pal-in input:focus { box-shadow: none; outline: none; }
.pal-in .i { color: var(--ink-3); width: 18px; height: 18px; }
.pal-scope { font-size: var(--fs-small); color: var(--ink-3); white-space: nowrap; }
.pal-list { max-height: min(440px, 56vh); overflow-y: auto; padding: 6px; }
.pal-g { font: var(--f-label); color: var(--ink-3); padding: var(--s-2) var(--s-3) var(--s-1); }
.pal-it { display: flex; align-items: center; gap: var(--s-3); height: 36px; padding: 0 var(--s-3); border-radius: var(--r-m); cursor: pointer; color: var(--ink); }
.pal-it .i { color: var(--ink-3); }
.pal-it .d { color: var(--ink-3); font-size: var(--fs-small); margin-left: auto; display: flex; gap: var(--s-1); align-items: center; white-space: nowrap; }
.pal-it[aria-selected="true"] { background: var(--sel); }
.pal-it[aria-selected="true"] .i { color: var(--accent); }
.pal-it[aria-selected="true"] .d { color: var(--ink-2); }
.pal-it mark { background: none; color: var(--accent-ink); font-weight: var(--w-semibold); }
.pal-foot { display: flex; gap: var(--s-4); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); font-size: var(--fs-small); color: var(--ink-3); }
.pal-foot span { display: inline-flex; align-items: center; gap: 5px; }
.pal-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-none { padding: 28px var(--s-4); text-align: center; color: var(--ink-2); }
.pal-tip { margin-left: auto; }

.modal {
  position: fixed; left: 50%; top: 50%; width: min(480px, calc(100vw - 24px)); transform: translate(-50%, -48%) scale(.98); opacity: 0;
  background: var(--raised); border-radius: var(--r-l); box-shadow: var(--shadow-pop); z-index: 41; transition: transform .2s var(--rise), opacity .14s;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; display: flex; flex-direction: column;
}
.modal.on { transform: translate(-50%, -50%); opacity: 1; }
.modal.wide { width: min(640px, calc(100vw - 24px)); }
.modal-h { padding: var(--s-5) var(--s-5) 0; }
.modal-h h2 { margin: 0; font: var(--f-title-s); }
.modal-h p { margin: var(--s-1) 0 0; color: var(--ink-2); }
/* a tall dialog scrolls its body; the heading and the buttons stay in view */
.modal-h, .modal-steps, .modal-f { flex: none; }
.modal-b { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-f { padding: var(--s-3) var(--s-5) var(--s-4); display: flex; justify-content: flex-end; gap: var(--s-2); }
.modal-steps { display: flex; gap: 6px; padding: var(--s-4) var(--s-5) 0; }
.modal-steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--line-2); }
.modal-steps i.on { background: var(--accent); }

/* popover (switcher, account, confirm, row menu) */
.pop {
  position: fixed; z-index: 35; background: var(--raised); border-radius: var(--r-l); box-shadow: var(--shadow-pop); opacity: 0;
  transform: translateY(-4px) scale(.99); transform-origin: top left; transition: opacity .14s var(--ease), transform .18s var(--rise); pointer-events: none;
}
.pop.on { opacity: 1; transform: none; pointer-events: auto; }
.pop.from-right { transform-origin: top right; }
.sw { width: 600px; display: grid; grid-template-columns: 250px 1fr; min-height: 280px; }
.sw-col { padding: var(--s-2); }
.sw-col + .sw-col { border-left: 1px solid var(--line); }
.sw-h { font: var(--f-label); color: var(--ink-3); padding: 6px var(--s-2); }
.sw-it { display: flex; align-items: center; gap: var(--s-2); width: 100%; border: 0; background: none; text-align: left; padding: var(--s-2); border-radius: var(--r-s); }
.sw-it:hover { background: var(--hover); }
.sw-it[aria-current="true"] { background: var(--sel); }
.sw-it .t { flex: 1; min-width: 0; }
.sw-it .t b { font-weight: var(--w-semibold); display: block; }
.sw-it .t small { color: var(--ink-3); font-size: var(--fs-small); }
.sw-it[aria-current="true"] .t small { color: var(--ink-2); }

/* 8. toast: one statement, one line */
.toasts { position: fixed; left: var(--s-4); right: var(--s-4); bottom: var(--s-5); z-index: 50; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; pointer-events: none; }
.toasts > * { pointer-events: auto; max-width: min(560px, 100%); }
.toast {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4); min-height: 40px; border-radius: var(--r-m); background: var(--toast-bg); color: var(--toast-ink);
  box-shadow: var(--shadow-toast); animation: toastin .32s var(--rise);
}
.toast .i { color: var(--toast-ic); }
.toast.bad .i { color: var(--toast-ic-bad); }
.toast button { border: 0; background: var(--toast-btn); color: inherit; border-radius: var(--r-s); height: var(--h-sm); padding: 0 var(--s-3); font-weight: var(--w-medium); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- narrow ---------- */
@media (max-width: 1100px) { .hide-m { display: none !important; } }
@media (max-width: 1080px) {
  .g-main { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav {
    position: fixed; top: 48px; left: 0; bottom: 0; width: 280px; z-index: 32; transform: translateX(-102%); transition: transform .28s var(--ease);
  }
  .nav.on {
    box-shadow: 0 0 60px rgba(0, 0, 0, .2);
  }
  .nav.on { transform: none; }
  .menu-btn { display: grid; }
  .search span, .search kbd, .top-r .hide-s { display: none; }
  .search { flex: 0 0 var(--h-md); width: var(--h-md); margin: 0 0 0 auto; padding: 0; justify-content: center; border: 0; background: none; }
  .search .i { color: var(--ink-2); }
  .page { padding: var(--s-5) var(--s-4) var(--s-12); }
  .banner { padding: var(--s-3) var(--s-4); flex-wrap: wrap; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:first-child, .stat:last-child { border-radius: 0; }
  .hide-s { display: none !important; }
  .show-s { display: block !important; }
  .sheet { top: 0; width: 100vw; z-index: 45; }
  .sw { width: calc(100vw - 16px); grid-template-columns: 1fr; }
  .sw-col + .sw-col { border-left: 0; border-top: 1px solid var(--line); }
  dl.kv { grid-template-columns: 110px 1fr; }
  .tbl td, .tbl th { padding: 0 var(--s-2); }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs button, .tabs a { white-space: nowrap; flex: none; }
  /* a table that can't fit becomes cards: each row a block, its first cell left and its next one right, its actions
     (.card-act) on a line of their own; a cell's data-label names it where the column head is gone */
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards thead { display: none; }
  .tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
  .tbl.cards tr:last-child { border-bottom: 0; }
  .tbl.cards td, .tbl.cards td:first-child, .tbl.cards td:last-child { display: block; height: auto; padding: 0; border: 0; white-space: normal; min-width: 0; }
  .tbl.cards td[data-label]::before { content: attr(data-label); display: block; font: var(--f-label); color: var(--ink-3); }
  .tbl.cards td.card-act { grid-column: 1 / -1; display: flex; gap: var(--s-1); justify-content: flex-start; text-align: left; margin-left: calc(-1 * var(--s-3)); }
  .tbl.cards td.card-act:empty { display: none; }
  .pal-tip, .pal-scope { display: none; }
  .pal { width: calc(100vw - var(--s-4)); }
  .pal-in { padding: 0 var(--s-3); gap: var(--s-2); }
  .pal-in input::placeholder { font-size: var(--fs-small); }
  .main { min-width: 0; }
}
.show-s { display: none !important; }
@media (max-width: 760px) { .show-s { display: block !important; } }
