/* ==========================================================================
   EVAMATS Dashboard Space v2 — utilitarian, keyboard-first
   ========================================================================== */

/* Fonts are served from this app (CSP font-src 'self'): Inter and JetBrains Mono, SIL OFL 1.1 (see fonts/OFL-*.txt). */
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url("fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url("fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url("fonts/inter-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-display: swap; font-weight: 400; src: url("fonts/jetbrains-mono-regular.woff2") format("woff2"); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-display: swap; font-weight: 500 700; src: url("fonts/jetbrains-mono-medium.woff2") format("woff2"); }


:root {
  color-scheme: light;
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f8f8fa;
  --hover: #f1f1f4;
  --selected: #ececf9;
  --border: #e3e3e8;
  --border-strong: #cfcfd7;
  --text: #17171c;
  --muted: #4d4d58;
  --faint: #6b6b76;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --green: #15803d;
  --amber: #a14f05;
  --red: #b91c1c;
  --blue: #1d4ed8;
  --gray: #5f5f6b;
  --violet: #6d28d9;
  --focus: #4338ca;
  --shadow: 0 1px 2px rgb(16 16 24 / .06), 0 8px 24px -12px rgb(16 16 24 / .18);
  --shadow-lg: 0 24px 60px -20px rgb(16 16 24 / .35);
  --scrim: rgb(16 16 24 / .4);
  --sb-thumb: rgb(23 23 28 / .22);
  --sb-track: transparent;

  --r: 10px;
  --r-sm: 7px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0c0f;
    --surface: #131317;
    --surface-2: #17171c;
    --hover: #1c1c22;
    --selected: #23233a;
    --border: #26262d;
    --border-strong: #34343d;
    --text: #ececf1;
    --muted: #b4b4bf;
    --faint: #8f8f9b;
    --accent: #8b8cf8;
    --accent-hover: #a5a6fb;
    --accent-soft: #1e1e3a;
    --on-accent: #0c0c18;
    --green: #4ade80;
    --amber: #fbbf24;
    --red: #f87171;
    --blue: #60a5fa;
    --gray: #a1a1aa;
    --violet: #c4b5fd;
    --focus: #8b8cf8;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / .7);
    --scrim: rgb(0 0 0 / .6);
    --sb-thumb: rgb(255 255 255 / .18);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0f;
  --surface: #131317;
  --surface-2: #17171c;
  --hover: #1c1c22;
  --selected: #23233a;
  --border: #26262d;
  --border-strong: #34343d;
  --text: #ececf1;
  --muted: #b4b4bf;
  --faint: #8f8f9b;
  --accent: #8b8cf8;
  --accent-hover: #a5a6fb;
  --accent-soft: #1e1e3a;
  --on-accent: #0c0c18;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --gray: #a1a1aa;
  --violet: #c4b5fd;
  --focus: #8b8cf8;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
  --shadow-lg: 0 24px 60px -20px rgb(0 0 0 / .7);
  --scrim: rgb(0 0 0 / .6);
  --sb-thumb: rgb(255 255 255 / .18);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--sb-thumb) var(--sb-track); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }

.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.i.sm { width: 14px; height: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.rows, .detail, .side, .page, .dlg-body, .table-wrap, textarea { scrollbar-width: thin; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-track { background: var(--sb-track); }
}
@media (prefers-contrast: more) {
  :root { --sb-thumb: var(--text); --border: var(--border-strong); }
}

kbd {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 500 11px var(--mono); color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* ---------- Tone helpers ---------- */
.tone-green { --tone: var(--green); }
.tone-amber { --tone: var(--amber); }
.tone-red { --tone: var(--red); }
.tone-blue { --tone: var(--blue); }
.tone-gray { --tone: var(--gray); }
.tone-violet { --tone: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--gray)); flex: none; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--tone); font-weight: 600; white-space: nowrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--tone, var(--muted));
  background: color-mix(in oklab, var(--tone, var(--gray)) 11%, transparent);
}
.badge .i { width: 13px; height: 13px; }
.env { font: 500 11px var(--mono); letter-spacing: .04em; color: var(--muted); padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 5px; }
.env.test { color: var(--blue); border-color: color-mix(in oklab, var(--blue) 45%, transparent); }

