/* Dataroom chrome — semantic tokens only, from the shared brand.css (the hub's token layer).
   If a value you need isn't a token, add the token upstream rather than a hex here. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-canvas);
  color: var(--color-text);
  font: var(--text-base) / var(--leading-body) var(--font-sans);
}

a { color: var(--color-link); }
a:hover { color: var(--color-link-hover); }
h1, h2, h3 { color: var(--color-heading); line-height: var(--leading-tight); }
code { font-family: var(--font-mono); font-size: 0.92em; }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  z-index: 20;
}
.skip:focus { top: var(--space-2); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

.muted { color: var(--color-text-muted); }
.hint { margin: 0; font-size: var(--text-sm); color: var(--color-text-subtle); }
.eyebrow {
  margin: 0 0 var(--space-1);
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text-muted);
}
.status { color: var(--color-text-muted); }
.empty {
  margin: 0;
  padding: var(--space-7) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
}

.icon { display: inline-flex; flex: none; }
.icon svg { display: block; }

/* ---- Top bar ------------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: 60px;
  padding: 0 var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
}

.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.brand img { display: block; height: 24px; width: auto; }
/* The logo follows the theme: the OS choice, unless the reader picked one (data-theme). */
.brand .on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .on-light { display: none; }
  :root:not([data-theme="light"]) .brand .on-dark { display: block; }
}
:root[data-theme="dark"] .brand .on-light { display: none; }
:root[data-theme="dark"] .brand .on-dark { display: block; }
.brand-tag {
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text-muted);
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-3);
}

/* Dataroom | Manage — a segmented switch, admins only. */
.mode {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}
.mode a {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
}
.mode a:hover { color: var(--color-text); }
.mode a[aria-current="page"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

.user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-out { white-space: nowrap; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ---- Page frame ---------------------------------------------------------------------------- */

.content {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.card > h2 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.card > .muted { margin: 0 0 var(--space-4); }

/* ---- Buttons and fields -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--color-accent); color: var(--color-text-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); color: var(--color-text-on-accent); }
.btn-ghost { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover:not(:disabled) { background: var(--color-accent-subtle); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: var(--color-text-on-accent); }
.btn-danger:hover { filter: brightness(1.08); color: var(--color-text-on-accent); }
.btn-quiet-danger { color: var(--color-danger); }
.btn-quiet-danger:hover:not(:disabled) { background: var(--color-danger-surface); color: var(--color-danger); }
.btn-small { padding: 2px var(--space-2); font-size: var(--text-sm); font-weight: 500; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--color-accent-subtle); }

.field { display: grid; gap: var(--space-1); font-size: var(--text-sm); font-weight: 600; }
.field input, .field select, .search input {
  font: inherit;
  font-weight: 400;
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  min-width: 0;
}
.field input:focus, .field select:focus, .search input:focus {
  outline: 2px solid var(--color-focus);
  outline-offset: -1px;
  border-color: transparent;
}
.check { display: flex; align-items: center; gap: var(--space-2); }
.check input { width: 16px; height: 16px; accent-color: var(--color-accent); }

.form-error {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  color: var(--color-danger);
  background: var(--color-danger-surface);
  border-radius: var(--radius-md);
}

/* ---- Sidebar lists (investor folders, admin folders) ---------------------------------------- */

.nav-title {
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-3);
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text-subtle);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list a, .nav-list button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-list a:hover, .nav-list button:hover { background: var(--color-accent-subtle); }
.nav-list [aria-current="page"] { background: var(--color-accent-subtle); font-weight: 600; }
.nav-list [aria-current="page"] .icon { color: var(--color-accent); }
.nav-list .icon { color: var(--color-text-muted); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: var(--text-xs); color: var(--color-text-subtle); font-variant-numeric: tabular-nums; }

/* ---- Investor view: folders + documents ---------------------------------------------------- */

.room { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.room-nav { position: sticky; top: calc(60px + var(--space-6)); }

.room-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.room-head h1 { margin: 0; font-size: var(--text-xl); }
.search input { width: 260px; max-width: 100%; }

.doc-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.doc-rows:empty { display: none; }
.doc-rows li + li { border-top: 1px solid var(--color-border-subtle); }
.doc-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  text-decoration: none;
  transition: background var(--duration) var(--ease);
}
.doc-row:hover { background: var(--color-surface-sunken); color: var(--color-text); }
.doc-row > .icon { color: var(--color-text-subtle); }
.doc-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-danger-surface);
  color: var(--color-danger);
}
.doc-text { flex: 1; min-width: 0; display: grid; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { display: block; font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 400; }

/* ---- Acknowledgement ----------------------------------------------------------------------- */

.ack { max-width: 760px; margin: var(--space-4) auto; border-top: var(--rule-width) solid var(--color-accent); }
.ack h1 { margin: 0 0 var(--space-4); font-size: var(--text-xl); }
.ack-text {
  max-height: 48vh;
  overflow: auto;
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-md);
}
.ack-text > :first-child { margin-top: 0; }
.ack-text > :last-child { margin-bottom: 0; }
.ack-text li + li { margin-top: var(--space-2); }
.ack-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }

