/* ==========================================================================
   Legacy Ledger — base styles + components.
   Consumes the custom properties declared in tokens.css (loaded first, see
   templates/base.html). Nothing here is load-bearing for security (that's
   the CSP header, not this file); no inline <style>, everything plain CSS,
   no build step. Component class names + usage are documented in
   docs/styleguide.md "Component class reference".
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  margin: 0;
  background-color: hsl(var(--ll-background));
  color: hsl(var(--ll-foreground));
  font-family: var(--ll-font-body);
  font-size: var(--ll-text-body);
  line-height: var(--ll-leading-body);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--ll-font-heading);
  color: hsl(var(--ll-heritage-maroon));
  line-height: 1.3;
  margin: 0 0 var(--ll-space-4) 0;
}

h1 { font-size: var(--ll-text-heading-xl); }
h2 { font-size: var(--ll-text-heading-lg); }
h3 { font-size: var(--ll-text-heading-md); }
h4 { font-size: var(--ll-text-heading-sm); }

p, span, label, li, td, th {
  overflow-wrap: break-word;
  word-break: break-word;
}

a {
  color: hsl(var(--ll-primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover:not(.btn) { opacity: 0.85; }

/* ---- Focus ring — visible on every interactive element ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--ll-background)), 0 0 0 4px hsl(var(--ll-ring));
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ll-space-4);
  margin-bottom: var(--ll-space-6);
}
.page-header h1, .page-header h2 { margin-bottom: var(--ll-space-1); }
.page-header-meta {
  margin: 0;
  color: hsl(var(--ll-muted-foreground));
  font-size: 14px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ll-space-2);
  white-space: nowrap;
  border-radius: var(--ll-radius-md);
  font-size: 14px;
  font-weight: var(--ll-weight-medium);
  height: 40px;
  padding: 0 var(--ll-space-4);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 150ms ease, opacity 150ms ease, transform 120ms ease-out;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { pointer-events: none; opacity: 0.5; }

.btn-primary {
  background-color: hsl(var(--ll-primary));
  color: hsl(var(--ll-primary-foreground));
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background-color: hsl(var(--ll-secondary));
  color: hsl(var(--ll-secondary-foreground));
}
.btn-secondary:hover { background-color: hsl(var(--ll-secondary) / 0.8); }

.btn-destructive {
  background-color: hsl(var(--ll-destructive));
  color: hsl(var(--ll-destructive-foreground));
}
.btn-destructive:hover { opacity: 0.9; }

.btn-outline {
  background-color: hsl(var(--ll-background));
  color: hsl(var(--ll-foreground));
  border-color: hsl(var(--ll-input));
}
.btn-outline:hover { background-color: hsl(var(--ll-accent) / 0.1); }

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--ll-foreground));
}
.btn-ghost:hover { background-color: hsl(var(--ll-accent) / 0.1); }
/* Destructive, but quiet until pointed at: a row-level Delete/Remove
   should not be the loudest thing in a table. */
.btn-ghost-destructive { color: hsl(var(--ll-muted-foreground)); }
.btn-ghost-destructive:hover {
  color: hsl(var(--ll-destructive));
  background-color: hsl(var(--ll-destructive) / 0.08);
}

.btn-sm { height: 36px; padding: 0 var(--ll-space-3); font-size: 13px; }
.btn-lg { height: 44px; padding: 0 var(--ll-space-8); font-size: 15px; }

/* ---- Inputs / select / textarea ---- */
/* `.field > input` covers widgets rendered straight from a Django form
   (`{{ form.field }}`, allauth's pages), which carry no class of their own. */
