/* RSL assistant platform: one stylesheet for the workspace and the visitor page.
   Tokens first; every component below reads them. The visitor page adds only its layout. */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/instrument-sans-latin-wght-normal.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: "Noto Sans Kannada";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/noto-sans-kannada-kannada-500-normal.woff2") format("woff2");
  unicode-range: U+0C80-0CFF, U+200C-200D, U+25CC;
}

:root {
  --f-sans: "Instrument Sans", "Noto Sans Kannada", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --lh: 1.55;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;

  --canvas: #f4f6f9;
  --panel: #ffffff;
  --panel-subtle: #f8fafc;
  --line: #e2e7ee;
  --line-strong: #cdd5df;
  --line-input: #8a96a8;
  --ink: #152033;
  --muted: #556274;
  --subtle: #6b7686;
  --rail: #0d1728;
  --rail-raised: #16223a;
  --rail-text: #e6ebf3;
  --rail-muted: #9aa7bb;

  --accent: #3b4bc8;
  --accent-hover: #3240ad;
  --accent-soft: #eef0fc;
  --accent-line: #c4caf2;
  --teal: #0f766e;
  --teal-soft: #e6f4f1;

  --ok: #17663f; --ok-bg: #e8f5ee; --ok-line: #a8d5bb;
  --warn: #8a5300; --warn-bg: #fff5df; --warn-line: #ecc77a;
  --danger: #b42318; --danger-bg: #fdeceb; --danger-line: #f1b5ae;
  --test: #8f4307; --test-bg: #fdf1e6; --test-line: #d98a4a;
  --neutral: #3d4a5c; --neutral-bg: #eef1f5;

  --focus: #3b4bc8;
  --focus-on-dark: #8fb4ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.22);
  --ease: 140ms ease;

  --rail-w: 264px;
  --topbar-h: 60px;
}

