/* ==========================================================================
   EoUBase stylesheet. Hand-written: no framework, no external assets.
   Order: tokens, base, app shell, page chrome, buttons, forms, surfaces,
   tables, badges, alerts, tabs, timeline, lifecycle, files and uploads,
   viewer, auth and plain pages, utilities, responsive.
   ========================================================================== */

/* --- Tokens ---------------------------------------------------------------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-sunken: #f7f8fa;
  --line: #e1e4ea;
  --line-strong: #c8cdd7;
  --ink: #161d2b;
  --ink-2: #465166;
  --ink-3: #68738a;

  --brand: #1f3f9c;
  --brand-strong: #172f78;
  --brand-tint: #e8edfa;
  --brand-ink: #183178;

  --side-bg: #0f1a33;
  --side-ink: #b9c2d6;
  --side-muted: #8a96b0;
  --side-line: #23314f;
  --side-active: #1c2b52;
  --side-accent: #8fa8ff;

  --st-draft-bg: #eceff3;      --st-draft-ink: #3a4556;
  --st-review-bg: #fdf0d2;     --st-review-ink: #7a4b00;
  --st-changes-bg: #fde6e1;    --st-changes-ink: #9b2610;
  --st-approved-bg: #dff2e6;   --st-approved-ink: #136236;
  --st-final-bg: #e6e5fb;      --st-final-ink: #3a2fa0;

  --danger: #b3261e;
  --danger-tint: #fdeceb;
  --ok: #136236;
  --ok-tint: #e3f4ea;
  --warn-ink: #7a4b00;
  --warn-tint: #fdf3d8;

  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 26, 51, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 26, 51, 0.12);
  --focus: 0 0 0 3px rgba(31, 63, 156, 0.28);
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--ink); }
h1 { font-family: var(--font-serif); font-size: 27px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }

.icon {
  width: 18px; height: 18px; flex: none; vertical-align: -3px;
  stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 28px; height: 28px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }

/* --- App shell ------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--side-bg); color: var(--side-ink);
}
.brand {
  display: block; padding: 2px 10px 16px;
  font-family: var(--font-serif); font-size: 23px; font-weight: 700; letter-spacing: -0.01em; color: #fff;
}
.brand span { color: var(--side-accent); }
.brand:hover { text-decoration: none; }
.brand-dark { color: var(--side-bg); padding: 0; }
.brand-dark span { color: var(--brand); }

.switcher { position: relative; margin-bottom: 14px; }
.switcher > summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--side-line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary:hover { background: rgba(255, 255, 255, 0.08); }
.switcher-label { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--side-muted); }
.switcher-name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  padding: 6px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink);
}
.menu-item:hover { background: var(--surface-sunken); text-decoration: none; }
.menu-item small { color: var(--ink-3); }
.menu-item.is-current { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.menu-item-action { justify-content: flex-start; color: var(--brand); margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--side-ink); font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--side-accent); }
.nav-heading { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--side-muted); }
.nav-count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--side-accent); color: var(--side-bg); font-size: 11.5px; font-weight: 700; text-align: center;
}

.side-user { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--side-line); }
.side-user-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--radius-sm); color: #fff; }
.side-user-link:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.side-user-text { display: grid; min-width: 0; line-height: 1.25; }
.side-user-text strong { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text small { color: var(--side-muted); }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: #2b3d70; color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
}
.avatar-light { background: var(--brand-tint); color: var(--brand-ink); }

.main { min-width: 0; display: flex; flex-direction: column; }

/* --- Page chrome ----------------------------------------------------------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 26px 32px 18px;
}
.page-head-text { min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); }
.crumbs .icon { width: 13px; height: 13px; }
.page-sub { margin: 6px 0 0; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-body { width: 100%; max-width: 1240px; padding: 0 32px 56px; }
.page-body.is-wide { max-width: none; }
.page-body.is-narrow { max-width: 780px; }
.alerts { display: grid; gap: 8px; max-width: 1240px; padding: 0 32px; margin-bottom: 16px; }
.auth-card .alerts, .plain .alerts { padding: 0; }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-sunken); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #0e4d2a; border-color: #0e4d2a; }
.btn-danger { color: var(--danger); border-color: #e3b5b1; }
.btn-danger:hover { background: var(--danger-tint); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(22, 29, 43, 0.06); color: var(--ink); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(22, 29, 43, 0.07); color: var(--ink); }
.icon-btn-dark { color: var(--side-ink); }
.icon-btn-dark:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

/* --- Forms ----------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.optional { margin-left: 4px; font-size: 12px; font-weight: 400; color: var(--ink-3); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 96px; line-height: 1.45; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23465166' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
select[multiple] { background-image: none; padding-right: 10px; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-sunken); color: var(--ink-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.help { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); }
.error { margin: 6px 0 0; font-size: 13px; font-weight: 500; color: var(--danger); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.inline-form select, .select-sm { width: auto; min-height: 30px; padding: 3px 28px 3px 8px; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters .field { margin: 0; }
.filters label { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.filters select, .filters input { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; }
.filters .grow { flex: 1 1 220px; }
.filters .check { margin: 0 0 7px; font-size: 14px; font-weight: 500; color: var(--ink); text-transform: none; letter-spacing: 0; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: var(--font-mono); font-size: 12.5px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }

/* --- Surfaces -------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; }
.card-head .muted { font-weight: 400; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-sunken); border-radius: 0 0 var(--radius) var(--radius); }
.stack > * + * { margin-top: 18px; }
.stack-sm > * + * { margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); }
.empty .icon { width: 30px; height: 30px; margin-bottom: 8px; color: var(--line-strong); }
.empty h3 { margin-bottom: 4px; color: var(--ink-2); }
.empty p { max-width: 46ch; margin-left: auto; margin-right: auto; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--brand-tint); color: var(--brand-ink); font-size: 14px; }
.notice-warn { background: var(--warn-tint); color: var(--warn-ink); }
.notice-danger { background: var(--danger-tint); color: #8c1d18; }
.notice-ok { background: var(--ok-tint); color: #0f5230; }
.notice-plain { background: var(--surface-sunken); color: var(--ink-2); }
.devbox { padding: 12px 14px; border: 1px dashed #d9bb70; border-radius: var(--radius-sm); background: var(--warn-tint); color: var(--warn-ink); font-size: 13.5px; }
.devbox strong { display: block; margin-bottom: 6px; }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 9px 14px; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3);
  background: var(--surface-sunken); border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .center { text-align: center; }
.table-plain th { background: transparent; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.ref { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.hash { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.yes { color: var(--ok); }
.no { color: var(--line-strong); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-3); }

/* --- Badges ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--st-draft-bg); color: var(--st-draft-ink);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--st-draft-bg); color: var(--st-draft-ink); }
.badge-in_review, .badge-warn { background: var(--st-review-bg); color: var(--st-review-ink); }
.badge-changes_requested, .badge-danger { background: var(--st-changes-bg); color: var(--st-changes-ink); }
.badge-approved, .badge-ok { background: var(--st-approved-bg); color: var(--st-approved-ink); }
.badge-final { background: var(--st-final-bg); color: var(--st-final-ink); }
.badge-info { background: var(--brand-tint); color: var(--brand-ink); }
.badge-outline { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-sunken); font-size: 12px; color: var(--ink-2); white-space: nowrap; }

/* --- Alerts ---------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 1px solid; border-radius: var(--radius-sm); font-size: 14px; }
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--ok-tint); border-color: #b9dfc8; color: #0f5230; }
.alert-error { background: var(--danger-tint); border-color: #f1c0bc; color: #8c1d18; }
.alert-warning { background: var(--warn-tint); border-color: #ecd49b; color: var(--warn-ink); }
.alert-info, .alert-debug { background: var(--brand-tint); border-color: #c5d2f3; color: var(--brand-ink); }

/* --- Tabs ------------------------------------------------------------------ */
/* Tabs wrap onto a second row in a narrow column (beside the viewer pane), so none is ever hidden. */
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 10px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--ink-2); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.count { padding: 0 7px; border-radius: 999px; background: var(--st-draft-bg); color: var(--ink-2); font-size: 12px; font-weight: 600; }

