/* ===========================================================================
   Design tokens
   =========================================================================== */
:root {
  /* Brand -- Travis Terry & Company, CPA. Navy/blue-gray, understated --
     derived from the firm's existing mark, not an invented bright SaaS
     color. Kept distinct from the semantic status colors below. */
  --brand-navy: #1f3a56;
  --brand-navy-dark: #152a3f;
  --brand-navy-tint: #eaeff4;

  /* Neutrals */
  --ink: #1a2230;
  --ink-soft: #33404f;
  --subtle: #6b7684;
  --muted: #98a2ae;
  --border: #e3e7eb;
  --border-strong: #cbd2d9;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;

  /* Accent = brand-derived; used for links, focus rings, primary actions */
  --accent: var(--brand-navy);
  --accent-dark: var(--brand-navy-dark);
  --accent-tint: var(--brand-navy-tint);

  /* Semantic status colors (never repurposed for branding) */
  --green: #1e8e5a;
  --green-tint: #e5f5ec;
  --amber: #b7791f;
  --amber-tint: #fdf3e0;
  --red: #c0392b;
  --red-tint: #fbe9e7;
  --blue: #2b6cb0;
  --blue-tint: #e8f0fa;
  --gray: #6b7684;
  --gray-tint: #eceef1;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Roboto Mono", Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-banner {
  background: var(--amber-tint);
  color: #7a5b00;
  text-align: center;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid #eecb62;
}

/* ===========================================================================
   App shell -- persistent left nav + top context bar
   =========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-4) 0 var(--space-5);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-4) var(--space-4);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--brand-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-name { font-weight: 700; font-size: 14px; color: var(--ink); display: block; }
.sidebar-brand-sub { font-size: 11px; color: var(--subtle); display: block; }

.sidebar-build {
  margin-top: auto;
  padding: var(--space-3) var(--space-4) 0;
  font-size: 10px;
  color: var(--subtle);
  letter-spacing: 0.02em;
}

.nav-group { padding: 0 var(--space-3); }
.nav-group + .nav-group {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 var(--space-2) var(--space-2);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 1px;
}
.nav-link:hover { background: var(--gray-tint); color: var(--ink); }
.nav-link.active { background: var(--accent-tint); color: var(--accent-dark); font-weight: 600; }
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }
.nav-group.secondary .nav-link { color: var(--subtle); font-size: 12.5px; }
.nav-group.secondary .nav-group-label { color: var(--muted); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.context-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px var(--space-5);
}
.context-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: default;
}
.context-selector .context-icon { color: var(--subtle); }
.context-selector .caret { color: var(--muted); font-size: 11px; margin-left: 2px; }
.context-selector input[type="month"] {
  border: none; background: transparent; font: inherit; font-weight: 600; color: inherit;
  padding: 0; cursor: pointer; width: 108px;
}
.context-bar-search {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 480px;
}
.context-bar-search input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2398a2ae' stroke-width='2'><circle cx='6' cy='6' r='5'/><line x1='10' y1='10' x2='13' y2='13'/></svg>") 10px center no-repeat;
}
.context-bar-search kbd {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--card-bg);
}
.context-bar-search-wrap { position: relative; flex: 1; max-width: 480px; }

.context-bar-right { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.content { padding: var(--space-5) var(--space-6); max-width: 1440px; width: 100%; }

.footer { text-align: center; color: var(--subtle); font-size: 12px; padding: var(--space-5); }

/* ===========================================================================
   Page header
   =========================================================================== */
.page-header { margin-bottom: var(--space-5); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.01em; }
.page-header .page-subtitle { color: var(--subtle); font-size: 13.5px; margin: 0; }
.page-header-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

