/* ==========================================================================
   Aperture Investor Data Room — design system
   Mirrors the Aperture Platform (frontendApp) 1:1: zinc palette, Averta +
   Source Serif, 0.625rem radius, shadcn primitives (rounded-lg buttons,
   rounded-md inputs, shadow-xs), 240px sidebar + 57px header dashboard chrome,
   real file table, split-screen auth with animated aperture brand panel.
   ========================================================================== */

@font-face { font-family: "Averta"; src: url("/assets/averta/AvertaCY-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Averta"; src: url("/assets/averta/AvertaCY-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Averta"; src: url("/assets/averta/AvertaCY-Semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Averta"; src: url("/assets/averta/AvertaCY-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --radius: 0.625rem;
  --background: #ffffff;
  --foreground: #18181b;
  --card: #ffffff;
  --primary: #18181b;
  --primary-foreground: #ffffff;
  --secondary: #f4f4f5;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #dc2626;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #a1a1aa;
  --brand: #18181b;
  --brand-foreground: #ffffff;
  --sidebar: #f7f7f6;
  --amber: #f59e0b;

  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,.05);
  --font-sans: "Averta", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  /* Shared tree tokens — sidebar document tree and on-this-page outline are the
     SAME component, modeled on shadcn SidebarMenuSub. Both consume these. */
  --tree-row-h: 28px;          /* h-7 */
  --tree-radius: 6px;          /* rounded-md */
  --tree-rail: var(--border);
  --tree-fg: var(--muted-foreground);
  --tree-fg-strong: var(--foreground);
  --tree-active-bg: var(--accent);

  /* Always-dark "ink" surface for the split-screen brand panel. Fixed across
     light/dark so the panel never inverts to white-on-white. */
  --ink: #18181b;
  --ink-fg: #ffffff;
}

/* ─── Dark theme tokens (verbatim from the Platform's globals.css .dark) ───
   Applied either by system preference or the manual [data-theme] toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #09090b;
    --foreground: #fafafa;
    --card: #18181b;
    --primary: #fafafa;
    --primary-foreground: #09090b;
    --secondary: #27272a;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #ef4444;
    --border: #27272a;
    --input: #27272a;
    --ring: #52525b;
    --brand: #fafafa;
    --brand-foreground: #09090b;
    --sidebar: #18181b;
    --ink: #18181b;            /* brand panel stays dark */
    --ink-fg: #ffffff;
    --shadow-xs: 0 1px 3px 0 rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #09090b;
  --foreground: #fafafa;
  --card: #18181b;
  --primary: #fafafa;
  --primary-foreground: #09090b;
  --secondary: #27272a;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --border: #27272a;
  --input: #27272a;
  --ring: #52525b;
  --brand: #fafafa;
  --brand-foreground: #09090b;
  --sidebar: #18181b;
  --ink: #18181b;
  --ink-fg: #ffffff;
  --shadow-xs: 0 1px 3px 0 rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body {
  margin: 0; font-family: var(--font-sans); color: var(--foreground); background: var(--background);
  line-height: 1.5; font-size: 14px; font-feature-settings: 'rlig' 1, 'calt' 1;
}
h1,h2,h3,h4,h5,h6 { letter-spacing: -0.025em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
::selection { background: color-mix(in srgb, var(--foreground) 12%, transparent); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes auth-float-1 { 0%,100% { transform: translate(0,0) scale(1); } 25% { transform: translate(12px,-18px) scale(1.04); } 50% { transform: translate(-8px,-30px) scale(1.02); } 75% { transform: translate(6px,-12px) scale(.98); } }
@keyframes auth-float-2 { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(-16px,14px) scale(1.06); } 66% { transform: translate(10px,-10px) scale(.96); } }
@keyframes auth-float-3 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px,16px); } }
@keyframes auth-pulse-glow { 0%,100% { opacity: .35; } 50% { opacity: .6; } }
@keyframes auth-grid-fade { 0%,100% { opacity: .03; } 50% { opacity: .07; } }
@keyframes auth-ring-spin { from { transform: translate(-50%,-50%) rotate(0); } to { transform: translate(-50%,-50%) rotate(360deg); } }

.animate-fade-up { animation: fade-up .3s cubic-bezier(.16,1,.3,1) both; }
.animate-fade-in { animation: fade-in .2s ease both; }
.stagger > * { animation: fade-up .28s cubic-bezier(.16,1,.3,1) both; }
.stagger > *:nth-child(1){animation-delay:0ms}.stagger > *:nth-child(2){animation-delay:30ms}
.stagger > *:nth-child(3){animation-delay:60ms}.stagger > *:nth-child(4){animation-delay:90ms}
.stagger > *:nth-child(5){animation-delay:120ms}.stagger > *:nth-child(6){animation-delay:150ms}
.stagger > *:nth-child(7){animation-delay:180ms}.stagger > *:nth-child(8){animation-delay:210ms}
.stagger > *:nth-child(9){animation-delay:240ms}.stagger > *:nth-child(10){animation-delay:270ms}
.stagger > *:nth-child(n+11){animation-delay:300ms}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration:.001ms !important; animation-iteration-count:1 !important; } }