/* --- base ------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--f-sans); font-size: var(--fs-md); line-height: var(--lh);
  color: var(--ink); background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 650; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0; }
p + p { margin-top: var(--s-2); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
ul, ol { margin: 0; }
code, .code { font-family: var(--f-mono); font-size: 0.92em; }
img { max-width: 100%; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
[tabindex="-1"]:focus { outline: none; }
main:focus { outline: none; }

.skip { position: absolute; left: -999px; top: 0; z-index: 100; }
.skip:focus { left: var(--s-3); top: var(--s-3); background: var(--panel); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); box-shadow: var(--shadow-md); }
.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; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.block { display: block; }
.pre { white-space: pre-line; }
.error { color: var(--danger); font-size: var(--fs-sm); }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: var(--fs-sm); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.lg { width: 22px; height: 22px; }

/* --- buttons ---------------------------------------------------------------------------- */

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
button:hover, .button:hover { border-color: var(--line-input); background: var(--panel-subtle); color: var(--ink); }
button.primary, .button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.ghost, .button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover, .button.ghost:hover { background: var(--neutral-bg); color: var(--ink); }
button.danger, .button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #9a1e14; border-color: #9a1e14; }
button.quiet-danger { background: transparent; border-color: transparent; color: var(--danger); }
button.quiet-danger:hover { background: var(--danger-bg); color: var(--danger); }
button.link { min-height: 44px; padding: 0 var(--s-2); background: none; border: none; color: var(--accent); font-weight: 600; text-decoration: underline; }
button.link:hover { background: none; color: var(--accent-hover); }
button:disabled, button:disabled:hover { opacity: 0.5; cursor: not-allowed; background: var(--panel); border-color: var(--line-strong); color: var(--ink); }
button.primary:disabled, button.primary:disabled:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn { padding: 0; width: 44px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.actions.end { justify-content: flex-end; }

/* --- forms ------------------------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; }
.fields { display: grid; gap: var(--s-5); min-width: 0; }
.field > label, legend { font-weight: 600; font-size: var(--fs-sm); color: var(--ink); }
.field .hint { margin-top: -2px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: var(--fs-md); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-input); border-radius: var(--r-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-line); }
textarea { resize: vertical; min-height: 96px; }
select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=file] { min-height: 44px; padding: 8px; font: inherit; font-size: var(--fs-sm); border: 1px dashed var(--line-input); border-radius: var(--r-sm); background: var(--panel-subtle); width: 100%; }
input[type=file]::file-selector-button { min-height: 32px; margin-right: var(--s-3); padding: 0 var(--s-3); font: inherit; font-weight: 600; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--panel); cursor: pointer; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: var(--s-2); }
.check, .choice {
  display: flex; gap: var(--s-3); align-items: flex-start; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); cursor: pointer;
}
.check + .check, .choice + .choice { margin-top: var(--s-2); }
.check:hover, .choice:hover { border-color: var(--line-strong); }
.check:has(input:checked), .choice:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
.check input, .choice input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check.disabled { cursor: not-allowed; color: var(--muted); background: var(--panel-subtle); }
.check .why, .choice .why { display: block; font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.form-error { margin-top: var(--s-4); padding: var(--s-3); border-radius: var(--r-sm); background: var(--danger-bg); border: 1px solid var(--danger-line); }

/* --- pills and notes -------------------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; white-space: nowrap;
  color: var(--neutral); background: var(--neutral-bg); border: 1px solid transparent; border-radius: 99px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.pill.plain::before { display: none; }
.pill.ok, .pill.live { color: var(--ok); background: var(--ok-bg); }
.pill.live { color: var(--teal); background: var(--teal-soft); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.danger { color: var(--danger); background: var(--danger-bg); }
.pill.accent { color: var(--accent); background: var(--accent-soft); }
.pill.test { color: var(--test); background: var(--test-bg); border: 1px dashed var(--test-line); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 99px; white-space: nowrap; }

.note, .info-strip {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--ink); background: var(--panel-subtle); border: 1px solid var(--line);
}
.note > .icon, .info-strip > .icon { margin-top: 2px; color: var(--muted); }
.note.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.note.warn > .icon { color: var(--warn); }
.note.test, .test-banner { background: var(--test-bg); border: 1px dashed var(--test-line); color: var(--test); }
.test-banner { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; }

/* --- surfaces --------------------------------------------------------------------------- */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: var(--s-6); min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head p { color: var(--muted); font-size: var(--fs-sm); }
.stack > * + * { margin-top: var(--s-5); }
.stack > .card-head + * { margin-top: 0; }
.spacer { flex: 1; }
.stack-sm > * + * { margin-top: var(--s-3); }

/* --- application shell ------------------------------------------------------------------ */

.app { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); }
.app.has-rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app-body { min-width: 0; display: flex; flex-direction: column; }
#main { flex: 1; min-width: 0; padding: var(--s-7) var(--s-7) var(--s-9); }