.input, select.select, textarea.textarea,
.field > input:not([type="checkbox"], [type="radio"], [type="hidden"]) {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--ll-space-3);
  border: 1px solid hsl(var(--ll-input));
  border-radius: var(--ll-radius-md);
  background-color: hsl(var(--ll-card));
  color: hsl(var(--ll-foreground));
  font-family: var(--ll-font-body);
  font-size: 14px;
}
textarea.textarea { height: auto; min-height: 80px; padding: var(--ll-space-3); }
.input::placeholder { color: hsl(var(--ll-muted-foreground)); }
.input:disabled, select.select:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: var(--ll-space-1); margin-bottom: var(--ll-space-4); }
.field label, .field legend {
  font-size: 15px;
  font-weight: var(--ll-weight-medium);
}
.field fieldset { border: 0; padding: 0; margin: 0; }
.field-hint { color: hsl(var(--ll-muted-foreground)); font-size: 13px; margin: 0; }
.field-error { color: hsl(var(--ll-danger)); font-size: 13px; }
.field .errorlist { color: hsl(var(--ll-danger)); font-size: 13px; list-style: none; margin: 0; padding: 0; }
.field-invalid .input, .field-invalid select.select, .field-invalid textarea.textarea { border-color: hsl(var(--ll-danger)); }
.alert .errorlist { list-style: none; margin: 0; padding: 0; }
.field-checkbox { flex-direction: row; align-items: center; gap: var(--ll-space-2); }
.field-checkbox input { width: 18px; height: 18px; margin: 0; accent-color: hsl(var(--ll-primary)); }
.field-checkbox label { font-weight: var(--ll-weight-body); }
/* Short fields side by side; a field named in `.form-grid .field-<name>`
   below spans the full row. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--ll-space-4); }
.form-grid .field-notes, .form-grid .form-actions { grid-column: 1 / -1; }
/* Submit + secondary actions under a form */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ll-space-2); margin-top: var(--ll-space-6); }
@media (max-width: 767px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---- Card ---- */
.card {
  background-color: hsl(var(--ll-card));
  color: hsl(var(--ll-card-foreground));
  border: 1px solid hsl(var(--ll-border));
  border-radius: var(--ll-radius);
  box-shadow: var(--ll-shadow-card);
  padding: var(--ll-space-6);
}
.card + .card { margin-top: var(--ll-space-4); }
/* One display face per page: the h1. Inside a card a heading is a
   section label, set in the body face so the page title stays the
   loudest thing on screen. */
.card h2, .card h3, .card h4 {
  font-family: var(--ll-font-body);
  font-size: 17px;
  font-weight: var(--ll-weight-semibold);
  color: hsl(var(--ll-foreground));
  margin-bottom: var(--ll-space-3);
}
/* A card whose content is a full-width table: no inner padding, the
   table's own rows run edge to edge. A table wider than the screen
   scrolls inside its card instead of squeezing its columns. */
.card-flush { padding: 0; overflow-x: auto; }
.card:has(> .table) { overflow-x: auto; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: var(--ll-space-6); }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: var(--ll-space-6); }
.card-flush .empty-state { padding: var(--ll-space-8) var(--ll-space-6); }
.card-flush .pagination { padding: var(--ll-space-3) var(--ll-space-6); border-top: 1px solid hsl(var(--ll-border)); }
/* Row-level actions sit at the right edge, read as quiet until hovered. */
.row-actions { display: flex; justify-content: flex-end; gap: var(--ll-space-1); white-space: nowrap; }

/* Plan surface: no-shadow flat card, forecast/plan panels only */
.surface-card {
  background-color: hsl(var(--ll-surface));
  border: var(--ll-surface-border-width) solid hsl(var(--ll-surface-border));
  border-radius: var(--ll-radius-surface);
  padding: var(--ll-surface-padding);
}

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
/* The global `word-break: break-word` lets a cell shrink to one glyph, so
   narrow screens stacked headers and file names letter by letter. Words
   stay whole here; the card scrolls instead. */
