/* =========================================================================
   Blocade — Civic Ledger design system
   Editorial-fintech: ink on warm paper, voter blue for action, and match gold
   for every 8:1 public-matching-funds moment. Loaded after the legacy layout
   layer so every Jinja screen inherits one coherent product language.
   ========================================================================= */

:root {
  /* Civic Ledger palette */
  --paper: #faf8f3;
  --surface: #ffffff;
  --surface-2: #f4f1e9;
  --surface-3: #eeeae0;
  --ink: #15151b;
  --ink-2: #54545f;
  --ink-3: #6e6d77;
  --line: #e7e2d6;
  --line-2: #d9d3c4;
  --blue: #2a45d4;
  --blue-press: #2138b8;
  --blue-soft: #eceefb;
  --blue-ink: #1b2c8a;
  --gold: #8a5b0f;
  --gold-bright: #e8a33d;
  --gold-soft: #fbf0d9;
  --gold-line: #ead3a0;

  /* Compatibility names used by the migrated Jinja templates */
  --accent: var(--blue);
  --accent-hover: var(--blue-press);
  --accent-active: #1a2f9d;
  --accent-soft: var(--blue-soft);
  --accent-contrast: #ffffff;
  --bg: var(--paper);
  --bg-elevated: var(--surface);
  --bg-subtle: var(--surface-2);
  --bg-inset: var(--surface-3);
  --sidebar-bg: color-mix(in srgb, var(--surface) 62%, var(--paper));
  --header-bg: color-mix(in srgb, var(--paper) 82%, transparent);
  --border: var(--line);
  --border-strong: var(--line-2);
  --text: var(--ink);
  --text-secondary: var(--ink-2);
  --text-tertiary: var(--ink-3);
  --text-on-accent: #ffffff;

  /* ---- Semantic ------------------------------------------------------- */
  --success: #166b45; --success-soft: #e4f3eb;
  --warning: #86560e; --warning-soft: #fbf0da;
  --danger: #a4332c; --danger-soft: #fbe9e7;
  --info: var(--blue); --info-soft: var(--blue-soft);

  /* ---- Radii ---------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  /* ---- Shadows -------------------------------------------------------- */
  --shadow-xs: 0 1px 2px rgba(20, 20, 27, 0.05), 0 1px 1px rgba(20, 20, 27, 0.04);
  --shadow-sm: 0 4px 16px rgba(20, 20, 27, 0.07), 0 1px 3px rgba(20, 20, 27, 0.05);
  --shadow-md: 0 10px 28px rgba(20, 20, 27, 0.1), 0 2px 6px rgba(20, 20, 27, 0.05);
  --shadow-lg: 0 18px 48px rgba(20, 20, 27, 0.14), 0 6px 14px rgba(20, 20, 27, 0.08);
  --shadow-focus: 0 0 0 3px var(--accent-soft);

  /* ---- Type ----------------------------------------------------------- */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;

  /* ---- Layout --------------------------------------------------------- */
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 74px;
  --sidebar-width: var(--sidebar-w);
  --sidebar-collapsed-width: var(--sidebar-w-collapsed);
  --header-h: 60px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --speed: 180ms;
}

[data-theme="dark"] {
  --paper: #0c0c12;
  --surface: #15151d;
  --surface-2: #1c1c26;
  --surface-3: #23232e;
  --ink: #eceae2;
  --ink-2: #b8b6c0;
  --ink-3: #96949f;
  --line: #2d2d38;
  --line-2: #41414d;
  --blue: #8e9cff;
  --blue-press: #a4afff;
  --blue-soft: #1a1e36;
  --blue-ink: #c3cbff;
  --gold: #f0b662;
  --gold-bright: #f0b048;
  --gold-soft: #2b2114;
  --gold-line: #594521;
  --accent: var(--blue);
  --accent-hover: var(--blue-press);
  --accent-active: #b7c0ff;
  --accent-soft: var(--blue-soft);
  --accent-contrast: #ffffff;
  --bg: var(--paper);
  --bg-elevated: var(--surface);
  --bg-subtle: var(--surface-2);
  --bg-inset: var(--surface-3);
  --sidebar-bg: var(--surface);
  --header-bg: color-mix(in srgb, var(--paper) 82%, transparent);
  --border: var(--line);
  --border-strong: var(--line-2);
  --text: var(--ink);
  --text-secondary: var(--ink-2);
  --text-tertiary: var(--ink-3);
  --success: #55ca91; --success-soft: #12281d;
  --warning: #f2b24d; --warning-soft: #2a2012;
  --danger: #f0837a; --danger-soft: #2b1513;
  --info: var(--blue); --info-soft: var(--blue-soft);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-focus: 0 0 0 3px rgba(124, 124, 240, 0.25);
}

