@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --sidebar: #0f1e32;
  --sidebar-deep: #0c1726;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(59, 130, 246, 0.16);
  --sidebar-text: #c3d0e0;
  --sidebar-muted: #7d90a8;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff5ff;
  --accent-ring: rgba(37, 99, 235, 0.16);
  --bg: #f0f3f7;
  --surface: #ffffff;
  --ink: #182230;
  --muted: #64748b;
  --line: #e3e8f0;
  --line-strong: #c9d3e0;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --row-alt: #f8fafc;
  --row-hover: #eef4fc;
  --review: #fff8e6;
  --excluded: #f4f4f4;
  --sans: "DM Sans", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
  --sidebar-w: 244px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

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

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

/* ---------- App layout ---------- */

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

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}

.nav-top,
.nav-menu {
  display: contents;
}

.nav-toggle,
.nav-backdrop {
  display: none;
}

.sidebar .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1.5rem 1.1rem 1.2rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.sidebar .brand:hover { text-decoration: none; opacity: 0.95; }

.brand-logo { display: block; flex-shrink: 0; }
.brand-wordmark { display: block; }

.sidebar .env-pill {
  margin: 0.15rem 1.1rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
}

.sidebar .env-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
}

.committee-switch {
  padding: 0 0.85rem 0.6rem;
}

.committee-switch select {
  width: 100%;
  background: rgba(255,255,255,0.07);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0;
  cursor: pointer;
}

.committee-switch select:hover { background: rgba(255,255,255,0.1); }
.committee-switch select:focus { outline: none; border-color: var(--accent); }

.committee-switch select option {
  color: var(--ink);
  background: #fff;
}

.sidebar-footer .settings-link {
  border-left: none;
}

.sidebar-footer .settings-title {
  display: block;
  font-weight: 600;
}

.sidebar-footer .settings-link .meta {
  margin-top: 0.1rem;
}

.nav-section {
  padding: 0.6rem 0 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-label {
  padding: 0.35rem 1.15rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0.65rem;
  padding: 0.48rem 0.65rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.25);
}

.nav-link .nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-link.active .nav-icon { opacity: 1; color: #93c5fd; }
.nav-link:hover .nav-icon { opacity: 1; }

.nav-link .meta {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--sidebar-muted);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.6rem 0 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .nav-link { align-items: flex-start; }
.sidebar-footer .nav-link .nav-icon { margin-top: 0.15rem; }

.settings-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.settings-text .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar form.inline {
  display: block;
  margin: 0;
}

.sidebar form.inline button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: calc(100% - 1.3rem);
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  border-radius: 8px;
  margin: 0 0.65rem;
  padding: 0.48rem 0.65rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar form.inline button:hover {
  background: var(--sidebar-hover);
  color: #fff;
  filter: none;
}

.sidebar form.inline button .nav-icon {
  width: 17px;
  height: 17px;
  opacity: 0.75;
}

/* ---------- Workspace ---------- */

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

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.workspace-header .workspace-bar {
  position: static;
  border-bottom: none;
  padding-bottom: 0.3rem;
}

.workspace-bar h1 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.workspace-bar .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.ledger-search {
  width: min(240px, 42vw);
  margin: 0;
  padding: 0.42rem 0.7rem;
  font-size: 0.88rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.ledger-search:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.ledger-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0 1.5rem;
  background: var(--surface);
}

.ledger-tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin: 0;
  padding: 0.5rem 0.85rem 0.6rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  transition: color 0.12s ease;
}

.ledger-tab:hover {
  color: var(--ink);
  filter: none;
}

.ledger-tab.active,
.ledger-tab[aria-selected="true"] {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
  font-weight: 650;
}

.ledger-empty[hidden] {
  display: none;
}

.workspace[data-ledger-kind="expenditure"] .col-election {
  display: none;
}

.donor-search-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0;
}

.donor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(280px, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.donor-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 0.85rem;
}

.donor-totals-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.donor-totals-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.register tbody tr.row-saved {
  outline: 2px solid rgba(21, 128, 61, 0.4);
  outline-offset: -2px;
}

@media (max-width: 960px) {
  .donor-layout { grid-template-columns: 1fr; }
}

.workspace-main {
  padding: 1.25rem 1.5rem 2.5rem;
  flex: 1;
}

/* ---------- Auth pages ---------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(59, 130, 246, 0.28), transparent 60%),
    radial-gradient(700px 420px at -10% 100%, rgba(37, 99, 235, 0.18), transparent 55%),
    linear-gradient(165deg, #0c1726 0%, #142539 55%, #101f31 100%);
}

.auth-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 20px 60px rgba(12, 23, 38, 0.28);
}

.auth-card .auth-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.auth-card .stack-form { max-width: none; }

.auth-card button[type="submit"] {
  width: 100%;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  margin-top: 0.35rem;
}

/* ---------- Misc text ---------- */

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.muted { color: var(--muted); }

