/* Story Becomes staff app. shadcn/ui look, apollo-style palette: neutral ground, white cards, indigo accent.
   Tokens on :root; dark mode follows the system. No third-party fonts or scripts. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #101828;
  --fg-soft: #344054;
  --muted: #f1f3f7;
  --muted-fg: #667085;
  --border: #e4e7ec;
  --input: #d0d5dd;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-fg: #ffffff;
  --primary-soft: #eef0ff;
  --accent-text: #4338ca;
  --ring: rgba(79, 70, 229, 0.35);
  --ok: #067647;
  --ok-soft: #e7f6ec;
  --warn: #b54708;
  --warn-soft: #fef4e6;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --bad-fill: #b42318; /* behind white text: 6.5:1 */
  --info: #175cd3;
  --info-soft: #eaf1fd;
  --neutral: #475467;
  --neutral-soft: #f0f2f5;
  --tip-bg: #101828;
  --tip-fg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 20px 40px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Inter", "InterVariable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --card: #12151d;
    --fg: #e8eaf0;
    --fg-soft: #c5cad6;
    --muted: #1a1f2b;
    --muted-fg: #98a1b3;
    --border: #252b39;
    --input: #343c4f;
    --primary: #5a54ea;
    --primary-hover: #6d68f0;
    --primary-fg: #ffffff;
    --primary-soft: #1d1f45;
    --accent-text: #a5b4fc;
    --ring: rgba(129, 140, 248, 0.5);
    --ok: #4ade80;
    --ok-soft: #10261a;
    --warn: #fbbf24;
    --warn-soft: #2a2010;
    --bad: #f87171;
    --bad-soft: #2c1416;
    --bad-fill: #dc2626; /* #f87171 is for text; white on it is only 2.8:1, on this 4.8:1 */
    --info: #93b4ff;
    --info-soft: #152039;
    --neutral: #b3bccd;
    --neutral-soft: #1c2130;
    --tip-bg: #e8eaf0;
    --tip-fg: #0b0d12;
    --shadow: none;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted-fg); }
.small { font-size: 12.5px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- icons -- */
.ic { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.ic-sm { display: inline-flex; width: 13px; height: 13px; flex: none; }
.ic-sm svg { width: 100%; height: 100%; }

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--muted); color: var(--fg);
  font-weight: 550; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--card); border-color: var(--input); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--muted); }
.btn-danger { background: var(--bad-fill); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-danger-outline { background: var(--card); border-color: var(--input); color: var(--bad); }
.btn-danger-outline:hover { background: var(--bad-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled { pointer-events: none; }
.btn.is-disabled:hover { background: var(--card); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 0;
  background: transparent; color: var(--muted-fg); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--muted); color: var(--fg); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); cursor: pointer; font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }

/* --------------------------------------------------------------- inputs -- */
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--input); background: var(--card); color: var(--fg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted-fg) 50%), linear-gradient(135deg, var(--muted-fg) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.select-sm { height: 30px; font-size: 13px; padding: 0 28px 0 10px; background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px; width: auto; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input:disabled, .select:disabled { opacity: 0.6; cursor: not-allowed; }
.input-num { width: 110px; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; }
.label { font-weight: 550; font-size: 13.5px; }
.hint { color: var(--muted-fg); font-size: 12.5px; }
.field-error { color: var(--bad); font-size: 12.5px; }
.form { display: grid; gap: 16px; }
.pw-row { position: relative; }
.pw-row .input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 5px; height: 28px; padding: 0 8px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-fg); font-size: 12.5px; cursor: pointer; }
.pw-toggle:hover { background: var(--muted); color: var(--fg); }

/* switch */
.switch {
  position: relative; width: 40px; height: 22px; border-radius: 999px; border: 0; flex: none;
  background: var(--input); cursor: pointer; transition: background 0.15s; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; cursor: pointer; }
input[type="checkbox"]:disabled { cursor: not-allowed; pointer-events: none; }

