/* Whisper — R4 admin console pass (owner 2026-11-16: "admin page is still not the best in class … the left sidebar
   contains heading and pills all merged … the highlight effect of button is oldschool").
   Loaded last. RESTRAINT.md holds: neutral surfaces, one accent, 1px borders, no glow, 4px grid, 400/500/600.
   1. tokens  2. control states (buttons, fields, segmented)  3. admin shell + section nav
   4. page header  5. content rhythm  6. phone */

/* ============================== 1. tokens ============================== */
:root {
  /* focus: a crisp 2px accent ring with a 2px gap (no soft halo); rows/lists keep --ring-inset */
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --ring-field: 0 0 0 1px var(--accent);
  --ring-inset: inset 0 0 0 2px var(--accent);
  /* neutral washes for hover / selected rows (work on any surface) */
  --wash-1: rgba(15, 23, 42, 0.045);
  --wash-2: rgba(15, 23, 42, 0.075);
  --wash-3: rgba(15, 23, 42, 0.10);
  --danger-fill: #B83A33;
  --danger-fill-hover: #A3322C;
  --adm-nav-w: 240px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --wash-1: rgba(255, 255, 255, 0.04); --wash-2: rgba(255, 255, 255, 0.09); --wash-3: rgba(255, 255, 255, 0.11); }
}
:root[data-theme="dark"] { --wash-1: rgba(255, 255, 255, 0.04); --wash-2: rgba(255, 255, 255, 0.09); --wash-3: rgba(255, 255, 255, 0.11); }

/* ============================== 2. control states ============================== */
/* buttons: background shift on hover, darker on press, no scale/bounce, crisp focus ring */
.btn { transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.btn:active:not(:disabled), .btn.is-pressed { transform: none; background: var(--surface-3); border-color: var(--line-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-fill); filter: brightness(0.92); border-color: transparent; }
.btn-ghost:hover { background: var(--wash-1); color: var(--text); border-color: transparent; }
.btn-ghost:active:not(:disabled) { background: var(--wash-2); border-color: transparent; }
.btn-danger { background: var(--danger-fill); border-color: var(--danger-fill); color: #FFFFFF; }
.btn-danger:hover { background: var(--danger-fill-hover); border-color: var(--danger-fill-hover); color: #FFFFFF; }
.btn-danger:active:not(:disabled) { background: var(--danger-fill-hover); filter: brightness(0.94); }
.btn-danger-ghost:hover { background: var(--err-soft); color: var(--err); }
.icon-btn:hover:not(:disabled) { background: var(--wash-1); }
.icon-btn:active:not(:disabled) { background: var(--wash-2); transform: none; }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .mini-icon-btn:active:not(:disabled) { transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* fields: accent border + 1px accent edge (reads as a 2px border), no glow */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus,
.field input:focus, .field select:focus, .field textarea:focus, .text-input:focus, .sql-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring-field);
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--ring); }

/* segmented controls: one neutral pattern (track + raised selected segment) for .seg, .w2-segs and .kn-seg */
.seg > button.active, .seg > button[aria-pressed="true"] { box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(15, 23, 42, 0.04); }
.w2-segs, .kn-seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface-2); overflow: visible; }
.w2-seg, .kn-seg-l { flex: 0 0 auto; height: 26px; line-height: 26px; padding: 0 10px; border: 0 !important; border-radius: 4px; background: transparent; color: var(--text-2); font-size: var(--fs-13); font-weight: var(--fw-med); text-align: center; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.w2-seg:hover, .kn-seg-l:hover { background: transparent; color: var(--text); }
.w2-seg.on, .kn-seg-i:checked + .kn-seg-l { background: var(--surface); color: var(--text); font-weight: var(--fw-med); box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(15, 23, 42, 0.04); }
.w2-seg:focus-visible { outline: none; box-shadow: var(--ring-inset); }
.kn-seg-i:focus-visible + .kn-seg-l { box-shadow: var(--ring-inset); }
.kn-seg { display: flex; }
.kn-seg-l { flex: 1 1 auto; padding: 0 6px; }
#view-admin .kar-seg { display: inline-flex; }
#view-admin .kar-seg .kn-seg-l { flex: 0 0 auto; padding: 0 10px; }
@media (max-width: 719.98px) {
  .w2-segs { display: flex; width: 100%; flex-wrap: wrap; }
  .w2-segs > .w2-seg { flex: 1 1 0; border: 0 !important; }
  .kn-seg { display: flex; width: 100%; }
  .kn-seg-l, .kar-seg .kn-seg-l { flex: 1 1 0; height: 36px; line-height: 36px; }
}

/* ============================== 3. admin shell + section nav ============================== */
/* the settings nav is its own pane: flush to the rail, full height, surface + hairline; the content column
   has one max width so every section lines up the same way */
@media (min-width: 1024px) {
  #view-admin .adm-page.adm-has-nav { grid-template-columns: var(--adm-nav-w) minmax(0, 1fr); gap: 0; padding: 0; min-height: 100%; align-items: stretch; }
  #view-admin .adm-nav {
    position: sticky; top: 0; align-self: start;
    display: flex; flex-direction: column; gap: 0;
    height: calc(100vh - var(--topbar-h)); margin: 0; padding: 20px 12px 32px;
    background: var(--surface); border-right: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: transparent transparent;
  }
  #view-admin .adm-has-nav > .adm-main { padding: 24px var(--page-x) 48px 40px; max-width: calc(1080px + var(--page-x) + 40px); width: 100%; }
}
#view-admin .adm-nav:hover, #view-admin .adm-nav:focus-within { scrollbar-color: var(--line-strong) transparent; }
#view-admin .adm-settings { max-width: none; }
#view-admin .adm-nav-list { display: flex; flex-direction: column; gap: 16px; }
#view-admin .adm-nav-list.is-finding { gap: 12px; }
#view-admin .adm-nav-group { display: flex; flex-direction: column; gap: 1px; }
#view-admin .adm-nav-group[hidden], #view-admin .adm-nav-item[hidden], #view-admin .adm-nav-none[hidden] { display: none; }
/* group label: small caps-style label, clearly not a row */
#view-admin .adm-nav-h {
  display: flex; align-items: center; height: 22px; padding: 0 10px; margin: 0 0 2px;
  font-size: var(--fs-11); line-height: 16px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); user-select: none;
}
/* rows: full-width, 32px, quiet; selected = neutral fill + strong text; no accent bar, no border */
#view-admin .adm-nav-item {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 30px; padding: 5px 10px; border: 0; border-radius: var(--r-ctl);
  background: transparent; color: var(--text-2);
  font: inherit; font-size: var(--fs-13); line-height: 20px; font-weight: 400; text-align: left; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