/* ════════════════ SPLIT-SCREEN AUTH / NDA ════════════════ */
.split { display: flex; min-height: 100dvh; }
.brand-panel { position: relative; display: none; flex-shrink: 0; overflow: hidden; background: var(--ink); flex-direction: column; justify-content: space-between; }
@media (min-width: 1024px) { .brand-panel { display: flex; width: 50%; } }
.bp-grid { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 28px 28px; animation: auth-grid-fade 8s ease-in-out infinite; }
.bp-orb1 { position: absolute; top: -8rem; right: -8rem; width: 420px; height: 420px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(255,255,255,.06) 0%, transparent 70%); animation: auth-float-1 14s ease-in-out infinite; }
.bp-orb2 { position: absolute; bottom: -6rem; left: -6rem; width: 340px; height: 340px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(255,255,255,.04) 0%, transparent 70%); animation: auth-float-2 18s ease-in-out infinite; }
.bp-ring1 { position: absolute; top: 50%; left: 50%; width: 500px; height: 500px; border-radius: 50%; pointer-events: none; border: 1px solid rgba(255,255,255,.04); animation: auth-ring-spin 90s linear infinite; }
.bp-ring2 { position: absolute; top: 50%; left: 50%; width: 360px; height: 360px; border-radius: 50%; pointer-events: none; border: 1px solid rgba(255,255,255,.03); animation: auth-ring-spin 120s linear infinite reverse; }
.bp-mark { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); pointer-events: none; animation: auth-pulse-glow 6s ease-in-out infinite; }
.bp-dot { position: absolute; border-radius: 50%; pointer-events: none; }
.bp-content { position: relative; z-index: 10; display: flex; height: 100%; flex-direction: column; justify-content: space-between; padding: 2.75rem; }
.bp-logo-img { height: 24px; width: auto; align-self: flex-start; }
.bp-eyebrow { margin: 0 0 1rem; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.3); }
.bp-hero { font-size: 2rem; line-height: 1.15; font-weight: 700; color: #fff; letter-spacing: -.03em; }
.bp-sub { margin: 1rem 0 0; max-width: 320px; font-size: 14px; line-height: 1.6; color: rgba(255,255,255,.35); }
.bp-bullets { margin-top: 2rem; display: flex; flex-direction: column; gap: .8rem; }
.bp-bullet { display: flex; align-items: center; gap: 12px; }
.bp-bullet .ic { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; background: rgba(255,255,255,.06); backdrop-filter: blur(4px); }
.bp-bullet .ic svg { width: 14px; height: 14px; color: rgba(255,255,255,.45); }
.bp-bullet span { font-size: 13px; color: rgba(255,255,255,.42); }
.bp-foot { font-size: 11px; color: rgba(255,255,255,.15); }

.form-side { display: flex; flex: 1; align-items: center; justify-content: center; background: var(--background); padding: 3.5rem 1.5rem; }
@media (min-width: 1024px) { .form-side { width: 50%; } }
.form-box { width: 100%; max-width: 360px; }
.form-box.nda { max-width: 520px; }
.mobile-logo-img { height: 22px; width: auto; margin-bottom: 2rem; display: block; }
@media (min-width: 1024px) { .mobile-logo-img { display: none; } }

.form-icon { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 8%, transparent); display: grid; place-items: center; margin-bottom: 1.25rem; }
.form-icon svg { width: 19px; height: 19px; color: var(--brand); }
h1.form-title { font-size: 1.65rem; font-weight: 700; color: var(--foreground); letter-spacing: -.03em; margin: 0 0 .35rem; }
.form-desc { font-size: 14px; color: var(--muted-foreground); margin: 0 0 1.75rem; line-height: 1.55; }
.form-desc strong { color: var(--foreground); font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 1rem; }
.field label { font-size: 14px; font-weight: 500; color: var(--foreground); }
.field-input { position: relative; }
.field-input > svg { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-foreground); pointer-events: none; }
.input {
  width: 100%; height: 40px; font-family: var(--font-sans); font-size: 14px; color: var(--foreground);
  padding: 0 14px 0 36px; border: 1px solid var(--input); border-radius: 12px; background: var(--background);
  box-shadow: var(--shadow-xs); transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
.input.no-icon { padding-left: 14px; }
.input.code { letter-spacing: .3em; font-weight: 600; }
.input.err { border-color: var(--destructive); }
.input.err:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent); }
.field-err { font-size: 12px; color: var(--destructive); margin: 0; }