.error, .ok, .warn {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0 0.85rem;
  font-size: 0.9rem;
}

.error {
  color: var(--error);
  background: var(--error-soft);
  border: 1px solid #fecaca;
}

.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid #bbf7d0;
}

.ok a, .error a { color: inherit; font-weight: 600; }

.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #fde68a;
}

.warn a { color: inherit; font-weight: 600; }

/* ---------- Buttons ---------- */

.btn,
button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent-strong);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}

.btn:hover,
button:hover {
  background: var(--accent-hover);
  filter: none;
  text-decoration: none;
}

.btn:active,
button:active { transform: translateY(0.5px); }

.btn:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn.secondary,
button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover,
button.secondary:hover {
  background: #f8fafc;
  border-color: #aeb9c8;
  filter: none;
}

.btn.ghost,
button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border-color: transparent;
  box-shadow: none;
}

.btn.ghost:hover,
button.ghost:hover {
  background: var(--accent-soft);
  filter: none;
}

button.primary { background: var(--accent-strong); }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.small,
.btn.small {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
}

.btn.danger,
button.danger {
  border-color: #fecaca;
  color: var(--error);
  background: var(--surface);
}

.btn.danger:hover,
button.danger:hover {
  background: var(--error-soft);
  border-color: var(--error);
  filter: none;
}

/* ---------- Forms ---------- */

label {
  display: block;
  margin: 0.65rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

input, select, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  width: 100%;
  margin-top: 0.28rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input::placeholder { color: #9aa8ba; }

input[disabled], input[readonly] {
  background: #f4f6f9;
  color: var(--muted);
}

textarea { min-height: 72px; resize: vertical; }

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  color: var(--ink);
}

.check input { width: auto; margin: 0; }

/* ---------- Panels & cards ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-body { padding: 1rem; }

.panel-body.flush { padding: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-draft { background: #eef2f7; color: #475569; }
.badge-submitted, .badge-sent, .badge-ready { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #b91c1c; }
.badge-pending, .badge-staged, .badge-needs_review { background: #fef3c7; color: #92400e; }
.badge-excluded { background: #f1f5f9; color: #64748b; }
.badge-info { background: #dbeafe; color: #1d4ed8; }

/* ---------- Spreadsheet / register ---------- */

.register-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: calc(100vh - 180px);
  box-shadow: var(--shadow-sm);
}

.register {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 960px;
}

.register th,
.register td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.register tr:last-child td { border-bottom: none; }

.register th:last-child,
.register td:last-child { border-right: none; }

.register thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line-strong);
  user-select: none;
}

.register thead th.sortable {
  cursor: pointer;
  padding-right: 1.25rem;
}

.register thead th.sortable:hover {
  color: var(--ink);
  background: #eef2f7;
}

.register thead th.sortable::after {
  content: "↕";
  float: right;
  margin-left: 0.35rem;
  opacity: 0.3;
  font-size: 0.7rem;
  font-weight: 600;
}

.register thead th.sortable.sort-asc::after {
  content: "↑";
  opacity: 0.9;
}

.register thead th.sortable.sort-desc::after {
  content: "↓";
  opacity: 0.9;
}

.register tbody tr:nth-child(even) { background: var(--row-alt); }
.register tbody tr:hover { background: var(--row-hover); }
.register tbody tr.status-needs_review { background: var(--review); }