.mono {
  --h: 260;
  width: 36px; height: 36px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
  background: oklch(.55 .15 var(--h));
}
.mono.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 11px; }
.mono.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 16px; }
.mono.archived { background: var(--gray); }
.ava {
  --h: 260;
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 9.5px; font-weight: 700; color: #fff;
  background: oklch(.55 .12 var(--h));
}
.ava.md { width: 30px; height: 30px; font-size: 11px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn kbd { margin-left: 2px; background: transparent; }
.btn.primary kbd { color: inherit; border-color: color-mix(in oklab, var(--on-accent) 35%, transparent); }

.icon-btn {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent; color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.icon-btn[aria-pressed="true"].star { color: var(--amber); }
.icon-btn[aria-pressed="true"].star .i { fill: currentColor; }
.icon-btn.ok { color: var(--green); }

.input {
  width: 100%;
  height: 36px; padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; line-height: 1.5; }
.input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.input:user-invalid { border-color: var(--red); }
select.input {
  appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
}
@supports (appearance: base-select) {
  select.input, select.input::picker(select) { appearance: base-select; }
  select.input { display: flex; align-items: center; gap: 6px; background-image: none; padding-right: 8px; }
  select.input::picker-icon {
    content: ""; width: 14px; height: 14px; margin-left: auto;
    background: currentColor; color: var(--faint);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: rotate .2s var(--ease);
  }
  select.input:open::picker-icon { rotate: 180deg; }
  select.input:open { border-color: var(--accent); }
  select.input::picker(select) {
    margin-block: 4px;
    width: max-content;
    min-width: max(180px, anchor-size(width));
    max-height: min(320px, 60dvh);
    padding: 4px;
    border-radius: var(--r);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    scrollbar-width: thin;
  }
  select.input:open::picker(select) { animation: pop-in .14s var(--ease); }
  select.input option {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 6px;
    font-size: 13px; color: var(--muted); cursor: pointer;
  }
  select.input option:hover, select.input option:focus-visible { background: var(--hover); color: var(--text); outline: none; }
  select.input option:checked { color: var(--text); font-weight: 600; background: var(--accent-soft); }
  select.input option::checkmark { order: 1; margin-left: auto; color: var(--accent); }
}
@keyframes pop-in { from { opacity: 0; translate: 0 -4px; } }

.switch {
  appearance: none; margin: 0; flex: none;
  width: 34px; height: 20px; border-radius: 99px;
  background: var(--border-strong);
  position: relative; cursor: pointer;
  transition: background .15s;
}
.switch::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: translate .18s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch.secret:checked { background: var(--amber); }
.switch:checked::before { translate: 14px 0; }
.switch:disabled { opacity: .4; cursor: not-allowed; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--hover); }
.seg button, .seg label span {
  height: 28px; padding: 0 10px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.seg button[aria-pressed="true"], .seg button[aria-selected="true"], .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--focus); }

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: 236px minmax(320px, 400px) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
.app.is-page .listpane, .app.is-page .detail { display: none; }
.page { grid-column: 2 / -1; overflow-y: auto; container: page / inline-size; }

/* Sidebar */
.side {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-x: hidden; overflow-y: auto;
  padding: 14px 10px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 10px; }
.logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--text); flex: none; }
.logo svg { width: 16px; height: 16px; fill: var(--bg); }
.brand b { font-weight: 700; font-size: 14px; letter-spacing: .02em; display: block; line-height: 1.2; }
.brand span { font-size: 12px; color: var(--faint); }
.nav-group { display: grid; gap: 1px; margin-bottom: 14px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 6px 10px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 10px;
  border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted);
  font-size: 13.5px; font-weight: 500; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.nav-item .i { color: var(--faint); }