/* --------------------------------------------------------- badges, nums -- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
  max-width: 100%; min-width: 0;
}
.badge-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral); }
.tone-accent { background: var(--primary-soft); color: var(--accent-text); }
.num {
  font-variant-numeric: tabular-nums; cursor: help;
  text-decoration: underline dotted color-mix(in srgb, var(--muted-fg) 70%, transparent);
  text-underline-offset: 3px;
}
[data-tip] { cursor: help; }
button[data-tip], a[data-tip], .btn[data-tip] { cursor: pointer; }
.btn.is-disabled[data-tip] { cursor: not-allowed; }

/* -------------------------------------------------------------- tooltip -- */
.tip {
  position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px; border-radius: 8px; background: var(--tip-bg); color: var(--tip-fg);
  font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-lg); pointer-events: none;
  white-space: pre-line; overflow-wrap: anywhere; margin: 0;
}

/* ------------------------------------------------------------------ alerts -- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.alert .ic { margin-top: 2px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); color: var(--fg-soft); font-size: 13.5px; }

/* ------------------------------------------------------------------ toasts -- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 900; display: grid; gap: 8px; max-width: calc(100vw - 32px); width: 360px; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 14px; border-radius: var(--radius);
  background: var(--card); color: var(--fg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px;
}
.toast-text { flex: 1; }
.toast.tone-ok { border-left: 3px solid var(--ok); }
.toast.tone-bad { border-left: 3px solid var(--bad); }
.toast.tone-warn { border-left: 3px solid var(--warn); }

/* ------------------------------------------------------------------ topbar -- */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mark { width: 26px; height: 26px; flex: none; display: block; }
.tabs { display: flex; gap: 2px; align-items: center; min-width: 0; }
.tab { display: inline-flex; align-items: center; height: 32px; padding: 0 11px; border-radius: var(--radius-sm); color: var(--muted-fg); font-weight: 550; font-size: 13.5px; white-space: nowrap; }
.tab:hover { color: var(--fg); background: var(--muted); text-decoration: none; }
.tab[aria-current="page"] { color: var(--fg); background: var(--muted); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-text { color: var(--muted-fg); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.who-text strong { color: var(--fg); font-weight: 600; }

/* -------------------------------------------------------------------- page -- */
.container { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.page-sub { color: var(--muted-fg); font-size: 13.5px; margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.section-title { font-size: 15px; font-weight: 620; margin: 28px 0 10px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted-fg); }
.empty strong { display: block; color: var(--fg); font-weight: 600; margin-bottom: 4px; }
.center-msg { max-width: 460px; margin: 60px auto; text-align: center; display: grid; gap: 12px; justify-items: center; }

/* skeleton */
.skeleton-list { display: grid; gap: 10px; padding: 16px; }
.skeleton { height: 44px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--muted) 0%, var(--neutral-soft) 50%, var(--muted) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ----------------------------------------------------------------- filters -- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--fg-soft); font-weight: 550; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--input); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--card); border-color: var(--fg); }
.chip .count { font-variant-numeric: tabular-nums; font-size: 12px; padding: 0 6px; border-radius: 999px; background: var(--muted); color: var(--muted-fg); text-underline-offset: 2px; }
.chip[aria-pressed="true"] .count { background: color-mix(in srgb, var(--card) 22%, transparent); color: var(--card); text-decoration-color: currentColor; }

.pill-status { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: 12.5px; color: var(--fg-soft); font-weight: 550; }
.pill-status .ic-sm { color: var(--muted-fg); }
.pill-status.tone-ok .ic-sm { color: var(--ok); }
.pill-status.tone-warn .ic-sm { color: var(--warn); }
.pill-status.tone-bad .ic-sm { color: var(--bad); }
.pill-status[class*="tone-"] { background: var(--card); color: var(--fg-soft); }