.btn {
  appearance: none; cursor: pointer; width: 100%; height: 40px; border: none; border-radius: 12px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: var(--brand-foreground); transition: all .18s ease;
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 90%, #fff); }
.btn:active:not(:disabled) { transform: scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.mt { margin-top: .25rem; }

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 1.5rem; font-size: 12px; font-weight: 500; color: var(--muted-foreground); background: none; border: none; cursor: pointer; font-family: var(--font-sans); transition: color .15s ease; }
.back-link:hover { color: var(--foreground); }
.back-link svg { width: 14px; height: 14px; }
.resend { margin-top: 1.5rem; text-align: center; font-size: 14px; color: var(--muted-foreground); }
.link-btn { background: none; border: none; padding: 0; cursor: pointer; font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: var(--foreground); text-underline-offset: 4px; }
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: var(--muted-foreground); cursor: not-allowed; }
.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: 12px; margin-top: 1rem; font-size: 13px; line-height: 1.45; }
.alert.error { background: color-mix(in srgb, var(--destructive) 8%, transparent); color: var(--destructive); font-weight: 500; }
.alert.ok { border: 1px solid var(--border); color: var(--foreground); }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.alert.hidden { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }

/* NDA rendered as a sheet of paper: transparent, hairline border at /60,
   serif body, generous leading. No fill, no shadow — just the document. */
.nda-paper {
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 14px; background: transparent; padding: 30px 32px;
  max-height: 320px; overflow: auto; margin: .25rem 0 1.5rem;
}
.nda-head { text-align: center; }
.nda-kicker { font-size: 10.5px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted-foreground); }
.nda-title { font-family: var(--font-serif); font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 8px 0 10px; color: var(--foreground); }
.nda-parties { font-family: var(--font-serif); font-size: 13.5px; font-style: italic; color: var(--muted-foreground); margin: 0; }
.nda-parties strong { font-style: normal; font-weight: 600; color: var(--foreground); }
.nda-rule { height: 1px; background: color-mix(in srgb, var(--border) 60%, transparent); margin: 22px 0; }
.nda-clauses { font-family: var(--font-serif); font-size: 14px; line-height: 1.7; color: color-mix(in srgb, var(--foreground) 80%, transparent); }
.nda-clauses p { margin: 0 0 14px; }
.nda-clauses strong { font-weight: 600; color: var(--foreground); }
.nda-clauses ol { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 11px; }
.nda-clauses ol li { padding-left: 4px; }
.nda-clauses ol li::marker { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.nda-fine { font-size: 12.5px; font-style: italic; color: var(--muted-foreground); margin-bottom: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 1.25rem; cursor: pointer; user-select: none; }
.check input { margin-top: 2px; width: 16px; height: 16px; flex: none; accent-color: var(--foreground); }
.check span { font-size: 13px; color: var(--foreground); line-height: 1.5; }

/* ════════════════ DASHBOARD CHROME: sidebar + header + content ════════════════ */
.layout { display: flex; min-height: 100dvh; background: var(--background); }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
}
@media (max-width: 860px) { .sidebar { display: none; } }
.sb-head { height: 57px; flex-shrink: 0; display: flex; align-items: center; gap: 9px; padding: 0 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 18px; letter-spacing: -.045em; }
.sb-head .sb-mark { width: 20px; height: 20px; color: var(--foreground); flex: none; }
.sb-head .sb-word { font-size: 19px; font-weight: 700; letter-spacing: -.045em; color: var(--foreground); }
.sb-body { flex: 1; overflow-y: auto; padding: 12px 8px; }
.sb-group { margin-bottom: 8px; }
.sb-label { padding: 8px 10px 4px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--muted-foreground) 50%, transparent); }
.sb-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; color: var(--muted-foreground); transition: all .1s ease; cursor: pointer; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
}
.sb-item svg { width: 17px; height: 17px; flex: none; }
.sb-item .lbl { overflow: hidden; text-overflow: ellipsis; }
.sb-item:hover { background: var(--muted); color: var(--foreground); }
.sb-item.active { font-weight: 600; color: var(--foreground); background: color-mix(in srgb, var(--foreground) 6%, transparent); }