.register tbody tr[data-kind="contribution"] { background: #f0faf4; }
.register tbody tr[data-kind="contribution"]:nth-child(even) { background: #e8f6ee; }
.register tbody tr[data-kind="contribution"]:hover { background: #ddf0e6; }
.register tbody tr[data-kind="contribution"].status-needs_review { background: #eef6e4; }

.register tbody tr[data-kind="expenditure"] { background: #fdf5f4; }
.register tbody tr[data-kind="expenditure"]:nth-child(even) { background: #faf0ef; }
.register tbody tr[data-kind="expenditure"]:hover { background: #f5e9e7; }
.register tbody tr[data-kind="expenditure"].status-needs_review { background: #f8eee8; }

.register tbody tr.over-limit {
  background: #fdecea;
  box-shadow: inset 3px 0 0 var(--error);
}
.register tbody tr.over-limit:hover {
  background: #f9d7d4;
}
.register tbody tr.over-limit.status-needs_review {
  background: #fdecea;
}
.over-limit-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  background: var(--error);
  border-radius: 4px;
  vertical-align: middle;
}

.register .name-cell {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}
.register .name-cell input {
  flex: 1;
  min-width: 0;
}
.over-limit-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.2rem;
  padding: 0 0.28rem;
  border-radius: 4px;
  background: var(--error);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}
.over-limit-mark:hover {
  filter: brightness(0.92);
}

.employer-mark {
  display: inline-flex;
  align-items: center;
  height: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #fde68a;
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
a.employer-mark:hover { filter: brightness(0.95); }

.employer-warnings p { margin: 0 0 0.35rem; }
.employer-warnings ul { margin: 0; padding-left: 1.1rem; }
.employer-warnings li { margin: 0.15rem 0; }

.donor-name-cell.has-donor-tip {
  position: relative;
  cursor: help;
}
.donor-name-cell.has-donor-tip input {
  cursor: help;
}
.donor-float-tip {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  padding: 0.6rem 0.75rem;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: none;
}
.donor-float-tip .donor-hover-row {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.donor-float-tip .donor-hover-row span {
  color: #94a3b8;
  font-family: var(--font, inherit);
}
.donor-float-tip .donor-hover-total {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}
.donor-float-tip .donor-hover-warn {
  margin-top: 0.4rem;
  color: #fecaca;
  font-weight: 600;
  font-size: 0.72rem;
}
.register tbody tr.status-excluded { background: var(--excluded); color: var(--muted); }

.register td .cell,
.register td input,
.register td select {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  margin: 0;
  padding: 0.42rem 0.55rem;
  font-size: 13px;
  min-height: 36px;
  box-shadow: none;
}

.register td input:focus,
.register td select:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-strong);
  background: #fff;
  position: relative;
  z-index: 1;
  border-radius: 0;
}

.register td input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.register .col-id { width: 56px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.register .col-date { width: 138px; }
.register .col-date input[type="date"] {
  font-family: var(--mono);
  font-size: 12px;
  min-width: 0;
}
.register .col-date input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.55;
  margin-left: 0;
}
.register .col-date input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
.register .col-amount {
  width: 110px;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  text-align: right;
}
.register .col-amount input { text-align: right; font-family: var(--mono); }
.register .col-status { width: 130px; }
.register .col-type { width: 140px; }
.register .col-actions {
  width: 72px;
  text-align: center;
  padding: 0.25rem 0.4rem;
  white-space: nowrap;
}
.register .col-actions form.inline { display: inline; margin: 0; }
.register .col-decide { width: 88px; text-align: center; }
.register .col-category { min-width: 200px; width: 240px; }
.register .col-place { min-width: 200px; width: 240px; }
.register .cat-select {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.4rem;
  font-size: 0.78rem;
  border: none;
  background: transparent;
  appearance: auto;
}
.register .cat-select:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-strong);
  background: #fff;
}

/* Row action links inside read-only register tables */
.register .col-actions > a,
.register td.col-actions > a {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-strong);
  border: 1px solid transparent;
  text-decoration: none;
}

.register .col-actions > a:hover,
.register td.col-actions > a:hover {
  background: var(--accent-soft);
  border-color: #cdddff;
  text-decoration: none;
}

/* ---------- P/G slider ---------- */

.pg-slider {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding: 0.28rem 0.45rem 0.34rem;
  min-width: 148px;
}
.pg-slider.has-donor-tip {
  cursor: help;
}
.pg-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  line-height: 1.2;
}
.pg-slider-labels .pg-p {
  color: color-mix(in srgb, var(--accent-strong) 55%, white);
  font-weight: 600;
}
.pg-slider-labels .pg-g {
  color: var(--accent-strong);
  font-weight: 600;
}
.pg-range,
.register td input.pg-range {
  --pg-p-track: color-mix(in srgb, var(--accent-strong) 42%, white);
  --pg-g-track: var(--accent-strong);
  width: 100%;
  margin: 0;
  height: 0.45rem;
  min-height: 0.45rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  padding: 0;
  background: linear-gradient(
    to right,
    var(--pg-p-track) 0%,
    var(--pg-p-track) var(--pg-pct, 50%),
    var(--pg-g-track) var(--pg-pct, 50%),
    var(--pg-g-track) 100%
  );
}
.pg-range::-webkit-slider-runnable-track {
  height: 0.45rem;
  border-radius: 999px;
  background: transparent;
}
.pg-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.85rem;
  height: 0.85rem;
  margin-top: -0.2rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-strong);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}
.pg-range::-moz-range-track {
  height: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--pg-p-track) 0%,
    var(--pg-p-track) var(--pg-pct, 50%),
    var(--pg-g-track) var(--pg-pct, 50%),
    var(--pg-g-track) 100%
  );
}
.pg-range::-moz-range-progress {
  background: transparent;
}
.pg-range::-moz-range-thumb {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-strong);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}
.pg-slider.saving { opacity: 0.55; pointer-events: none; }
.pg-slider.saved {
  outline: 2px solid var(--ok);
  outline-offset: -2px;
  border-radius: 4px;
}
.pg-leg-label { font-size: 0.8rem; }
.register .col-check { width: 40px; text-align: center; }