/* ------------------------------------------------------------------- board -- */
.board-grid { display: grid; grid-template-columns: minmax(200px, 2.4fr) minmax(150px, 1fr) minmax(70px, 0.7fr) minmax(90px, 0.8fr) minmax(70px, 0.6fr) auto; }
.b-head, .b-row, .b-body { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.b-head, .b-row { column-gap: 14px; align-items: center; padding: 12px 16px; }
.b-body { row-gap: 0; }
.b-head { font-size: 12px; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px; }
.b-row { border-bottom: 1px solid var(--border); }
.b-row:last-child { border-bottom: 0; }
.board-grid > .load-more, .board-grid > .card-pad, .board-grid > .empty, .board-grid > .skeleton-list { grid-column: 1 / -1; }
.b-row:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.b-title { font-weight: 600; font-size: 14.5px; color: var(--fg); overflow-wrap: break-word; }
.b-sub { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; color: var(--muted-fg); font-size: 12.5px; margin-top: 2px; }
.b-sub > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.b-note { color: var(--muted-fg); font-size: 12.5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.b-status { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.b-stage { color: var(--fg-soft); font-size: 13px; }
.b-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.b-label { display: none; }
.cell-muted { color: var(--muted-fg); }
.load-more { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--border); }

/* Narrow: the title keeps the room; badges stack in a capped column beside it, and on a phone
   they take their own line, so two badges can never squeeze "Film for" to one letter a line. */
@media (max-width: 860px) {
  .board-grid, .b-body { display: block; }
  .b-head { display: none; }
  .b-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main status" "meta meta" "actions actions"; gap: 8px 10px; padding: 14px; }
  .b-main { grid-area: main; min-width: 0; }
  .b-status { grid-area: status; flex-direction: column; align-items: flex-end; align-self: start; max-width: 45vw; }
  .b-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
  .b-actions { grid-area: actions; justify-content: flex-start; }
  .b-label { display: inline; color: var(--muted-fg); margin-right: 4px; }
  .b-cell { display: inline; }
}
@media (max-width: 560px) {
  .b-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "status" "meta" "actions"; }
  .b-status { flex-direction: row; align-items: center; justify-content: flex-start; max-width: none; }
}
@media (min-width: 861px) {
  .b-meta { display: contents; }
}

/* --------------------------------------------------------------- dialogs -- */
.dlg {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--card); color: var(--fg);
  box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
}
.dlg:not([open]) { display: none; }
.dlg-sm { width: min(420px, calc(100vw - 24px)); }
.dlg-lg { width: min(760px, calc(100vw - 24px)); }
.dlg-video { width: min(960px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(10, 12, 20, 0.5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 10px 20px; }
.dlg-title { font-size: 16px; font-weight: 620; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.dlg-body { padding: 4px 20px 20px; overflow: auto; flex: 1; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--muted) 45%, var(--card)); flex-wrap: wrap; }
.dlg-text { color: var(--fg-soft); }
.dlg.sheet { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; max-width: 100vw; width: min(560px, 100vw); border-radius: 0; border-width: 0 0 0 1px; }
@media (max-width: 640px) {
  .dlg.sheet { width: 100vw; border: 0; }
  .dlg-body { padding: 4px 16px 16px; }
  .dlg-head { padding: 12px 10px 8px 16px; }
  .dlg-foot { padding: 12px 16px; }
}
.video-wrap { background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.video-wrap video { display: block; width: 100%; max-height: 70vh; background: #000; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; min-width: 0; }
.link-once { display: grid; gap: 12px; }

/* -------------------------------------------------------------- drawer -- */
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted-fg); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.d-section { margin-top: 22px; }
.d-section h3 { font-size: 13px; font-weight: 620; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-fg); margin-bottom: 10px; }
.d-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding-bottom: 12px; position: relative; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin: 6px 3px 0; }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.ev-kind { font-weight: 600; }
.ev-data { color: var(--muted-fg); font-size: 12.5px; overflow-wrap: anywhere; }
.answers { display: grid; gap: 0; }
.answer { padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; gap: 3px; }
.answer:last-child { border-bottom: 0; }
.answer .q { color: var(--muted-fg); font-size: 12.5px; font-weight: 550; }
.answer .a { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer .a.none { color: var(--muted-fg); font-style: italic; }
.answer ul { margin: 0; padding-left: 18px; }
.answer .note { color: var(--muted-fg); font-size: 12.5px; }
.photos, .answer .photos { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.photos li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13.5px; }
.photos .pn { font-family: var(--mono); font-size: 12.5px; }
.photos .pnote { color: var(--muted-fg); grid-column: 2; }

/* ------------------------------------------------------------------ table -- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.person { display: grid; gap: 1px; min-width: 0; }
.person-name { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.person-sub { color: var(--muted-fg); font-size: 12.5px; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.lock-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-fg); font-size: 12.5px; }

@media (max-width: 760px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
  .rtable tr:last-child { border-bottom: 0; }
  .rtable td { padding: 0; border: 0; }
  .rtable td[data-label]::before { content: attr(data-label) ": "; color: var(--muted-fg); font-size: 12.5px; }
  .rtable .row-actions { justify-content: flex-start; margin-top: 4px; }
}

/* --------------------------------------------------------------- settings -- */
.set-group { margin-bottom: 20px; }
.set-group > h2 { font-size: 15px; font-weight: 620; margin: 0 0 10px; }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; padding: 16px; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting.wide { grid-template-columns: 1fr; }
.set-label { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.set-key { font-family: var(--mono); font-size: 11.5px; color: var(--muted-fg); font-weight: 400; }
.set-desc { color: var(--fg-soft); font-size: 13.5px; margin-top: 2px; max-width: 640px; }
.set-meta { color: var(--muted-fg); font-size: 12.5px; margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.set-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-self: center; }
.setting.wide .set-control { justify-content: flex-start; }
.set-error { grid-column: 1 / -1; }
.matrix { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 4px; }
.matrix th { font-size: 12px; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.matrix th.c, .matrix td.c { text-align: center; width: 76px; }
.matrix td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.matrix tr:last-child td { border-bottom: 0; }
.matrix td.c { vertical-align: middle; }
.matrix .cap-desc { color: var(--fg); }
.matrix .cap-key { font-family: var(--mono); font-size: 11.5px; color: var(--muted-fg); }
.matrix tr.locked .cap-desc { color: var(--muted-fg); }
.matrix .ovr { margin-left: 6px; }
.cell-tip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 4px; border-radius: 6px; }
@media (max-width: 640px) {
  .setting { grid-template-columns: 1fr; }
  .set-control { justify-content: flex-start; }
  .matrix th.c, .matrix td.c { width: 56px; }
}

/* ------------------------------------------------------------------ audit -- */
.detail-pre { margin: 6px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--muted); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; }
.detail-short { font-family: var(--mono); font-size: 12px; color: var(--muted-fg); overflow-wrap: anywhere; }

/* ------------------------------------------------------------ auth pages -- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; margin-bottom: 22px; }
.auth-title { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted-fg); margin: 4px 0 20px; }
.auth-foot { color: var(--muted-fg); font-size: 12.5px; margin-top: 18px; text-align: center; }
.btn-block { width: 100%; height: 40px; }

/* ----------------------------------------------------------------- phones -- */
@media (max-width: 720px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 8px 16px 0; }
  .brand { height: 40px; }
  .who { order: 2; }
  .who-text { font-size: 12.5px; max-width: 46vw; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; padding: 4px 0 8px; margin: 0 -4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .container { padding: 16px 16px 48px; }
  .page-title { font-size: 20px; }
  .signout-text { display: none; }
}
.d-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.d-gap { margin-top: 14px; }
.d-gap-b { margin-bottom: 16px; }
.b-body > .empty { grid-column: 1 / -1; }
.setting.wide .set-control { display: block; }
.matrix-wrap { width: 100%; overflow-x: auto; }
.table td .num, .b-cell .num { white-space: nowrap; }