.table :is(th, td, span) { word-break: normal; }
.table th {
  white-space: nowrap;
  text-align: left;
  padding: var(--ll-space-3);
  font-size: 11px;
  font-weight: var(--ll-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--ll-muted-foreground));
  border-bottom: 1px solid hsl(var(--ll-border));
}
.table td {
  padding: var(--ll-space-3);
  border-bottom: 1px solid hsl(var(--ll-border) / 0.5);
}
.table tr:last-child td { border-bottom: 0; }
.table .tr-num { text-align: right; font-variant-numeric: tabular-nums; color: hsl(var(--ll-primary)); }
/* A group row (e.g. one day's events) between data rows */
.table .table-group th {
  padding-top: var(--ll-space-4);
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: hsl(var(--ll-foreground));
  background-color: hsl(var(--ll-muted) / 0.6);
}

/* ---- Audit log rows ---- */
.audit-table td { vertical-align: top; }
.audit-when { white-space: nowrap; font-variant-numeric: tabular-nums; color: hsl(var(--ll-muted-foreground)); }
.audit-who { max-width: 14rem; }
.audit-what { font-weight: var(--ll-weight-medium); }
.audit-target { display: block; color: hsl(var(--ll-muted-foreground)); }
.audit-details { color: hsl(var(--ll-muted-foreground)); font-size: 13px; }
.audit-details span { display: block; }
.audit-details code { font-size: 11px; opacity: 0.7; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--ll-space-3);
  font-size: 14px;
  color: hsl(var(--ll-muted-foreground));
}
.pagination a { text-decoration: none; }

/* ---- Badge / status pill ---- */
.badge {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0 var(--ll-space-3);
  height: 24px;
  font-size: 11px;
  font-weight: var(--ll-weight-bold);
  line-height: 1;
}
.badge-default { background-color: hsl(var(--ll-primary)); color: hsl(var(--ll-primary-foreground)); }
.badge-secondary { background-color: hsl(var(--ll-secondary)); color: hsl(var(--ll-secondary-foreground)); }
.badge-destructive { background-color: hsl(var(--ll-destructive)); color: hsl(var(--ll-destructive-foreground)); }
.badge-outline { background-color: transparent; color: hsl(var(--ll-foreground)); border-color: hsl(var(--ll-border)); }

/* Firm/beneficiary grant state pills — pair with text, never colour alone */
.badge-invited { background-color: hsl(var(--ll-state-invited) / 0.15); color: hsl(var(--ll-state-invited)); }
.badge-confirmed { background-color: hsl(var(--ll-state-confirmed) / 0.15); color: hsl(var(--ll-state-confirmed)); }
.badge-revoked { background-color: hsl(var(--ll-state-revoked) / 0.15); color: hsl(var(--ll-state-revoked)); }

/* Gift state pills */
.badge-verified { background-color: hsl(var(--ll-state-verified) / 0.15); color: hsl(var(--ll-state-verified)); }
.badge-waiting { background-color: hsl(var(--ll-state-waiting) / 0.15); color: hsl(var(--ll-state-waiting)); }

/* Document status pills (ADR 0006) */
.badge-received { background-color: hsl(var(--ll-state-invited) / 0.15); color: hsl(var(--ll-state-invited)); }
.badge-ready { background-color: hsl(var(--ll-state-confirmed) / 0.15); color: hsl(var(--ll-state-confirmed)); }
.badge-rejected { background-color: hsl(var(--ll-destructive) / 0.15); color: hsl(var(--ll-destructive)); }
.badge-duplicate { background-color: hsl(var(--ll-secondary)); color: hsl(var(--ll-secondary-foreground)); }
.badge-failed { background-color: hsl(var(--ll-state-revoked) / 0.15); color: hsl(var(--ll-state-revoked)); }