h1 { font-size: 22px; margin-bottom: 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 14px; margin-top: var(--space-5); margin-bottom: var(--space-2); color: var(--ink); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
h3 { font-size: 14px; margin: 0 0 var(--space-2); font-weight: 700; }

.subtle { color: var(--subtle); font-size: 12.5px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.section-head .link-action { font-size: 12.5px; font-weight: 600; text-decoration: none; }

/* ===========================================================================
   Status strip + metric cards
   =========================================================================== */
.status-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (max-width: 1100px) { .status-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .status-strip { grid-template-columns: repeat(2, 1fr); } }

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.metric-card-top { display: flex; align-items: center; gap: 8px; }
.metric-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.metric-icon.tone-green { background: var(--green-tint); color: var(--green); }
.metric-icon.tone-amber { background: var(--amber-tint); color: var(--amber); }
.metric-icon.tone-red { background: var(--red-tint); color: var(--red); }
.metric-icon.tone-blue { background: var(--blue-tint); color: var(--blue); }
.metric-icon.tone-gray { background: var(--gray-tint); color: var(--gray); }
.metric-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.metric-value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.metric-value.amount::before { content: "$"; color: var(--muted); font-weight: 600; }
.metric-detail { font-size: 12px; font-weight: 600; }
.metric-detail.tone-green { color: var(--green); }
.metric-detail.tone-amber { color: var(--amber); }
.metric-detail.tone-red { color: var(--red); }
.metric-detail.tone-blue { color: var(--blue); }
.metric-detail.tone-gray { color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
@media (max-width: 800px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--subtle); margin-top: 4px; }

/* ===========================================================================
   Progress stepper (Month Close Progress)
   =========================================================================== */
.stepper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-5) var(--space-4);
  margin-bottom: var(--space-5);
}
.stepper-step {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}
.stepper-connector {
  /* Was `flex: 0 0 auto; width: 100%` -- a non-shrinking item demanding
     100% of the container's width, which starved the steps down to
     their minimum content size and spread them across a huge gap
     instead of dividing the row evenly. A small, shrinkable/growable
     spacer keeps steps evenly spaced with a clean short line between
     them at any width. */
  flex: 1 1 32px;
  min-width: 12px;
  max-width: 64px;
  height: 2px;
  background: var(--border);
  margin-top: 15px;
  align-self: flex-start;
}
.stepper-connector.tone-green { background: var(--green); }
.stepper-connector.tone-amber { background: var(--amber); }
.stepper-connector.tone-blue { background: var(--blue); }
.stepper-connector.tone-red { background: var(--red); }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  margin-bottom: 8px;
}
.step-dot.tone-green { border-color: var(--green); background: var(--green-tint); color: var(--green); }
.step-dot.tone-amber { border-color: var(--amber); background: var(--amber-tint); color: var(--amber); }
.step-dot.tone-blue { border-color: var(--blue); background: var(--blue); color: #fff; }
.step-dot.tone-red { border-color: var(--red); background: var(--red-tint); color: var(--red); }
.step-dot.tone-gray { border-color: var(--border); background: var(--gray-tint); color: var(--muted); }
.step-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.step-detail { font-size: 11.5px; color: var(--subtle); margin-top: 2px; }
.step-detail.tone-amber { color: var(--amber); font-weight: 600; }
.step-detail.tone-green { color: var(--green); font-weight: 600; }
.step-detail.tone-blue { color: var(--blue); font-weight: 600; }
.step-detail.tone-red { color: var(--red); font-weight: 600; }
.step-detail.tone-gray { color: var(--muted); }
@media (max-width: 700px) {
  .stepper { padding: var(--space-4) var(--space-3) var(--space-3); }
  .stepper-connector { flex-basis: 12px; min-width: 8px; margin-top: 15px; }
  .step-label { font-size: 12px; }
  .step-detail { font-size: 10.5px; }
}

/* ===========================================================================
   Needs attention (exception cards)
   =========================================================================== */
.attention-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (max-width: 1100px) { .attention-grid { grid-template-columns: repeat(2, 1fr); } }
.attention-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
}
.attention-card.tone-red { border-left-color: var(--red); }
.attention-card.tone-blue { border-left-color: var(--blue); }
.attention-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.attention-card-title { font-weight: 700; font-size: 13.5px; }
.attention-card-amount { font-weight: 700; font-size: 13.5px; font-family: var(--font-mono); }
.attention-card-meta { font-size: 12px; color: var(--subtle); margin-top: 2px; }
.attention-card-reason { font-size: 12px; margin-top: var(--space-2); font-weight: 600; }

/* ===========================================================================
   Tables (table shell)
   =========================================================================== */
.table-shell {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.simple-table, table.kv-table, table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data-table { border: none; border-radius: 0; }
table.simple-table th, table.simple-table td,
table.kv-table th, table.kv-table td,
table.data-table th, table.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
table.kv-table th { width: 220px; color: var(--subtle); font-weight: 600; }
table.simple-table th, table.data-table th {
  background: #fafbfc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--subtle);
  font-weight: 700;
  position: sticky;
  top: 0;
}
table.simple-table tr:last-child td, table.kv-table tr:last-child td, table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { cursor: default; }
table.data-table tbody tr.row-clickable { cursor: pointer; }
table.data-table tbody tr.row-clickable:hover { background: var(--accent-tint); }
table.data-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.amount, td.amount, .amount-cell {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
th.amount-col, td.amount-col { text-align: right; }
.amount-negative { color: var(--red); }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-wrap: wrap;
}
.table-toolbar input[type="text"], .table-toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.table-toolbar .search-input { flex: 1; min-width: 180px; max-width: 320px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 var(--space-4); background: var(--card-bg); }
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--subtle);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tab .tab-count { color: var(--muted); font-weight: 600; margin-left: 4px; }
.tab.active .tab-count { color: var(--accent); }

/* ===========================================================================
   Badges / pills
   =========================================================================== */