.register .decide-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}

.register .save-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

.register .decide {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem;
}

.register .icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.register .icon-btn.split {
  width: auto;
  min-width: 30px;
  padding: 0 0.35rem;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.register .icon-btn.split:hover {
  color: var(--ink);
  background: var(--row-hover);
  border-color: var(--line-strong);
}

.register .icon-btn.ok { color: var(--ok); }
.register .icon-btn.no { color: var(--error); }

.register .icon-btn.ok:hover,
.register .icon-btn.ok.active {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  filter: none;
}

.register .icon-btn.no:hover,
.register .icon-btn.no.active {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
  filter: none;
}

.amount-pos { color: var(--ok); }
.amount-neg { color: var(--error); }

/* ---------- Plain tables & lists ---------- */

.table-plain {
  width: 100%;
  border-collapse: collapse;
}

.table-plain th,
.table-plain td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.table-plain tr:last-child td { border-bottom: none; }

.table-plain th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 700;
}

.table-plain tbody tr:hover { background: var(--row-alt); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.list.compact li { padding: 0.3rem 0; }

.stack-form {
  display: grid;
  gap: 0.15rem;
  max-width: 520px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 0.85rem;
}

.code {
  background: #0f172a;
  color: #e6edf3;
  padding: 0.9rem 1rem;
  overflow: auto;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
}

.mt { margin-top: 0.85rem; }
.narrow { max-width: 560px; }

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.9rem;
}

.mono-note {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: -0.01em;
}

.crumb {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent-strong); }

/* ---------- Place / expense category cells ---------- */

.expense-cat-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem;
}

.expense-cat-wrap > select {
  flex: 1;
  min-width: 0;
}

.place-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem;
}

