/* brokerassist — hand-authored design system. Replaces Bootstrap entirely;
   the class vocabulary below (btn, card, table, badge, form-*, the grid
   utilities, spacing utilities) intentionally mirrors Bootstrap's naming
   so templates didn't need to be rewritten, but every rule here is our
   own, matching the approved Slate & Cobalt design. */

@font-face {
  font-family: "Public Sans";
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url("../vendor/fonts/public-sans-var.45ac3f4b61c1.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
  src: url("../vendor/fonts/source-serif4-var.6a682eb0234e.woff2") format("woff2");
}

:root {
  --slate-900: #131A23;
  --slate-800: #1E2A38;
  --slate-700: #263447;
  --slate-600: #3A4A60;
  --cobalt-600: #2158D6;
  --cobalt-500: #2F6FED;
  --cobalt-400: #5B8DEF;
  --paper-0: #F2F4F7;
  --paper-50: #F8F9FB;
  --surface: #FFFFFF;
  --ink-900: #1B222C;
  --ink-600: #4B5563;
  --ink-500: #6B7684;
  --line: #E2E6EC;
  --line-soft: #EBEEF2;
  --success: #1E8E5A;
  --success-bg: #E4F3EA;
  --warn: #B4740C;
  --warn-bg: #FBF0DC;
  --danger: #C23B3B;
  --danger-bg: #FAE6E6;
  --info: var(--cobalt-500);
  --info-bg: #E8EFFD;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(19, 26, 35, 0.05), 0 4px 14px rgba(19, 26, 35, 0.045);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper-0);
  color: var(--ink-900);
  font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cobalt-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, .h3, .h4 {
  font-family: "Source Serif 4", ui-serif, Georgia, serif;
  font-weight: 600;
  text-wrap: balance;
  margin: 0 0 0.5rem;
  color: var(--ink-900);
}
h1, .h3 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
.h4 { font-size: 1.1rem; }

::selection { background: var(--cobalt-400); color: #fff; }

/* ── Layout utilities ─────────────────────────────────────────────── */

.d-flex { display: flex; }
.d-inline { display: inline; }
.d-none { display: none; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.align-items-start { align-items: flex-start; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow-1 { flex: 1 1 auto; min-width: 0; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }

.row { display: flex; flex-wrap: wrap; margin: 0 -0.5rem; }
.row > [class*="col"] { padding: 0 0.5rem; }
.row.g-2 { row-gap: 0.5rem; }
.row.g-3 { row-gap: 1rem; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-12 { flex: 0 0 auto; width: 100%; }
.col-md-3, .col-lg-6 { flex: 0 0 auto; width: 100%; }
@media (min-width: 768px) {
  .col-md-3 { width: 25%; }
}
@media (min-width: 992px) {
  .col-lg-6 { width: 50%; }
}

/* ── Spacing utilities ────────────────────────────────────────────── */

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: 1rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.px-0 { padding-left: 0; padding-right: 0; }
.p-4 { padding: 1.5rem; }

/* ── Typography utilities ─────────────────────────────────────────── */

.text-muted { color: var(--ink-500); }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-dark { color: var(--ink-900); }
.text-uppercase { text-transform: uppercase; letter-spacing: 0.06em; }
.small { font-size: 0.85rem; }
.fw-bold { font-weight: 700; }
.fs-4 { font-size: 1.4rem; font-family: "Source Serif 4", serif; font-weight: 600; }
.tabnum { font-variant-numeric: tabular-nums; }

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.5rem 1rem;
  /* Same padding/font alone isn't enough — a short label ("Delete") and a
     longer one ("Back to queue") still end up visibly different widths
     sitting right next to each other. This floors every button at the same
     minimum width; a genuinely long label still grows past it rather than
     wrapping or getting cut off. */
  min-width: 110px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
/* :focus-visible rather than :focus — a mouse click doesn't need a ring,
   only real keyboard navigation does. Browsers' own default outline on a
   custom-colored button is inconsistent (barely visible in some, clipped
   by border-radius in others), so this replaces it with one that matches
   the rest of the app's focus treatment on inputs. */
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.35); }
.btn-primary { background: var(--cobalt-500); color: #fff; }
.btn-primary:hover { background: var(--cobalt-600); }
.btn-outline-secondary { background: var(--surface); border-color: var(--line); color: var(--ink-900); }
.btn-outline-secondary:hover { border-color: var(--cobalt-500); color: var(--cobalt-600); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a83030; }
/* .btn-sm intentionally left as a same-size alias — every button in the app
   (page actions, table row actions, everything) renders at one consistent
   size, so .btn-sm no longer shrinks anything; kept only so existing
   templates that reference it don't need editing. */
.btn-sm { padding: 0.5rem 1rem; font-size: 0.9rem; }
.btn-trash-action { width: 110px; }

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
}
.card.shadow-sm { box-shadow: var(--shadow-card); }
.card-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  background: var(--paper-50);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--paper-50);
}
.card > table { margin-bottom: 0; }

/* KPI cards (reports dashboard) */
.kpi-card .text-muted { display: block; margin-bottom: 0.4rem; font-size: 0.72rem; }

/* "Needs attention" cards (core/home.html) */
.attn-card { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s ease; }
.attn-card:hover { border-color: var(--cobalt-500); text-decoration: none; }
.attn-card-zero { opacity: 0.6; }

/* Search result rows (core/search_results.html) */
.search-result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.8rem 1.2rem; border-bottom: 1px solid var(--line-soft);
  text-decoration: none; color: inherit;
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:hover { background: var(--paper-50); text-decoration: none; }
.search-result-more { font-size: 0.78rem; font-weight: 600; color: var(--cobalt-600); white-space: nowrap; flex-shrink: 0; }
mark { background: var(--info-bg); color: var(--cobalt-600); border-radius: 3px; padding: 0 0.15rem; }

/* Global search box (sidebar, every page) */
.sidebar-search { position: relative; margin: 0 0.1rem 1.1rem; }
.sidebar-search input[type="text"] {
  width: 100%; padding: 0.5rem 0.7rem 0.5rem 2.1rem; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.06);
  color: #EFF1F5; font-size: 0.84rem; font-family: inherit;
}
.sidebar-search input::placeholder { color: #8792A3; }
.sidebar-search input:focus {
  outline: none; border-color: var(--cobalt-400); background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.25);
}
.sidebar-search svg { position: absolute; left: 0.65rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: #8792A3; pointer-events: none; }

/* ── Tables ───────────────────────────────────────────────────────── */

.table-responsive { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
table:not(.detail-table) thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-weight: 600;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-50);
}
table:not(.detail-table) td {
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.9rem;
}
table:not(.detail-table) tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--paper-50); }
.table-sm td, .table-sm th { padding: 0.5rem 0.75rem; }