#view-admin .adm-nav-item:hover { background: var(--wash-1); color: var(--text); }
#view-admin .adm-nav-item:active { background: var(--wash-2); }
#view-admin .adm-nav-item.active, #view-admin .adm-nav-item[aria-current="page"] { background: var(--wash-2); color: var(--text); font-weight: var(--fw-med); box-shadow: none; }
#view-admin .adm-nav-item:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-admin .adm-nav-item .kar-tabn { margin-left: auto; height: 18px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--wash-2); color: var(--text-2); font-size: var(--fs-11); font-weight: 600; font-variant-numeric: tabular-nums; }
/* finder */
#view-admin .adm-nav-find { position: relative; margin: 0 0 12px; }
#view-admin .adm-nav-find > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
#view-admin .adm-nav-q {
  width: 100%; height: 32px; padding: 0 10px 0 30px; margin: 0;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface);
  color: var(--text); font-size: var(--fs-13);
}
#view-admin .adm-nav-q::placeholder { color: var(--text-3); }
#view-admin .adm-nav-q:hover:not(:focus) { border-color: var(--line-strong); }
#view-admin .adm-nav-none { margin: 0; padding: 6px 10px; font-size: var(--fs-13); color: var(--text-3); }

/* ============================== 4. page header ============================== */
#view-admin .adm-head { margin: 0 0 24px; padding: 0 0 20px; border-bottom: 1px solid var(--line); align-items: flex-end; }
#view-admin .adm-eyebrow { margin: 0 0 4px; font-size: var(--fs-12); line-height: 16px; font-weight: var(--fw-med); color: var(--text-3); }
#view-admin .adm-head .page-title { font-size: var(--fs-20); line-height: 28px; }
#view-admin .adm-desc { margin-top: 4px; max-width: 76ch; white-space: normal; color: var(--text-2); }
#view-admin .adm-head .page-actions:empty { display: none; }
#view-admin .adm-head .page-actions { align-self: flex-end; }
/* sections whose plugin brings its own intro bar: the bar becomes the header's last row
   (description left, actions right) and the page-level description steps aside */