/* ---- Viewer -------------------------------------------------------------------------------- */

.is-viewer .content { max-width: 1100px; padding-top: var(--space-4); }
.viewer-bar { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.viewer-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-lg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager { display: flex; align-items: center; gap: var(--space-2); }
.pager-count { min-width: 8ch; text-align: center; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.page-frame { display: flex; justify-content: center; }
.page-canvas {
  display: block;
  max-width: 100%;
  background: var(--white);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
}

/* ---- Console ------------------------------------------------------------------------------- */

.console-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.console-head h1 { margin: 0; font-size: var(--text-xl); }

/* Scrolls sideways on a narrow screen, never up and down: overflow-x alone switches overflow-y on
   too, and a tab overlapping the underline made the bar 1px too tall — hence the stray
   scrollbar. The underline is an inset shadow now, inside the box. */
.tablist {
  display: flex;
  gap: var(--space-5);
  box-shadow: inset 0 -1px 0 var(--color-border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tablist::-webkit-scrollbar { display: none; }
.tablist [role="tab"] {
  flex: none;
  padding: var(--space-2) 0 var(--space-3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tablist [role="tab"]:hover { color: var(--color-text); }
.tablist [role="tab"][aria-selected="true"] { color: var(--color-heading); border-bottom-color: var(--color-accent); }

.split { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.split-nav {
  padding: var(--space-3) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
}
.split-nav-head { display: flex; align-items: center; justify-content: space-between; padding-right: var(--space-1); margin-bottom: var(--space-2); }
.split-nav-head .nav-title { margin: 0; }
.split-main {
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.pane-head h2 { margin: 0 0 var(--space-1); font-size: var(--text-lg); }
.pane-head .muted { margin: 0; }
.pane-actions { display: flex; gap: var(--space-2); }
.pane-empty { padding: var(--space-7) var(--space-4); text-align: center; }
.pane-empty h2 { margin: 0 0 var(--space-2); }
.pane-empty p { max-width: 46ch; margin: 0 auto var(--space-4); }

.dropzone {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-sunken);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--color-accent); background: var(--color-accent-subtle); }
.dropzone-icon { color: var(--color-accent); }
.link { color: var(--color-link); text-decoration: underline; }

.uploads { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-2); }
.uploads:empty { display: none; }
.upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-track { height: 6px; border-radius: var(--radius-pill); background: var(--color-border-subtle); overflow: hidden; }
.upload-bar { display: block; height: 100%; width: var(--p, 0%); background: var(--color-accent); transition: width 120ms linear; }
.upload.is-done .upload-bar { background: var(--color-success); }
.upload.is-done .upload-state { color: var(--color-success); }
.upload.is-error .upload-state { color: var(--color-danger); }
.upload-state { color: var(--color-text-muted); white-space: nowrap; }

.callout {
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  border-left: var(--rule-width) solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.callout a { white-space: nowrap; margin-left: var(--space-1); }

.inline-form { display: flex; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.inline-form .field:first-child { flex: 1; min-width: 220px; }

.person { display: inline-flex; align-items: center; gap: var(--space-2); }
.chips { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }
.chip {
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-accent-subtle);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat-label { font-size: var(--text-sm); color: var(--color-text-muted); }
.stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat-value--text { font-size: var(--text-md); line-height: 2.1rem; }
.stat-note { font-size: var(--text-sm); color: var(--color-text-subtle); }

.subhead {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Time by page — vertical bars, page numbers underneath. */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-bottom: 18px; overflow-x: auto; }
.bar-col { position: relative; display: flex; align-items: flex-end; flex: 1 0 14px; max-width: 36px; height: 100%; }
.bar { display: block; width: 100%; height: var(--h); min-height: 1px; background: var(--color-accent); border-radius: 2px 2px 0 0; }
.bar-label {
  position: absolute;
  left: 0; right: 0;
  bottom: -18px;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  font-variant-numeric: tabular-nums;
}

.page-strip { display: inline-flex; align-items: flex-end; gap: 2px; height: 24px; }
.page-bar { flex: 0 0 5px; height: var(--h); background: var(--color-accent); border-radius: 1px; }

/* ---- Tables -------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th {
  text-align: left;
  font-size: var(--label-size);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td { padding: var(--space-3); border-bottom: 1px solid var(--color-border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-rows tbody tr { cursor: pointer; }
.table-rows tbody tr:hover, .table-rows tbody tr[aria-selected="true"], .table-rows tbody tr[aria-expanded="true"] {
  background: var(--color-surface-sunken);
}
.detail-row td { background: var(--color-surface-sunken); padding: 0 var(--space-4) var(--space-4); }
.table-inner { font-size: var(--text-sm); background: var(--color-surface); border-radius: var(--radius-md); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: var(--space-1); }
.doc-cell { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text); text-decoration: none; min-width: 0; }
.doc-cell:hover .doc-title { text-decoration: underline; }
.doc-cell .doc-icon { width: 30px; height: 30px; }

/* ---- Dialog and toast ---------------------------------------------------------------------- */

.dialog {
  width: min(440px, calc(100vw - 2 * var(--space-4)));
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(15 23 32 / 0.45); }
.dialog-form { display: grid; gap: var(--space-4); padding: var(--space-5); }
.dialog-form h2 { margin: 0; font-size: var(--text-lg); }
.dialog-form p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  z-index: 30;
}
.toast.is-error { background: var(--color-danger); color: var(--color-text-on-accent); }

/* ---- Small screens ------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .room, .split { grid-template-columns: minmax(0, 1fr); }
  .room-nav { position: static; }
  .nav-list { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar { padding: 0 var(--space-4); gap: var(--space-3); }
  .content { padding: var(--space-5) var(--space-4) var(--space-7); }
  .brand-tag, .user-email { display: none; }
  .console-head { flex-wrap: wrap; align-items: flex-start; }
  .upload { grid-template-columns: minmax(0, 1fr) auto; }
  .upload-track { display: none; }
  .search, .search input { width: 100%; }
}

/* ==== Projects, Q&A, permissions ============================================================= */

.page-head { margin-bottom: var(--space-5); }
.page-head h1 { margin: 0 0 var(--space-1); font-size: var(--text-xl); }
.page-head .muted { margin: 0; }
.section-title { margin: 0 0 var(--space-3); font-size: var(--text-md); }

.crumbs { margin-bottom: var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); }
.crumbs a { color: var(--color-text-muted); }
.crumbs a:hover { color: var(--color-link); }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.project-card {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.project-card:hover { border-color: var(--color-accent); box-shadow: var(--shadow-md); color: var(--color-text); }
.project-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}
.project-name { font-size: var(--text-md); font-weight: 700; color: var(--color-heading); }
.project-desc { color: var(--color-text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); }
.project-stats { display: flex; gap: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }
.project-stats strong { color: var(--color-text); font-variant-numeric: tabular-nums; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-5); align-items: start; }
.dash-grid > .card > h2 { margin: 0 0 var(--space-2); font-size: var(--text-md); }
.archived { margin-top: var(--space-5); }
.archived summary { cursor: pointer; font-weight: 600; color: var(--color-text-muted); margin-bottom: var(--space-3); }

.mini-list { list-style: none; margin: 0; padding: 0; display: grid; }
.mini-list li + li { border-top: 1px solid var(--color-border-subtle); }
.mini-list a { display: grid; gap: 2px; padding: var(--space-3) 0; color: var(--color-text); text-decoration: none; }
.mini-list a:hover .mini-title { text-decoration: underline; }
.mini-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini-meta { font-size: var(--text-sm); color: var(--color-text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge-warn { background: var(--color-warning-surface); color: var(--color-warning); border-color: transparent; }
.badge-accent { background: var(--color-accent-subtle); color: var(--color-accent); border-color: transparent; }
.tab-count:not(:empty) {
  display: inline-block;
  min-width: 18px;
  margin-left: var(--space-1);
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  font-size: var(--text-xs);
  text-align: center;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-surface);
  color: var(--color-warning);
  font-weight: 600;
}

/* The room: folders + documents under the tabs. */
.room-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.folder-heading { margin: 0 0 var(--space-3); font-size: var(--text-md); }
.room-head p { margin: var(--space-1) 0 0; }
.doc-row .badge { margin-left: auto; }

/* Q&A */
.qa-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-5); align-items: start; }
.qa-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip-btn {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-text-on-accent); }
.qa-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.qa-item {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.qa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted); }
.qa-question { margin: var(--space-3) 0 0; font-size: var(--text-md); white-space: pre-wrap; }
.qa-answer {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: var(--rule-width) solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
}
.qa-answer p { margin: var(--space-1) 0 0; white-space: pre-wrap; }
.qa-answer-label { font-size: var(--label-size); letter-spacing: var(--label-tracking); text-transform: uppercase; font-weight: 600; color: var(--color-text-muted); }
.qa-item--admin form { margin-top: var(--space-3); }
.qa-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.spacer { flex: 1; }
.ask-card { position: sticky; top: calc(60px + var(--space-5)); }
.ask-card h2 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }

.stack { display: grid; gap: var(--space-3); }
textarea {
  font: inherit;
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
  width: 100%;
}
textarea:focus { outline: 2px solid var(--color-focus); outline-offset: -1px; border-color: transparent; }
.field-inline { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.field-inline select { padding: var(--space-1) var(--space-2); }

/* People */
.people-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-5); align-items: start; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
.card-head h2 { margin: 0; font-size: var(--text-lg); }
.card-head p { margin: var(--space-1) 0 0; max-width: 70ch; }
.group-list { list-style: none; margin: 0; padding: 0; }
.group-item { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; border-top: 1px solid var(--color-border-subtle); }
.group-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-select, .level-select {
  font: inherit;
  font-size: var(--text-sm);
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

/* Permissions grid: colour carries the level; the text label says it too. */
.perm-table th, .perm-table td { white-space: nowrap; }
.perm-table thead th { vertical-align: bottom; }
.col-label { display: block; text-transform: none; letter-spacing: 0; font-size: var(--text-sm); color: var(--color-text); }
.col-sub { display: block; }
.col-close { margin-left: var(--space-1); border: 0; background: none; color: var(--color-text-subtle); cursor: pointer; font-size: var(--text-md); line-height: 1; }
.perm-table tbody th { text-transform: none; letter-spacing: 0; font-size: var(--text-base); color: var(--color-text); }
.perm-folder th { font-weight: 700; color: var(--color-heading); }
.perm-folder td, .perm-folder th { background: var(--color-surface-sunken); }
.perm-doc th { font-weight: 400; padding-left: var(--space-6); }
.level-select.lvl-none { color: var(--color-danger); }
.level-select.lvl-view { color: var(--color-accent); }
.level-select.lvl-download { color: var(--color-success); }
.level-select.is-set { font-weight: 700; border-color: currentColor; }
.level-pill { font-size: var(--text-sm); font-weight: 600; }
.level-pill.lvl-none { color: var(--color-danger); }
.level-pill.lvl-view { color: var(--color-accent); }
.level-pill.lvl-download { color: var(--color-success); }

.settings-card { max-width: 640px; }
.settings-card h2 { margin: 0 0 var(--space-3); font-size: var(--text-lg); }
.viewer-actions { display: flex; gap: var(--space-2); }

@media (max-width: 960px) {
  .dash-grid, .qa-layout, .people-grid, .room-body { grid-template-columns: minmax(0, 1fr); }
  .ask-card { position: static; }
}

/* ==== File kinds and the spreadsheet viewer =================================================== */

.doc-icon.kind-sheet { background: var(--color-success-surface); color: var(--color-success); }
.doc-icon.kind-image { background: var(--color-accent-subtle); color: var(--color-accent); }
.doc-icon.kind-file { background: var(--color-surface-sunken); color: var(--color-text-muted); }

.sheet-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
}
.sheet-tabs [role="tab"] {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border-subtle);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.sheet-tabs [role="tab"][aria-selected="true"] { background: var(--color-surface); color: var(--color-heading); }