/* =========================================================================
   Base
   ========================================================================= */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.006em;
}
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
a { color: var(--accent); text-decoration: none; transition: color var(--speed) var(--ease); }
a:hover { color: var(--accent-hover); }
.text-muted { color: var(--text-tertiary) !important; }
.text-primary { color: var(--accent) !important; }
hr { border-color: var(--border); opacity: 1; }
code, pre { font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace; }

::selection { background: var(--accent-soft); color: var(--text); }

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); background-clip: padding-box; }

/* =========================================================================
   App shell — sidebar / header / content
   ========================================================================= */
.layout-wrapper { background: var(--bg); }

.sidebar {
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--border);
  width: var(--sidebar-w);
}
.sidebar .sidebar-header { border-bottom: 1px solid var(--border); }
.sidebar-toggle {
  color: var(--text-tertiary); background: transparent; border: none;
  border-radius: var(--radius-sm); width: 28px; height: 28px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.sidebar-toggle:hover { background: var(--bg-subtle); color: var(--text); }

.sidebar .nav-section-header {
  color: var(--text-tertiary);
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 16px 16px 6px;
}
.sidebar .nav-link {
  color: var(--text-secondary) !important;
  border-radius: var(--radius-sm);
  margin: 1px 8px; padding: 7px 10px;
  font-size: var(--fs-base); font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.sidebar .nav-link i { width: 18px; text-align: center; font-size: 0.95rem; color: var(--text-tertiary); transition: color var(--speed) var(--ease); }
.sidebar .nav-link:hover { background: var(--bg-subtle); color: var(--text) !important; }
.sidebar .nav-link:hover i { color: var(--text-secondary); }
.sidebar .nav-link.active {
  background: var(--accent-soft); color: var(--accent) !important; font-weight: 600;
}
.sidebar .nav-link.active i { color: var(--accent); }
.sidebar .nav-dropdown-menu { background: transparent; }
.sidebar .nav-dropdown-item { font-size: var(--fs-sm); padding-left: 38px !important; }
.nav-badge {
  margin-left: auto; font-size: 0.625rem; font-weight: 600;
  background: var(--bg-inset); color: var(--text-tertiary);
  padding: 1px 7px; border-radius: var(--radius-pill);
}
.nav-link-disabled { opacity: 0.55; }

.main-content { background: var(--bg); }
.top-header {
  background: var(--header-bg) !important;
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  position: sticky; top: 0; z-index: 1020;
}
.top-header .text-muted { font-weight: 500; }

.user-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), #8a5bd6);
  color: #fff; font-size: var(--fs-sm); font-weight: 600;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-xs);
}

/* Theme toggle button */
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); width: 34px; height: 34px;
  border-radius: var(--radius-sm); display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--speed) var(--ease);
}
.theme-toggle:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
[data-theme="dark"] .theme-toggle .fa-sun  { display: inline; }
.theme-toggle .fa-sun { display: none; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  font-weight: 550; font-size: var(--fs-base);
  border-radius: var(--radius-sm); padding: 6px 13px;
  border: 1px solid transparent;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease), color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.btn:active { transform: translateY(0.5px); }
.btn:focus, .btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn-sm { padding: 4px 10px; font-size: var(--fs-sm); border-radius: var(--radius-xs); }
.btn-lg { padding: 9px 18px; font-size: var(--fs-md); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:active { background: var(--accent-active); }

.btn-secondary, .btn-outline-secondary {
  background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text);
}
.btn-secondary:hover, .btn-outline-secondary:hover { background: var(--bg-subtle); border-color: var(--border-strong); color: var(--text); }

.btn-outline-primary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline-primary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger  { background: var(--danger);  border-color: var(--danger); }
.btn-light   { background: var(--bg-subtle); border-color: var(--border); color: var(--text); }
.btn-link    { color: var(--accent); }