/* ════════════════ TREE COMPONENT (shared) ════════════════
   Modeled on shadcn SidebarMenuSub. The guide rail is a single border-left on
   the children container (mx-3.5 px-2.5); rows are h-7, rounded-md, restrained.
   The same component renders the sidebar document tree and the page outline. */
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--tree-row-h);
  padding: 4px 8px; border: none; background: none; cursor: pointer; font-family: var(--font-sans);
  font-size: 13px; color: var(--tree-fg); border-radius: var(--tree-radius);
  transition: background .1s ease, color .1s ease; text-align: left;
}
.tree-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .tw-ic { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.tree-row .tw-ic svg { width: 16px; height: 16px; }
.tree-row:hover { background: var(--accent); color: var(--tree-fg-strong); }

/* Chevron disclosure (folders only; files render an empty spacer of same width) */
.tw-chev { width: 14px; height: 14px; flex: none; display: grid; place-items: center; color: var(--tree-fg); transition: transform .18s cubic-bezier(.16,1,.3,1); }
.tw-chev svg { width: 12px; height: 12px; }
.tree-folder.open > .tree-toggle .tw-chev { transform: rotate(90deg); }
.tree-folder.open > .tree-toggle .lbl, .tree-toggle.on-path .lbl { color: var(--tree-fg-strong); }

/* Children: indented group with a single hairline rail (shadcn SidebarMenuSub:
   mx-3.5, translate-x-px, border-l, px-2.5). The list shifts +1px so an active
   row's flush left edge can sit on the rail. */
.tree-children {
  display: none; flex-direction: column; gap: 1px; min-width: 0;
  margin: 1px 0 1px 14px; padding-left: 10px; transform: translateX(1px);
  border-left: 1px solid var(--tree-rail);
}
.tree-folder.open > .tree-children { display: flex; }

/* Active row: subtle accent fill + medium weight, no rail recoloring. */
.tree-file.active, .tree-row.active { background: var(--tree-active-bg); color: var(--tree-fg-strong); font-weight: 500; }
.tree-file.active .tw-ic { color: var(--tree-fg-strong); }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 8px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.sb-user .av { width: 30px; height: 30px; border-radius: 50%; background: var(--foreground); color: var(--background); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.sb-user .meta { min-width: 0; flex: 1; }
.sb-user .nm { font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .em { font-size: 11px; color: var(--muted-foreground); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .out { width: 28px; height: 28px; border-radius: 7px; border: none; background: none; color: var(--muted-foreground); cursor: pointer; display: grid; place-items: center; flex: none; transition: all .12s ease; }
.sb-user .out:hover { background: var(--muted); color: var(--foreground); }
.sb-user .out svg { width: 15px; height: 15px; }
/* Platform version row — pixel-exact port of B2B PlatformVersionRow.
   row:   mt-1 flex justify-between px-2
   label: text-[10px] font-medium tracking-[0.08em] text-muted-foreground/50 uppercase
   pill:  rounded-md bg-[var(--brand)]/10 px-1.5 py-0.5 text-[10px] font-semibold
          text-[var(--brand)] tabular-nums */
.sb-version { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; padding: 0 8px; }
.sb-version-label {
  font-size: 10px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
}
.sb-version-pill {
  font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 2px 6px; border-radius: calc(var(--radius) - 2px);
  background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-header {
  position: sticky; top: 0; z-index: 30; height: 57px; flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 80%, transparent); backdrop-filter: blur(12px);
}
.hdr-trigger { width: 28px; height: 28px; margin-left: -4px; border: none; background: none; border-radius: 7px; color: var(--muted-foreground); cursor: pointer; display: grid; place-items: center; transition: all .12s ease; }
.hdr-trigger:hover { background: var(--accent); color: var(--foreground); }
.hdr-trigger svg { width: 17px; height: 17px; }
.hdr-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.main-header .h-title { display: flex; flex-direction: column; }

/* ─── Header right side — pixel-exact port of B2B siteHeader ───
   ml-auto flex items-center gap-3 (theme toggle + user block). */
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ThemeToggle: h-7 w-7 rounded-md text-muted-foreground hover:bg-accent.
   Shows the icon for the CURRENT resolved theme (sun in light, moon in dark),
   matching B2B's ActiveIcon = resolvedTheme==='dark' ? Moon : Sun. */
.theme-toggle { width: 28px; height: 28px; border: none; background: none; border-radius: 6px; color: var(--muted-foreground); cursor: pointer; display: grid; place-items: center; transition: color .12s ease, background .12s ease; outline: none; }
.theme-toggle:hover { background: var(--accent); color: var(--foreground); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .ic-sun { display: grid; place-items: center; }
.theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: grid; place-items: center; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ic-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .ic-moon { display: grid; place-items: center; }
}

/* User block: flex items-center gap-2.5; name/email stack (gap-[3px],
   right-aligned, hidden < sm); circular avatar h-7 w-7 ring-1 ring-border. */
.hdr-user { display: flex; align-items: center; gap: 10px; cursor: default; }
.hu-names { display: none; flex-direction: column; align-items: flex-end; gap: 3px; }
@media (min-width: 640px) { .hu-names { display: flex; } }
.hu-name { font-size: 13px; font-weight: 500; line-height: 1; color: var(--foreground); }
.hu-email { font-size: 11px; line-height: 1; color: color-mix(in srgb, var(--muted-foreground) 60%, transparent); }
.hu-av { width: 28px; height: 28px; border-radius: 50%; background: var(--foreground); color: var(--background); display: grid; place-items: center; font-size: 10px; font-weight: 600; box-shadow: 0 0 0 1px var(--border); flex: none; }
.main-header .h-title .t { font-size: 14px; font-weight: 600; line-height: 1.2; }
.main-header .h-title .s { font-size: 11px; color: var(--muted-foreground); line-height: 1.3; }

/* Collapsible sidebar */
.sidebar.collapsed { display: none; }

.content { flex: 1; padding: 28px 40px 72px; width: 100%; min-width: 0; }

/* Breadcrumbs */
.crumbs { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13px; margin-bottom: 18px; }
.crumbs a { color: var(--muted-foreground); font-weight: 500; transition: color .15s; }
.crumbs a:hover { color: var(--foreground); }
.crumbs .sep { color: var(--border); }
.crumbs .current { color: var(--foreground); font-weight: 600; }

.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 1.5rem; letter-spacing: -.03em; font-weight: 700; }
.page-head .sub { color: var(--muted-foreground); font-size: 13.5px; margin-top: 5px; }

/* ─── File table (mirrors shadcn Table) ─── */
.filetable-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.filetable { width: 100%; border-collapse: collapse; font-size: 14px; }
.filetable thead th { height: 40px; padding: 0 16px; text-align: left; font-weight: 500; font-size: 12px; color: var(--muted-foreground); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--sidebar) 50%, var(--background)); white-space: nowrap; }
.filetable tbody tr { border-bottom: 1px solid var(--border); transition: background .12s ease; cursor: pointer; }
.filetable tbody tr:last-child { border-bottom: none; }
.filetable tbody tr:hover { background: color-mix(in srgb, var(--muted) 50%, transparent); }
.filetable td { padding: 0 16px; height: 56px; line-height: 1; vertical-align: middle; }
.filetable td a { display: flex; align-items: center; }
.fname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fname .ic { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--secondary); }
.fname .ic svg { width: 17px; height: 17px; color: var(--foreground); display: block; }
.fname .ic.folder { background: color-mix(in srgb, var(--foreground) 7%, transparent); }
.fname .nm { font-weight: 600; font-size: 14px; letter-spacing: -.01em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-type { width: 130px; color: var(--muted-foreground); font-size: 13px; }
.col-size { width: 110px; color: var(--muted-foreground); font-size: 13px; font-variant-numeric: tabular-nums; }
/* Chevron cell: fixed-size flex box so folder rows (with a chevron) and file
   rows (without) have identical cell metrics — no height drift between rows. */
.col-chev { width: 40px; padding-left: 0; }
.col-chev .chev-box { display: flex; align-items: center; justify-content: flex-end; height: 16px; color: color-mix(in srgb, var(--muted-foreground) 55%, transparent); }
.col-chev .chev-box svg { width: 16px; height: 16px; display: block; }
.col-size .dash { color: var(--border); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; background: var(--secondary); font-size: 11.5px; font-weight: 500; color: var(--foreground); line-height: 1; }

.empty { text-align: center; padding: 72px 20px; color: var(--muted-foreground); }
.empty .ic { width: 52px; height: 52px; border-radius: 14px; background: var(--secondary); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .ic svg { width: 24px; height: 24px; color: var(--muted-foreground); }
.empty .big { font-family: var(--font-serif); font-style: italic; font-size: 19px; color: var(--foreground); margin-bottom: 6px; }
.empty p { font-size: 14px; }

/* ─── Document viewer ─── */
.doc-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.doc-bar .grow { flex: 1; }
.btn-sm { width: auto; height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-ghost { background: var(--background); color: var(--foreground); border: 1px solid var(--border); box-shadow: var(--shadow-xs); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { background: var(--accent); }
.btn-ghost svg { width: 15px; height: 15px; }
/* Tertiary: no border, no fill, no shadow — a quiet text+icon action. */
.btn-tertiary { background: transparent; color: var(--muted-foreground); border: none; box-shadow: none; font-weight: 500; padding: 0 6px; margin-left: -6px; }
.btn-tertiary:hover:not(:disabled) { background: transparent; color: var(--foreground); }
.btn-tertiary svg { width: 15px; height: 15px; }

.doc-card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); background: var(--card); overflow: hidden; }

/* Editorial reading column. Fills the card width with generous padding; body
   text holds a comfortable measure via max-width on text blocks (below) while
   tables, images, and centered HTML use the full width. */
.prose {
  max-width: none; margin: 0; padding: 60px 72px 72px;
  font-size: 16.5px; line-height: 1.75; color: color-mix(in srgb, var(--foreground) 90%, transparent);
}
@media (max-width: 900px) { .prose { padding: 44px 40px 52px; } }
@media (max-width: 700px) { .prose { padding: 36px 24px 44px; font-size: 16px; } }
/* Keep prose text at a readable measure even though the card is wide, but let
   block-level visuals (tables, images, hr, centered HTML) span the full width. */
.prose > p, .prose > ul, .prose > ol, .prose > blockquote, .prose > h1,
.prose > h2, .prose > h3, .prose > h4 { max-width: 760px; }
.prose > div[align="center"], .prose > .table-wrap, .prose > table,
.prose > img, .prose > hr, .prose > figure { max-width: none; }

.prose > *:first-child { margin-top: 0 !important; }
.prose > *:last-child { margin-bottom: 0 !important; }

.prose h1, .prose h2, .prose h3, .prose h4 { letter-spacing: -.022em; line-height: 1.25; font-weight: 700; color: var(--foreground); }
.prose h1 { font-size: 2.1em; margin: 0 0 .5em; letter-spacing: -.035em; }
/* The opening paragraph after the title reads as a lead. */
.prose h1 + p { font-size: 1.12em; line-height: 1.6; color: var(--muted-foreground); margin: 0 0 1.6em; }
.prose h2 { font-size: 1.32em; margin: 2em 0 .7em; padding-bottom: .4em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.12em; margin: 1.7em 0 .5em; }
.prose h4 { font-size: 1em; margin: 1.5em 0 .5em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
.prose p { margin: 0 0 1.2em; }
.prose a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--foreground) 30%, transparent); transition: text-decoration-color .15s; }
.prose a:hover { text-decoration-color: var(--foreground); }
.prose strong { font-weight: 600; color: var(--foreground); }