.rail { background: var(--rail); color: var(--rail-text); }
.rail-inner {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s-5); padding: var(--s-5) var(--s-4);
}
.rail[hidden] { display: none; }
.rail :focus-visible { outline-color: var(--focus-on-dark); }
.brand { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { color: inherit; }
.brand img { width: 30px; height: 24px; }
.brand .brand-sub { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--rail-muted); letter-spacing: 0; }
.rail-org { padding: var(--s-3); border-radius: var(--r-md); background: var(--rail-raised); }
.rail-org strong { display: block; font-size: var(--fs-sm); line-height: 1.35; overflow-wrap: anywhere; }
.rail-org p { font-size: var(--fs-xs); color: var(--rail-muted); }
.rail-org a { color: var(--rail-text); }
.rail-nav ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-nav a {
  display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-3);
  color: var(--rail-text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  border-radius: var(--r-sm); position: relative;
}
.rail-nav a .icon { color: var(--rail-muted); }
.rail-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.rail-nav a[aria-current], .rail-nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.rail-nav a[aria-current] .icon, .rail-nav a.active .icon { color: #7dd3c8; }
.rail-nav a[aria-current]::before, .rail-nav a.active::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #2dd4bf; }
.rail-nav .count { margin-left: auto; font-size: var(--fs-xs); color: var(--rail-muted); }
.rail-nav .rail-steps { list-style: none; padding: 2px 0 4px 30px; }
.rail-steps a { min-height: 40px; font-size: var(--fs-xs); color: var(--rail-muted); gap: var(--s-2); }
.rail-steps a[aria-current] { color: #fff; background: rgba(255, 255, 255, 0.06); }
.rail-steps a[aria-current]::before { display: none; }
.step-dot { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1.5px solid var(--rail-muted); font-size: 10px; font-weight: 700; }
.step-dot.done { border-color: #2dd4bf; background: #2dd4bf; color: var(--rail); }
.step-dot .icon { width: 12px; height: 12px; stroke-width: 3; }
.rail-foot { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.rail-foot .who { font-size: var(--fs-sm); line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.rail-foot .who span { display: block; font-size: var(--fs-xs); color: var(--rail-muted); }
.rail-foot button { color: var(--rail-text); background: transparent; border-color: rgba(255, 255, 255, 0.16); }
.rail-foot button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.3); }

.topbar {
  position: sticky; top: 0; z-index: 20; min-height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-7);
  background: rgba(244, 246, 249, 0.92); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(6px);
}
.topbar .menu-btn, .topbar .brand { display: none; }
.topbar .brand { color: var(--ink); }
.topbar .context { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.topbar .context strong { color: var(--ink); font-weight: 600; }
.topbar .account { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--muted); }

@media (max-width: 959px) {
  .app.has-rail { grid-template-columns: minmax(0, 1fr); }
  .app.has-rail .rail { display: none; }
  .app.has-rail.nav-open .rail {
    display: block; position: fixed; z-index: 40; top: var(--topbar-h); left: 0; right: 0; bottom: 0; overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .app.has-rail.nav-open .rail-inner { position: static; height: auto; min-height: 100%; }
  .app.has-rail .topbar .menu-btn { display: inline-flex; }
  .app.has-rail .topbar .brand { display: inline-flex; }
  .app.has-rail .topbar .context .org-name, .app.has-rail .topbar .context .pill.warn { display: none; }
  .topbar .brand > span { display: none; }
  .topbar { padding: var(--s-2) var(--s-4); }
  #main { padding: var(--s-5) var(--s-4) var(--s-8); }
}
@media (min-width: 960px) {
  .app.has-rail .topbar .account { display: none; }
}

/* --- auth and home ---------------------------------------------------------------------- */

.auth { min-height: calc(100vh - var(--topbar-h)); display: grid; place-items: start center; padding-top: var(--s-6); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .card { padding: var(--s-7); }
.auth-card h1 { font-size: var(--fs-xl); }
.auth-intro { margin-bottom: var(--s-6); }
.auth-intro .mark { width: 44px; height: 34px; margin-bottom: var(--s-4); }
.auth-intro p { color: var(--muted); margin-top: var(--s-2); }
.auth-foot { margin-top: var(--s-5); font-size: var(--fs-xs); color: var(--subtle); text-align: center; }
.auth-card form .primary { width: 100%; margin-top: var(--s-6); }
.auth-wide { max-width: 640px; }
.app:not(.has-rail) .topbar .brand { display: inline-flex; }

.org-list { list-style: none; padding: 0; display: grid; gap: var(--s-3); }
.org-card { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); }
.org-card .avatar { flex: none; }
.org-card .org-main { flex: 1; min-width: 0; }
.org-card h2 { font-size: var(--fs-md); overflow-wrap: anywhere; }
.org-card p { font-size: var(--fs-sm); color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.empty { text-align: center; padding: var(--s-8) var(--s-5); }
.empty .icon { width: 28px; height: 28px; color: var(--subtle); margin-bottom: var(--s-3); }
.empty h2 { font-size: var(--fs-md); }
.empty p { color: var(--muted); font-size: var(--fs-sm); max-width: 44ch; margin: var(--s-2) auto 0; }
.empty .actions { justify-content: center; margin-top: var(--s-4); }

/* --- pages ------------------------------------------------------------------------------ */

.page { max-width: 1120px; margin: 0 auto; }
.page.wide { max-width: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); }
.page-head > div:not(.actions) { flex: 1 1 320px; min-width: 0; max-width: 68ch; }
.page-head > .actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.lede { margin-top: var(--s-2); color: var(--muted); font-size: var(--fs-md); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.save-state .icon { width: 16px; height: 16px; color: var(--ok); }

.progress-line { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-5); font-size: var(--fs-sm); color: var(--muted); }
progress { flex: 1; max-width: 240px; height: 6px; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; appearance: none; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--teal); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--teal); border-radius: 99px; }

/* --- guided setup ----------------------------------------------------------------------- */

.setup-grid { display: grid; gap: var(--s-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .setup-grid { grid-template-columns: minmax(0, 620px) minmax(0, 1fr); } }
.form-card { padding: var(--s-7); }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-7); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.form-foot .grow { flex: 1; }
@media (max-width: 640px) {
  .form-foot .save-state { order: -1; width: 100%; }
  .form-foot .grow { display: none; }
  .form-foot .primary { flex: 1; }
}
.group + .group { margin-top: var(--s-6); padding-top: var(--s-6); border-top: 1px solid var(--line); }
.group-head { margin-bottom: var(--s-4); }
.group-head h2 { font-size: var(--fs-md); }
.group-head .hint { margin-top: 2px; }
.rt { display: grid; gap: var(--s-4); margin-top: var(--s-4); padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-subtle); }
.rt > legend { float: left; width: 100%; margin: 0; font-size: var(--fs-md); }
.rt > h3 { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--muted); }
.rt-field { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
@media (min-width: 900px) { .rt-field { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.rt-field-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.rt-field-foot .check { border: 0; background: none; padding-left: 0; }
#rt-title + .hint { margin: 2px 0 var(--s-2); }
.readonly-row { display: flex; gap: var(--s-2); font-size: var(--fs-sm); }
.readonly-row span:first-child { color: var(--muted); }
.aside { display: grid; gap: var(--s-5); position: sticky; top: calc(var(--topbar-h) + var(--s-5)); }
@media (max-width: 1099px) { .aside { position: static; } }
.aside .card { padding: var(--s-5); }
.aside h2 { font-size: var(--fs-sm); font-weight: 650; }
.aside .card-head { margin-bottom: var(--s-3); }

.checklist { list-style: none; padding: 0; display: grid; gap: 2px; }
.checklist a, .checklist .row { display: flex; align-items: flex-start; gap: var(--s-3); min-height: 44px; padding: 10px var(--s-2); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-sm); }
.checklist a:hover { background: var(--panel-subtle); }
.checklist a[aria-current] { background: var(--accent-soft); }
.checklist .mark { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1.5px solid var(--line-input); color: transparent; margin-top: 1px; }
.checklist .done .mark { background: var(--teal); border-color: var(--teal); color: #fff; }
.checklist .mark .icon { width: 12px; height: 12px; stroke-width: 3; }
.checklist .needs { display: block; font-size: var(--fs-xs); color: var(--muted); }

.mini-visitor { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--canvas); }
.mini-visitor .mv-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--panel); border-bottom: 1px solid var(--line); }
.mini-visitor .mv-head strong { display: block; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.mini-visitor .mv-head span { display: block; font-size: var(--fs-xs); color: var(--muted); }
.mini-visitor .mv-body { padding: var(--s-4); display: grid; gap: var(--s-3); }
.mini-visitor .avatar { width: 34px; height: 34px; font-size: var(--fs-sm); }
.mini-visitor .msg { max-width: 100%; }
.mini-visitor .topic-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- knowledge -------------------------------------------------------------------------- */

.k-stats { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.k-stats span { font-size: var(--fs-sm); color: var(--muted); padding: 4px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.k-stats strong { color: var(--ink); }
.k-section + .k-section { margin-top: var(--s-6); }
.k-list { list-style: none; padding: 0; }
.k-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4); align-items: start; padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }
.k-row:first-child { border-top: 0; }
.k-q { font-weight: 600; overflow-wrap: anywhere; }
.k-a { margin-top: 4px; color: var(--ink); font-size: var(--fs-sm); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.k-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); margin-top: var(--s-2); font-size: var(--fs-xs); color: var(--muted); }
.k-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.k-row .note { margin-top: var(--s-2); }
.k-section .card-head { padding: var(--s-5) var(--s-6) 0; margin-bottom: var(--s-3); }
.k-section .empty { padding: var(--s-7) var(--s-5) var(--s-8); }
.k-section .suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin-top: var(--s-4); }
@media (max-width: 640px) {
  .k-row { grid-template-columns: minmax(0, 1fr); padding: var(--s-4); }
  .k-actions { justify-content: flex-start; }
  .k-section .card-head { padding: var(--s-4) var(--s-4) 0; }
}
details { margin-top: var(--s-2); }
details summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--accent); font-size: var(--fs-sm); font-weight: 600; }
.passages { margin-top: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-7); max-height: 320px; overflow-y: auto; background: var(--panel-subtle); border: 1px solid var(--line); border-radius: var(--r-sm); }
.passages li { font-size: var(--fs-sm); }
.passages li + li { margin-top: var(--s-2); }