/* =========================================================================
   Cards / panels
   ========================================================================= */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  font-weight: 600; padding: 14px 18px; color: var(--text);
}
.card-body { padding: 18px; }
.card-footer { background: transparent; border-top: 1px solid var(--border); }

/* =========================================================================
   Tables — dense, crisp, sticky header
   ========================================================================= */
.table {
  color: var(--text); font-size: var(--fs-base);
  border-color: var(--border); margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: 10px 14px; background: transparent; border-bottom-color: var(--border); }
.table thead th {
  color: var(--text-tertiary); font-weight: 600; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--bg-elevated); z-index: 1;
}
.table tbody tr { transition: background var(--speed) var(--ease); }
.table-hover tbody tr:hover, .table tbody tr:hover { background: var(--bg-subtle); }
.table td { vertical-align: middle; }
.table a { color: var(--text); font-weight: 550; }
.table a:hover { color: var(--accent); }

/* A wrapper to give tables the card treatment */
.table-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs);
}
.table-card .table { margin-bottom: 0; }

/* =========================================================================
   Forms
   ========================================================================= */
.form-control, .form-select, .input-group-text {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text); font-size: var(--fs-base);
  border-radius: var(--radius-sm); padding: 7px 11px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.form-control::placeholder { color: var(--text-tertiary); }
.form-control:focus, .form-select:focus {
  background: var(--bg-elevated); border-color: var(--accent);
  box-shadow: var(--shadow-focus); color: var(--text);
}
.form-label { font-size: var(--fs-sm); font-weight: 550; color: var(--text-secondary); margin-bottom: 5px; }
.form-text { color: var(--text-tertiary); font-size: var(--fs-xs); }
.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--shadow-focus); border-color: var(--accent); }
.input-group-text { background: var(--bg-subtle); color: var(--text-tertiary); }

/* =========================================================================
   Badges / chips
   ========================================================================= */
.badge {
  font-weight: 600; font-size: var(--fs-xs); letter-spacing: 0.01em;
  padding: 3px 9px; border-radius: var(--radius-pill);
}
.badge.bg-success, .bg-success { background: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-secondary, .bg-secondary { background: var(--bg-inset) !important; color: var(--text-secondary) !important; }
.badge.bg-primary, .bg-primary { background: var(--accent-soft) !important; color: var(--accent) !important; }
.badge.bg-warning, .bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-danger, .bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-info, .bg-info { background: var(--info-soft) !important; color: var(--info) !important; }

/* =========================================================================
   Dropdowns / modals / alerts
   ========================================================================= */
.dropdown-menu {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 5px; font-size: var(--fs-base);
}
.dropdown-item { color: var(--text); border-radius: var(--radius-sm); padding: 7px 10px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-subtle); color: var(--text); }
.dropdown-header { color: var(--text-tertiary); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.dropdown-divider { border-color: var(--border); }

.modal-content { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); }

.alert { border-radius: var(--radius); border: 1px solid var(--border); font-size: var(--fs-base); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: transparent; }

/* =========================================================================
   Pagination
   ========================================================================= */
.page-link { color: var(--text-secondary); border-color: var(--border); background: var(--bg-elevated); border-radius: var(--radius-sm) !important; margin: 0 2px; font-size: var(--fs-sm); }
.page-link:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--border-strong); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-item.disabled .page-link { color: var(--text-tertiary); background: var(--bg); }

/* =========================================================================
   Footer / misc
   ========================================================================= */
footer.bg-light { background: transparent !important; border-top: 1px solid var(--border); margin-top: 48px !important; }
.bg-light { background: var(--bg-subtle) !important; }
.bg-white { background: var(--bg-elevated) !important; }
.border { border-color: var(--border) !important; }

/* Reusable utility components ------------------------------------------- */
.ds-page-title { font-size: var(--fs-2xl); font-weight: 680; letter-spacing: -0.02em; margin: 0; }
.ds-page-subtitle { color: var(--text-tertiary); font-size: var(--fs-md); margin-top: 2px; }
.ds-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ds-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 600; }