#view-admin .adm-main.adm-has-lede .adm-desc { display: none; }
#view-admin .adm-main.adm-has-lede .adm-head { margin-bottom: 0; padding-bottom: 4px; border-bottom: 0; }
#view-admin .adm-main.adm-has-lede .adm-lede-bar {
  display: flex; align-items: flex-end; gap: 8px 16px; flex-wrap: wrap;
  margin: 0 0 24px !important; padding: 0 0 20px !important; border-bottom: 1px solid var(--line);
}
#view-admin .adm-lede-bar .v2p-tabbar-text { flex: 1 1 360px; max-width: 76ch; font-size: var(--fs-13); line-height: 20px; color: var(--text-2); }
#view-admin .adm-lede-bar .btn { height: 32px; padding: 0 12px; }
#view-admin .adm-lede-bar + .v2p-asof { margin: -12px 0 16px; }

/* ============================== 5. content rhythm ============================== */
/* page-level toolbars: 32px controls, 8px gaps, 16px below */
#view-admin .adm-content > .toolbar, #view-admin .adm-content > div > .toolbar:first-child { margin-bottom: 16px; }
#view-admin .adm-toolbar .btn, #view-admin .v2p-tabbar .btn, #view-admin .w3j-bar-t .btn { height: 32px; }
#view-admin .adm-toolbar select, #view-admin .adm-toolbar input:not([type="checkbox"]):not([type="radio"]) { height: 32px; }
/* section headings inside a page: 14/600 title, muted one-line help, 32px between sections with a hairline */
#view-admin .adm-h2 { font-size: var(--fs-14); line-height: 22px; font-weight: 600; margin: 0 0 2px; }
#view-admin .adm-sec-head .adm-h2 { font-size: var(--fs-14); }
#view-admin .adm-p { line-height: 20px; max-width: 76ch; }
#view-admin .adm-set-intro { margin: 0 0 12px; }
#view-admin .adm-set-intro.adm-set-next { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
#view-admin .adm-settings > .panel, #view-admin .adm-settings > section.panel { margin-bottom: 0; }
/* panels in admin: a 44px head, 14/600 title, quiet meta at right */
#view-admin .adm-content .panel-head { min-height: 44px; }
#view-admin .adm-content .panel-head .panel-title, #view-admin .adm-content .panel-head h2, #view-admin .adm-content .panel-head h3 { font-size: var(--fs-14); font-weight: 600; }
/* tables: actions in a row are compact secondary buttons, right-aligned */
#view-admin .adm-content .dtable td .btn:not(.btn-primary):not(.adm-acc) { height: 28px; padding: 0 10px; font-size: var(--fs-13); }
#view-admin .adm-content .dtable td:last-child:has(> .btn) { text-align: right; white-space: nowrap; }
#view-admin .adm-content .dtable thead th { font-weight: var(--fw-med); color: var(--text-3); }
/* hint lines and "as of" captions */
#view-admin .hint-line { color: var(--text-3); }
#view-admin .v2p-asof { font-size: var(--fs-12); color: var(--text-3); }
/* duplicates of the page header inside plugins (title repeated as a panel/section heading) */
#view-admin .kar-head .kar-h { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#view-admin .kar-head { align-items: center; margin-bottom: 16px; }
#view-admin .kar-count { margin: 0; font-size: var(--fs-13); color: var(--text-2); }
#view-admin .sm-adm { max-width: none; }
#view-admin .sm-adm > .panel > .panel-head { display: none; }
#view-admin .sm-adm-body { padding: 16px; gap: 16px; }
/* empty states: small and calm */
#view-admin .adm-content .empty { padding: 32px 16px; }
#view-admin .adm-content .empty-title { font-size: var(--fs-14); font-weight: 600; color: var(--text); }
#view-admin .adm-content .empty-body { font-size: var(--fs-13); color: var(--text-2); }