.chip {
  min-height: 44px; padding: 0 var(--s-4); border-radius: 99px;
  font-size: var(--fs-sm); font-weight: 500; background: var(--panel); border: 1px solid var(--line-strong);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* --- dialog ----------------------------------------------------------------------------- */

dialog.dialog {
  width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0;
  color: var(--ink); background: var(--panel); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
dialog.dialog::backdrop { background: rgba(13, 23, 40, 0.48); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-4) var(--s-6); border-bottom: 1px solid var(--line); }
.dialog-body { padding: var(--s-6); }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--panel-subtle); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@media (max-width: 640px) { .dialog-body { padding: var(--s-4); } .dialog-head { padding-left: var(--s-4); } .dialog-foot { padding: var(--s-3) var(--s-4); } }

/* --- conversation (preview and visitor) ------------------------------------------------- */

.chat-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.chat-head strong { display: block; font-size: var(--fs-md); overflow-wrap: anywhere; }
.chat-head span { display: block; font-size: var(--fs-xs); color: var(--muted); }
.chat-scroll { padding: var(--s-5); background: var(--panel-subtle); display: grid; gap: var(--s-4); }
.chat { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.preview-page .chat-scroll { min-height: 360px; max-height: 60vh; overflow-y: auto; align-content: start; }
.msg { max-width: min(560px, 88%); padding: 10px 14px; border-radius: 14px; font-size: var(--fs-md); overflow-wrap: anywhere; }
.msg.you { align-self: flex-end; color: var(--ink); background: var(--accent-soft); border: 1px solid var(--accent-line); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.msg.bot.unsupported { border-color: var(--warn-line); background: #fffcf4; }
.msg .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); }
.msg .meta .pill { font-size: 11px; }
.msg .excerpt-note { margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); }
.chat-form { display: flex; gap: var(--s-2); align-items: flex-end; padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); background: var(--panel); }
.chat-form .field { flex: 1; min-width: 0; }
.chat-form .field > label { font-size: var(--fs-xs); color: var(--muted); }
.chat-form button { flex: none; }

