/* Imperial Claims Desk: "Imperial Glass" (CONTRACT 12). Tokens, the shell, and the UI kit every view uses.
   Dark by default (html[data-theme="dark"]); light ivory with html[data-theme="light"]. Every text color is measured
   at ≥ 4.5:1 on the surfaces it sits on (test/contrast.test.ts reads the tokens from this file).
   Feature styles go in /css/<feature>.css (loadCss() in app.js) and use only these variables. */

/* ---------- fonts (self-hosted, OFL) ---------- */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-wght-italic.woff2') format('woff2'); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Cormorant Garamond'; src: url('/fonts/cormorant-garamond-latin-wght-normal.woff2') format('woff2'); font-weight: 300 700; font-style: normal; font-display: swap; }

/* ---------- tokens ---------- */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #150D20;
  --glow-1: rgba(91, 58, 140, .35);
  --glow-2: rgba(200, 164, 90, .16);
  --pane: rgba(31, 21, 48, .62);
  --pane-solid: #1D1430;
  --pane-2: rgba(40, 27, 61, .9);
  --pane-2-solid: #251937;
  --hover: rgba(255, 255, 255, .05);
  --press: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --text: #F3EEF8;
  --text-2: #B8AECB;
  --text-3: #A99EBD;
  --gold-text: #D9B96E;
  --accent: #CDB8F5;
  --accent-bg: rgba(155, 120, 220, .18);
  --primary-1: #D9B96E;
  --primary-2: #B8913F;
  --primary-ink: #2A1840;
  --secondary: #5B3A8C;
  --secondary-hover: #6A47A0;
  --secondary-ink: #FFFFFF;
  --secondary-line: transparent;
  --danger: #FFA3A3;
  --danger-bg: rgba(255, 107, 107, .14);
  --danger-solid: #B8322C;
  --amber: #F4C774;
  --amber-bg: rgba(244, 199, 116, .14);
  --blue: #A6CFFF;
  --blue-bg: rgba(120, 170, 255, .14);
  --green: #93DFB3;
  --green-bg: rgba(110, 210, 150, .14);
  --gray: #C4BAD6;
  --gray-bg: rgba(255, 255, 255, .08);
  --gold-bg: rgba(217, 185, 110, .14);
  --purple-bg: rgba(155, 120, 220, .2);
  --banner-bg: rgba(217, 185, 110, .12);
  --banner-line: rgba(217, 185, 110, .28);
  --banner-text: #EBD49C;
  --input-bg: rgba(255, 255, 255, .05);
  --input-line: rgba(255, 255, 255, .18);
  --focus: #D9B96E;
  --scrim: rgba(8, 4, 14, .62);
  --shadow: 0 12px 32px rgba(0, 0, 0, .38);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .25);
  --sk: rgba(255, 255, 255, .07);
  --sk-hi: rgba(255, 255, 255, .13);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #FAF7F1;
  --glow-1: rgba(91, 58, 140, .09);
  --glow-2: rgba(200, 164, 90, .16);
  --pane: rgba(255, 255, 255, .7);
  --pane-solid: #FFFFFF;
  --pane-2: rgba(255, 255, 255, .94);
  --pane-2-solid: #FFFFFF;
  --hover: rgba(30, 21, 41, .045);
  --press: rgba(30, 21, 41, .08);
  --line: rgba(30, 21, 41, .1);
  --line-2: rgba(30, 21, 41, .18);
  --text: #1E1529;
  --text-2: #554A63;
  --text-3: #62576F;
  --gold-text: #7E5F1E;
  --accent: #5B3A8C;
  --accent-bg: rgba(91, 58, 140, .1);
  --primary-1: #6A47A0;
  --primary-2: #5B3A8C;
  --primary-ink: #FFFFFF;
  --secondary: #FFFFFF;
  --secondary-hover: #F4EFF9;
  --secondary-ink: #5B3A8C;
  --secondary-line: rgba(91, 58, 140, .35);
  --danger: #B42318;
  --danger-bg: rgba(180, 35, 24, .08);
  --danger-solid: #B42318;
  --amber: #875400;
  --amber-bg: rgba(214, 150, 30, .14);
  --blue: #1D5BB0;
  --blue-bg: rgba(29, 95, 184, .09);
  --green: #146540;
  --green-bg: rgba(27, 122, 75, .1);
  --gray: #554A63;
  --gray-bg: rgba(30, 21, 41, .07);
  --gold-bg: rgba(200, 164, 90, .18);
  --purple-bg: rgba(91, 58, 140, .1);
  --banner-bg: rgba(200, 164, 90, .16);
  --banner-line: rgba(126, 95, 30, .28);
  --banner-text: #5E4512;
  --input-bg: rgba(255, 255, 255, .92);
  --input-line: rgba(30, 21, 41, .24);
  --focus: #5B3A8C;
  --scrim: rgba(30, 21, 41, .38);
  --shadow: 0 12px 32px rgba(42, 24, 64, .14);
  --shadow-sm: 0 2px 10px rgba(42, 24, 64, .08);
  --sk: rgba(30, 21, 41, .06);
  --sk-hi: rgba(30, 21, 41, .11);
}
:root {
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --blur: 24px;
  --r: 14px;
  --r-sm: 10px;
  --r-xs: 7px;
  --rail-w: 236px;
  --tab-h: 62px;
  --gap: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font: 400 15px/1.5 var(--font); color: var(--text); background-color: var(--bg);
  background-image:
    radial-gradient(900px 600px at 12% -8%, var(--glow-1), transparent 62%),
    radial-gradient(760px 520px at 105% 108%, var(--glow-2), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-bg); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.gold { color: var(--gold-text); }
.mono { font-family: var(--mono); font-size: .92em; }
.serif { font-family: var(--serif); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }
.icon { flex: none; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack.tight { gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: grid; place-items: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- glass ---------- */
.glass, .card, .rail, .topbar, .tabbar, .modal, .toast, .callbar:not(:empty) {
  background: var(--pane); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.2); backdrop-filter: blur(var(--blur)) saturate(1.2);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .card, .rail, .topbar, .tabbar, .callbar:not(:empty) { background: var(--pane-solid); }
  .modal, .toast { background: var(--pane-2-solid); }
}

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 14px; border-width: 0 1px 0 0; border-radius: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 700 22px/1 var(--serif); letter-spacing: .14em; color: var(--text); }
.brand-sub { font: 600 10.5px/1 var(--font); letter-spacing: .24em; color: var(--gold-text); margin-top: 5px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 550; text-decoration: none; transition: background .15s, color .15s; }
.rail-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.rail-link.active { background: var(--accent-bg); color: var(--text); }
.rail-link.active .nav-icon { color: var(--gold-text); }
html[data-theme="light"] .rail-link.active .nav-icon { color: var(--accent); }
.nav-icon { position: relative; display: inline-flex; }
.nav-badge { position: absolute; top: -6px; right: -9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger-solid); color: #FFFFFF; font: 700 11px/18px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.nav-badge.static { position: static; box-shadow: none; margin-left: auto; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 4px 0; border-top: 1px solid var(--line); }
.me-chip { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text); flex: 1; min-width: 0; text-decoration: none; }
.me-chip:hover { background: var(--hover); text-decoration: none; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.avatar { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #5B3A8C, #2A1840); color: #F3EEF8; font: 650 12.5px/1 var(--font); letter-spacing: .04em; border: 1px solid var(--line-2); }
.rt-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); margin-right: 8px; }
.rt-dot[data-rt="live"] { background: #5BD08F; box-shadow: 0 0 0 3px rgba(91, 208, 143, .18); }
.rt-dot[data-rt="down"] { background: #F4C774; }

.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 24px; border-width: 0 0 1px; border-radius: 0; position: relative; z-index: 2; }
.topbar-mark { display: none; }
.page-title { font-size: 20px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.banner { display: flex; align-items: flex-start; gap: 10px; margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--banner-bg); border: 1px solid var(--banner-line); color: var(--banner-text); font-size: 13.5px; line-height: 1.45; }
.banner .icon { margin-top: 1px; color: var(--gold-text); }
.view { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 24px 32px; outline: none; scrollbar-gutter: stable; }
.view > * + * { margin-top: var(--gap); }
.callbar:empty { display: none; }
.callbar:not(:empty) { border-width: 1px 0 0; border-radius: 0; }
.tabbar { display: none; }

@media (max-width: 768px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rail { display: none; }
  .main-col { height: auto; min-height: 0; }
  .topbar { min-height: 54px; padding: 8px 16px; }
  .topbar-mark { display: block; }
  .page-title { font-size: 18px; }
  .banner { margin: 10px 16px 0; font-size: 12.5px; padding: 8px 12px; cursor: pointer; }
  .banner:not(.open) .banner-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .view { padding: 16px 16px 24px; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px 4px calc(4px + var(--safe-b)); border-width: 1px 0 0; border-radius: 0; z-index: 3; }
  .tab-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 4px 2px; border: 0; background: none; border-radius: var(--r-sm); color: var(--text-2); font: 600 11px/1.1 var(--font); text-decoration: none; cursor: pointer; }
  .tab-link:hover { text-decoration: none; }
  .tab-link.active { color: var(--text); }
  .tab-link.active .nav-icon { color: var(--gold-text); }
  html[data-theme="light"] .tab-link.active .nav-icon { color: var(--accent); }
  .tab-link .nav-badge { top: -4px; right: -10px; }
}
.more-list { display: flex; flex-direction: column; }
.more-link { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 6px; color: var(--text); border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 550; }
.more-link:last-child { border-bottom: 0; }
.more-link:hover { text-decoration: none; background: var(--hover); }
.more-link > span:first-of-type { flex: 1; }