/* ---- Alert ---- */
.alert {
  border-radius: var(--ll-radius);
  border: 1px solid hsl(var(--ll-border));
  padding: var(--ll-space-4);
  font-size: 14px;
  margin-bottom: var(--ll-space-4);
}
.alert > p { margin: 0; font-size: inherit; }
.alert > p + p { margin-top: var(--ll-space-2); }
.alert-info { background-color: hsl(var(--ll-info) / 0.08); border-color: hsl(var(--ll-info) / 0.3); color: hsl(var(--ll-info)); }
.alert-warning { background-color: hsl(var(--ll-warning) / 0.08); border-color: hsl(var(--ll-warning) / 0.3); color: hsl(var(--ll-warning)); }
.alert-danger { background-color: hsl(var(--ll-danger) / 0.08); border-color: hsl(var(--ll-danger) / 0.3); color: hsl(var(--ll-danger)); }
.alert-success { background-color: hsl(var(--ll-success) / 0.08); border-color: hsl(var(--ll-success) / 0.3); color: hsl(var(--ll-success)); }

/* System messages (Django messages framework) reuse the alert shape */
.messages { list-style: none; margin: 0 0 var(--ll-space-4) 0; padding: 0; }
.message { padding: var(--ll-space-3) var(--ll-space-4); border-radius: var(--ll-radius); border: 1px solid hsl(var(--ll-border)); margin-bottom: var(--ll-space-2); font-size: 14px; }
.message-error { background-color: hsl(var(--ll-danger) / 0.08); border-color: hsl(var(--ll-danger) / 0.3); color: hsl(var(--ll-danger)); }
.message-success { background-color: hsl(var(--ll-success) / 0.08); border-color: hsl(var(--ll-success) / 0.3); color: hsl(var(--ll-success)); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: var(--ll-space-8) var(--ll-space-6);
  color: hsl(var(--ll-muted-foreground));
}
.empty-state p { margin: 0; }
/* One sentence where a table would be, action included */
.empty-line { margin: 0; color: hsl(var(--ll-muted-foreground)); }
.card-footer-link { margin: var(--ll-space-3) 0 0; font-size: 14px; }

/* ---- Choice list: a card of rows, each row one button ----
   For "pick one of these" screens (organization picker). Pair the
   `.choice-list` with `.card.card-flush`; the whole row is the target. */
.choice-list { list-style: none; margin: 0 0 var(--ll-space-4) 0; padding: 0; }
.choice-list li + li { border-top: 1px solid hsl(var(--ll-border)); }
.choice-list form { margin: 0; }
.choice-row {
  display: flex;
  align-items: center;
  gap: var(--ll-space-3);
  width: 100%;
  min-height: var(--ll-touch-target);
  padding: var(--ll-space-4) var(--ll-space-6);
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .choice-row:hover { background-color: hsl(var(--ll-muted)); }
}
/* Press feedback is instant; only the release fades. */
.choice-row:active { background-color: hsl(var(--ll-border)); transition-duration: 0ms; }
/* The card clips overflow, so the ring sits inside the row. */
.choice-row:focus-visible { box-shadow: inset 0 0 0 2px hsl(var(--ll-ring)); }
.choice-row-title { flex: 1; min-width: 0; font-size: 17px; font-weight: var(--ll-weight-semibold); }
.choice-row-meta { font-size: 14px; color: hsl(var(--ll-muted-foreground)); }
.choice-row::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid hsl(var(--ll-muted-foreground));
  border-bottom: 1.5px solid hsl(var(--ll-muted-foreground));
  transform: rotate(-45deg);
}

/* ---- Disclosure: a secondary action folded behind a quiet toggle ----
   A <details> whose <summary class="btn btn-ghost"> reads "+ Label";
   the content (usually a `.card` form) opens below it. */
.disclosure > summary { list-style: none; width: fit-content; color: hsl(var(--ll-muted-foreground)); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; font-size: 18px; line-height: 1; }
.disclosure[open] > summary { color: hsl(var(--ll-foreground)); }
.disclosure > .card { margin-top: var(--ll-space-2); }