.risk-badge, .status-badge, .badge, .pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.risk-auto-eligible { background: var(--green-tint); color: var(--green); }
.risk-review { background: var(--amber-tint); color: var(--amber); }
.risk-escalate { background: var(--red-tint); color: var(--red); }
.risk-none { background: var(--gray-tint); color: var(--subtle); }

.status-unreviewed { background: var(--gray-tint); color: var(--subtle); }
.status-approved { background: var(--green-tint); color: var(--green); }
.status-changed { background: var(--blue-tint); color: var(--blue); }
.status-needs_documentation { background: var(--amber-tint); color: var(--amber); }
.status-sent_to_review { background: var(--red-tint); color: var(--red); }

.badge-doc { background: var(--amber-tint); color: var(--amber); margin-left: 6px; }
.badge-abstain { background: var(--red-tint); color: var(--red); margin-left: 6px; }
.badge-risk { background: var(--red-tint); color: var(--red); }

.status-data { background: var(--gray-tint); color: var(--subtle); }
.status-section_header { background: var(--blue-tint); color: var(--blue); }
.status-section_summary { background: var(--green-tint); color: var(--green); }

.status-pending_review { background: var(--gray-tint); color: var(--subtle); }
.status-rejected { background: var(--red-tint); color: var(--red); }
.status-deferred { background: var(--amber-tint); color: var(--amber); }
.status-completed { background: var(--green-tint); color: var(--green); }
.status-verification_failed { background: var(--red-tint); color: var(--red); }
.status-write_failed { background: var(--red-tint); color: var(--red); }
.status-auto_eligible { background: var(--green-tint); color: var(--green); }
.status-review { background: var(--amber-tint); color: var(--amber); }
.status-needs_docs { background: var(--amber-tint); color: var(--amber); }
.status-blocked { background: var(--red-tint); color: var(--red); }
.status-match_high_confidence { background: var(--red-tint); color: var(--red); }
.status-match_possible { background: var(--amber-tint); color: var(--amber); }
.status-no_match { background: var(--gray-tint); color: var(--subtle); }

/* Generic tone pills, for anything not covered by a status-specific class above */
.pill-green { background: var(--green-tint); color: var(--green); }
.pill-amber { background: var(--amber-tint); color: var(--amber); }
.pill-red { background: var(--red-tint); color: var(--red); }
.pill-blue { background: var(--blue-tint); color: var(--blue); }
.pill-gray { background: var(--gray-tint); color: var(--subtle); }

/* ===========================================================================
   Buttons
   =========================================================================== */