/* ---------- cards ---------- */
.card { border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 16px 18px 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 650; }
.card-sub { font-size: 13.5px; margin-top: 3px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin: 4px 0 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--r-sm); background: var(--hover); border: 1px solid var(--line); }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12.5px; color: var(--text-2); }
.kv { display: grid; gap: 8px; }
.kv-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 32px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row > :first-child { flex: none; white-space: nowrap; }
.kv-row > :last-child { min-width: 0; text-align: right; overflow-wrap: anywhere; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-sm); border: 1px solid transparent; font: 600 14.5px/1 var(--font); letter-spacing: .005em;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--primary-1), var(--primary-2)); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px rgba(0, 0, 0, .2); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn.secondary { background: var(--secondary); color: var(--secondary-ink); border-color: var(--secondary-line); }
.btn.secondary:hover:not(:disabled) { background: var(--secondary-hover); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { background: var(--danger-solid); color: #FFFFFF; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 550; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field-hint { font-size: 12.5px; color: var(--text-2); margin: 0; }
.field-error { font-size: 13px; color: var(--danger); margin: 6px 0 0; font-weight: 550; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--input-line);
  background: var(--input-bg); color: var(--text); font-size: 16px; line-height: 1.35; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--line-2); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-bg); }
.input.pin { letter-spacing: .4em; font-variant-numeric: tabular-nums; font-size: 20px; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--secondary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .field + .field { margin-top: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* ---------- chips, pills, badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font: 600 13.5px/1 var(--font); cursor: pointer; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip.on { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.chip-count { font-size: 12px; padding: 2px 7px; border-radius: 999px; background: var(--gray-bg); color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font: 650 12px/1.3 var(--font); white-space: nowrap; }
.tone-red { color: var(--danger); background: var(--danger-bg); }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-blue { color: var(--blue); background: var(--blue-bg); }
.tone-green { color: var(--green); background: var(--green-bg); }
.tone-gray { color: var(--gray); background: var(--gray-bg); }
.tone-gold { color: var(--gold-text); background: var(--gold-bg); }
.tone-purple { color: var(--accent); background: var(--purple-bg); }
.badge { display: inline-block; min-width: 20px; padding: 2px 6px; border-radius: 999px; font: 700 11.5px/1.3 var(--font); text-align: center; }
.badge.tone-red { background: var(--danger-solid); color: #FFFFFF; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; margin-bottom: 14px; }
.notice .icon { margin-top: 1px; }

/* ---------- lists + tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row.link { cursor: pointer; border-radius: var(--r-xs); }
.list-row.link:hover { background: var(--hover); }
.list-title { font-weight: 600; }
.list-sub { font-size: 13px; color: var(--text-2); }
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font: 650 12px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.link { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl .num { text-align: right; }
@media (max-width: 768px) {
  /* Tables become stacked cards on phones: each cell shows its data-label. */
  .tbl.stack-sm thead { display: none; }
  .tbl.stack-sm, .tbl.stack-sm tbody, .tbl.stack-sm tr, .tbl.stack-sm td { display: block; width: 100%; }
  .tbl.stack-sm tr { padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .tbl.stack-sm td { border: 0; padding: 3px 4px; display: flex; justify-content: space-between; gap: 12px; }
  .tbl.stack-sm td[data-label]::before { content: attr(data-label); color: var(--text-2); font-size: 12.5px; font-weight: 600; }
}

/* ---------- empty + skeleton + spinner ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 28px 16px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-bg); color: var(--gold-text); margin-bottom: 4px; }
html[data-theme="light"] .empty-icon { color: var(--accent); }
.empty-title { font-weight: 650; font-size: 15.5px; margin: 0; }
.empty-body { max-width: 46ch; margin: 0 0 8px; }
.skeleton { display: grid; gap: 12px; }
.skeleton-cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.sk-item { padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--pane); }
.skeleton-rows .sk-item { padding: 12px 14px; }
.sk-line { height: 11px; border-radius: 6px; margin: 7px 0; background: linear-gradient(90deg, var(--sk) 25%, var(--sk-hi) 37%, var(--sk) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; }
.sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; } .sk-line.w90 { width: 90%; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { display: inline-block; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal, sheet, side panel ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: var(--scrim); opacity: 0; transition: opacity .18s var(--ease); }
.overlay.in { opacity: 1; }
.overlay.out { opacity: 0; }
.modal { display: flex; flex-direction: column; width: 100%; max-height: min(86vh, 900px); border-radius: 18px; background: var(--pane-2); box-shadow: var(--shadow); border-color: var(--line-2); transform: translateY(8px) scale(.985); transition: transform .2s var(--ease); outline: none; }
.overlay.in .modal { transform: none; }
.modal.size-sm { max-width: 420px; }
.modal.size-md { max-width: 560px; }
.modal.size-lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 6px 20px; }
.modal-title { flex: 1; font-size: 17px; }
.modal-body { padding: 8px 20px 18px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.modal.as-sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: none; max-height: 88vh; border-radius: 20px 20px 0 0; border-width: 1px 0 0; padding-bottom: var(--safe-b); transform: translateY(24px); }
.overlay:has(.as-sheet) { place-items: end stretch; padding: 0; }
.modal.as-sheet .modal-foot .btn { flex: 1 1 140px; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; }
.modal.as-side { position: fixed; top: 0; right: 0; bottom: 0; max-width: 460px; max-height: none; border-radius: 18px 0 0 18px; transform: translateX(24px); }
.overlay:has(.as-side) { place-items: stretch end; padding: 0; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 768px) { #toasts { bottom: calc(var(--tab-h) + 16px + var(--safe-b)); } }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: var(--r-sm); background: var(--pane-2); box-shadow: var(--shadow); border-color: var(--line-2); color: var(--text); pointer-events: auto; animation: toast-in .2s var(--ease); }
.toast.tone-ok, .toast.tone-err, .toast.tone-info { background: var(--pane-2); }
.toast.tone-ok .icon { color: var(--green); }
.toast.tone-err .icon { color: var(--danger); }
.toast.tone-info .icon { color: var(--accent); }
.toast-text { flex: 1; font-size: 14px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- sign-in ---------- */
.auth-page, #auth { min-height: 100vh; min-height: 100dvh; }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 26px 20px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-mark { width: 56px; height: 56px; }
.auth-words { display: flex; flex-direction: column; line-height: 1; }
.auth-name { font: 700 32px/1 var(--serif); letter-spacing: .12em; text-transform: uppercase; }
.auth-sub { font: 600 11.5px/1 var(--font); letter-spacing: .26em; text-transform: uppercase; color: var(--gold-text); margin-top: 7px; }
.auth-title { font-size: 19px; margin-bottom: 14px; }
.auth-form .btn.block { margin-top: 18px; }
.auth-hint { font-size: 13px; margin-top: 14px; text-align: center; }
.auth-foot { display: flex; justify-content: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lang-switch { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid var(--line-2); }
.lang-btn { min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; }
.lang-btn.on { background: var(--accent-bg); color: var(--text); }
#sso-card { text-align: center; display: grid; justify-items: center; gap: 14px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--gap); align-items: start; }
@media (max-width: 420px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.team-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: 0; }
.team-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.team-row .list-title, .team-row .list-sub { overflow-wrap: anywhere; }
/* The team card sits in a ~370 px column at desktop widths: with a member's actions beside it the name column was squeezed
   to one letter per line. Under 560 px of card width the role and actions go below the name. */
.team-list { container-type: inline-size; }
@container (max-width: 560px) { .team-row { grid-template-columns: auto minmax(0, 1fr); } .team-row > :last-child { grid-column: 2 / -1; align-items: flex-start !important; } .team-row > :last-child .row { justify-content: flex-start !important; } }
@media (max-width: 480px) { .team-row { grid-template-columns: auto minmax(0, 1fr); } .team-row > :last-child { grid-column: 1 / -1; align-items: stretch !important; } .team-row > :last-child .row { justify-content: flex-start !important; } }
.coming { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 16px; }

/* ---------- 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; }
}