/* Lists: tighter line spacing inside an item, clear gap between items, marker tinted. */
.prose ul, .prose ol { margin: 0 0 1.3em; padding-left: 1.5em; }
.prose li { margin: .5em 0; padding-left: .2em; line-height: 1.6; }
.prose li::marker { color: var(--muted-foreground); }
.prose ol li::marker { font-variant-numeric: tabular-nums; font-weight: 500; }
.prose li > ul, .prose li > ol { margin: .5em 0 .2em; }

.prose blockquote { margin: 1.6em 0; padding: .35em 0 .35em 1.3em; border-left: 2.5px solid var(--foreground); color: var(--muted-foreground); font-family: var(--font-serif); font-style: italic; font-size: 1.05em; line-height: 1.6; }
.prose blockquote p { margin: 0; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: var(--muted); padding: .15em .4em; border-radius: 5px; font-weight: 500; }
.prose pre { background: var(--sidebar); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; overflow: auto; margin: 1.5em 0; }
.prose pre code { background: none; padding: 0; font-size: .85em; line-height: 1.6; }
.prose img { max-width: 100%; height: auto; margin: 1.6em 0; display: block; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.6em 0; }
.table-wrap { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--border); border-radius: 10px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92em; }
.prose th, .prose td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.prose th { font-weight: 600; background: var(--sidebar); font-size: .92em; letter-spacing: .01em; }
.prose tr:last-child td { border-bottom: none; }