.nav-item[aria-current="true"] .i { color: var(--accent); }
.nav-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .n { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item .n.warn { color: var(--amber); font-weight: 700; }
.side-foot { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 6px; padding: 4px 6px; }
.me .icon-btn { width: 28px; height: 28px; }
.me .who { flex: 1; min-width: 0; line-height: 1.25; }
.me .who b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { font-size: 12px; color: var(--faint); }

/* List pane */
.listpane {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.list-head { display: flex; gap: 6px; align-items: center; padding: 12px 12px 8px; }
.menu-btn { display: none; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  transition: border-color .12s, box-shadow .12s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent); background: var(--surface); }
.search .i { color: var(--faint); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; font-size: 14px; }
.search input::placeholder { color: var(--faint); }
.list-sub { display: flex; align-items: center; gap: 8px; padding: 2px 12px 8px; border-bottom: 1px solid var(--border); }
.list-sub h1 { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub h1 span { color: var(--faint); font-weight: 500; margin-left: 4px; }
.list-sub .input { width: auto; height: 30px; font-size: 12.5px; }

.rows { list-style: none; margin: 0; padding: 4px 6px; overflow-y: auto; flex: 1; outline: none; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: var(--r-sm);
  cursor: pointer;
  scroll-margin: 8px;
}
.row:hover { background: var(--hover); }
.row[aria-selected="true"] { background: var(--selected); }
.rows:focus-visible .row[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--focus); }
.row .t { min-width: 0; display: grid; }
.row .t b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.row .t b .star-i { width: 12px; height: 12px; color: var(--amber); fill: currentColor; flex: none; }
.row .t small { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { display: flex; align-items: center; gap: 8px; }
.row .flag { width: 15px; height: 15px; color: var(--tone); }
.row mark { background: color-mix(in oklab, var(--amber) 28%, transparent); color: inherit; border-radius: 2px; }
.rows .group { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 10px 8px 4px; list-style: none; }
.rows .none { padding: 40px 16px; text-align: center; color: var(--muted); list-style: none; }
.rows .none b { display: block; color: var(--text); margin-bottom: 4px; }
.hints {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--faint);
}
.hints span { display: inline-flex; align-items: center; gap: 4px; }
.hints kbd { height: 18px; min-width: 18px; font-size: 10.5px; }

/* Detail pane */
.detail { overflow-y: auto; background: var(--bg); min-width: 0; position: relative; container: detail / inline-size; }
.ov { display: grid; gap: 20px; min-width: 0; }
.ov-sec { display: grid; gap: 8px; align-content: start; min-width: 0; }
.ov-sec .sec-title, .ov-wide .sec-title { margin-bottom: 0; }
.ov-wide { display: grid; gap: 8px; }
.ov .card { display: flex; flex-direction: column; }
.card-foot { margin: auto 0 0; display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; line-height: 1.5; color: var(--faint); }
.card-foot .i { margin-top: 2px; }
.d-purpose { font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 80ch; margin-top: -6px; }
@container detail (min-width: 1040px) {
  .detail .d-wrap { max-width: 1320px; padding-inline: 36px; }
  .ov { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; row-gap: 20px; }
  .ov-sec { grid-row: span 2; grid-template-rows: subgrid; row-gap: 8px; }
  .ov-wide { grid-column: 1 / -1; }
}
.d-wrap { max-width: 760px; margin: 0 auto; padding: 24px 28px 40px; display: grid; gap: 20px; }
.d-head { display: flex; align-items: flex-start; gap: 14px; }
.d-back { display: none; }
.d-title { flex: 1; min-width: 0; display: grid; gap: 6px; }
.d-title h2 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
.d-meta { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.d-tools { display: flex; gap: 4px; }
.d-open { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-open .url { flex: 1; min-width: 0; font: 400 12.5px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.kv { display: grid; }
.kv-row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 48px; padding: 8px 8px 8px 14px;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { font-size: 13px; color: var(--muted); }
.kv-row .v { min-width: 0; font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kv-row .v.code { font: 500 13px var(--mono); }
.kv-row .v .nw { white-space: nowrap; }
.kv-row .v .ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv-row .v a.link { color: var(--accent); }
.kv-row .v a.link:hover { text-decoration: underline; }
.kv-row .acts { display: flex; gap: 2px; align-items: center; }
.kv-row .acts kbd { margin-right: 4px; }
.kv-row.top { align-items: start; }
.kv-row ol { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-weight: 400; }
.kv-row ol li::marker { color: var(--faint); }

.secret .v { letter-spacing: .14em; }
.secret[data-state="shown"] .v { letter-spacing: 0; color: var(--text); }
.secret[data-state="loading"] .v { color: var(--faint); letter-spacing: 0; }
.secret .timer { font: 500 11.5px var(--mono); color: var(--amber); margin-right: 4px; }
.locked-row .v { color: var(--muted); font-weight: 400; font-size: 13px; letter-spacing: 0; gap: 8px; }
.locked-row .v .i { color: var(--faint); }

.purpose { font-size: 14.5px; line-height: 1.6; padding: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; color: var(--muted); padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border-strong); }
.note { padding: 12px 14px; font-size: 13.5px; color: var(--muted); border-left: 3px solid var(--amber); background: color-mix(in oklab, var(--amber) 6%, var(--surface)); border-radius: 0 var(--r) var(--r) 0; }
.foot-note { font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; line-height: 1.5; }
.foot-note .i { margin-top: 2px; }

.d-tabs { border-bottom: 1px solid var(--border); display: flex; gap: 2px; }
.d-tab {
  position: relative; height: 36px; padding: 0 12px;
  border: 0; background: none; color: var(--muted);
  font-weight: 600; font-size: 13.5px;
}
.d-tab:hover { color: var(--text); }
.d-tab[aria-selected="true"] { color: var(--text); }
.d-tab[aria-selected="true"]::after { content: ""; position: absolute; inset: auto 8px -1px; height: 2px; border-radius: 2px; background: var(--accent); }

.empty-detail { height: 100%; display: grid; place-content: center; text-align: center; gap: 8px; color: var(--faint); padding: 24px; }
.empty-detail .i { width: 32px; height: 32px; margin: 0 auto; }

.mobile-bar { display: none; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 4px 14px; }
.timeline li { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--tone); background: color-mix(in oklab, var(--tone) 12%, transparent); }
.timeline .ic .i { width: 14px; height: 14px; }
.timeline small { display: block; color: var(--faint); font-size: 12px; }

/* ---------- Pages (maintenance / access / audit) ---------- */
.page-wrap { max-width: 1320px; margin: 0 auto; padding: 28px 36px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.page-wrap .card { min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head > div { flex: 1; min-width: 260px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head .menu-btn { align-self: center; }
.stats { display: flex; gap: 8px 24px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.stats b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; font-weight: 600; flex: 1; }
.panel-head p { font-size: 12.5px; color: var(--faint); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--faint); padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }
.cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell b { font-weight: 600; white-space: nowrap; }
.cell small { display: block; font-size: 12px; color: var(--faint); white-space: nowrap; }
.cell.link { cursor: pointer; }
.cell.link:hover b { color: var(--accent); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.code { font-family: var(--mono); font-size: 12.5px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }

.access-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@container page (min-width: 900px) {
  .access-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .users-card { position: sticky; top: 16px; }
}
.u-meta { display: grid; justify-items: end; gap: 2px; flex: none; }
.u-meta small { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.perm-head { gap: 12px; }
.perm-head > div:not(.stats) { flex: 1; min-width: 0; }
.perm-head h2 { flex: none; }
.stats.sm { font-size: 12.5px; gap: 4px 16px; }
.stats.sm b { font-size: 14px; }
.perm .w-sw { width: 150px; }
.matrix .w-role { width: 190px; }
tr.grp td { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--faint); padding: 6px 14px; }
tbody tr.grp:hover { background: none; }
.user-list { padding: 4px; display: grid; gap: 1px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; width: 100%; }
.user-row:hover { background: var(--hover); }
.user-row[aria-pressed="true"] { background: var(--selected); }
.user-row .u { flex: 1; min-width: 0; line-height: 1.3; }
.user-row .u b { display: block; font-size: 13.5px; font-weight: 600; }
.user-row .u span { font-size: 12px; color: var(--faint); display: block; line-height: 1.35; }
.user-row .n { font-size: 12px; color: var(--faint); }
.yes { color: var(--green); }
.no { color: var(--faint); }
.part { color: var(--amber); font-size: 12.5px; font-weight: 600; }

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; min-width: 0; }
@container page (min-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr) 340px; } }
.nowrap { white-space: nowrap; }
table.fixed-acts .w-act { width: 1%; }
.empty-note { display: flex; align-items: center; gap: 10px; padding: 16px 14px; color: var(--muted); font-size: 13.5px; }
.empty-note .i { color: var(--green); }
.fold > summary { list-style: none; cursor: pointer; border-bottom: 0; }
.fold > summary::-webkit-details-marker { display: none; }
.fold[open] > summary { border-bottom: 1px solid var(--border); }
.fold > summary:hover { background: var(--hover); border-radius: var(--r); }
.fold .chev { rotate: -90deg; color: var(--faint); transition: rotate .2s var(--ease); }
.fold[open] .chev { rotate: 90deg; }
.imp { padding: 6px 14px 14px; }
.imp-file { display: flex; align-items: center; gap: 10px; padding: 12px; margin: 8px 0; border: 1px dashed var(--border-strong); border-radius: var(--r); font-size: 13px; color: var(--muted); }
.imp-file .i { color: var(--accent); width: 20px; height: 20px; }
.imp-file b { color: var(--text); display: block; }
.imp-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.imp-row:last-of-type { border-bottom: 0; }
.imp-row .t { flex: 1; min-width: 0; }
.imp-row .t b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-row .t span { display: block; font: 400 11.5px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Dialogs ---------- */
dialog {
  padding: 0; border: 1px solid var(--border-strong); color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  max-width: none; max-height: none;
  opacity: 0;
  transition-property: opacity, translate, display, overlay;
  transition-duration: .2s;
  transition-timing-function: var(--ease);
  transition-behavior: allow-discrete;
}
dialog[open]:where(:not([data-closing])) {
  opacity: 1; translate: 0 0;
  @starting-style { opacity: 0; }
}
dialog::backdrop {
  background-color: transparent;
  transition-property: background-color, display, overlay;
  transition-duration: .2s;
  transition-behavior: allow-discrete;
}
dialog[open]:where(:not([data-closing]))::backdrop { background-color: var(--scrim); }
@starting-style { dialog[open]:where(:not([data-closing]))::backdrop { background-color: transparent; } }

.modal { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); border-radius: 14px; translate: 0 10px; }
.modal[open]:where(:not([data-closing])) { @starting-style { translate: 0 10px; } }
.nav-sheet { position: fixed; inset: 0 auto 0 0; margin: 0; height: 100dvh; width: min(300px, 86vw); border-radius: 0 14px 14px 0; border-left: 0; translate: -24px 0; background: var(--bg); }
.nav-sheet[open]:where(:not([data-closing])) { @starting-style { translate: -24px 0; } }
.nav-sheet .side { display: flex; border: 0; height: 100%; }

.modal { overflow: hidden; }
.modal[open] { display: flex; flex-direction: column; }
.dlg { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { flex: 1; font-size: 16px; font-weight: 700; }
.dlg-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: grid; gap: 18px; container-type: inline-size; overscroll-behavior: contain; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.dlg-foot .hint { flex: 1; min-width: 200px; font-size: 12.5px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.fs { border: 0; margin: 0; padding: 0; min-width: 0; }
.fs legend { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 0; margin-bottom: 10px; }
.fgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@container (min-width: 520px) {
  .fgrid { grid-template-columns: 1fr 1fr; }
  .fgrid .span2 { grid-column: span 2; }
}
.field { display: grid; gap: 5px; min-width: 0; align-content: start; } /* fields in one row line up at the top */
.field > label, .field > .flabel { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .req { color: var(--red); }
.help { font-size: 12.5px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.dup { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--amber); background: color-mix(in oklab, var(--amber) 9%, var(--surface)); border: 1px solid color-mix(in oklab, var(--amber) 30%, transparent); }
.dup:empty { display: none; }
.dup .btn { margin-left: auto; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 20px; translate: -50% 0; display: grid; gap: 6px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r);
  background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s var(--ease) both;
}
.toast .i { color: color-mix(in oklab, var(--tone, var(--green)) 70%, var(--bg)); }
.toast.out { animation: toast-out .2s ease-in both; }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }
@keyframes toast-out { to { opacity: 0; translate: 0 4px; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
  .app > .side { display: none; }
  .menu-btn { display: grid; }
  .page { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); height: 100dvh; }
  .listpane { border-right: 0; }
  .hints { display: none; }
  .row { padding: 10px 8px; }
  .detail {
    position: fixed; inset: 0; z-index: 30;
    translate: 100% 0; visibility: hidden;
    transition: translate .25s var(--ease), visibility 0s .25s;
  }
  .app.show-detail .detail { translate: 0 0; visibility: visible; transition: translate .25s var(--ease); }
  .app.show-detail .detail { display: flex; flex-direction: column; }
  .d-wrap { padding: 8px 16px 20px; gap: 16px; flex: 1 0 auto; width: 100%; align-content: start; }
  .d-head {
    display: grid; gap: 4px 12px; align-items: start;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "back . tools" "mono title title";
  }
  .d-back { display: grid; grid-area: back; margin-left: -8px; }
  .d-tools { grid-area: tools; margin-right: -6px; }
  .d-head .mono.lg { grid-area: mono; width: 44px; height: 44px; margin-top: 2px; }
  .d-title { grid-area: title; }
  .d-title h2 { font-size: 20px; }
  .d-open .btn.primary { display: none; }
  .kv-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 8px 10px 12px; }
  .kv-row .k { grid-column: 1 / -1; font-size: 12px; }
  .kv-row .v { flex-wrap: wrap; row-gap: 2px; }
  .kv-row .acts kbd { display: none; }
  .mobile-bar {
    display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px;
    position: sticky; z-index: 2; bottom: 0;
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .mobile-bar .btn { height: 46px; font-size: 14px; }
  .page-wrap { padding: 16px 16px 40px; }
  .perm .w-sw { width: 72px; }
  .perm th.c { white-space: normal; font-size: 11px; }
  .perm td, .perm th { padding-inline: 10px; }
  .cell b { white-space: normal; }
  .fixed-acts thead { display: none; }
  .fixed-acts, .fixed-acts tbody { display: block; }
  .fixed-acts tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .fixed-acts tr:last-child { border-bottom: 0; }
  .fixed-acts td { display: block; padding: 0; border: 0; }
  .fixed-acts td:first-child { flex-basis: 100%; }
  .fixed-acts td.r { margin-left: auto; }
  .matrix .w-role { width: auto; }
  .toasts { bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  dialog, .detail { transition-duration: .01s !important; }
  dialog { translate: none; }
  .toast, select.input:open::picker(select) { animation: none !important; }
}

/* ==========================================================================
   Server-rendered app: additions to the v2 design
   ========================================================================== */
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.inline { display: inline; margin: 0; }

/* Avatar and monogram hues: classes instead of inline styles (CSP style-src 'self'). */
.h0 { --h: 10; } .h1 { --h: 40; } .h2 { --h: 70; } .h3 { --h: 145; } .h4 { --h: 175; } .h5 { --h: 200; }
.h6 { --h: 230; } .h7 { --h: 260; } .h8 { --h: 285; } .h9 { --h: 310; } .h10 { --h: 335; } .h11 { --h: 355; }

/* Switches rendered as submit buttons: work without JavaScript. */
button.switch { border: 0; padding: 0; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch.secret[aria-checked="true"] { background: var(--amber); }
.switch[aria-checked="true"]::before { translate: 14px 0; }

/* Side navigation: a grid column on wide screens, a popover sheet on narrow ones (no JS needed). */
a.nav-item { text-decoration: none; }
.side .nav-item.btnlike { cursor: pointer; }
.side-foot .row-actions { display: flex; align-items: center; gap: 4px; padding: 0 6px; }
.side-foot .row-actions form { margin: 0; }
.side-foot .langs { display: flex; gap: 2px; padding: 0 6px; }
.lang { height: 26px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--faint); font-size: 12px; font-weight: 600; }
.lang:hover { background: var(--hover); color: var(--text); }
.lang[aria-current="true"] { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.me .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 1101px) {
  .app > .side[popover] { position: static; inset: auto; width: auto; height: auto; margin: 0; border: 0; border-right: 1px solid var(--border); padding: 14px 10px 10px; color: inherit; background: var(--bg); overflow-y: auto; display: flex; }
}
@media (max-width: 1100px) {
  .app > .side[popover] { display: none; }
  .app > .side[popover]:popover-open {
    display: flex; position: fixed; inset: 0 auto 0 0; margin: 0; height: 100dvh; width: min(300px, 86vw);
    border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 14px 14px 0; box-shadow: var(--shadow-lg);
  }
  .app > .side[popover]::backdrop { background: var(--scrim); }
}

/* List rows are links. */
.rows li.item { list-style: none; }
a.row { color: inherit; text-decoration: none; }
.rows .row.on { background: var(--selected); }
.rows:focus-visible .row.on { box-shadow: inset 0 0 0 2px var(--focus); }
.list-sub form { display: contents; }
.list-sub .icon-btn.bordered { color: var(--text); }

/* Card detail */
.d-tools form { margin: 0; }
a.icon-btn { color: var(--muted); }
.cred-head { padding: 10px 14px 0; font-size: 12px; font-weight: 600; color: var(--faint); }
.kv + .cred-head { border-top: 1px solid var(--border); }
.kv-row .v .pre { white-space: pre-wrap; font-weight: 400; }
.kv-row .v .muted { font-weight: 400; }
.kv-row form { margin: 0; }
.notes-text { padding: 12px 14px; font-size: 13.5px; color: var(--muted); white-space: pre-wrap; }
.note { white-space: pre-wrap; }
.grant-role td:first-child b { font-weight: 600; }

/* Pages */
.page-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .input { width: auto; min-width: 150px; height: 32px; font-size: 13px; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--faint); }
.pager .acts { display: flex; gap: 6px; }
a.user-row { color: inherit; text-decoration: none; }
.perm-head .acts { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.perm-head .acts form { margin: 0; display: flex; gap: 6px; }
.perm-head .acts .input { width: auto; height: 28px; font-size: 12.5px; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bulk .search { flex: 1 1 220px; height: 32px; }
.bulk .sel { font-size: 12.5px; color: var(--faint); }
td.chk, th.chk { width: 1%; }
.badge.red-txt { color: var(--red); }
.cats { display: grid; }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: 0; }
.cat-row form { margin: 0; display: flex; align-items: center; gap: 8px; }
.cat-row form.grow { flex: 1; min-width: 0; }
.cat-row .n { font-size: 12px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.add-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.imp-form { padding: 14px; display: grid; gap: 12px; }
.imp-form p { font-size: 13px; color: var(--muted); }
.imp-form code { font: 12px var(--mono); }
.link-box { display: flex; gap: 8px; align-items: center; padding: 14px; }
.link-box .code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); font-size: 13.5px; border: 1px solid color-mix(in oklab, var(--tone, var(--red)) 30%, transparent); color: var(--tone, var(--red)); background: color-mix(in oklab, var(--tone, var(--red)) 8%, var(--surface)); }
.alert .i { margin-top: 2px; }
.alert.tone-green { --tone: var(--green); }
.alert.tone-blue { --tone: var(--blue); }
.alert.tone-amber { --tone: var(--amber); }
.page-msg { max-width: 1320px; margin: 16px auto 0; padding: 0 36px; }

/* Editor in the catalog's right pane, next to the list; fills the pane. */
.editor { max-width: 1320px; margin: 0 auto; padding: 24px 28px 48px; }
.editor .card { overflow: clip; }
.editor .dlg-body { overflow: visible; padding: 20px 22px; gap: 22px; }
.editor .dlg-foot { position: sticky; bottom: 0; z-index: 1; }
@container (min-width: 900px) { /* wide pane: four columns, short fields share a row */
  .editor .fgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 16px; }
  .editor .fgrid .full { grid-column: 1 / -1; }
}
.field .err { font-size: 12.5px; color: var(--red); }
.field .desc { font-size: 12.5px; color: var(--faint); }
.input.invalid { border-color: var(--red); }
.creds { display: grid; gap: 10px; }
.cred { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.cred-top { display: flex; gap: 8px; align-items: flex-end; }
.cred-top .field { flex: 1; }

/* Auth pages */
.auth { min-height: 100dvh; display: grid; place-content: center; gap: 14px; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(400px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.auth-card .lead { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn.primary { width: 100%; height: 40px; }
.auth-card .foot { font-size: 12.5px; color: var(--faint); }
.auth-card .links { display: grid; gap: 8px; justify-items: center; text-align: center; }
.auth-card .links a { color: var(--accent); font-size: 13px; }
.auth-card .links .btn { height: 28px; }
.wordmark { display: grid; justify-items: center; gap: 10px; padding: 0 0 8px; }
.wordmark img { height: 42px; width: auto; display: block; }
.wordmark span { font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.wordmark .on-dark { display: none; }
:root[data-theme="dark"] .wordmark .on-light { display: none; }
:root[data-theme="dark"] .wordmark .on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark .on-light { display: none; }
  :root:not([data-theme="light"]) .wordmark .on-dark { display: block; }
}
.auth .langs { display: flex; align-items: center; justify-content: center; gap: 4px; }
.auth .theme-toggle { display: flex; }
.auth .sep { width: 1px; height: 14px; margin: 0 6px; background: var(--border-strong); }
.auth .theme-toggle .icon-btn { width: 26px; height: 26px; }
.otp { font: 500 22px var(--mono); letter-spacing: .35em; text-align: center; height: 48px; }
.qr { width: 204px; height: 204px; justify-self: center; border-radius: var(--r); background: #fff; padding: 10px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.codes code { font: 500 13px var(--mono); padding: 6px 8px; text-align: center; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
details.small summary { cursor: pointer; font-size: 13px; color: var(--faint); }
details.small code { display: block; margin-top: 6px; font: 12.5px var(--mono); overflow-wrap: anywhere; }

/* Step-up dialog (server-rendered) */
.modal.narrow { width: min(420px, calc(100vw - 24px)); }
.modal .error-text { color: var(--red); font-size: 13px; min-height: 1em; }

/* Not found */
.empty-page { max-width: 560px; margin: 12vh auto 0; padding: 0 24px; display: grid; gap: 12px; justify-items: start; }
.empty-page h1 { font-size: 22px; font-weight: 700; }
.empty-page p { color: var(--muted); }

@media (max-width: 760px) {
  .app.has-detail .detail { translate: 0 0; visibility: visible; display: flex; flex-direction: column; transition: none; }
  .editor { padding: 16px 12px 32px; }
  .editor .dlg-foot .hint { display: none; } /* keep both buttons on one line */
  .editor .dlg-foot { justify-content: flex-end; }
  .page-msg { padding: 0 16px; }
  .toolbar .input { min-width: 0; flex: 1 1 140px; }
  .bulk .search { flex-basis: 100%; }
}
.hidden { display: none !important; }
[data-block] { display: block; }
.user-row[aria-current="true"] { background: var(--selected); }
.add-user { padding: 10px 10px 0; }
.add-user > summary { list-style: none; width: 100%; }
.add-user > summary::-webkit-details-marker { display: none; }
.add-user[open] > summary { margin-bottom: 4px; }
.add-user .imp-form { padding: 6px 0 10px; border-bottom: 1px solid var(--border); }
.perm .w-chk { width: 44px; }
.btn.tone-red { color: var(--red); }
.group-bulk { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.imp-form .imp-file { margin: 0; }
.desc { font-size: 12.5px; color: var(--faint); }
a.desc { color: var(--accent); }
a.desc:hover { text-decoration: underline; }
.dlg-head .menu-btn { margin-left: -6px; }
@media (max-width: 1100px) {
  .app > .side[popover]:popover-open { padding: 14px 10px 10px; color: var(--text); background: var(--bg); overflow-y: auto; flex-direction: column; }
}
.users-card { overflow: hidden; }
.user-row .u span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perm-head .acts { flex: 1 1 100%; }
.field .seg { width: max-content; align-self: start; }
@container page (min-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr); } }
@container page (min-width: 1360px) { .split { grid-template-columns: minmax(0, 1fr) 320px; } }
.user-list > * { min-width: 0; }
.user-row .u b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .u-meta .badge { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