table.detail-table { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
table.detail-table tr { border-bottom: 1px solid var(--line-soft); }
table.detail-table tr:last-child { border-bottom: none; }
table.detail-table th, table.detail-table td { padding: 0.7rem 1.1rem; text-align: left; font-size: 0.9rem; }
table.detail-table th { width: 200px; font-weight: 600; color: var(--ink-600); background: var(--paper-50); }

/* Total-premium line above the split coverage tables — policy_detail.html,
   only shown once a policy has 2+ coverage types (see PolicyDetailView's
   other_coverages). */
.premium-summary {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.7rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); font-size: 0.9rem;
}
.premium-summary strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* ── Badges (status chips) ────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bg-success { background: var(--success-bg); color: var(--success); }
.bg-secondary { background: var(--line-soft); color: var(--ink-600); }
.bg-danger { background: var(--danger-bg); color: var(--danger); }
.bg-warning { background: var(--warn-bg); color: var(--warn); }
.bg-info { background: var(--info-bg); color: var(--cobalt-600); }
.bg-light { background: var(--paper-50); color: var(--ink-500); }
.border { border: 1px solid var(--line); }

/* Processing indicator — the badge's own dot pulses instead of sitting
   static, so a document actively being read by the extraction worker
   reads differently at a glance from one merely queued behind it. */
.badge.is-processing::before { animation: badge-pulse 1.1s ease-in-out infinite; }
@keyframes badge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .badge.is-processing::before { animation: none; }
}

tr.table-danger td { background: var(--danger-bg); }
tr.table-warning td { background: var(--warn-bg); }