.pdf-frame { width: 100%; height: 82vh; border: none; border-radius: var(--radius); background: var(--card); display: block; }
.img-view { max-width: 100%; display: block; margin: 0 auto; border-radius: calc(var(--radius) - 4px); }
.doc-note { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted-foreground); }
.doc-note svg { width: 15px; height: 15px; }
.outline-empty { font-size: 12.5px; color: color-mix(in srgb, var(--muted-foreground) 75%, transparent); padding: 2px 8px; line-height: 1.5; }

/* ════════════════════════════════════════════════════════════════════════
   CONTENT PROTECTION  (client-side deterrents — not absolute security)
   The authoritative protection is server-side per-view logging. These raise
   friction against casual copying/screenshotting and leave a forensic trace.
   ════════════════════════════════════════════════════════════════════════ */

/* Disable selection + native drag everywhere inside the protected app. */
.protected, .protected * {
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-user-drag: none; -webkit-touch-callout: none;
}
.protected img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

.doc-card { position: relative; }

/* ─── Document + on-this-page outline rail ─── */
.doc-layout { display: block; }
.doc-layout.has-rail { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 40px; align-items: start; }
@media (max-width: 1080px) { .doc-layout.has-rail { grid-template-columns: minmax(0,1fr); } .doc-layout.has-rail .outline { display: none; } }