/* ---- Utilities ---- */
/* Text for assistive tech only, e.g. the action a whole-row button takes. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Overview: stat strip + next steps ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ll-space-4);
  margin-bottom: var(--ll-space-4);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--ll-space-1);
  padding: var(--ll-space-4) var(--ll-space-6);
  background-color: hsl(var(--ll-card));
  border: 1px solid hsl(var(--ll-border));
  border-radius: var(--ll-radius);
  box-shadow: var(--ll-shadow-card);
  color: inherit;
  text-decoration: none;
  transition: border-color 150ms ease;
}
.stat:hover { border-color: hsl(var(--ll-primary) / 0.4); opacity: 1; }
.stat-value {
  font-family: var(--ll-font-heading);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--ll-primary));
}
.stat-label { font-size: 13px; color: hsl(var(--ll-muted-foreground)); }
.next-steps { margin: 0; padding-left: 1.25rem; }
.next-steps li + li { margin-top: var(--ll-space-2); }
@media (max-width: 767px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Modal / confirm dialog (for revoke) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background-color: hsl(var(--ll-card));
  color: hsl(var(--ll-card-foreground));
  border-radius: var(--ll-radius);
  box-shadow: var(--ll-shadow-card);
  padding: var(--ll-space-6);
  max-width: 480px;
  width: 100%;
}
@media (max-width: 767px) {
  .modal { width: 100vw; max-width: none; border-radius: 0; }
}

/* ---- In-app styleguide (/styleguide/, DEBUG only) ----
   docs/styleguide.md rendered by core.styleguide: each HTML example runs
   live in a `.styleguide-example` frame above its code. */
.styleguide pre {
  margin: 0 0 var(--ll-space-8) 0;
  padding: var(--ll-space-4);
  overflow-x: auto;
  background-color: hsl(var(--ll-muted));
  border-radius: var(--ll-radius);
  font-size: 13px;
  line-height: 1.5;
}
.styleguide .table { margin-bottom: var(--ll-space-6); }
.styleguide-example {
  padding: var(--ll-space-6);
  margin-bottom: var(--ll-space-2);
  background-color: hsl(var(--ll-background));
  border: 1px dashed hsl(var(--ll-border));
  border-radius: var(--ll-radius);
  /* A transform makes this the containing block for position: fixed, so
     a live `.modal-overlay` dims the frame, not the whole page. */
  transform: translateZ(0);
}
.styleguide-example:has(.modal-overlay) { min-height: 18rem; }

/* ---- Auth screens (sign in, two-factor, password reset) ----
   allauth's entrance pages render inside one narrow centred card
   (templates/allauth/layouts/entrance.html); its manage pages group
   settings in `.auth-panel` cards. */
main.auth-card { max-width: 28rem; margin: var(--ll-space-12) auto; }
.auth-card h1 { font-size: var(--ll-text-heading-md); margin-bottom: var(--ll-space-2); }
.auth-card > p { font-size: 16px; }
.auth-card > h1 + p { margin: 0 0 var(--ll-space-6) 0; }
.auth-card .form-actions { flex-direction: column; }
.auth-card .form-actions .btn { width: 100%; }
.auth-card .auth-footnote { text-align: center; font-size: 14px; margin: var(--ll-space-4) 0 0 0; }
.auth-panel { margin-bottom: var(--ll-space-6); }
.auth-panel h2 { font-size: var(--ll-text-heading-sm); }
@media (max-width: 767px) {
  main.auth-card { margin: 0; max-width: none; border-radius: 0; border-left: 0; border-right: 0; }
}