/* Month/year group divider row (policy_list.html) */
tr.table-group-header th {
  background: var(--paper-50);
  color: var(--cobalt-600);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

/* ── Alerts (flash messages) ──────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--cobalt-600); border-color: color-mix(in srgb, var(--cobalt-500) 25%, transparent); }
.alert-secondary { background: var(--paper-50); color: var(--ink-600); border-color: var(--line); }
.alert-dismissible { position: relative; padding-right: 2.5rem; }
.btn-close {
  position: absolute; top: 0.6rem; right: 0.75rem;
  background: none; border: none; font-size: 1rem; line-height: 1; cursor: pointer;
  color: inherit; opacity: 0.6;
}
.btn-close:hover { opacity: 1; }

/* ── Forms ────────────────────────────────────────────────────────── */

.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-600); margin-bottom: 0.35rem; }
.form-text { font-size: 0.78rem; color: var(--ink-500); margin-top: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
select, textarea, .form-control, .form-select {
  width: 100%;
  max-width: 460px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-50);
  color: var(--ink-900);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { max-width: 100%; min-height: 5rem; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cobalt-500);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.16);
}

.form-check { display: flex; align-items: center; gap: 0.4rem; }
.form-check-label { font-size: 0.88rem; }
.form-check-inline { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 0.9rem; margin-bottom: 0.4rem; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cobalt-500); cursor: pointer; }

/* Multi-select dropdown (progressive enhancement, see js/multiselect.js) */
.multiselect { position: relative; max-width: 460px; }
select.multiselect-native { display: none; }
.multiselect-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  color: var(--ink-900);
}
.multiselect-trigger:focus-visible { outline: none; border-color: var(--cobalt-500); box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.16); }
.multiselect-trigger::after {
  content: "";
  flex: 0 0 auto;
  width: 8px; height: 8px;
  margin-left: 0.6rem;
  border-right: 1.6px solid var(--ink-500);
  border-bottom: 1.6px solid var(--ink-500);
  transform: rotate(45deg) translateY(-2px);
}
.multiselect-trigger[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(2px); }
.multiselect-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 0.35rem;
}
.multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.multiselect-option:hover { background: var(--paper-0); }
.multiselect-option label { flex: 1; cursor: pointer; }
.multiselect-option-premium {
  width: 84px; max-width: 84px; flex-shrink: 0;
  padding: 0.25rem 0.4rem; font-size: 0.82rem;
}

/* ── Extraction candidate cards (job_detail.html) ─────────────────── */

.candidate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}
.candidate-head h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.type-pill {
  display: inline-block;
  background: var(--info-bg);
  color: var(--cobalt-600);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin: 0 0.3rem 0.3rem 0;
}
.fact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (max-width: 900px) { .fact-grid { grid-template-columns: repeat(2, 1fr); } }
.fact dt {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}
.fact dd { margin: 0; font-size: 0.95rem; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.fact dd.dim { color: var(--ink-500); font-style: italic; font-size: 0.88rem; }
.fact dd.premium { font-weight: 600; }

/* ── Grouped edit form (candidate_review.html) ────────────────────── */

.form-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cobalt-600);
  margin: 1.8rem 0 0.9rem;
}
.form-group-label:first-child { margin-top: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.4rem; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
.field-row .mb-3 { min-width: 0; }
/* Read-only display fields, e.g. #premium-total-display (policy_form.html
   and extraction/candidate_review.html — the live sum of every checked
   type's own premium box, wherever it currently lives). */
input[readonly] { background: var(--line-soft); color: var(--ink-600); font-variant-numeric: tabular-nums; }

/* "Other coverage numbers" — policy_form.html, one row per added coverage
   type (i.e. not the anchor type — see _anchor_type_id), built by the
   inline script there. Each row stacks that type's own policy number
   above its own premium — the premium <input> here is the very same
   element multiselect.js built for that type's dropdown row, relocated
   down into this stack rather than duplicated. */
.coverage-number-row { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.5rem; }
.coverage-number-row:last-child { margin-bottom: 0; }
.coverage-number-row .coverage-number-type { font-size: 0.82rem; color: var(--ink-600); width: 160px; flex-shrink: 0; padding-top: 0.5rem; }
.coverage-number-stack { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.coverage-number-stack input { margin: 0; }
.coverage-number-stack .multiselect-option-premium { width: 100%; max-width: 460px; padding: 0.5rem 0.7rem; font-size: 0.9rem; }

.search-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.88rem;
  width: 260px;
  font-family: inherit;
  color: var(--ink-900);
}
.search-input:focus { outline: none; border-color: var(--cobalt-500); box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14); }