/* ============================== 6. narrow screens ============================== */
@media (max-width: 1023.98px) {
  #view-admin .adm-page.adm-has-nav { display: block; }
  #view-admin .adm-nav { display: none; }
  /* the section switcher reads as the page title; the h1 stays for assistive tech */
  #view-admin .adm-picker-wrap { display: block; margin: 0 0 4px; }
  #view-admin select.adm-picker { height: 40px; padding: 0 36px 0 12px; font-size: var(--fs-16); font-weight: 600; border-color: var(--line-strong); }
  #view-admin .adm-has-nav .adm-head .page-title { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  #view-admin .adm-has-nav .adm-eyebrow { display: none; }
  #view-admin .adm-head { margin-bottom: 16px; padding-bottom: 16px; }
  #view-admin .adm-main.adm-has-lede .adm-lede-bar { margin-bottom: 16px !important; padding-bottom: 16px !important; }
}
@media (max-width: 719.98px) {
  #view-admin .page-sub.adm-desc { display: block; font-size: var(--fs-13); }
  #view-admin .adm-lede-bar .v2p-tabbar-text { flex-basis: 100%; }
  #view-admin .adm-lede-bar .btn { height: 40px; }
  #view-admin .adm-set-intro.adm-set-next { margin-top: 24px; padding-top: 20px; }
  #view-admin .kar-head { flex-direction: column; align-items: stretch; gap: 8px; }
}

/* ============================== 7. main rail (app-wide) ============================== */
/* active = a clear neutral fill + white text and icon; no accent bar. hover = a lighter fill. */
.nav-item { border-radius: var(--r-ctl); transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #FFFFFF; }
.nav-item.active, .nav-item[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: #FFFFFF; font-weight: var(--fw-med); }
.nav-item.active:hover { background: rgba(255, 255, 255, 0.12); }
.nav-item.active::before, .shell.rail-collapsed .nav-item.active::before, .shell .nav-item.active::before { content: none; display: none; }
.rail .nav-item:active { background: rgba(255, 255, 255, 0.14); }

/* ============================== 8. status badges ============================== */
/* one component: neutral pill, small dot; the dot carries meaning only where status is the information */
.st-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-12); line-height: 1; font-weight: var(--fw-med); white-space: nowrap; vertical-align: middle;
}
.st-badge .st-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.st-badge.st-ok .st-dot { background: var(--ok); }
.st-badge.st-warn .st-dot { background: var(--warn); }
.st-badge.st-err .st-dot { background: var(--err); }
.st-badge.st-off { color: var(--text-3); }
.st-badge.st-off .st-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
/* legacy pills in admin read the same way: neutral text, colour only in the dot */
#view-admin .pill { height: 22px; border-radius: var(--r-sm); font-size: var(--fs-12); font-weight: var(--fw-med); }
#view-admin .pill-warn, #view-admin .pill-err, #view-admin .pill-amber, #view-admin .pill-red { color: var(--text-2); }
#view-admin .pill-warn::before, #view-admin .pill-amber::before { background: var(--warn); }
#view-admin .pill-err::before, #view-admin .pill-red::before { background: var(--err); }

