:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --muted: #a8a29e;
  --line: #e7e5e4;
  --primary: #b91c1c;
  --primary-ink: #ffffff;
  --primary-soft: #fee2e2;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

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

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; gap: 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--ink); font-size: 1rem;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 36px; width: 36px; border-radius: 6px;
  object-fit: cover; display: block;
}
.nav { display: flex; gap: 18px; flex: 1; margin-left: 24px; }
.nav a {
  color: var(--ink-soft); font-weight: 500; padding: 4px 0;
}
.nav a:hover { color: var(--ink); text-decoration: none; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--ink-soft); font-size: .9rem; }

.role {
  display: inline-block; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 8px; border-radius: 999px;
  background: var(--line); color: var(--ink-soft); font-weight: 600;
}
.role-admin { background: #1c1917; color: #fff; }
.role-manager { background: #dbeafe; color: #1e40af; }
.role-leadership { background: #fef3c7; color: #92400e; }
.role-finance { background: #dcfce7; color: #166534; }

/* Main */
.main { padding: 28px 0 60px; }
.footer { padding: 20px 0; color: var(--muted); text-align: center; }

/* Page heads */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }
.page-head h1 .pill { vertical-align: middle; margin-left: 8px; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.card h3 { font-size: .95rem; color: var(--ink-soft); margin-bottom: .25rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Stats */
.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 1000px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line); vertical-align: middle;
}
.table th { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.table tbody tr:hover { background: #fafaf9; }

/* Forms */
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--ink-soft); }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: auto; }
.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--ink-soft); }