/* ── List group (amendments) ──────────────────────────────────────── */

.list-group-item { border-bottom: 1px solid var(--line-soft); padding: 0.6rem 0; font-size: 0.9rem; }
.list-group-item:last-child { border-bottom: none; }

/* ── Pagination ───────────────────────────────────────────────────── */

.pagination { display: flex; gap: 0.3rem; list-style: none; margin: 0.75rem 0 0; padding: 0; }
.page-item.disabled .page-link { color: var(--ink-500); cursor: default; }
.page-link {
  display: block;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-600);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
a.page-link:hover { border-color: var(--cobalt-500); color: var(--cobalt-600); text-decoration: none; }

/* ── App shell: sidebar + topbar ──────────────────────────────────── */

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--slate-800);
  color: #C7CEDA;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.5rem 1.35rem; }
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; display: block; }
.sidebar-brand .wordmark { font-family: "Source Serif 4", serif; font-size: 1.02rem; font-weight: 600; color: #F3F5F8; }
.sidebar-brand .tagline { font-size: 0.62rem; color: #8792A3; letter-spacing: 0.09em; text-transform: uppercase; }

.nav-group-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.09em; color: #6C7789; padding: 0.85rem 0.6rem 0.35rem; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.6rem; border-radius: var(--radius-sm);
  color: #B7C0CE; text-decoration: none; font-size: 0.85rem; font-weight: 500; position: relative;
}
.sidebar .nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, 0.05); color: #F3F5F8; text-decoration: none; }
.sidebar .nav-link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--cobalt-400); }
.sidebar .nav-link.active { background: rgba(47, 111, 237, 0.16); color: #F3F5F8; }
.sidebar .nav-link.active::before {
  content: ""; position: absolute; left: -0.85rem; top: 0.5rem; bottom: 0.5rem; width: 3px;
  background: var(--cobalt-400); border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #E5484D; color: #fff; font-size: 0.68rem; font-weight: 600; line-height: 18px;
  text-align: center; flex-shrink: 0;
}

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.08); position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 0.6rem; width: 100%;
  background: none; border: none; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; text-align: left;
  transition: background 0.12s ease;
  /* Without this, some browsers still paint native <button> chrome (a
     light face/border) underneath the rules above, regardless of the
     explicit background/border overrides. */
  appearance: none; -webkit-appearance: none;
}
.user-chip:hover, .user-chip[aria-expanded="true"] { background: rgba(255, 255, 255, 0.06); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--cobalt-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: #fff; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta .name { font-size: 0.8rem; font-weight: 600; color: #EFF1F5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 0.68rem; color: #8792A3; }
.chip-caret { width: 14px; height: 14px; color: #8792A3; flex-shrink: 0; transition: transform 0.15s ease; }
.user-chip[aria-expanded="true"] .chip-caret { transform: rotate(180deg); }

/* Opens upward (bottom: 100%) since the trigger sits at the very bottom of
   the sidebar — a menu opening downward would run off the viewport. */
.account-menu {
  position: absolute; left: 0.6rem; right: 0.6rem; bottom: calc(100% + 0.4rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(19, 26, 35, 0.28); overflow: hidden;
  opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity 0.12s ease, transform 0.12s ease;
}
.account-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.account-menu a, .account-menu button {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left; padding: 0.6rem 0.8rem;
  font-size: 0.82rem; color: var(--ink-900); background: none; border: none; font-family: inherit; cursor: pointer;
  text-decoration: none;
}
.account-menu a svg, .account-menu button svg { width: 15px; height: 15px; color: var(--ink-500); flex-shrink: 0; }
.account-menu a:hover, .account-menu button:hover { background: var(--paper-50); text-decoration: none; }
.account-menu .divider { height: 1px; background: var(--line); margin: 0.2rem 0; }
.account-menu .danger { color: var(--danger); }
.account-menu .danger svg { color: var(--danger); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 2rem; border-bottom: 1px solid var(--line);
  background: var(--paper-50); position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.topbar h1 { font-size: 1.35rem; margin: 0; }
.topbar .meta { font-size: 0.78rem; color: var(--ink-500); margin-top: 0.15rem; }
.content { padding: 1.6rem 2rem 3.5rem; max-width: 1200px; }

/* Mobile sidebar toggle — collapsed to a hamburger button below 880px (see
   sidebar-toggle.js); the sidebar itself stays a normal static column above
   that width, so nothing here affects desktop. */
.sidebar-toggle {
  display: none; width: 36px; height: 36px; flex-shrink: 0;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-900); cursor: pointer;
}
.sidebar-toggle svg { width: 20px; height: 20px; }
.sidebar-toggle:hover { border-color: var(--cobalt-500); color: var(--cobalt-600); }
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
  .sidebar-toggle { display: inline-flex; }

  .app-shell { position: relative; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); box-shadow: 12px 0 32px rgba(19, 26, 35, 0.28); }

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 30;
    background: rgba(10, 14, 20, 0.45);
  }

  .topbar { padding: 1rem 1.1rem; }
  .content { padding: 1.25rem 1.1rem 3rem; }
}