/* ==========================================================================
   App shell: top bar (context switcher slot), estate/adviser banner,
   side nav slot.
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Top bar: light strip over the content column. Left: the active
   organization (a <details> switcher when more than one is reachable);
   right: account links. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ll-space-4);
  height: 52px;
  padding: 0 var(--ll-space-6);
  background-color: hsl(var(--ll-card));
  border-bottom: 1px solid hsl(var(--ll-border));
}
.topbar-left { display: flex; align-items: center; gap: var(--ll-space-6); }
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ll-space-2);
  font-family: var(--ll-font-heading);
  font-size: 1.125rem;
}
.topbar-links {
  display: flex;
  align-items: center;
  gap: var(--ll-space-4);
  font-size: 14px;
}
.topbar-links a {
  color: hsl(var(--ll-muted-foreground));
  text-decoration: none;
}
.topbar-links a:hover { color: hsl(var(--ll-foreground)); opacity: 1; }

.topbar-switcher { position: relative; }
.topbar-org {
  display: inline-flex;
  align-items: center;
  gap: var(--ll-space-2);
  font-size: 15px;
  font-weight: var(--ll-weight-semibold);
  list-style: none;
  cursor: default;
}
.topbar-org::-webkit-details-marker { display: none; }
.topbar-switcher summary.topbar-org {
  cursor: pointer;
  padding: var(--ll-space-1) var(--ll-space-2);
  margin-left: calc(-1 * var(--ll-space-2));
  border-radius: var(--ll-radius-sm);
}
.topbar-switcher summary.topbar-org::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.6;
}
.topbar-switcher summary.topbar-org:hover { background-color: hsl(var(--ll-muted)); }
.topbar-switcher-menu {
  position: absolute;
  top: calc(100% + var(--ll-space-1));
  left: 0;
  z-index: 20;
  min-width: 240px;
  padding: var(--ll-space-1);
  background-color: hsl(var(--ll-popover));
  color: hsl(var(--ll-popover-foreground));
  border: 1px solid hsl(var(--ll-border));
  border-radius: var(--ll-radius);
  box-shadow: var(--ll-shadow-card);
}
.topbar-switcher-menu button,
.topbar-switcher-menu a {
  display: block;
  width: 100%;
  padding: var(--ll-space-2) var(--ll-space-3);
  border: 0;
  border-radius: var(--ll-radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.topbar-switcher-menu button:hover,
.topbar-switcher-menu a:hover { background-color: hsl(var(--ll-muted)); opacity: 1; }
.topbar-switcher-menu a {
  margin-top: var(--ll-space-1);
  border-top: 1px solid hsl(var(--ll-border));
  border-radius: 0;
  color: hsl(var(--ll-muted-foreground));
}

/* Estate banner — adviser viewing a client estate on a firm grant.
   Copy pattern: "Viewing {client} as {Firm} ({access level})" — see
   ll-design.md §Estate access level. */
.estate-banner {
  background-color: hsl(var(--ll-advisor-header));
  color: hsl(var(--ll-advisor-header-foreground));
  padding: var(--ll-space-2) var(--ll-space-6);
  font-size: 12px;
  font-weight: var(--ll-weight-semibold);
  letter-spacing: 0.02em;
}

.sidenav {
  background-color: hsl(var(--ll-sidebar-background));
  color: hsl(var(--ll-sidebar-foreground));
  border-right: 1px solid hsl(var(--ll-sidebar-border));
  width: 240px;
  flex-shrink: 0;
  padding: var(--ll-space-3) var(--ll-space-3) var(--ll-space-4);
}
.sidenav-brand {
  display: flex;
  align-items: center;
  gap: var(--ll-space-3);
  padding: var(--ll-space-2) var(--ll-space-3);
  margin-bottom: var(--ll-space-6);
  color: hsl(var(--ll-sidebar-foreground));
  font-family: var(--ll-font-heading);
  font-size: 1.125rem;
  text-decoration: none;
}
.sidenav-brand img { border-radius: var(--ll-radius-sm); }
.sidenav-brand:hover { opacity: 1; }
.sidenav a {
  display: block;
  color: hsl(var(--ll-sidebar-foreground) / 0.8);
  text-decoration: none;
  font-size: 15px;
  padding: var(--ll-space-2) var(--ll-space-3);
  border-radius: var(--ll-radius-sm);
}
.sidenav a:hover {
  color: hsl(var(--ll-sidebar-accent-foreground));
  background-color: hsl(var(--ll-sidebar-accent) / 0.6);
  opacity: 1;
}
.sidenav a.active {
  color: hsl(var(--ll-sidebar-accent-foreground));
  background-color: hsl(var(--ll-sidebar-accent));
  font-weight: var(--ll-weight-semibold);
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}
.app-content {
  max-width: 64rem;
  margin: 0 auto;
  padding: var(--ll-space-6) var(--ll-space-4);
}
/* Single-task pages (e.g. the organization picker): one short column. */
.app-content-narrow { max-width: 36rem; }
/* .app-content already caps and pads; the bare `main` rule below is for
   pages outside the shell. Without this, messages and page content sit
   at different indents. */