/* The watermark tile is the grid's own background (cells are transparent), scrolling with it. */
.sheet {
  min-height: 60vh;
  max-height: calc(100vh - 220px);
  overflow: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  background-color: var(--white);
  background-image: var(--wm);
  background-attachment: local;
  color: #1F2933;
  box-shadow: var(--shadow-md);
}
.sheet-table { border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.sheet-table th, .sheet-table td { border: 1px solid #E4E8EC; padding: 2px var(--space-2); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.sheet-table thead th { position: sticky; top: 0; z-index: 1; background: #F4F7F9; color: #5A6B75; font-weight: 600; text-align: center; }
.sheet-table tbody th { position: sticky; left: 0; background: #F4F7F9; color: #5A6B75; font-weight: 600; text-align: right; }
.sheet-table .corner { left: 0; z-index: 2; }
.sheet-note { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: #5A6B75; }

/* ==== Viewer questions panel ================================================================== */

.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.viewer-body.has-panel { grid-template-columns: minmax(0, 1fr) 360px; }
.is-viewer .content { max-width: 1400px; }
.viewer-main { min-width: 0; }
.qa-panel {
  position: sticky;
  top: calc(60px + var(--space-4));
  max-height: calc(100vh - 60px - var(--space-6));
  overflow: auto;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.qa-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.qa-panel-head h2 { margin: 0; font-size: var(--text-md); }
.qa-ask { padding-bottom: var(--space-4); margin-bottom: var(--space-4); border-bottom: 1px solid var(--color-border-subtle); }
.qa-panel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-4); }
.qa-panel-item .qa-question { font-size: var(--text-base); }
.qa-panel-empty { margin: 0; }
.link-btn { padding: 0; border: 0; background: none; color: var(--color-link); font: inherit; text-decoration: underline; cursor: pointer; }

@media (max-width: 960px) {
  .viewer-body.has-panel { grid-template-columns: minmax(0, 1fr); }
  .qa-panel { position: static; max-height: none; }
}

/* ==== Theme switch ============================================================================ */

.theme-toggle {
  margin-left: auto;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--color-text); background: var(--color-accent-subtle); }
.theme-toggle .theme-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .theme-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .theme-moon { display: block; }
}