.button, .button-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  border: none;
  cursor: pointer;
  transition: background 0.12s ease;
}
.button-small { padding: 5px 10px; font-size: 12px; }
.button:hover, .button-small:hover { background: var(--accent-dark); }
.button:disabled { background: var(--border-strong); cursor: not-allowed; }
.button-secondary {
  background: var(--card-bg);
  color: var(--ink-soft);
  border: 1px solid var(--border-strong);
}
.button-secondary:hover { background: var(--gray-tint); color: var(--ink); }
.button-danger { background: var(--red); }
.button-danger:hover { background: #96281f; }
button.button-small { border: none; cursor: pointer; font-family: inherit; }

.inline-form { margin: var(--space-3) 0; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.inline-form select, .inline-form input[type=number], .inline-form input[type=text] {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* ===========================================================================
   Alerts / status boxes / empty states
   =========================================================================== */
.status-box { border-radius: var(--radius); padding: var(--space-4) var(--space-5); border: 1px solid var(--border); background: var(--card-bg); margin-bottom: var(--space-4); }
.status-box.status-local { border-left: 4px solid var(--green); }
.status-box.status-connected { border-left: 4px solid var(--blue); }
.status-box.status-error { border-left: 4px solid var(--red); }
.status-box-title { font-weight: 700; font-size: 14px; margin-bottom: var(--space-2); }

.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success { background: var(--green-tint); color: #0f5132; border-color: #bfe5cf; }
.alert-warning { background: var(--amber-tint); color: #6b4a08; border-color: #f0dca3; }
.alert-error { background: var(--red-tint); color: #7d241a; border-color: #f0c2bd; }
.alert-info { background: var(--blue-tint); color: #17457a; border-color: #bcd6ee; }
.alert-title { font-weight: 700; margin-bottom: 2px; }

.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-5);
  color: var(--subtle);
}
.empty-state-icon { font-size: 26px; margin-bottom: var(--space-2); color: var(--muted); }
.empty-state-title { font-weight: 700; color: var(--ink-soft); font-size: 14px; margin-bottom: 4px; }
.empty-state-detail { font-size: 12.5px; max-width: 420px; margin: 0 auto; }

/* ===========================================================================
   Drawer (right-side panel)
   =========================================================================== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.32);
  opacity: 0; visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 40;
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 92vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 0.18s ease;
  z-index: 41;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.drawer-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--muted); line-height: 1; padding: 2px 4px;
}
.drawer-close:hover { color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-4); }
.drawer-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--space-2); flex-wrap: wrap;
}
.drawer-section { margin-bottom: var(--space-4); }
.drawer-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.drawer-txn-payee { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.drawer-txn-amount { font-size: 20px; font-weight: 700; font-family: var(--font-mono); }
.drawer-txn-meta { font-size: 12.5px; color: var(--subtle); }
.evidence-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.evidence-list li { display: flex; gap: 8px; padding: 3px 0; }
.evidence-list li .tick { color: var(--green); flex-shrink: 0; }
.evidence-list li .tick.warn { color: var(--amber); }
.recommendation-box {
  background: var(--accent-tint);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.recommendation-box .rec-name { font-weight: 700; font-size: 14px; color: var(--accent-dark); }
.confidence-pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: var(--radius-pill); background: var(--green-tint); color: var(--green); }
.confidence-pill.tone-amber { background: var(--amber-tint); color: var(--amber); }
.confidence-pill.tone-gray { background: var(--gray-tint); color: var(--subtle); }
details.tech-details { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-3); }
details.tech-details summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--subtle); }
details.tech-details summary:hover { color: var(--ink); }

.raw-json {
  max-height: 420px;
  overflow: auto;
  background: #f6f7f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
}

/* ===========================================================================
   Misc reused blocks (legacy pages)
   =========================================================================== */
.txn-header { margin-bottom: var(--space-2); }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-top: var(--space-3); }
.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); }
.panel.wide { grid-column: 1 / -1; }
@media (max-width: 850px) { .review-grid { grid-template-columns: 1fr; } }

/* Desktop/T-Drive Folder Import phase: the three-way Input Package
   source choice on the Workpapers page. */
.source-option-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-top: var(--space-3); }
.source-option { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
@media (max-width: 900px) { .source-option-grid { grid-template-columns: 1fr; } }
.folder-preflight-table { width: 100%; border-collapse: collapse; margin: var(--space-2) 0; font-size: 0.9em; }
.folder-preflight-table th, .folder-preflight-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.folder-preflight-file-row.excluded { opacity: 0.5; text-decoration: line-through; }

/* ===========================================================================
   Historical Replay -- Bookkeeping review card
   =========================================================================== */
.bk-replay-summary { display: flex; gap: var(--space-4); flex-wrap: wrap; margin: var(--space-3) 0; font-size: 12.5px; }
.bk-replay-summary strong { font-size: 14px; }
.bk-review-card {
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--space-3); margin-bottom: var(--space-3);
  background: var(--card-bg);
}
.bk-review-card.tone-amber { border-left-color: var(--amber); }
.bk-review-card.tone-green { border-left-color: var(--green); }
.bk-review-card.tone-red { border-left-color: var(--red); }
.bk-review-header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.bk-review-title { font-weight: 700; font-size: 13.5px; }
.bk-review-amount { font-weight: 700; font-family: var(--font-mono); font-size: 13.5px; }
.bk-review-meta { color: var(--subtle); font-size: 12px; margin-top: 1px; }
.bk-review-sections { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-3); }
@media (max-width: 1000px) { .bk-review-sections { grid-template-columns: 1fr; } }
.bk-review-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--subtle); margin-bottom: 4px; }
.bk-review-section dl { margin: 0; }
.bk-review-section dt { font-size: 11.5px; color: var(--subtle); float: left; clear: left; width: 78px; }
.bk-review-section dd { margin: 0 0 3px 82px; font-size: 12.5px; }
.bk-review-resolution {
  margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--border);
  background: var(--bg); border-radius: var(--radius-sm); padding: var(--space-3);
}
.bk-review-resolution-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--subtle); margin-bottom: 6px; }

.action-buttons { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.action-btn {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fafbfc;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.action-btn.selected { outline: 2px solid var(--accent); background: var(--accent-tint); }

#category-picker { margin-bottom: var(--space-4); }
#category-picker select { width: 100%; max-width: 420px; padding: 6px 8px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--subtle); }
textarea { width: 100%; max-width: 600px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; }

.submit-row { margin-top: var(--space-4); display: flex; align-items: center; gap: var(--space-3); }

.queue-table td, .queue-table th { white-space: nowrap; }
.hidden { display: none; }

/* Rollout Mega Pass, Part 3: bulk reclassification -- a changed-but-
   unsaved row stays visually obvious until "Save All Changes". */
.bulk-reclassify-row.bulk-row-changed { background: var(--accent-tint); }
.bulk-reclassify-row.bulk-row-changed .bulk-reclassify-select { border-color: var(--accent); font-weight: 600; }