.place-fields {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.register td .place-fields input {
  width: auto;
  min-height: 34px;
}

.register td .place-fields input[name="field_city"] {
  flex: 1;
  width: 0;
  min-width: 4rem;
}

.register td .place-fields input.place-state {
  flex: none;
  width: 3rem;
  padding-left: 0.3rem;
  padding-right: 0.3rem;
  text-transform: uppercase;
}

/* ---------- Vendor suggest dropdown ---------- */

.suggest-pop {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
}

.suggest-pop.is-empty .suggest-bolt {
  visibility: hidden;
  pointer-events: none;
}

.suggest-pop .suggest-menu {
  display: none;
}

button.suggest-bolt {
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-strong);
  box-shadow: none;
  filter: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

button.suggest-bolt:hover,
button.suggest-bolt[aria-expanded="true"] {
  filter: none;
  background: var(--accent-soft);
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.suggest-pop.ambiguous button.suggest-bolt {
  color: var(--accent);
  border-color: #b7d4ff;
  background: var(--accent-soft);
}

.suggest-pop.ambiguous button.suggest-bolt:hover,
.suggest-pop.ambiguous button.suggest-bolt[aria-expanded="true"] {
  background: #e0edff;
  border-color: var(--accent);
  color: var(--accent);
}

.suggest-float {
  position: fixed;
  z-index: 80;
  min-width: 13.5rem;
  max-width: 22rem;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}

.suggest-float[hidden] {
  display: none;
}

button.suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  filter: none;
  padding: 0.42rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
}

button.suggest-item:hover {
  filter: none;
  background: var(--row-hover);
  color: var(--ink);
}

.suggest-item-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-item-code {
  font-weight: 700;
  font-family: var(--mono);
}

.suggest-item-pct {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

select.expense-cat.vendor-suggest-applied {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------- Jobs / misc ---------- */

.job-status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
}

.job-status dt { color: var(--muted); margin: 0; }
.job-status dd { margin: 0; font-family: var(--mono); }

.stack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  [hidden] { display: none !important; }
  body.nav-menu-open { overflow: hidden; }

  .app { flex-direction: column; }

  /* Sticky top bar + dropdown navigation */
  .sidebar {
    width: 100%;
    height: auto;
    min-height: 56px;
    position: sticky;
    top: 0;
    z-index: 80;
    overflow: visible;
    flex-direction: column;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 8px 22px rgba(12, 23, 38, 0.14);
  }

  .nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    position: relative;
    z-index: 3;
    height: 56px;
    padding: 0 0.55rem 0 0.75rem;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  }

  .sidebar .brand {
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.3rem 0.25rem;
  }
  .sidebar .brand-logo { width: 31px; height: 31px; }
  .sidebar .brand-wordmark { width: 98px; height: auto; }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: #fff;
    box-shadow: none;
    flex: none;
  }
  .nav-toggle:hover,
  .nav-toggle[aria-expanded="true"] {
    background: rgba(255,255,255,0.11);
    filter: none;
  }
  .nav-toggle-lines {
    position: relative;
    display: block;
    width: 19px;
    height: 14px;
  }
  .nav-toggle-line {
    position: absolute;
    left: 0;
    width: 19px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.16s ease, opacity 0.16s ease, top 0.16s ease;
  }
  .nav-toggle-line:nth-child(1) { top: 0; }
  .nav-toggle-line:nth-child(2) { top: 6px; }
  .nav-toggle-line:nth-child(3) { top: 12px; }
  .sidebar.nav-open .nav-toggle-line:nth-child(1) { top: 6px; transform: rotate(45deg); }
  .sidebar.nav-open .nav-toggle-line:nth-child(2) { opacity: 0; }
  .sidebar.nav-open .nav-toggle-line:nth-child(3) { top: 6px; transform: rotate(-45deg); }

  .nav-menu {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 0.35rem 0 0.55rem;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 18px 36px rgba(12, 23, 38, 0.32);
    opacity: 0;
    transform: translateY(-7px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  }
  .sidebar.nav-open .nav-menu {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(12, 23, 38, 0.46);
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease;
  }
  .nav-backdrop:hover { background: rgba(12, 23, 38, 0.46); filter: none; }
  .sidebar.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar .env-pill { margin: 0.35rem 1rem 0.35rem; }
  .nav-section {
    flex-direction: column;
    align-items: stretch;
    padding: 0.1rem 0 0.5rem;
    gap: 2px;
  }
  .nav-label { display: block; padding: 0.3rem 1.1rem 0.35rem; }
  .committee-switch { padding: 0.1rem 0.85rem 0.65rem; max-width: none; }
  .committee-switch select { min-height: 44px; font-size: 1rem; }
  .nav-link {
    margin: 0 0.55rem;
    min-height: 44px;
    padding: 0.62rem 0.7rem;
    font-size: 0.95rem;
  }
  .sidebar-footer {
    margin-top: 0;
    padding: 0.45rem 0 0.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: block;
  }
  .sidebar-footer .nav-link { align-items: center; }
  .sidebar-footer .nav-link .nav-icon { margin-top: 0; }
  .sidebar form.inline button {
    width: calc(100% - 1.1rem);
    min-height: 44px;
    margin: 0 0.55rem;
    padding: 0.62rem 0.7rem;
  }

  /* Page headers and content spacing */
  .workspace-header { position: static; }
  .workspace-bar,
  .workspace-header .workspace-bar {
    position: relative;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.6rem 0.75rem;
    padding: 0.75rem 0.9rem;
  }
  .workspace-bar > div:first-child { min-width: 0; }
  .workspace-bar h1 {
    font-size: 1.18rem;
    overflow-wrap: anywhere;
  }
  .workspace-bar .crumb {
    font-size: 0.76rem;
    overflow-wrap: anywhere;
  }
  .workspace-bar .actions {
    flex: 1 1 100%;
    min-width: 0;
    justify-content: flex-start;
    gap: 0.45rem;
  }
  .workspace-bar .actions > input[type="search"] {
    flex: 1 1 100%;
    width: 100%;
  }
  .workspace-bar .actions .btn,
  .workspace-bar .actions button {
    min-height: 38px;
  }
  .workspace-bar .actions form.inline { margin: 0; }
  #ledger-row-count {
    position: absolute;
    top: 0.82rem;
    right: 0.9rem;
    font-size: 0.76rem;
    line-height: 1.2;
  }
  .ledger-search { width: 100%; }
  .donor-search-form { flex: 1 1 12rem; }
  .donor-search-form .ledger-search {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
  .ledger-tabs {
    padding: 0 0.55rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ledger-tab {
    min-height: 44px;
    padding: 0.55rem 0.85rem 0.65rem;
    white-space: nowrap;
  }
  .ledger-tab:hover,
  .ledger-tab.active:hover {
    background: transparent;
  }
  .workspace-main { padding: 0.9rem 0.85rem 2.25rem; }

  /* Ledger: editable rows become cards */
  .ledger-register-wrap {
    overflow: visible;
    max-height: none;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  #ledger-table {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 14px;
  }
  /* Keep the existing clickable headers as a compact horizontal sort bar;
     the rows beneath no longer use table columns. */
  #ledger-table thead {
    display: block;
    margin: 0 0 0.7rem;
  }
  #ledger-table thead tr {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0.05rem 0.2rem;
    scrollbar-width: none;
  }
  #ledger-table thead tr::-webkit-scrollbar { display: none; }
  #ledger-table thead th {
    position: static;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.34rem 0.62rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: none;
    font-size: 0.66rem;
  }
  #ledger-table thead th.sortable::after {
    float: none;
    margin-left: 0.25rem;
  }
  #ledger-table thead th.sort-asc,
  #ledger-table thead th.sort-desc {
    color: var(--accent-strong);
    border-color: color-mix(in srgb, var(--accent-strong) 42%, var(--line-strong));
    background: var(--accent-soft);
  }
  #ledger-table thead th.col-decide { display: none; }
  #ledger-table tbody { display: block; }
  #ledger-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.65rem;
    position: relative;
    margin: 0 0 0.9rem;
    padding: 0.85rem 0.85rem 0.7rem;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-left-color: transparent;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    white-space: normal;
  }
  #ledger-table tbody tr[hidden] { display: none !important; }
  #ledger-table tbody tr,
  #ledger-table tbody tr:nth-child(even) { background: var(--surface); }
  #ledger-table tbody tr[data-kind="contribution"],
  #ledger-table tbody tr[data-kind="contribution"]:nth-child(even) {
    background: var(--ok-soft);
    border-top-color: color-mix(in srgb, var(--ok) 22%, var(--line));
    border-right-color: color-mix(in srgb, var(--ok) 22%, var(--line));
    border-bottom-color: color-mix(in srgb, var(--ok) 22%, var(--line));
  }
  #ledger-table tbody tr[data-kind="expenditure"],
  #ledger-table tbody tr[data-kind="expenditure"]:nth-child(even) {
    background: color-mix(in srgb, var(--error-soft) 58%, var(--surface));
    border-top-color: color-mix(in srgb, var(--error) 18%, var(--line));
    border-right-color: color-mix(in srgb, var(--error) 18%, var(--line));
    border-bottom-color: color-mix(in srgb, var(--error) 18%, var(--line));
  }
  #ledger-table tbody tr.status-needs_review,
  #ledger-table tbody tr[data-kind="contribution"].status-needs_review,
  #ledger-table tbody tr[data-kind="expenditure"].status-needs_review {
    background: var(--review);
    border-left-color: var(--warn);
  }
  #ledger-table tbody tr.status-excluded,
  #ledger-table tbody tr[data-kind="contribution"].status-excluded,
  #ledger-table tbody tr[data-kind="expenditure"].status-excluded {
    background: var(--excluded);
    color: var(--muted);
    border-left-color: var(--muted);
  }
  #ledger-table tbody tr.over-limit,
  #ledger-table tbody tr.over-limit.status-needs_review {
    background: var(--error-soft);
    border-left-color: var(--error);
    border-top-color: color-mix(in srgb, var(--error) 32%, var(--line));
    border-right-color: color-mix(in srgb, var(--error) 32%, var(--line));
    border-bottom-color: color-mix(in srgb, var(--error) 32%, var(--line));
  }
  #ledger-table tbody tr.row-saved {
    outline: 2px solid color-mix(in srgb, var(--ok) 62%, transparent);
    outline-offset: 2px;
  }

  #ledger-table tbody td {
    display: block;
    width: auto;
    min-width: 0;
    margin: 0 0 0.58rem;
    padding: 0;
    border: none;
    white-space: normal;
    vertical-align: top;
  }
  #ledger-table tbody td::before {
    display: block;
    margin: 0 0 0.24rem;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.2;
    text-transform: uppercase;
  }
  #ledger-table tbody td.col-date::before { content: "Date"; }
  #ledger-table tbody td.donor-name-cell::before { content: "Name / payee"; }
  #ledger-table tbody td.col-amount::before { content: "Amount"; }
  #ledger-table tbody td.col-election::before { content: "Election"; }
  #ledger-table tbody td.col-category::before { content: "Category / type"; }
  #ledger-table tbody td.col-desc::before { content: "Description"; }
  #ledger-table tbody td.col-place::before { content: "City / state"; }
  #ledger-table tbody td.col-decide::before { content: none; }

  #ledger-table tbody td.donor-name-cell { order: 1; grid-column: 1 / -1; margin-bottom: 0.48rem; }
  #ledger-table tbody td.col-date { order: 2; }
  #ledger-table tbody td.col-amount { order: 3; }
  #ledger-table tbody td.col-election { order: 4; grid-column: 1 / -1; }
  #ledger-table tbody td.col-category { order: 5; grid-column: 1 / -1; }
  #ledger-table tbody td.col-desc { order: 6; grid-column: 1 / -1; }
  #ledger-table tbody td.col-place { order: 7; grid-column: 1 / -1; }
  #ledger-table tbody td.col-decide { order: 8; grid-column: 1 / -1; margin: 0.2rem 0 0; padding-top: 0.62rem; border-top: 1px solid var(--line); }
  .workspace[data-ledger-kind="expenditure"] #ledger-table .col-election { display: none !important; }

  #ledger-table tbody td input:not([type="range"]),
  #ledger-table tbody td select {
    width: 100% !important;
    min-height: 42px;
    margin: 0;
    padding: 0.52rem 0.65rem;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: none;
    color: var(--ink);
    font-size: 16px;
  }
  #ledger-table tbody td input:not([type="range"]):focus,
  #ledger-table tbody td select:focus {
    border-color: var(--accent-strong);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-ring);
    outline: none;
  }
  #ledger-table tbody td.donor-name-cell input {
    font-weight: 650;
  }
  #ledger-table tbody td.col-amount input {
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  #ledger-table tbody td .cell {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0.45rem 0.1rem;
    border: none;
    background: transparent;
    box-shadow: none;
  }
  #ledger-table .name-cell { align-items: center; }
  #ledger-table .over-limit-mark,
  #ledger-table .employer-mark {
    min-height: 1.45rem;
    align-items: center;
  }

  #ledger-table .expense-cat-wrap,
  #ledger-table .place-wrap {
    gap: 0.45rem;
    padding: 0;
  }
  #ledger-table .expense-cat-wrap > select,
  #ledger-table .place-fields {
    flex: 1 1 auto;
    min-width: 0;
  }
  #ledger-table .place-fields { gap: 0.45rem; }
  #ledger-table td .place-fields input {
    min-height: 42px;
  }
  #ledger-table td .place-fields input[name="field_city"] {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
  }
  #ledger-table td .place-fields input.place-state {
    flex: 0 0 4rem !important;
    width: 4rem !important;
    text-align: center;
  }
  #ledger-table .suggest-pop {
    width: 42px;
    min-width: 42px;
  }
  #ledger-table button.suggest-bolt {
    width: 42px;
    height: 42px;
    border-radius: 9px;
  }

  #ledger-table .pg-slider {
    width: 100%;
    min-width: 0;
    gap: 0.5rem;
    padding: 0.2rem 0 0.35rem;
  }
  #ledger-table .pg-slider-labels { font-size: 0.78rem; }
  #ledger-table .pg-range,
  #ledger-table td input.pg-range {
    height: 0.55rem;
    min-height: 0.55rem;
  }
  #ledger-table .pg-range::-webkit-slider-thumb {
    width: 1.2rem;
    height: 1.2rem;
    margin-top: -0.325rem;
  }
  #ledger-table .pg-range::-moz-range-thumb {
    width: 1.2rem;
    height: 1.2rem;
  }

  #ledger-table .decide-wrap {
    display: flex !important;
    width: 100%;
    justify-content: flex-end;
  }
  #ledger-table .decide {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    gap: 0.55rem;
    padding: 0;
  }
  #ledger-table .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 1.1rem;
  }
  #ledger-table .icon-btn.split {
    min-width: 42px;
    padding: 0 0.45rem;
  }

  #ledger-table tbody tr.ledger-empty {
    padding: 0;
    border-style: dashed;
    border-left-width: 1px;
    background: var(--surface);
    box-shadow: none;
  }
  #ledger-table tbody tr.ledger-empty td {
    grid-column: 1 / -1;
    margin: 0;
    padding: 0;
  }
  #ledger-table tbody tr.ledger-empty td::before { content: none; }
  #ledger-table tbody tr.ledger-empty .cell {
    padding: 1rem !important;
  }

  .suggest-float {
    max-width: calc(100vw - 16px);
    max-height: min(60vh, 24rem);
    overflow-y: auto;
  }

  /* Tables outside the ledger stay tabular and scroll inside their container */
  .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel-body.flush {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .panel > .table-plain { min-width: 560px; }
  .panel-body.flush .table-plain { min-width: 600px; }
  .register-wrap .table-plain { min-width: 480px; }
  .register-wrap .register[style*="min-width:0"] { min-width: 540px !important; }
  .panel .register-wrap,
  .workspace-main > .register-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: none;
  }
  .table-plain th,
  .table-plain td { padding: 0.55rem 0.7rem; }

  /* Chat, confirmation, forms, and auth fit narrow screens */
  .chat-layout { gap: 0.9rem; }
  .chat-log {
    padding: 0.85rem;
    max-height: calc(100vh - 300px);
  }
  .chat-msg { max-width: 94%; }
  .chat-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 0.6rem;
  }
  .chat-actions button { justify-content: center; }
  .chat-drop { padding: 1.1rem 0.8rem; text-align: center; }
  .chat-plan .panel { position: static; }
  .confirm-stat {
    flex: 1 1 8rem;
    min-width: 0;
  }
  .confirm-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.8rem;
  }
  .confirm-bar span { margin-right: 0; }
  .confirm-bar .btn,
  .confirm-bar button {
    width: 100%;
    justify-content: center;
  }

  /* Let inline code, badges, and links flow with warning text instead of
     becoming separate flex items that rearrange on narrow screens. */
  .error, .ok, .warn {
    display: block;
    line-height: 1.45;
  }
  code { overflow-wrap: anywhere; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-shell { padding: 1rem; }
  .auth-card {
    width: min(400px, 100%);
    padding: 1.35rem;
  }
}