/* Stat card for dashboards */
.stat-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-xs); }
.stat-card .stat-label { color: var(--text-tertiary); font-size: var(--fs-sm); font-weight: 550; display: flex; align-items: center; gap: 8px; }
.stat-card .stat-value { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; line-height: 1.1; }
.stat-card .stat-trend { font-size: var(--fs-xs); font-weight: 600; margin-top: 6px; }
.stat-trend.up { color: var(--success); } .stat-trend.down { color: var(--danger); }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 1rem; }

/* Empty state */
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-tertiary); }
.empty-state .empty-icon { font-size: 2rem; color: var(--text-tertiary); opacity: 0.6; margin-bottom: 12px; }
.empty-state h3 { color: var(--text-secondary); font-size: var(--fs-lg); }

/* =========================================================================
   Command palette (⌘K)
   ========================================================================= */
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  color: var(--text-tertiary); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: var(--fs-sm); cursor: pointer; min-width: 220px;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.cmdk-trigger:hover { border-color: var(--border-strong); background: var(--bg-inset); }
.cmdk-trigger .cmdk-trigger-text { flex: 1; text-align: left; }
.cmdk-kbd, kbd.cmdk-kbd {
  font-family: var(--font-sans); font-size: 0.6875rem; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 1px 6px; color: var(--text-tertiary);
  box-shadow: var(--shadow-xs);
}
@media (max-width: 720px) { .cmdk-trigger { min-width: 0; } .cmdk-trigger .cmdk-trigger-text, .cmdk-kbd { display: none; } }