.summary-card { padding: var(--s-4) var(--s-5); background: var(--panel); border: 1px solid var(--accent-line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.summary-card h2 { font-size: var(--fs-md); margin-bottom: var(--s-3); }
.summary-card .chips { margin: var(--s-3) 0; }
.summary-card .actions { margin-top: var(--s-3); }
.summary-card .step-of { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.summary-card .step-of progress { max-width: 160px; }
.summary-card .fine { margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--muted); }
.receipt { padding: var(--s-4) var(--s-5); background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: var(--r-md); }
.receipt .receipt-title { display: flex; align-items: center; gap: var(--s-2); font-weight: 650; color: var(--ok); }
.receipt .code { display: inline-block; margin-top: var(--s-2); padding: 2px 8px; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--ok-line); font-weight: 600; letter-spacing: 0.02em; }
.receipt .next { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--ink); }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: var(--s-2) var(--s-5); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.kv dd .link { min-height: 32px; padding: 0 var(--s-1); margin-left: var(--s-1); font-size: var(--fs-xs); }
.summary-card .kv dd { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); }
.summary-card .kv dd .link { min-height: 44px; }
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd + dt { margin-top: var(--s-2); } }

/* --- test assistant --------------------------------------------------------------------- */

.preview-grid { display: grid; gap: var(--s-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .preview-grid { grid-template-columns: minmax(0, 1fr) 340px; } }
.request-buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.plain-list { list-style: none; padding: 0; display: grid; gap: var(--s-2); font-size: var(--fs-sm); }
.plain-list li { display: flex; flex-wrap: wrap; gap: 4px var(--s-2); justify-content: space-between; padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.open-qs li.open-q { display: grid; gap: var(--s-2); }
.open-q-text { display: flex; flex-wrap: wrap; gap: 4px var(--s-2); align-items: center; overflow-wrap: anywhere; }
.open-q-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.open-q-actions select { width: auto; flex: 1 1 220px; max-width: 340px; min-height: 44px; }
.open-q-actions button { flex: 0 0 auto; }
.k-alts { margin: 2px 0 var(--s-1); overflow-wrap: anywhere; }

/* --- activate --------------------------------------------------------------------------- */

.summary { padding-left: 0; list-style: none; display: grid; gap: var(--s-2); }
.summary li { display: flex; gap: var(--s-3); font-size: var(--fs-sm); }
.summary li .icon { margin-top: 2px; color: var(--teal); }
.activate-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.link-box { display: grid; gap: var(--s-3); padding: var(--s-4); margin: var(--s-4) 0; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.link-row { display: flex; gap: var(--s-2); align-items: stretch; }
code.url { flex: 1; min-width: 0; display: flex; align-items: center; padding: var(--s-2) var(--s-3); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow-wrap: anywhere; font-size: var(--fs-sm); }
@media (max-width: 480px) { .link-row { flex-direction: column; } }
.live-items { list-style: none; padding: 0; }
.live-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.live-item > :not(.head):not(.actions) { grid-column: 1 / -1; }
.live-item:first-child { border-top: 0; }
.live-item .head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.live-item .head strong { overflow-wrap: anywhere; }
.live-item.withdrawn { color: var(--muted); }
.live-item.withdrawn .head strong { text-decoration: line-through; text-decoration-color: var(--line-input); }
.live-item .confirm { display: grid; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--danger-line); background: var(--danger-bg); }

/* --- overview --------------------------------------------------------------------------- */

.ov-grid { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .ov-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ov-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.ov-status h2 { font-size: var(--fs-xl); margin-top: var(--s-1); }
.figure { font-size: var(--fs-2xl); font-weight: 650; line-height: 1.1; letter-spacing: -0.02em; }
.figure-label { font-size: var(--fs-sm); color: var(--muted); }
.figures { display: flex; flex-wrap: wrap; gap: var(--s-6); margin: var(--s-2) 0 var(--s-4); }

/* --- request inbox ---------------------------------------------------------------------- */

.inbox-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--neutral-bg); border: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4); border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.inbox-note { margin-bottom: var(--s-4); }
.inbox-filter { display: flex; align-items: center; gap: var(--s-2); }
.inbox-filter label { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.inbox-filter select { width: auto; min-width: 200px; }
.inbox {
  display: grid; grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h) - 240px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
@media (min-width: 960px) { .inbox { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); } }
.inbox-list { border-right: 1px solid var(--line); min-width: 0; background: var(--panel); }
.inbox-list .list-head { padding: var(--s-3) var(--s-4); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.req-list { list-style: none; padding: 0; }
.req-list li + li { border-top: 1px solid var(--line); }
.req-list a { display: grid; gap: 4px; padding: var(--s-3) var(--s-4) var(--s-3) var(--s-5); min-height: 44px; color: var(--ink); text-decoration: none; position: relative; }
.req-list a:hover { background: var(--panel-subtle); }
.req-list a[aria-current="true"] { background: var(--accent-soft); }
.req-list a[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.row-top strong { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.row-top time { flex: none; font-size: var(--fs-xs); color: var(--muted); }
.row-preview { font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-bottom .code { font-size: var(--fs-xs); color: var(--subtle); }
.inbox-detail { min-width: 0; padding: var(--s-6) var(--s-7); }
.inbox-detail .empty { padding: var(--s-9) var(--s-5); }
.inbox .empty-list { padding: var(--s-8) var(--s-5); }
.back-link { display: none; }
@media (max-width: 959px) {
  .inbox { min-height: 0; }
  .inbox-list { border-right: 0; }
  .inbox.has-detail .inbox-list { display: none; }
  .inbox:not(.has-detail) .inbox-detail { display: none; }
  .inbox-detail { padding: var(--s-4); }
  .back-link { display: inline-flex; margin-bottom: var(--s-4); }
  .inbox-filter { width: 100%; }
  .inbox-filter select { flex: 1; min-width: 0; }
}
.req-detail { display: grid; gap: var(--s-6); }
.req-detail > header { display: grid; gap: var(--s-2); }
.req-detail h2 { font-size: var(--fs-xl); overflow-wrap: anywhere; }
.req-detail .status-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); font-size: var(--fs-sm); color: var(--muted); }
.req-detail section > h3 { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s-3); }
.req-detail.is-test { padding: var(--s-4); border: 1px dashed var(--test-line); border-radius: var(--r-md); }
.staff-actions { padding: var(--s-5); border-radius: var(--r-md); background: var(--panel-subtle); border: 1px solid var(--line); }
.staff-actions .actions { margin-top: var(--s-4); }
.staff-actions .fine { margin-top: var(--s-3); font-size: var(--fs-xs); color: var(--muted); }
.history { list-style: none; padding: 0; position: relative; }
.history li { position: relative; padding: 0 0 var(--s-4) var(--s-6); font-size: var(--fs-sm); }
.history li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
.history li::after { content: ""; position: absolute; left: 9px; top: 20px; bottom: 0; width: 1px; background: var(--line-strong); }
.history li:last-child::after { display: none; }
.history .when { color: var(--muted); }
.history blockquote { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3); border-left: 3px solid var(--line-strong); background: var(--panel-subtle); border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* --- toast ------------------------------------------------------------------------------ */

.toast {
  position: fixed; left: 50%; bottom: var(--s-6); z-index: 60; transform: translate(-50%, 8px);
  max-width: min(520px, calc(100vw - 32px)); padding: var(--s-3) var(--s-4);
  color: #fff; background: var(--rail); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); opacity: 0; pointer-events: none; transition: opacity var(--ease), transform var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* A visually hidden input must not widen the page: pin it inside its row (it used to cause sideways scroll on phones). */
.k-actions { position: relative; }
input.sr-only { left: 0; top: 0; width: 1px; height: 1px; min-height: 0; min-width: 0; }