.app-content > main { max-width: none; margin: 0; padding: 0; }

/* Legacy header ("brand" strip, default theme) — kept for pages that don't
   opt into the full app shell (e.g. auth screens). */
.brand {
  display: flex;
  align-items: center;
  gap: var(--ll-space-2);
  padding: var(--ll-space-3) var(--ll-space-4);
  background: hsl(var(--ll-primary));
  color: hsl(var(--ll-primary-foreground));
}
.brand strong {
  font-family: var(--ll-font-heading);
  font-size: 1.125rem;
  letter-spacing: 0.02em;
}

nav ul {
  display: flex;
  gap: var(--ll-space-4);
  list-style: none;
  margin: 0;
  padding: var(--ll-space-3) var(--ll-space-4);
  border-bottom: 1px solid hsl(var(--ll-border));
  flex-wrap: wrap;
}

main,
body > .messages {
  max-width: 64rem;
  margin: 0 auto;
  padding: var(--ll-space-6) var(--ll-space-4);
}

form input,
form button {
  font: inherit;
}

/* ---- Narrow screens (< 768px) ----
   The side navigation becomes one scrolling row above the top bar, so the
   page starts within the first screen; the brand keeps only its icon. */
@media (max-width: 767px) {
  .btn, a[role="button"], select.select, input[type="checkbox"], input[type="radio"] {
    min-height: var(--ll-touch-target);
  }
  .app-shell { flex-direction: column; }
  .sidenav {
    display: flex;
    align-items: center;
    gap: var(--ll-space-1);
    width: 100%;
    padding: var(--ll-space-2) var(--ll-space-3);
    overflow-x: auto;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid hsl(var(--ll-sidebar-border));
  }
  .sidenav::-webkit-scrollbar { display: none; }
  .sidenav .sidenav-brand { flex-shrink: 0; margin: 0; padding: var(--ll-space-1); font-size: 0; }
  .sidenav a { flex-shrink: 0; white-space: nowrap; }
  .sidenav a:not(.sidenav-brand) { display: flex; align-items: center; min-height: var(--ll-touch-target); }

  .topbar {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    row-gap: var(--ll-space-2);
    padding: var(--ll-space-2) var(--ll-space-4);
  }
  .topbar-left { flex-wrap: wrap; row-gap: var(--ll-space-1); min-width: 0; }
  .topbar-brand, .topbar-org { white-space: nowrap; }
  .topbar-links { flex-wrap: wrap; gap: var(--ll-space-1) var(--ll-space-3); }
  .topbar-links a { white-space: nowrap; }
  .estate-banner { padding: var(--ll-space-2) var(--ll-space-4); }

  .section-tabs { overflow-x: auto; scrollbar-width: none; }
  .section-tabs a { flex-shrink: 0; white-space: nowrap; }
}

/* ---- Sort form (documents inbox/vault) ---- */
.sort-form {
  display: flex;
  align-items: center;
  gap: var(--ll-space-2);
}
.sort-form select.select {
  display: inline-block;
  width: auto;
}

/* ---- Section tabs (documents vault) ---- */
.section-tabs {
  display: flex;
  align-items: center;
  gap: var(--ll-space-4);
  margin-bottom: var(--ll-space-4);
}