.cmdk-overlay {
  position: fixed; inset: 0; z-index: 2000; display: none;
  background: rgba(10, 10, 14, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.cmdk-overlay.open { display: flex; animation: cmdk-fade var(--speed) var(--ease); }
@keyframes cmdk-fade { from { opacity: 0; } to { opacity: 1; } }
.cmdk-panel {
  width: 100%; max-width: 620px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: cmdk-pop var(--speed) var(--ease);
}
@keyframes cmdk-pop { from { transform: translateY(-8px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cmdk-input-row i { color: var(--text-tertiary); }
.cmdk-input { flex: 1; border: none; outline: none; background: transparent; color: var(--text); font-size: var(--fs-lg); }
.cmdk-input::placeholder { color: var(--text-tertiary); }
.cmdk-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-group-label { color: var(--text-tertiary); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px 4px; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.cmdk-item .cmdk-item-icon { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.cmdk-item .cmdk-item-sub { color: var(--text-tertiary); font-size: var(--fs-xs); }
.cmdk-item.active, .cmdk-item:hover { background: var(--accent-soft); }
.cmdk-item.active .cmdk-item-icon { background: var(--accent); color: #fff; }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-tertiary); font-size: var(--fs-sm); }
.cmdk-footer { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); color: var(--text-tertiary); font-size: var(--fs-xs); }
.cmdk-footer kbd { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 5px; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* =========================================================================
   Civic Ledger promotion layer
   ========================================================================= */
body {
  background-color: var(--paper);
  background-image: radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--blue) 6%, transparent), transparent 60%);
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, .ds-page-title, .page-title, .modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.num, .mono, .stat-value, .metric-value, [data-count],
.table td.text-end, .table th.text-end {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
}

code, pre, kbd { font-family: var(--font-mono); }
::selection { background: var(--gold-soft); color: var(--ink); }

.layout-wrapper { background: transparent; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--line);
  box-shadow: none;
  padding: 10px 9px;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-header {
  height: 52px;
  padding: 2px 5px 10px;
  border-bottom: 0 !important;
  gap: 6px;
}
.civic-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px;
  color: var(--ink);
  text-decoration: none;
}
.civic-brand:hover { color: var(--ink); }
.civic-brand img { width: 32px; height: 32px; flex: none; }
.civic-wordmark {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.civic-wordmark b { color: var(--gold); font-weight: 600; }
.sidebar.collapsed .civic-wordmark { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .civic-brand { padding: 0; }
.sidebar.collapsed .sidebar-toggle { display: inline-flex; width: 26px; height: 26px; padding: 5px; }

.sidebar-nav {
  height: calc(100vh - 62px);
  padding: 2px 0 18px;
}
.sidebar .nav-section-header {
  color: var(--ink-3);
  font-size: 0.65625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 13px 10px 5px;
}
.sidebar .nav-link {
  min-height: 38px;
  margin: 1px 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2) !important;
  gap: 10px;
}
.sidebar .nav-link i {
  width: 17px;
  font-size: 0.9rem;
  color: currentColor;
  opacity: 0.82;
}
.sidebar .nav-link-text { margin-left: 0; }
.sidebar .nav-link:hover { background: var(--surface-2); color: var(--ink) !important; }
.sidebar .nav-link.active {
  background: var(--blue-soft);
  color: var(--blue-ink) !important;
}
[data-theme="dark"] .sidebar .nav-link.active { color: var(--blue) !important; }
.sidebar .nav-link.active::before { display: none; }

.main-content {
  margin-left: var(--sidebar-w);
  background: transparent;
  min-width: 0;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-w-collapsed); }
.top-header {
  min-width: 0;
  height: var(--header-h);
  padding: 0 24px;
  justify-content: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg) !important;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.header-brand { display: none; }
.top-header > .ms-auto { min-width: 0; }
.top-header .cmdk-trigger {
  order: 1;
  flex: 1 1 420px;
  max-width: 540px;
  min-width: 240px;
  margin-left: 0 !important;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border-color: var(--line-2);
}
.top-header .cmdk-trigger > i { color: var(--gold); }  /* AA contrast on the light header (--gold-bright was ~2.1:1) */
.top-header .cmdk-trigger:hover {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
.top-header > .ms-auto { order: 2; margin-left: auto !important; }
.main-content > main {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 32px 80px !important;
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-press); border-color: var(--blue-press); }
.btn-gold {
  color: #211604;
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 6px 22px rgba(232, 163, 61, 0.28);
}
.btn-gold:hover { color: #211604; filter: brightness(1.04); }
.card, .table-card, .stat-card {
  border-color: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header { font-family: var(--font-display); font-size: var(--fs-lg); }
.table-responsive, .table-card { scrollbar-color: var(--line-2) transparent; }
.table thead th { letter-spacing: 0.065em; }

.eyebrow {
  color: var(--ink-3);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.match-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.match-card {
  background: linear-gradient(180deg, var(--gold-soft), var(--surface));
  border-color: var(--gold-line);
}
.match-text { color: var(--gold) !important; }
.civic-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.civic-page-head h1 { font-size: clamp(1.65rem, 3vw, 2.2rem); margin: 2px 0 0; }
.civic-page-head p { margin: 4px 0 0; color: var(--ink-2); }

.skip-link {
  position: fixed;
  z-index: 3000;
  left: 12px;
  top: 10px;
  transform: translateY(-150%);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
}
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 65%, white); outline-offset: 2px; }

@media (max-width: 991px) {
  .sidebar { width: 270px; max-width: 86vw; padding: 10px 9px; }
  .top-header { position: sticky; padding: 0 18px; }
  .header-brand { display: none; }
  .top-header .cmdk-trigger { flex-basis: auto; min-width: 38px; width: 38px; max-width: 38px; padding: 9px; }
  .top-header .cmdk-trigger .cmdk-trigger-text,
  .top-header .cmdk-trigger .cmdk-kbd { display: none; }
  .main-content > main { max-width: 100%; padding: 22px 20px 72px !important; }
}

@media (max-width: 640px) {
  .top-header { padding: 0 12px; gap: 8px; }
  .top-header .d-none.d-md-inline { display: none !important; }
  .top-header .dropdown.me-3 { margin-right: 0 !important; }
  .top-header .dropdown.me-3 > .btn { width: 38px; height: 38px; padding: 0; font-size: 0; }
  .top-header .dropdown.me-3 > .btn i { margin: 0 !important; font-size: 0.875rem; }
  .user-avatar { width: 34px; height: 34px; }
  .main-content > main { padding: 16px 14px 64px !important; }
  .civic-page-head { flex-direction: column; align-items: flex-start; }
  .card-body { padding: 15px; }
}

/* ── Topbar approvals bell (agent action-approval queue entry point) ───────── */
.approvals-bell {
  position: relative;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.approvals-bell:hover { background: var(--bg-subtle); color: var(--text); }
.approvals-bell-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; line-height: 1;
  color: #fff; background: var(--danger);
  border: 1.5px solid var(--bg-elevated); border-radius: 999px;
}