/* --- Timeline -------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { position: relative; padding: 0 0 20px 28px; }
.timeline > li::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: -8px; width: 1px; background: var(--line); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li:last-child::before { display: none; }
.timeline > li::after {
  content: ""; position: absolute; left: 3px; top: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong);
}
.timeline > li.is-current::after { background: var(--brand); border-color: var(--brand); }
.timeline > li.is-ok::after { background: var(--ok); border-color: var(--ok); }
.timeline > li.is-problem::after { background: var(--danger); border-color: var(--danger); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.tl-title { font-weight: 600; }
.tl-meta { font-size: 13px; color: var(--ink-3); }
.tl-body { margin-top: 4px; color: var(--ink-2); overflow-wrap: anywhere; }
.tl-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.quote { padding: 8px 12px; border-left: 3px solid var(--line-strong); background: var(--surface-sunken); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }

/* --- Lifecycle tracker ----------------------------------------------------- */
.lifecycle { display: flex; list-style: none; margin: 0; padding: 0; overflow-x: auto; }
.lifecycle li {
  flex: 1 1 0; min-width: 118px; padding: 9px 14px;
  background: var(--surface-sunken); border: 1px solid var(--line); border-left-width: 0;
  font-size: 12.5px; color: var(--ink-3);
}
.lifecycle li:first-child { border-left-width: 1px; border-radius: var(--radius) 0 0 var(--radius); }
.lifecycle li:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.lifecycle .step-name { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.lifecycle li.is-done { background: var(--ok-tint); color: #2f6b49; }
.lifecycle li.is-done .step-name { color: var(--ok); }
.lifecycle li.is-current { background: var(--brand-tint); color: var(--brand-ink); box-shadow: inset 0 -3px 0 var(--brand); }
.lifecycle li.is-current .step-name { color: var(--brand-ink); }
.lifecycle li.is-problem { background: var(--st-changes-bg); color: var(--st-changes-ink); box-shadow: inset 0 -3px 0 var(--danger); }
.lifecycle li.is-problem .step-name { color: var(--st-changes-ink); }

/* --- Files and uploads ----------------------------------------------------- */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row.is-selected { background: var(--brand-tint); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.file-icon {
  width: 34px; height: 40px; border-radius: 4px; display: grid; place-items: center;
  background: var(--st-draft-bg); color: var(--ink-2); font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
}
.file-icon.is-pdf { background: #fde6e1; color: #9b2610; }
.file-icon.is-doc { background: #e3ebfb; color: #1d4296; }
.file-icon.is-xls { background: #dff2e6; color: #136236; }
.file-icon.is-ppt { background: #fdebd8; color: #9a4a06; }
.file-icon.is-img { background: #efe6fb; color: #5b2aa0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-name a { color: var(--ink); }
.file-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; color: var(--ink-3); }
.file-actions { display: flex; align-items: center; gap: 4px; }
.dropzone {
  padding: 22px; text-align: center; color: var(--ink-2);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-sunken);
  transition: border-color 0.12s, background 0.12s;
}
.dropzone.is-over { border-color: var(--brand); background: var(--brand-tint); }
.dropzone p { margin-bottom: 10px; }
.dropzone .help { margin-top: 10px; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; font-size: 13.5px; }
.upload-row progress { grid-column: 1 / -1; }
.upload-row.is-error { color: var(--danger); }
progress { width: 100%; height: 6px; accent-color: var(--brand); }
.staged-table select, .staged-table input[type="text"] { min-height: 32px; padding: 4px 8px; font-size: 13.5px; }
.staged-table select { padding-right: 28px; }
.diff-added { color: var(--ok); }
.diff-removed { color: var(--danger); }
.diff-changed { color: var(--warn-ink); }
.diff-unchanged { color: var(--ink-3); }
.strike { text-decoration: line-through; color: var(--ink-3); }

/* --- Auth and plain pages -------------------------------------------------- */
.page-auth { background: var(--bg); }
.auth { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 18px; padding: 32px 16px; }
.brand-auth { padding: 0; font-size: 30px; color: var(--side-bg); }
.brand-auth span { color: var(--brand); }
.auth-card { width: 100%; max-width: 420px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.auth-card.is-wide { max-width: 560px; }
.auth-card h1 { margin-bottom: 6px; font-size: 23px; }
.auth-card .alerts { margin-bottom: 16px; }
.lead { margin-bottom: 20px; color: var(--ink-2); }
.auth-foot { margin: 0; font-size: 13.5px; color: var(--ink-3); text-align: center; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13.5px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .brand { font-size: 21px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 14px; }
.topbar-user .avatar { background: var(--brand-tint); color: var(--brand-ink); }
.plain { max-width: 760px; margin: 32px auto 64px; padding: 0 20px; }
.plain.is-narrow { max-width: 520px; }
.plain > h1 { margin-bottom: 6px; }
.plain > .lead { margin-bottom: 22px; }

.hero { background: var(--side-bg); color: #dfe5f2; }
.hero-inner { max-width: 1040px; margin: 0 auto; padding: 22px 24px 72px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 64px; }
.hero-top .brand { padding: 0; }
.hero h1 { max-width: 18ch; color: #fff; font-size: 46px; line-height: 1.1; letter-spacing: -0.02em; }
.hero p.hero-lead { max-width: 56ch; margin: 18px 0 28px; font-size: 18px; color: #c3cce0; }
.hero .btn-ghost { color: #dfe5f2; }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.hero .btn-primary { background: #fff; border-color: #fff; color: var(--side-bg); }
.hero .btn-primary:hover { background: #e8edfa; border-color: #e8edfa; }
.features { max-width: 1040px; margin: -40px auto 64px; padding: 0 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.feature { padding: 22px; }
.feature .icon { width: 24px; height: 24px; color: var(--brand); margin-bottom: 10px; }
.feature h2 { margin-bottom: 6px; }
.feature p { color: var(--ink-2); font-size: 14.5px; }

/* --- Utilities ------------------------------------------------------------- */
.muted { color: var(--ink-3); }
.subtle { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prewrap { white-space: pre-line; overflow-wrap: anywhere; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.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; }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn-ink); }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
  .side .brand { padding: 0 8px 0 4px; }
  .switcher { margin: 0; min-width: 180px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .nav-heading { display: none; }
  .side-user { margin: 0 0 0 auto; padding: 0; border: 0; }
  .side-user-text { display: none; }
  .page-head { padding: 20px 16px 14px; }
  .page-body, .alerts { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-main, .form-grid, .features { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; }
}

/* --- Viewer ---------------------------------------------------------------- */
/* The EoU page: content on the left, the document on the right. */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, var(--pane-width, 46%)); gap: 20px; align-items: start; }
.split.is-single { grid-template-columns: minmax(0, 1fr); }
.split-main { min-width: 0; container-type: inline-size; }
@container (max-width: 520px) {
  .file-row { grid-template-columns: auto minmax(0, 1fr); }
  .file-actions { grid-column: 2; margin-left: -10px; }
}
.split-pane {
  position: sticky; top: 12px; height: calc(100vh - 24px); min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.pane-resizer { position: absolute; z-index: 5; left: -13px; top: 0; bottom: 0; width: 12px; cursor: col-resize; touch-action: none; }
.pane-resizer::after { content: ""; position: absolute; left: 5px; top: 50%; width: 3px; height: 44px; margin-top: -22px; border-radius: 3px; background: var(--line-strong); }
.pane-resizer:hover::after, .pane-resizer:focus-visible::after, .is-resizing .pane-resizer::after { background: var(--brand); }
.is-resizing { user-select: none; cursor: col-resize; }
.is-resizing iframe { pointer-events: none; }
.pane-head { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.pane-title { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.pane-title strong { font-size: 14px; }
.pane-title span { font-size: 12.5px; }
.pane-actions { display: flex; align-items: center; gap: 2px; }
.pane-body, .viewer-stage { flex: 1; min-height: 0; background: #40444b; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.pane-body iframe, .viewer-stage iframe { display: block; width: 100%; height: 100%; border: 0; background: #40444b; }
.pane-body.is-image, .viewer-stage.is-image { overflow: auto; display: grid; place-items: center; padding: 16px; }
.pane-body.is-image img, .viewer-stage.is-image img { max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow-md); }
.pane-empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; color: #d5d9e0; text-align: center; padding: 24px; }

/* A document in its own window, and two documents side by side. */
.page-viewer { background: #2b2f36; }
.viewer-window { height: 100vh; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; background: var(--side-bg); color: #fff; }
.brand-small { padding: 0; font-size: 19px; }
.viewer-bar-title { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.viewer-bar-title strong { font-size: 14px; }
.viewer-bar-title span { font-size: 12.5px; color: var(--side-muted); }
.viewer-bar-actions { display: flex; align-items: center; gap: 8px; }
.btn-on-dark { background: transparent; border-color: var(--side-line); color: #fff; }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.1); }
.viewer-window > .viewer-stage { border-radius: 0; }
.viewer-pair { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; background: #1c1f24; }
.viewer-half { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.viewer-half .viewer-stage { border-radius: 0; }

/* Small pop-up forms (restore, withdraw, void ...) built on <details>. */
.inline-details { position: relative; display: inline-block; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.popover {
  position: absolute; z-index: 30; left: 0; top: calc(100% + 6px); width: 320px; max-width: 80vw;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.popover-right { left: auto; right: 0; }
details.card > summary { cursor: pointer; list-style: none; border-bottom: 0; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { border-bottom: 1px solid var(--line); }
details.card > summary h2::before { content: "▸"; display: inline-block; width: 16px; color: var(--ink-3); }
details.card[open] > summary h2::before { content: "▾"; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }

@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-pane { position: static; height: 78vh; order: -1; }
  .pane-resizer { display: none; }
  .viewer-pair { grid-template-columns: 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
}

/* --- Review ---------------------------------------------------------------- */
.plan { margin: 0 0 14px; padding-left: 22px; }
.plan li { padding: 3px 0; }
.plan li span { margin-left: 6px; }
.step-list { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.step-list > li { padding: 6px 0; }
.dropzone-sm { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 12px; margin-bottom: 8px; font-size: 14px; }
.dropzone-sm p { margin: 0; }
details > summary.link-btn { display: inline-block; list-style: none; }
details > summary.link-btn::-webkit-details-marker { display: none; }

/* --- Licensing ------------------------------------------------------------- */
.send-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.send-row:last-child { border-bottom: 0; }
.send-files { margin: 8px 0 0 26px; display: grid; gap: 6px; font-size: 14px; }
.contact-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: 0; }
.check-grid-wide { grid-template-columns: 1fr; }
.timeline > li.is-voided { opacity: 0.7; }
.timeline > li.is-voided::after { border-style: dashed; }

/* --- Dashboard ------------------------------------------------------------- */
/* Stat tiles: the number is the chart. Values use the UI sans with proportional
   figures and ink colour; a small dot beside the label carries the status identity. */
.kpi-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat-tile {
  display: grid; gap: 2px; padding: 16px 18px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.stat-tile:hover { border-color: var(--line-strong); text-decoration: none; box-shadow: var(--shadow-md); }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.stat-value { font-family: var(--font-sans); font-size: 34px; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; color: var(--ink); }
.stat-hint { font-size: 12.5px; color: var(--ink-3); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--st-draft-ink); }
.status-in_review { background: #b7791f; }
.status-changes_requested { background: #c0392b; }
.status-approved { background: #1f8a4c; }
.status-final { background: #4f46c8; }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { display: grid; gap: 2px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.item-list > li:last-child { border-bottom: 0; }
.item-title { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
a.item-title:hover { color: var(--brand); }
.item-meta { font-size: 12.5px; color: var(--ink-3); }
.empty-sm { padding: 22px 18px; }
.empty-sm .icon { width: 22px; height: 22px; margin-bottom: 4px; }

/* --- Discussion ------------------------------------------------------------ */
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }

/* --- Export ---------------------------------------------------------------- */
.export-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0 16px; }
.export-filters .field { min-width: 0; }
.export-archived { align-self: end; }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range input { min-width: 0; flex: 1 1 0; padding-left: 8px; padding-right: 6px; }
.export-more { margin: 0; padding: 10px 18px; font-size: 13.5px; border-top: 1px solid var(--line); }

.picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.picker-side h3 { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }
.picker-side { position: relative; display: flex; flex-direction: column; }
.picker-list {
  flex: 1 1 auto; list-style: none; margin: 0; padding: 6px; min-height: 240px;
  background: var(--surface-sunken); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.picker-list.is-target { border-color: var(--brand); background: var(--brand-tint); }
.picker-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px; cursor: grab; user-select: none;
}
.picker-item:last-child { margin-bottom: 0; }
.picker-item.is-dragging { opacity: 0.45; border-style: dashed; }
.picker-grip { flex: none; width: 8px; height: 14px; background-image: radial-gradient(circle, var(--line-strong) 1.2px, transparent 1.4px); background-size: 4px 5px; }
.picker-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-picker="chosen"] { counter-reset: column; }
[data-picker="chosen"] .picker-label::before { counter-increment: column; content: counter(column) ". "; color: var(--ink-3); }
.picker-actions { display: flex; gap: 4px; flex: none; }
.picker-btn {
  min-width: 28px; height: 26px; padding: 0 8px; font: inherit; font-size: 12.5px; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.picker-btn:hover { background: var(--surface-sunken); }
[data-picker="available"] [data-move="up"], [data-picker="available"] [data-move="down"] { display: none; }
.picker-empty { position: absolute; left: 0; right: 0; top: 50%; margin: 0; text-align: center; color: var(--ink-3); font-size: 14px; pointer-events: none; }
@media (max-width: 720px) {
  .picker { grid-template-columns: 1fr; }
}

/* --- Sign-in security -------------------------------------------------------- */
.factor-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--ink-3); font-size: 13px; }
.factor-or::before, .factor-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.steps { margin: 0; padding-left: 20px; }
.steps > li + li { margin-top: 20px; }
.qr { margin-top: 10px; }
/* its own size (accounts/twofactor.py, qr_svg), shrunk only to fit; never cropped */
.qr svg { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); shape-rendering: crispEdges; }
.setup-key { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; font-family: var(--font-mono); font-size: 14px; }
.codes { list-style: none; margin: 12px 0 0; padding: 12px 14px; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 32px; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 14.5px; }
.card-attention { border-color: #d9bb70; }
.confirm-form { margin-top: 10px; max-width: 320px; }
.confirm-form .field { margin-bottom: 10px; }
.passkey-add { max-width: 360px; }
td details > summary, .card-body details > summary { cursor: pointer; }
td .confirm-form { text-align: left; }

.signup-steps { list-style: none; display: flex; gap: 6px; margin: 0 0 18px; padding: 0; font-size: 12.5px; color: var(--ink-3); }
.signup-steps li { flex: 1 1 0; display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 3px solid var(--line); white-space: nowrap; }
.signup-steps span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--line); color: var(--ink-2); font-size: 11px; font-weight: 600; }
.signup-steps .is-current { border-color: var(--brand); color: var(--ink); font-weight: 600; }
.signup-steps .is-current span, .signup-steps .is-done span { background: var(--brand); color: #fff; }
.signup-steps .is-done { border-color: var(--brand); }

/* --- Company users ----------------------------------------------------------- */
.invite-grid { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)); gap: 0 16px; }
.table-top td { vertical-align: top; }
.access > summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.access-chip { display: inline-block; margin: 2px 0 2px 8px; padding: 1px 8px; border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink); }
.access-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.access-row select { width: auto; min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13.5px; }
.access-name { flex: 0 0 190px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; }
td.actions form + form { margin-top: 6px; }
@media (max-width: 960px) {
  .invite-grid { grid-template-columns: 1fr; }
}

/* --- Patent register --------------------------------------------------------- */
.card-section { border-top: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.section-title a { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 13px; }