/* ── Auth pages (login, invite-accept, subscription-required) ────── */

.auth-page {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 12% 18%, rgba(47, 111, 237, 0.10), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(30, 42, 56, 0.06), transparent 50%),
    var(--paper-0);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 2rem 1.75rem 1.75rem;
}
.auth-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: 0.3rem; }
.auth-card .sub { color: var(--ink-500); font-size: 0.85rem; text-align: center; margin-bottom: 1.4rem; }

.errorlist { list-style: none; margin: 0 0 1rem; padding: 0.6rem 0.9rem; background: var(--danger-bg); border-radius: var(--radius-sm); color: var(--danger); font-size: 0.85rem; }

/* ── Night hero panel — shared by the login page and the marketing
   homepage (see templates/registration/login.html and
   templates/core/marketing_home.html). Deliberately separate from
   .auth-page/.auth-card above, which invite_accept.html and the
   subscription-required page still use unchanged. ─────────────────── */

.night-hero {
  position: relative;
  background: linear-gradient(155deg, var(--slate-900) 0%, var(--slate-800) 60%, var(--slate-700) 100%);
  color: #EDF1F7;
  overflow: hidden;
}
.night-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; }
@media (prefers-reduced-motion: reduce) { .night-hero canvas { opacity: 0.3; } }

.night-hero-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 0.65rem; }
.night-hero-wordmark { font-family: "Source Serif 4", serif; font-size: 1.15rem; font-weight: 600; color: #fff; }
.night-hero-tagline { font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; color: #93A2B8; margin-top: 1px; }

.night-hero-headline {
  position: relative; z-index: 1;
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  line-height: 1.15;
  color: #fff;
}
.night-hero-headline .accent { color: var(--cobalt-400); }
.night-hero-sub { position: relative; z-index: 1; color: #B7C1D1; line-height: 1.55; }

.night-hero-badges { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; }
.night-hero-badge {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.82rem; color: #C7D0DE;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}
.night-hero-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cobalt-400); box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.18);
}
.night-hero-foot { position: relative; z-index: 1; font-size: 0.78rem; color: #6E7E93; }

/* ── Login page ───────────────────────────────────────────────────── */

.login-shell {
  position: relative;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
}
.login-shell-brand {
  position: absolute; z-index: 1;
  top: clamp(1.25rem, 3vw, 2rem); left: clamp(1.25rem, 3vw, 2.5rem);
  display: flex; align-items: center; gap: 0.65rem;
}
.login-back {
  position: absolute; z-index: 1;
  top: clamp(1.25rem, 3vw, 2rem); right: clamp(1.25rem, 3vw, 2.5rem);
  font-size: 0.82rem; color: #C7D0DE; font-weight: 600;
}
.login-back:hover { color: #fff; }

.login-form-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 30px 70px -25px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  padding: 2.5rem 2rem 2rem;
}
.login-form-card h1 { font-size: 1.55rem; margin-bottom: 0.35rem; }
.login-form-card .sub { color: var(--ink-500); font-size: 0.92rem; margin-bottom: 2rem; line-height: 1.5; }
.login-foot-note { text-align: center; color: var(--ink-500); font-size: 0.82rem; margin-top: 1.5rem; line-height: 1.5; }

@media (max-width: 520px) {
  .login-shell { flex-direction: column; }
  .login-shell-brand { position: static; margin-bottom: 1.75rem; }
  .login-back { position: static; display: block; margin-bottom: 1.25rem; }
}

/* ── Marketing homepage ───────────────────────────────────────────── */

.mkt-scroll-progress {
  position: fixed; top: 0; left: 0; z-index: 50;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--cobalt-600), var(--cobalt-400));
  transition: width 0.1s linear;
}
@media (prefers-reduced-motion: reduce) { .mkt-scroll-progress { transition: none; } }