/* ============================== 9. tables: quiet inline controls ============================== */
/* inline selects in rows: no box until hover/focus, text aligned with the column */
#view-admin .dtable td select.adm-role, #view-admin .dtable td .adm-role-wrap select {
  height: 28px; min-width: 0; padding: 0 26px 0 8px; margin-left: -9px;
  border-color: transparent; background-color: transparent; color: var(--text); font-weight: 400;
  background-position: right 6px center;
}
#view-admin .dtable tr:hover td select.adm-role, #view-admin .dtable td select.adm-role:hover { border-color: var(--line-strong); background-color: var(--field-bg); }
#view-admin .dtable td select.adm-role:focus { border-color: var(--accent); background-color: var(--field-bg); }
#view-admin .adm-role-self { display: inline-block; padding: 0; color: var(--text); }
#view-admin .dtable td .adm-acc, #view-admin .dtable td .adm-acc.btn { display: inline-flex; height: 28px; padding: 0; margin: 0; border: 0; background: none; font-size: var(--fs-13); font-weight: 400; color: var(--text-2); }
#view-admin .dtable td .adm-acc:hover { color: var(--text); background: none; text-decoration: underline; text-underline-offset: 3px; }
#view-admin .adm-users td .adm-muted { font-size: var(--fs-13); color: var(--text-2); }
#view-admin .adm-users td { vertical-align: middle; }
#view-admin .adm-users .adm-act { width: 44px; text-align: right; }
#view-admin .adm-you { height: 18px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: var(--fs-11); color: var(--text-3); }

/* ============================== 10. overview (admin home) ============================== */
#view-admin .adm-kpis { margin-bottom: 16px; }
#view-admin .adm-ov-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin: 0 0 16px; }
#view-admin .adm-ov-row > .panel { margin: 0; min-width: 0; display: flex; flex-direction: column; }
#view-admin .adm-ov-more { font-size: var(--fs-13); color: var(--text-2); text-decoration: none; }
#view-admin .adm-ov-more:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
#view-admin .adm-act-list, #view-admin .adm-ql-list { list-style: none; margin: 0; padding: 0; }
#view-admin .adm-act-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: var(--fs-13); min-width: 0; }
#view-admin .adm-act-row:first-child { border-top: 0; }
#view-admin .adm-act-who { flex: 0 0 72px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-admin .adm-act-what { flex: 0 0 auto; font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); background: none; padding: 0; }
#view-admin .adm-act-det { flex: 1 1 auto; min-width: 0; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-admin .adm-act-when { flex: 0 0 auto; color: var(--text-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; white-space: nowrap; }
#view-admin .adm-act-empty { padding: 16px; font-size: var(--fs-13); color: var(--text-3); }
#view-admin .adm-ql { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t c" "d c"; column-gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; transition: background-color var(--t-fast) var(--ease); }
#view-admin .adm-ql-list li:first-child .adm-ql { border-top: 0; }
#view-admin .adm-ql:hover { background: var(--row-hover); text-decoration: none; }
#view-admin .adm-ql:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-admin .adm-ql-t { grid-area: t; font-size: var(--fs-13); font-weight: var(--fw-med); color: var(--text); }
#view-admin .adm-ql-d { grid-area: d; font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-admin .adm-ql-chev { grid-area: c; align-self: center; color: var(--text-3); display: inline-flex; }
#view-admin .adm-glance { gap: 16px; }
@media (max-width: 1279.98px) { #view-admin .adm-ov-row { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 719.98px) {
  #view-admin .adm-act-det { display: none; }
  #view-admin .adm-act-row { flex-wrap: wrap; gap: 4px 10px; }
  #view-admin .adm-act-when { margin-left: auto; }
}

/* ============================== 11. section sweep ============================== */
/* callouts: neutral panel, the icon carries the warning (no coloured rails) */
#view-admin .v2p-voice-risk, #view-admin .v2p-voice-paused, #view-admin .v2p-cert-attn, #view-admin .v2p-notice, #view-admin .w3-upl-warn {
  border: 1px solid var(--line); border-left-width: 1px; border-left-color: var(--line); background: var(--surface);
}
#view-admin .v2p-token { border-color: var(--line); background: var(--surface-2); }
/* the toolbar sentence in Document types is body text, not a caption */
#view-admin .adm-lede-bar .v7d-muted.v2p-tabbar-text { font-size: var(--fs-13); color: var(--text-2); }
/* one primary per view: when a section's form already has its Save, header actions drop to secondary */
#view-admin .adm-main:has(.adm-content .panel .btn-primary) .adm-lede-bar .btn-primary:not(:disabled) {
  background: var(--surface); border-color: var(--line-strong); color: var(--text);
}
#view-admin .adm-main:has(.adm-content .panel .btn-primary) .adm-lede-bar .btn-primary:not(:disabled):hover { background: var(--surface-2); border-color: var(--line-hover); }