.outline { position: sticky; top: 81px; padding-top: 4px; }
.outline-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--muted-foreground) 55%, transparent); padding: 0 0 12px 2px; }
.outline-tree { display: flex; flex-direction: column; gap: 1px; }

/* Outline rows. Top-level entries are bold anchors; nested entries hang off a
   clear vertical guide rail so the tree structure is unmistakable. */
.outline-item { position: relative; padding: 5px 8px; border-radius: 6px; color: var(--tree-fg); font-size: 13px; font-weight: 400; line-height: 1.4; }
.outline-item .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.outline-item:hover { background: var(--muted); color: var(--tree-fg-strong); }
.outline-item.o-top { font-weight: 600; color: var(--tree-fg-strong); margin-top: 4px; }
.outline-item.o-top:first-child { margin-top: 0; }

/* Nested group: indented, with a visible guide rail connecting to the parent. */
.outline-children {
  display: flex; flex-direction: column; gap: 1px;
  margin: 2px 0 2px 9px; padding-left: 13px;
  border-left: 1.5px solid var(--border);
}
.outline-children .outline-item { font-size: 12.5px; color: var(--tree-fg); }
.outline-children .outline-children { margin-left: 4px; }
.outline-children .outline-children .outline-item { font-size: 12px; }

/* Active row: filled pill; if it's a nested item, light up its rail segment. */
.outline-item.active { background: var(--tree-active-bg); color: var(--tree-fg-strong); font-weight: 500; }
.outline-children:has(> .outline-item.active) { border-left-color: color-mix(in srgb, var(--foreground) 35%, transparent); }
.outline-item.active { background: var(--tree-active-bg); color: var(--tree-fg-strong); font-weight: 500; }

/* Screenshot-key panic veil: if a print/screenshot keystroke is detected we
   blank the page to black for a moment. */
.screen-guard {
  position: fixed; inset: 0; z-index: 9999; background: #0a0a0a; display: none;
  align-items: center; justify-content: center; color: rgba(255,255,255,.5); font-size: 13px;
}
.screen-guard.on { display: flex; }

/* Print is blocked outright — confidential material must not leave as paper. */
@media print {
  body { display: none !important; }
  html::after {
    content: "This material is confidential and cannot be printed.";
    display: block; padding: 40px; font-family: var(--font-sans); color: #000;
  }
}