.mkt-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem clamp(1.5rem, 5vw, 4rem);
  border-bottom: 1px solid var(--line);
}
.mkt-nav-brand { display: flex; align-items: center; gap: 0.6rem; }
.mkt-btn-outline {
  font-size: 0.85rem; font-weight: 600; font-family: inherit;
  padding: 0.55rem 1.2rem; border-radius: 999px;
  border: 1.5px solid var(--slate-900); background: transparent; color: var(--slate-900);
  cursor: pointer;
}
.mkt-btn-outline:hover { background: var(--slate-900); color: #fff; text-decoration: none; }

.mkt-hero { text-align: center; padding: clamp(3.5rem, 9vw, 6.5rem) clamp(1.5rem, 5vw, 4rem) clamp(3rem, 7vw, 5rem); }
.mkt-hero-inner { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.mkt-hero .night-hero-headline { font-size: clamp(2.1rem, 5vw, 3.4rem); margin: 0 0 1.1rem; }
.mkt-hero .night-hero-sub { font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 46ch; margin: 0 auto 2.2rem; }
.mkt-hero .night-hero-badges { justify-content: center; margin-top: 2.75rem; }

.mkt-btn-cta {
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  padding: 0.85rem 1.9rem; border-radius: 999px; border: none;
  background: var(--cobalt-500); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 111, 237, 0.35);
}
.mkt-btn-cta:hover { background: var(--cobalt-600); text-decoration: none; color: #fff; }

.mkt-section { padding: clamp(3.5rem, 7vw, 5.5rem) clamp(1.5rem, 5vw, 4rem); }
.mkt-section.tint-blue { background: var(--info-bg); }
.mkt-section-inner {
  max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.mkt-section-inner.reverse .mkt-copy { order: 2; }
.mkt-section-inner.reverse .mkt-visual { order: 1; }
.mkt-eyebrow {
  position: relative; display: inline-block;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cobalt-500);
  margin-bottom: 0.7rem; padding-bottom: 0.55rem;
}
.mkt-eyebrow::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 0; height: 2px; background: var(--cobalt-500);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.35s;
}
.reveal.is-visible .mkt-eyebrow::after { width: 28px; }
.mkt-copy h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; margin: 0 0 0.9rem; }
.mkt-copy p { color: var(--ink-600); font-size: 1rem; line-height: 1.65; max-width: 42ch; }

.mkt-demo-card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: 0 10px 40px rgba(19, 26, 35, 0.12);
  padding: 1.5rem; max-width: 420px;
}
.mkt-demo-doc { display: flex; align-items: center; gap: 0.7rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px dashed var(--line); }
.mkt-demo-doc-icon {
  position: relative; overflow: hidden;
  width: 38px; height: 46px; border-radius: 4px; background: var(--paper-50); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 700; color: var(--ink-500);
  flex-shrink: 0;
}
/* Scan-line sweep — plays once when the AI Extraction card scrolls into
   view, dramatizing "a document being read" rather than a generic fade. */
.mkt-demo-doc-icon::after {
  content: ""; position: absolute; left: 0; right: 0; top: -60%; height: 60%;
  background: linear-gradient(180deg, transparent, rgba(47, 111, 237, 0.65), transparent);
  transition: top 1s cubic-bezier(0.65, 0, 0.35, 1) 0.1s;
}
.mkt-visual.is-visible .mkt-demo-doc-icon::after { top: 100%; }
.mkt-demo-doc-name { font-size: 0.88rem; font-weight: 600; }
.mkt-demo-doc-sub { font-size: 0.76rem; color: var(--ink-500); }
.mkt-demo-field { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0; font-size: 0.86rem; }
.mkt-demo-field + .mkt-demo-field { border-top: 1px solid var(--line); }
.mkt-demo-field .k { color: var(--ink-500); }
.mkt-demo-field .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt-demo-check { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--success-bg); color: var(--success); font-size: 0.7rem; margin-right: 0.5rem; }
.mkt-demo-note { font-size: 0.76rem; color: var(--ink-500); margin-top: 1rem; text-align: center; }