/* Buttons */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; cursor: pointer; font-weight: 600;
}
.btn:hover { background: #fafaf9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #991b1b; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line); }
.btn-block { display: block; width: 100%; margin-top: 6px; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input { max-width: 320px; }

/* Pills (statuses) */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--line); color: var(--ink-soft);
}
.pill-draft { background: #f1f5f9; color: #475569; }
.pill-submitted, .pill-leadership_review { background: #fef3c7; color: #92400e; }
.pill-changes_requested { background: #ffedd5; color: #9a3412; }
.pill-approved_by_leadership { background: #dbeafe; color: #1e40af; }
.pill-finance_review { background: #e0e7ff; color: #3730a3; }
.pill-ready_for_external_payment { background: #cffafe; color: #155e75; }
.pill-paid_outside_system { background: #dcfce7; color: #166534; }
.pill-rejected { background: #fee2e2; color: #991b1b; }
.pill-on_hold { background: #f5f5f4; color: #44403c; }

/* Leadership sub-status pills */
.pill-lead-pending { background: #fef3c7; color: #92400e; }
.pill-lead-approved { background: #dcfce7; color: #166534; }
.pill-lead-rejected { background: #fee2e2; color: #991b1b; }
.pill-lead-changes_requested { background: #ffedd5; color: #9a3412; }
.pill-lead-on_hold { background: #f5f5f4; color: #44403c; }

/* Finance sub-status pills */
.pill-fin-not_ready { background: #f1f5f9; color: #475569; }
.pill-fin-missing_docs { background: #fee2e2; color: #991b1b; }
.pill-fin-ready_for_payment { background: #cffafe; color: #155e75; }
.pill-fin-paid { background: #dcfce7; color: #166534; }
.pill-fin-on_hold { background: #f5f5f4; color: #44403c; }

/* Tax form status pills */
.pill-tax-missing { background: #fee2e2; color: #991b1b; }
.pill-tax-requested { background: #fef3c7; color: #92400e; }
.pill-tax-received { background: #dbeafe; color: #1e40af; }
.pill-tax-verified { background: #dcfce7; color: #166534; }
.pill-tax-expired { background: #fee2e2; color: #991b1b; }
.pill-tax-not_required { background: #f1f5f9; color: #475569; }

/* Contractor active-status pills */
.pill-active-active { background: #dcfce7; color: #166534; }
.pill-active-inactive { background: #f1f5f9; color: #475569; }
.pill-active-blocked { background: #fee2e2; color: #991b1b; }

/* Document type pill */
.pill-doc { background: #e0e7ff; color: #3730a3; }
/* Finance-only and missing-docs badges */
.pill-finance-only { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.pill-missing-docs { background: #fee2e2; color: #991b1b; }
.pill-w9-missing   { background: #fee2e2; color: #991b1b; }
.pill-w9-received  { background: #dbeafe; color: #1e40af; }
.pill-w9-verified  { background: #dcfce7; color: #166534; }

/* Document list */
.doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.doc-list li { padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; }
.doc-list .doc-name { font-weight: 600; font-size: .92rem; }
.doc-list .doc-meta { margin-top: 4px; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-list .doc-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.doc-w9-restricted { font-size: .85rem; color: var(--muted); font-style: italic; }

/* Missing-docs alert banner */
.missing-docs-alert {
  background: #fef2f2; border: 1px solid #fca5a5;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  font-size: .88rem; color: #991b1b; font-weight: 600;
}

/* Export dropdown menu */
.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-panel {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 0;
  min-width: 220px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
}
.export-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700;
  padding: 4px 14px 2px;
}
.export-link {
  display: block; padding: 7px 14px;
  font-size: .88rem; color: var(--ink);
  text-decoration: none;
}
.export-link:hover { background: #f1f5f9; color: var(--primary); }

.upload-form { margin-top: 14px; }
.err { color: #b91c1c; display: block; margin-top: 4px; font-size: .8rem; }

/* Flashes */
.flashes { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff;
}
.flash-success { border-color: #bbf7d0; background: #f0fdf4; color: #14532d; }
.flash-danger { border-color: #fecaca; background: #fef2f2; color: #7f1d1d; }
.flash-warning { border-color: #fde68a; background: #fffbeb; color: #78350f; }
.flash-info { border-color: #bfdbfe; background: #eff6ff; color: #1e3a8a; }

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding-top: 60px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-logo { width: 80px; height: 80px; border-radius: 12px; object-fit: cover; }
.auth-card h1 { margin: 0 0 4px; }
.muted { color: var(--muted); }

/* Detail page */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.reject-box { margin-top: 14px; }
.reject-box summary { cursor: pointer; color: var(--ink-soft); }
.reject-box form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.doc-list { list-style: none; padding: 0; margin: 0 0 12px; }
.doc-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.upload { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.upload .input { flex: 1; min-width: 240px; }

.comments { list-style: none; padding: 0; margin: 0 0 12px; }
.comments li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comments li:last-child { border-bottom: none; }
.comment-meta { font-size: .85rem; margin-bottom: 4px; }

/* 3-column filter grid */
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3 { grid-template-columns: 1fr; } }

/* Collapsible filter drawer */
.filter-drawer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px;
  padding: 0;
}
.filter-drawer summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.filter-drawer summary::-webkit-details-marker { display: none; }
.filter-form { padding: 0 16px 16px; }
.filter-form .field { margin-bottom: 8px; }
.filter-form .field label { font-size: .8rem; }

/* Actions card */
.actions-card { background: #fafaf9; }

/* Form action row */
.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* Confirmation box */
.confirm-box {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 8px; padding: 12px 14px; margin-top: 4px;
}

/* Audit timeline */
.audit-timeline { list-style: none; padding: 0; margin: 0; }
.audit-timeline li {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.audit-timeline li:last-child { border-bottom: none; }
.audit-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0; margin-top: 5px;
}
.audit-body { flex: 1; font-size: .88rem; }

/* Action groups inside the actions card */
.action-group {
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
}
.action-group:first-child { border-top: none; padding-top: 0; }
.action-group-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
.action-group-admin .action-group-label { color: #1c1917; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Collapsible action panels (details/summary for each action) */
.action-details { position: relative; }
.action-details > summary {
  list-style: none; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px;
}
.action-details > summary::-webkit-details-marker { display: none; }
.action-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  min-width: 320px; max-width: 480px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
}
.action-panel .field { margin-bottom: 10px; }
.action-panel .input { font-size: .9rem; }

/* W-9 warning banner inside action panels */
.w9-warning {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 8px 10px; margin-bottom: 10px;
  font-size: .85rem; color: #78350f;
}

/* Stat value color variants */
.stat-value-good { color: var(--success); }
.stat-value-warn { color: var(--warning); }
.stat-value-danger { color: var(--danger); }
.stat-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* Card header row (title + action button on right) */
.card-head {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

/* Role strip (admin dashboard user summary bar) */
.role-strip {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px;
}
.role-stat { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.role-stat-count { color: var(--ink-soft); font-weight: 600; }

/* ---- User management ---- */
.row-inactive td { color: var(--muted); }
.row-inactive td .role { opacity: .55; }
.badge-you {
  display: inline-block; font-size: .68rem; font-weight: 700;
  background: var(--primary-light, #e0e7ff); color: var(--primary);
  border-radius: 4px; padding: 1px 5px; vertical-align: middle; margin-left: 4px;
}
.pill-active  { background: #dcfce7; color: #15803d; }
.pill-inactive { background: #f3f4f6; color: #6b7280; }
.action-cell { white-space: nowrap; }
.card-note {
  font-size: .9rem; color: var(--ink-soft); background: #f8fafc;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 16px;
}
.field-hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ---- Account dropdown in top-bar ---- */
.account-menu { position: relative; }
.account-menu > summary {
  list-style: none; cursor: pointer;
  font-weight: 600; font-size: .9rem;
  color: var(--ink); padding: 4px 6px;
  border-radius: 4px;
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu[open] > summary { background: rgba(0,0,0,.06); }
.account-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); min-width: 180px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  display: flex; flex-direction: column; overflow: hidden;
}
.account-link {
  display: block; padding: 10px 16px; font-size: .9rem;
  color: var(--ink); text-decoration: none;
}
.account-link:hover { background: var(--bg); }
.account-link-signout { border-top: 1px solid var(--line); color: var(--danger); }

/* ===== Status Timeline (request detail) ===== */
.timeline-card { overflow-x: auto; }
.pr-timeline {
  display: flex; align-items: flex-start;
  gap: 0; min-width: 0; padding: 8px 0 4px;
}
.pr-tl-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 80px; max-width: 140px; position: relative; text-align: center;
}
/* Connecting line between steps */
.pr-tl-step:not(:first-child) .pr-tl-connector {
  position: absolute; top: 15px; right: calc(50% + 18px); left: -50%;
  height: 2px; background: var(--line); z-index: 0;
}
.pr-tl-done:not(:first-child) .pr-tl-connector  { background: var(--success); }
.pr-tl-active:not(:first-child) .pr-tl-connector { background: var(--primary); }
.pr-tl-failed:not(:first-child) .pr-tl-connector,
.pr-tl-returned:not(:first-child) .pr-tl-connector { background: var(--danger); }
.pr-tl-warning:not(:first-child) .pr-tl-connector { background: var(--warning); }
.pr-tl-skipped:not(:first-child) .pr-tl-connector {
  background: repeating-linear-gradient(90deg,var(--line) 0,var(--line) 4px,transparent 4px,transparent 8px);
}

/* Step dot */
.pr-tl-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; position: relative; z-index: 1;
  border: 2px solid var(--line); background: var(--surface); color: var(--muted);
}
.pr-tl-done    .pr-tl-dot { background: var(--success); border-color: var(--success); color: #fff; }
.pr-tl-active  .pr-tl-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.18); }
.pr-tl-failed  .pr-tl-dot { background: var(--danger);  border-color: var(--danger);  color: #fff; }
.pr-tl-warning .pr-tl-dot { background: #f59e0b;        border-color: #f59e0b;        color: #fff; }
.pr-tl-returned .pr-tl-dot{ background: #ea580c;        border-color: #ea580c;        color: #fff; }
.pr-tl-hold    .pr-tl-dot { background: #fbbf24;        border-color: #fbbf24;        color: #fff; }
.pr-tl-skipped .pr-tl-dot { background: #f3f4f6;        border-color: #d1d5db;        color: #9ca3af; }

/* Step body */
.pr-tl-body { margin-top: 8px; padding: 0 4px; }
.pr-tl-label {
  font-size: .78rem; font-weight: 700; line-height: 1.25;
  color: var(--ink-soft);
}
.pr-tl-done .pr-tl-label    { color: var(--ink); }
.pr-tl-active .pr-tl-label  { color: var(--primary); }
.pr-tl-failed .pr-tl-label  { color: var(--danger); }
.pr-tl-warning .pr-tl-label { color: #b45309; }
.pr-tl-returned .pr-tl-label{ color: #c2410c; }
.pr-tl-hold .pr-tl-label    { color: #92400e; }
.pr-tl-ts     { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.pr-tl-detail { font-size: .72rem; color: var(--muted); }
.pr-tl-sub    { font-size: .72rem; color: var(--muted); font-style: italic; margin-top: 2px; max-width: 120px; }

/* ===== Comment + Audit side-by-side grid ===== */
.grid-comment-audit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: start;
}
@media (max-width: 860px) {
  .grid-comment-audit { grid-template-columns: 1fr; }
}

/* ===== Comments ===== */
.comment-section h2, .audit-section h2 {
  display: flex; align-items: center; gap: 8px;
}
.count-badge {
  display: inline-block; font-size: .72rem; font-weight: 700;
  background: var(--primary-light, #e0e7ff); color: var(--primary);
  border-radius: 20px; padding: 1px 7px;
}
.comment-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.comment-item {
  border-radius: 8px; padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.comment-vis-finance_only    { background: #eff6ff; border-color: #bfdbfe; }
.comment-vis-leadership_only { background: #f5f3ff; border-color: #ddd6fe; }
.comment-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.comment-author-block { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comment-author { font-size: .9rem; }
.comment-role-badge { font-size: .68rem; padding: 1px 5px; }
.comment-vis-tag {
  font-size: .68rem; font-weight: 700; border-radius: 4px;
  padding: 1px 6px; letter-spacing: .03em;
}
.vis-finance    { background: #dbeafe; color: #1d4ed8; }
.vis-leadership { background: #ede9fe; color: #6d28d9; }
.comment-ts { font-size: .78rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.comment-body { font-size: .9rem; white-space: pre-wrap; color: var(--ink); line-height: 1.5; }
.comment-form { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.comment-input { font-size: .9rem; }
.comment-form-footer {
  display: flex; gap: 8px; margin-top: 8px;
  align-items: center; flex-wrap: wrap;
}
.comment-vis-select { width: auto; font-size: .85rem; }

/* ===== Audit trail ===== */
.audit-trail { list-style: none; margin: 0; padding: 0; }
.audit-entry {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.audit-entry:last-child { border-bottom: none; }

.audit-entry-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  margin-top: 5px;
}
.dot-status  { background: var(--primary); }
.dot-comment { background: #10b981; }
.dot-create  { background: #8b5cf6; }
.dot-fail    { background: var(--danger); }
.dot-default { background: var(--muted); }

.audit-entry-body { flex: 1; min-width: 0; }
.audit-entry-head {
  display: flex; align-items: flex-start; flex-wrap: wrap;
  gap: 6px; margin-bottom: 3px;
}
.audit-entry-action { font-weight: 600; font-size: .88rem; }
.audit-status-arrow {
  display: inline-flex; align-items: center; gap: 4px; font-size: .8rem;
}
.audit-status-arrow .pill { font-size: .7rem; padding: 1px 6px; }
.audit-value-change { font-size: .82rem; }
.audit-entry-notes {
  font-size: .82rem; color: var(--ink-soft);
  white-space: pre-wrap; margin-bottom: 3px;
  background: #f8fafc; border-radius: 4px; padding: 3px 6px;
}
.audit-entry-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .78rem; color: var(--muted); margin-top: 2px;
}
.audit-actor { font-weight: 600; color: var(--ink-soft); }
.audit-actor-role { font-size: .65rem; padding: 0 4px; }
.audit-ts { color: var(--muted); }

/* ===== Topbar search ===== */
.topbar-search {
  display: flex; align-items: center; flex: 1;
  max-width: 320px; margin: 0 16px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.topbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.topbar-search-input {
  flex: 1; border: none; background: transparent;
  padding: 7px 10px; font: inherit; font-size: .88rem;
  color: var(--ink); outline: none;
}
.topbar-search-input::placeholder { color: var(--muted); }
.topbar-search-btn {
  background: none; border: none; padding: 7px 10px;
  cursor: pointer; color: var(--muted); display: flex; align-items: center;
}
.topbar-search-btn:hover { color: var(--ink); }

/* Brand name hide on small screens */
@media (max-width: 640px) {
  .brand-name { display: none; }
  .topbar-search { max-width: none; flex: 1; margin: 0 8px; }
}

/* ===== Mobile hamburger ===== */
.hamburger {
  display: none; flex-direction: column; justify-content: center;
  gap: 5px; padding: 6px; background: none; border: none;
  cursor: pointer; border-radius: 6px; flex-shrink: 0;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--ink-soft); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-open span:nth-child(2) { opacity: 0; }
.hamburger-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 860px) {
  .hamburger { display: flex; }
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    flex-direction: column; gap: 0; margin: 0; padding: 8px 0; z-index: 100;
  }
  .nav.nav-open { display: flex; }
  .nav a { padding: 10px 20px; border-radius: 0; }
  .nav a:hover { background: var(--bg); }
  .topbar { position: sticky; top: 0; z-index: 20; }
  .topbar-inner { position: relative; }
}

/* Nav active link */
.nav a.nav-active { color: var(--primary); font-weight: 700; }

/* ===== Account panel header ===== */
.account-panel-header {
  padding: 10px 16px 8px; border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.account-panel-name { font-weight: 700; font-size: .92rem; color: var(--ink); }
.account-panel-email { font-size: .8rem; color: var(--muted); margin-top: 1px; }

/* ===== Flash icon ===== */
.flash { display: flex; align-items: center; gap: 8px; }
.flash-icon {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800;
}
.flash-success .flash-icon { background: #bbf7d0; color: #14532d; }
.flash-danger  .flash-icon { background: #fecaca; color: #7f1d1d; }
.flash-warning .flash-icon { background: #fde68a; color: #78350f; }
.flash-info    .flash-icon { background: #bfdbfe; color: #1e3a8a; }

/* ===== Empty states ===== */
.empty-state {
  text-align: center; padding: 48px 24px;
}
.empty-icon { font-size: 2.4rem; margin-bottom: 12px; line-height: 1; }
.empty-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-body { font-size: .9rem; color: var(--muted); max-width: 400px; margin: 0 auto; line-height: 1.5; }
.empty-actions { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ===== Filter bar (contractors, simple) ===== */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: flex-end;
}
.filter-bar-inputs { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.filter-bar-inputs .input { flex: 1; min-width: 140px; max-width: 260px; }
.filter-bar-actions { display: flex; gap: 8px; }

/* ===== Filter drawer improvements ===== */
.filter-drawer-summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.filter-drawer-summary::-webkit-details-marker { display: none; }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: .68rem; font-weight: 700;
}
.filter-actions {
  margin-top: 12px; display: flex; gap: 8px;
}

/* ===== Responsive table wrapper ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
}
@media (max-width: 1000px) {
  .hide-md { display: none; }
}
.tbl-id { white-space: nowrap; font-weight: 700; }

/* ===== Pagination ===== */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; padding: 14px 0 4px;
  border-top: 1px solid var(--line); margin-top: 4px;
}
.pagination-info { font-size: .82rem; color: var(--muted); }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: .85rem; font-weight: 600; color: var(--ink);
  background: var(--surface); text-decoration: none;
  transition: background .12s, border-color .12s;
}
.page-btn:hover { background: var(--bg); border-color: var(--ink-soft); text-decoration: none; }
.page-btn-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn-active:hover { background: #991b1b; }
.page-btn-disabled { color: var(--muted); cursor: default; }
.page-btn-disabled:hover { background: var(--surface); border-color: var(--line); }
.page-btn-gap { border-color: transparent; background: none; }

/* ===== Search results page ===== */
.search-query-display { font-weight: 400; color: var(--ink-soft); font-size: 1.1rem; margin-left: 4px; }
.search-page-form { display: flex; gap: 8px; align-items: center; }

/* ===== Status pills — cleaner labels via status_label() ===== */
/* Ensure pill text doesn't overflow on small screens */
.pill { white-space: nowrap; }

/* ===== Validation message improvements ===== */
.err {
  display: flex; align-items: center; gap: 4px;
  color: #b91c1c; font-size: .8rem; margin-top: 5px; font-weight: 500;
}
.err::before { content: "⚠"; font-size: .75rem; }
.field-error .input {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248,113,113,.18);
}
.field-hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ===== Dashboard formatting improvements ===== */
.stat-value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ===== Google OAuth button ===== */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 10px 16px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0; border-radius: 8px;
  font-size: .95rem; font-weight: 500; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .12s, box-shadow .12s;
  margin-bottom: 4px;
}
.btn-google:hover {
  background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,.12);
  text-decoration: none; color: #3c4043;
}
.btn-google-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ===== Auth page divider ===== */
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--muted); font-size: .82rem;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ===== Auth footer link ===== */
.auth-footer-link {
  text-align: center; margin-top: 18px; font-size: .88rem; color: var(--muted);
}
.auth-footer-link a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-footer-link a:hover { text-decoration: underline; }
.field-error { color: #dc2626; font-size: .82rem; margin: 3px 0 0; }

/* ===== Pending approval page ===== */
.pending-icon { font-size: 2.4rem; margin-bottom: 12px; }

/* ===== Pending users section (admin/users) ===== */
.pending-section { border: 1.5px solid #fbbf24; background: #fffbeb; }
.pending-section-head {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 20px 10px; border-bottom: 1px solid #fde68a;
}
.pending-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f59e0b; color: #fff;
  font-size: .78rem; font-weight: 700; padding: 3px 10px;
  border-radius: 12px; width: fit-content;
}
.pending-badge::before { content: "●"; font-size: .5rem; }
.row-pending { background: #fffbeb; }
.row-pending:hover { background: #fef3c7; }
.input-sm { padding: 4px 8px; font-size: .85rem; height: 30px; }
.btn-success {
  background: #15803d; color: #fff; border: none;
}
.btn-success:hover { background: #166534; }

/* ===== Contractor Onboarding ===== */
.onboarding-wrap { max-width: 680px; margin: 40px auto; padding: 0 16px 60px; }
.onboarding-card { padding: 32px; }
.onboarding-header { text-align: center; margin-bottom: 28px; }
.onboarding-logo { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; margin-bottom: 14px; }
.onboarding-header h1 { margin: 0 0 6px; }
.ob-steps {
  display: flex; gap: 4px; margin-bottom: 28px;
  border-bottom: 2px solid var(--line); padding-bottom: 0;
}
.ob-step {
  flex: 1; padding: 10px 4px; background: none; border: none;
  cursor: pointer; font-size: .85rem; font-weight: 500;
  color: var(--muted); border-bottom: 3px solid transparent;
  margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.ob-step:hover { color: var(--text); }
.ob-step.active { color: var(--accent); border-bottom-color: var(--accent); }
.ob-section-title { font-size: 1rem; font-weight: 600; margin: 0 0 18px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ob-section.hidden { display: none; }
.ob-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-hint { font-size: .8rem; color: var(--muted); margin: 4px 0 0; }
.req { color: #dc2626; }
.ob-agreement {
  background: #f9fafb; border: 1px solid var(--line); border-radius: 8px;
  padding: 20px 24px; font-size: .87rem; line-height: 1.65;
}
.ob-agreement strong { display: block; margin-bottom: 10px; font-size: .95rem; }
.ob-agreement ol { margin: 10px 0 0 18px; padding: 0; }
.ob-agreement li { margin-bottom: 10px; }
.ob-signature-input {
  font-family: 'Georgia', serif; font-size: 1.1rem;
  border-bottom: 2px solid var(--accent); border-top: none;
  border-left: none; border-right: none; border-radius: 0;
  padding: 8px 0; background: transparent;
}
.ob-signature-input:focus { outline: none; border-bottom-color: var(--accent); box-shadow: none; }
.invite-url-row { display: flex; gap: 8px; }
.invite-url-row .input { flex: 1; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
@media (max-width: 520px) {
  .field-row { flex-direction: column; gap: 0; }
  .ob-step { font-size: .75rem; padding: 8px 2px; }
}

/* ── Contractor portal ───────────────────────────────────────────────────── */
.role-contractor { background: #d1fae5; color: #065f46; }

.portal-stat-row {
  display: flex; gap: 16px; margin-top: 20px; flex-wrap: wrap;
}
.portal-stat-card {
  flex: 1; min-width: 160px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow);
}
.portal-stat-label { font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 6px; }
.portal-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--ink); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .8rem; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }

.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.section-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); margin: 0 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  text-align: center; padding: 48px 24px; color: var(--ink-soft);
}

/* ── Page intro / explainer blocks ─────────────────────────────── */
.page-intro {
  background: #f0f4f8;
  border-left: 3px solid #94a3b8;
  border-radius: 0 6px 6px 0;
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: .875rem;
  color: var(--ink-soft);
  line-height: 1.6;
}
.page-intro strong { color: var(--ink); }
.page-intro p { margin: 0 0 6px; }
.page-intro p:last-child { margin: 0; }
.page-intro .flow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px;
}
.page-intro .flow-step {
  background: #fff; border: 1px solid #cbd5e1; border-radius: 20px;
  padding: 2px 12px; font-size: .8rem; font-weight: 600; color: var(--ink);
  white-space: nowrap;
}
.page-intro .flow-arrow { color: #94a3b8; font-size: .9rem; }