@media (min-width: 560px) and (max-width: 900px) {
  .nav-menu {
    left: auto;
    width: min(27rem, 100%);
    border-bottom-left-radius: 14px;
  }
}

@media (max-width: 360px) {
  #ledger-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  #ledger-table tbody td { grid-column: 1 / -1; }
}

/* ---------- Office questionnaire ---------- */

.office-quiz { display: grid; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }
.office-quiz [hidden] { display: none !important; }

.quiz-q {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem 0.4rem;
  margin: 0;
  background: var(--surface);
}

.quiz-q legend {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  padding: 0 0.3rem;
}

.quiz-help { font-size: 0.82rem; margin: 0.1rem 0 0.4rem; }

.quiz-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.15rem 0;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.quiz-opt:hover { background: var(--row-hover); }

.quiz-opt input {
  width: auto;
  margin: 0.2rem 0 0;
  flex: none;
  box-shadow: none;
}

.quiz-label { display: block; }
.quiz-hint { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); }

.quiz-result, .quiz-confirm, .quiz-stop { margin: 0; }
.quiz-confirm .quiz-opt { margin: 0; padding: 0; color: inherit; }
.quiz-confirm .quiz-opt:hover { background: none; }


.quiz-title { font-size: 1rem; margin: 0.9rem 0 0.1rem; }
.quiz-details { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.quiz-details summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }

/* Import chat */
.small { font-size: 0.82rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chat-intro { max-width: 46rem; margin-top: 0; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 1.25rem; align-items: start; }
.chat-layout.chat-solo { grid-template-columns: minmax(0, 62rem); }
@media (max-width: 1100px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-pane { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.chat-log {
  display: flex; flex-direction: column; gap: 0.85rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; max-height: calc(100vh - 330px); min-height: 260px; overflow-y: auto; box-shadow: var(--shadow-sm);
}
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg[hidden] { display: none; }
.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-assistant { align-self: flex-start; }
.chat-bubble { white-space: pre-wrap; line-height: 1.5; padding: 0.65rem 0.85rem; border-radius: 14px; overflow-wrap: anywhere; }
.chat-user .chat-bubble { background: var(--accent-strong); color: #fff; border-bottom-right-radius: 4px; }
.chat-assistant .chat-bubble { background: var(--row-alt); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-error .chat-bubble { background: var(--error-soft); border-color: #fecaca; color: var(--error); }
.chat-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; padding: 0 0.25rem; }
.chat-typing { color: var(--muted); font-style: italic; }
.chat-composer { display: flex; flex-direction: column; gap: 0.6rem; }
.chat-composer textarea { width: 100%; resize: vertical; font: inherit; }
.chat-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.chat-drop {
  display: flex; align-items: center; justify-content: center; position: relative;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 1.4rem 1rem;
  background: var(--row-alt); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.chat-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chat-drop:hover, .chat-drop.dragging { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.chat-drop.has-file { border-style: solid; border-color: var(--accent); color: var(--ink); font-weight: 600; }
.chat-plan .panel { position: sticky; top: 1rem; }
.chat-warnings { margin: 0.5rem 0; padding: 0.6rem 0.8rem 0.6rem 1.6rem; }
.chat-warnings li + li { margin-top: 0.2rem; }
.chat-sample { font-size: 0.85rem; width: 100%; }
.confirm-summary { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.confirm-stat {
  display: flex; flex-direction: column; gap: 0.1rem; min-width: 9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; box-shadow: var(--shadow-sm);
}
.confirm-num { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.confirm-review { background: var(--warn-soft); border-color: #fde68a; }
.confirm-mapping summary { cursor: pointer; list-style: none; }
.confirm-mapping summary::-webkit-details-marker { display: none; }
.confirm-mapping summary h2::after { content: " ▸"; color: var(--muted); }
.confirm-mapping[open] summary h2::after { content: " ▾"; }
.confirm-rows td { padding: 0.4rem 0.55rem; }
.confirm-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
  margin-top: 1rem; padding: 0.85rem 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.confirm-bar span { margin-right: auto; }