/* Extraction rows populate one at a time, as though each field is being
   pulled out of the document in sequence — not a uniform group fade. */
.extract-row { opacity: 0; transform: translateX(-16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.mkt-visual.is-visible .extract-row { opacity: 1; transform: none; }
.mkt-visual.is-visible .extract-row-1 { transition-delay: 0.55s; }
.mkt-visual.is-visible .extract-row-2 { transition-delay: 0.72s; }
.mkt-visual.is-visible .extract-row-3 { transition-delay: 0.89s; }
.mkt-visual.is-visible .extract-row-4 { transition-delay: 1.06s; }

/* Renewal rows: each carries a thin urgency bar (--urgency, set inline per
   row) that fills in alongside the count-up number — closer renewals draw
   a longer bar, so the animation itself encodes the data instead of just
   decorating it. */
.renewal-row { opacity: 0; transform: translateX(18px); transition: opacity 0.5s ease, transform 0.5s ease; }
.mkt-visual.is-visible .renewal-row { opacity: 1; transform: none; }
.mkt-visual.is-visible .renewal-row-1 { transition-delay: 0.5s; }
.mkt-visual.is-visible .renewal-row-2 { transition-delay: 0.68s; }
.mkt-visual.is-visible .renewal-row-3 { transition-delay: 0.86s; }
.urgency-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s; }
.mkt-visual.is-visible .renewal-row .urgency-bar { width: var(--urgency, 0%); }

.mkt-feature-grid { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.mkt-feature-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 1.6rem; }
.mkt-feature-card .icon {
  width: 38px; height: 38px; border-radius: 9px; background: var(--info-bg); color: var(--cobalt-500);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 1rem;
}
.mkt-feature-card h3 { font-family: inherit; font-size: 1rem; margin: 0 0 0.4rem; font-weight: 700; }
.mkt-feature-card p { color: var(--ink-500); font-size: 0.88rem; line-height: 1.55; margin: 0; }

.mkt-closing { text-align: center; padding: clamp(3.5rem, 7vw, 5rem) 1.5rem; background: var(--slate-900); color: #fff; }
.mkt-closing h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 1.5rem; color: #fff; }

/* Scroll-triggered reveal — marketing homepage only (see scroll-reveal.js).
   Elements start hidden/shifted and settle into place once scrolled into
   view; .is-visible is added once and never removed, so revealing does not
   re-trigger when scrolling back up. Copy panels are revealed by a clip-path
   curtain sliding off them (like uncovering text rather than fading it in);
   cards settle with a gentle scale, as though being placed down. */
.reveal {
  opacity: 0;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), clip-path 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.is-visible { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }

.reveal-left { clip-path: inset(0 100% 0 0); }
.reveal-right { clip-path: inset(0 0 0 100%); }
.reveal-up { transform: translateY(36px); }
.reveal-card { transform: translateY(26px) scale(0.92); }

.mkt-feature-grid { perspective: 1400px; }
.reveal-pop { transform: translateY(30px) scale(0.9) rotateX(12deg); transform-origin: bottom center; }

.reveal-delay-1.is-visible { transition-delay: 0.12s; }
.reveal-delay-2.is-visible { transition-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; clip-path: none; transition: none; }
  .mkt-eyebrow::after { transition: none; }
  .reveal .mkt-eyebrow::after { width: 28px; }
  .extract-row, .renewal-row { opacity: 1; transform: none; transition: none; }
  .mkt-demo-doc-icon::after { transition: none; top: 100%; }
  .urgency-bar { transition: none; width: var(--urgency, 0%); }
}

.mkt-foot { text-align: center; padding: 1.75rem; color: var(--ink-500); font-size: 0.8rem; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .mkt-section-inner, .mkt-section-inner.reverse { grid-template-columns: 1fr; }
  .mkt-section-inner.reverse .mkt-copy, .mkt-section-inner.reverse .mkt-visual { order: initial; }
  .mkt-feature-grid { grid-template-columns: 1fr; }
}
