/* ==============================================================================
   HassleFreeBooks — Global Stylesheet (app.css)
   ==============================================================================
   Chunk 29: UI Foundation v1

   Design Philosophy:
   - Simple, welcoming, modern
   - Professional without intimidation
   - Fun but not silly
   - Inviting but not flashy
   - NO "AI purple" accents

   Primary Accent: Teal / Sea-glass (#0d9488)
   Uses CSS variables from theme system (Chunk 28)
   ============================================================================== */

/* ==============================================================================
   ROOT VARIABLES (fallbacks + accent colors)
   ============================================================================== */
:root {
  /* Accent colors — friendly blue (matching design-tokens.css) */
  --accent-color: #1a6fb8;
  --accent-hover: #155b99;
  --accent-light: #e8f0fe;
  --accent-dark: #174ea6;

  /* Semantic colors */
  --success-color: #04825B;
  --success-bg: #d1fae5;
  --success-border: #a7f3d0;

  --warning-color: #A75B04;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;

  --danger-color: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fecaca;

  --info-color: #0284c7;
  --info-bg: #e0f2fe;
  --info-border: #bae6fd;

  /* Fallback theme vars — warm palette (matches design-tokens.css) */
  --bg-color: #faf9f7;
  --text-color: #37352f;
  --border-color: #e8e5e1;
  --card-bg: #ffffff;
  --muted-text: #787774;
  --link-color: #1a6fb8;
  --table-stripe-bg: rgba(0, 0, 0, 0.02);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);

  /* Chunk 31: Surface layers for visual depth */
  --surface-0: #f8fafc;  /* page background - soft off-white */
  --surface-1: #ffffff;  /* card level */
  --surface-2: #ffffff;  /* raised/elevated level */

  /* Chunk 31: Text hierarchy */
  --text-strong: #111827;
  --text-default: var(--text-color);
  --text-muted: var(--muted-text);

  /* Chunk 31: Subtle border */
  --border-subtle: rgba(0, 0, 0, 0.06);

  /* Chunk 209: Calm UI spacing scale (semantic aliases) */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2.5rem;    /* 40px */
  --space-2xl: 4rem;     /* 64px */

  /* Chunk 209: Readable content width */
  --content-max-width: 960px;

  /* Chunk 209: Calm transition */
  --transition-calm: 0.2s ease;
}

/* Dark theme accent adjustments — matches design-tokens.css dark theme */
body.theme-dark {
  --accent-color: #529cca;
  --accent-hover: #6db3df;
  --accent-light: #1a3148;
  --link-color: #529cca;

  --success-color: #34d399;
  --success-bg: #064e3b;
  --success-border: #065f46;

  --warning-color: #fbbf24;
  --warning-bg: #451a03;
  --warning-border: #78350f;

  --danger-color: #f87171;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;

  --info-color: #38bdf8;
  --info-bg: #082f49;
  --info-border: #0c4a6e;

  /* Chunk 31: Dark surface layers */
  --surface-0: #0f172a;  /* deep slate page background */
  --surface-1: #1e293b;  /* card level */
  --surface-2: #334155;  /* raised level */

  /* Chunk 31: Dark text hierarchy */
  --text-strong: #f1f5f9;

  /* Chunk 31: Dark subtle border */
  --border-subtle: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: dark) {
  body.theme-system {
    --accent-color: #529cca;
    --accent-hover: #6db3df;
    --accent-light: #1a3148;
    --link-color: #529cca;

    --success-color: #34d399;
    --success-bg: #064e3b;
    --success-border: #065f46;

    --warning-color: #fbbf24;
    --warning-bg: #451a03;
    --warning-border: #78350f;

    --danger-color: #f87171;
    --danger-bg: #450a0a;
    --danger-border: #7f1d1d;

    --info-color: #38bdf8;
    --info-bg: #082f49;
    --info-border: #0c4a6e;

    /* Chunk 31: System dark surface layers */
    --surface-0: #0f172a;
    --surface-1: #1e293b;
    --surface-2: #334155;
    --text-strong: #f1f5f9;
    --border-subtle: rgba(255, 255, 255, 0.06);
  }
}

/* ==============================================================================
   APP HEADER (App Shell)
   ==============================================================================
   Chunk 31: Visual Polish v1 - Minimal, classy top header bar

   Structure:
   - Left: Brand wordmark linked to /dashboard
   - Center: Active entity name pill (optional)
   - Right: User menu links (Settings, Logout)
   ============================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.625rem var(--space-4);
  gap: var(--space-4);
}

/* Left: Brand */
.app-header-left {
  flex-shrink: 0;
}

.app-header-brand {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--accent-color);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
}

.app-header-brand:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

/* Center: Entity pill */
.app-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.app-header-entity {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-text);
  background: var(--table-stripe-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

/* Chunk 55: Lock date badge in header */
.app-header-lock-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-full);
  text-decoration: none;
  white-space: nowrap;
}

.app-header-lock-badge:hover {
  background: #fde68a;
  color: #92400e;
  text-decoration: none;
}

/* Dark mode lock badge */
body.theme-dark .app-header-lock-badge {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
}

body.theme-dark .app-header-lock-badge:hover {
  background: rgba(251, 191, 36, 0.25);
  color: #fde68a;
}

/* Right: User menu links */
.app-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.app-header-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.app-header-link:hover {
  color: var(--accent-color);
  text-decoration: none;
}

/* App Header responsive adjustments */
@media (max-width: 640px) {
  .app-header-inner {
    padding: 0.5rem var(--space-3);
    gap: var(--space-2);
  }

  .app-header-brand {
    font-size: 0.9375rem;
  }

  .app-header-entity {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    max-width: 140px;
  }

  .app-header-link {
    font-size: 0.8125rem;
  }

  .app-header-right {
    gap: var(--space-2);
  }
}

@media (max-width: 420px) {
  /* Hide entity pill on tiny phones - it's in the page header anyway */
  .app-header-center {
    display: none;
  }

  .app-header-brand {
    font-size: 0.875rem;
  }

  .app-header-link {
    font-size: 0.75rem;
  }
}

/* ==============================================================================
   SURFACE TREATMENTS (Chunk 31 Design Tokens)
   ==============================================================================
   Subtle surface variations for visual depth and hierarchy.
   ============================================================================== */

/* Elevated surface - for cards that need prominence */
.surface-elevated {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Inset surface - for nested content areas */
.surface-inset {
  background: var(--table-stripe-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

/* Subtle surface - very light background distinction */
.surface-subtle {
  background: var(--table-stripe-bg);
  border-radius: var(--radius-md);
}

/* ==============================================================================
   BASE TYPOGRAPHY
   ============================================================================== */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  color: var(--text-color);
  /* Chunk 31: Use surface-0 for subtle off-white/deep-slate page background */
  background-color: var(--surface-0, var(--bg-color));
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-sm) 0;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-strong, var(--text-color));
}

h1 { font-size: 1.75rem; margin-bottom: var(--space-md); }
h2 { font-size: 1.375rem; margin-bottom: var(--space-md); }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p {
  margin: 0 0 var(--space-md) 0;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color var(--transition-calm, 0.15s ease);
}

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

/* Chunk 209: Accessible focus-visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ==============================================================================
   LAYOUT
   ============================================================================== */
/* Container — focused width, not edge-to-edge */
.container {
  max-width: var(--content-max-width, 960px);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
}

.page {
  min-height: 100vh;
}

/* Page header — friendly, not clinical */
.page-header {
  margin-bottom: 1.75rem;
  padding-top: 0.5rem;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--color-text, var(--text-color));
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--color-text-secondary, var(--muted-text));
  font-size: 0.9375rem;
  margin: 0;
  line-height: 1.5;
}

/* Section title — clean, no left border accent */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem 0;
  padding: 0;
  border-bottom: none;
  border-left: none;
  color: var(--color-text, var(--text-color));
  letter-spacing: -0.01em;
}

/* ==============================================================================
   CARDS
   ============================================================================== */
/* Cards — warm shadow, generous radius */
.card {
  background: var(--color-surface, var(--card-bg));
  border: 1px solid var(--color-border, var(--border-color));
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04), 0 1px 2px rgba(55, 53, 47, 0.02);
}

.card-header {
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle, rgba(0,0,0,0.06));
  color: var(--color-text, var(--text-color));
  letter-spacing: -0.01em;
}

.card-body {
  /* Default padding handled by .card */
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

/* Metric cards — dashboard widgets with warm styling */
.metric-card {
  background: var(--color-surface, var(--card-bg));
  border: 1px solid var(--color-border, var(--border-color));
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  transition: box-shadow 150ms ease, border-color 150ms ease;
  position: relative;
}

.metric-card:hover {
  box-shadow: 0 2px 8px rgba(55, 53, 47, 0.06);
}

.metric-card.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.metric-card.success {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.metric-card.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.metric-card.info {
  background: var(--info-bg);
  border-color: var(--info-border);
}

.metric-card.accent {
  background: var(--accent-light);
  border-color: var(--accent-color);
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.875rem;
  color: var(--muted-text);
  margin-top: var(--space-1);
}

.metric-link {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: 0.8125rem;
  color: var(--accent-color);
}

/* ==============================================================================
   BUTTONS
   ============================================================================== */
/* Buttons — compact, warm, no harsh shadows */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0 0.875rem;
  height: 34px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
  transition-duration: 50ms;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--color-primary, #1a6fb8);
  color: #ffffff;
  border-color: var(--color-primary, #1a6fb8);
  box-shadow: 0 1px 2px rgba(35, 131, 226, 0.2);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover, #155b99);
  border-color: var(--color-primary-hover, #155b99);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(35, 131, 226, 0.28);
}

.btn-secondary {
  background-color: var(--color-surface, #ffffff);
  color: var(--color-text, #37352f);
  border-color: var(--color-border, #e8e5e1);
  box-shadow: 0 1px 2px rgba(55, 53, 47, 0.04);
}

.btn-secondary:hover {
  background-color: var(--color-surface-hover, #f0eeeb);
  border-color: var(--color-border-strong, #d3d1cb);
}

.btn-success {
  background-color: var(--color-success, #0f7b6c);
  color: #ffffff;
  border-color: var(--color-success, #0f7b6c);
}

.btn-success:hover {
  opacity: 0.9;
  color: #ffffff;
}

.btn-danger {
  background-color: var(--color-danger, #e03e3e);
  color: #ffffff;
  border-color: var(--color-danger, #e03e3e);
}

.btn-danger:hover {
  opacity: 0.9;
  color: #ffffff;
}

.btn-accent {
  background-color: var(--color-primary, #1a6fb8);
  color: #ffffff;
  border-color: var(--accent-color);
}

.btn-accent:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

.btn-link {
  background: transparent;
  color: var(--link-color);
  border: none;
  padding: 0.25rem 0.5rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-group {
  display: inline-flex;
  gap: var(--space-2);
}

/* ==============================================================================
   FORMS
   ============================================================================== */
.form-row {
  margin-bottom: var(--space-4);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--space-1);
  color: var(--text-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

select {
  cursor: pointer;
}

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

.help-text {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.8125rem;
  color: var(--muted-text);
}

/* ==============================================================================
   TABLE COMPONENT SYSTEM
   ==============================================================================
   Chunk 33: Table Polish v1 - Calm, designed, trustworthy tables.

   Variants:
   - .table (base) — default styling for all tables
   - .table--calm — relaxed spacing, softer hover (default for most views)
   - .table--compact — denser rows for data-heavy views (bank, ledger)
   - .table--bordered — visible cell borders (legacy support)

   Modifiers:
   - .table__cell--primary — emphasized cell (description/name columns)
   - .table__cell--muted — de-emphasized cell (secondary info)
   - .table__cell--mono — monospace for dates, amounts, IDs
   - .table__cell--numeric — right-aligned numeric data
   - .table__cell--center — centered content (checkboxes, status)
   - .table__cell--actions — action buttons column
   ============================================================================== */

/* Base table styling */
/* Tables — clean, warm, modern. No zebra stripes, no ALL CAPS headers.
   Inspired by Linear/Notion table aesthetics. */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--color-surface, var(--card-bg));
}

/* Header cells */
.table th,
.table thead th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--color-text-secondary, var(--muted-text));
  border-bottom: 1px solid var(--color-border, var(--border-color));
  white-space: nowrap;
}

/* Body cells — generous padding, warm text */
.table td,
.table tbody td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border-subtle, rgba(0,0,0,0.06));
  color: var(--color-text, var(--text-color));
}

/* Remove border from last row */
.table tbody tr:last-child td {
  border-bottom: none;
}

/* Footer cells */
.table tfoot td,
.table tfoot th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-top: 1px solid var(--color-border, var(--border-color));
  background: transparent;
}

/* Row hover — subtle warm highlight */
.table tbody tr {
  transition: background-color 100ms ease;
}

.table tbody tr:hover {
  background-color: var(--color-surface-hover, rgba(0,0,0,0.02));
}

/* No alternating row stripes — they look clinical */

/* -----------------------------------------------------------------------------
   Table Variants
   ----------------------------------------------------------------------------- */

/* Calm variant — roomier padding */
.table--calm th,
.table--calm td {
  padding: 0.875rem 1rem;
}

/* Compact variant — denser for data-heavy views */
.table--compact th,
.table--compact td {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.table--compact th {
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
}

/* Bordered variant — legacy support */
.table--bordered,
.table-bordered {
  border: 1px solid var(--color-border, var(--border-color));
}

.table--bordered th,
.table--bordered td,
.table-bordered th,
.table-bordered td {
  border: 1px solid var(--color-border, var(--border-color));
}

/* Legacy .table-sm support */
.table-sm th,
.table-sm td {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

/* -----------------------------------------------------------------------------
   Cell Modifiers
   ----------------------------------------------------------------------------- */

/* Primary cell - emphasized (description, name columns) */
.table__cell--primary {
  font-weight: 500;
  color: var(--text-strong, var(--text-color));
}

/* Muted cell - de-emphasized (secondary info) */
.table__cell--muted {
  color: var(--muted-text);
  font-size: 0.8125rem;
}

/* Monospace cell - dates, amounts, IDs */
.table__cell--mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  letter-spacing: -0.02em;
}

/* Numeric cell - right-aligned */
.table__cell--numeric {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* Center cell - checkboxes, status badges */
.table__cell--center {
  text-align: center;
}

/* Actions cell — subtle pill-style links */
.table__cell--actions {
  text-align: right;
  white-space: nowrap;
  /* font-size: 0 hides bare text nodes (pipe separators "|") between links */
  font-size: 0;
}

.table__cell--actions a,
.table__cell--actions span,
.table__cell--actions button {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary, #1a6fb8);
  background: transparent;
  border-radius: 6px;
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease;
}

.table__cell--actions a:hover {
  background: var(--color-primary-bg, #e8f0fe);
  color: var(--color-primary-hover, #155b99);
}

/* Danger action links (Deactivate, Delete, Void) */
.table__cell--actions .text-danger,
.table__cell--actions .table__action--danger {
  color: var(--color-danger, #e03e3e);
}
.table__cell--actions .text-danger:hover,
.table__cell--actions .table__action--danger:hover {
  background: rgba(224, 62, 62, 0.08);
}

/* Success action links (Activate, Approve) */
.table__cell--actions .text-success,
.table__cell--actions .table__action--success {
  color: var(--color-success, #0f7b6c);
}
.table__cell--actions .text-success:hover,
.table__cell--actions .table__action--success:hover {
  background: rgba(15, 123, 108, 0.08);
}

/* Muted text/dash in action cells stays muted */
.table__cell--actions .text-muted {
  color: var(--color-text-muted, #767676);
  background: none;
  padding: 0;
}

/* Numeric header alignment */
th.table__cell--numeric {
  text-align: right;
}

/* -----------------------------------------------------------------------------
   Row State Modifiers
   ----------------------------------------------------------------------------- */

/* Muted row - for secondary/processed items */
.table__row--muted,
.table tbody tr.table__row--muted {
  opacity: 0.6;
  background-color: var(--table-stripe-bg);
}

.table__row--muted:hover {
  opacity: 0.8;
}

/* Success row - accepted/posted items */
.table__row--success,
.table tbody tr.table__row--success {
  background-color: var(--success-bg);
}

/* Warning row - pending attention */
.table__row--warning,
.table tbody tr.table__row--warning {
  background-color: var(--warning-bg);
}

/* Danger row - rejected/error items */
.table__row--danger,
.table tbody tr.table__row--danger {
  background-color: var(--danger-bg);
  opacity: 0.7;
}

/* Account header row - for grouped ledger views */
.table__row--header {
  background-color: var(--info-bg) !important;
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Empty State
   ----------------------------------------------------------------------------- */

.table__empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted-text);
  font-style: italic;
}

.table__empty td {
  border-bottom: none;
}

/* -----------------------------------------------------------------------------
   Amount Styling (positive/negative)
   ----------------------------------------------------------------------------- */

.amount--positive {
  color: var(--success-color);
}

.amount--negative {
  color: var(--danger-color);
}

/* -----------------------------------------------------------------------------
   Table Action Buttons (inline)
   ----------------------------------------------------------------------------- */

.table__action {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.table__action--primary {
  background: var(--accent-color);
  color: white;
}

.table__action--primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.table__action--success {
  background: var(--success-color);
  color: white;
}

.table__action--success:hover {
  opacity: 0.9;
  text-decoration: none;
}

.table__action--danger {
  background: var(--danger-color);
  color: white;
}

.table__action--danger:hover {
  opacity: 0.9;
  text-decoration: none;
}

.table__action--muted {
  background: var(--border-color);
  color: var(--muted-text);
}

/* -----------------------------------------------------------------------------
   Table Wrapper Enhancements
   ----------------------------------------------------------------------------- */

/* Table wrapper should match card surface */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle, var(--border-color));
  border-radius: var(--radius-md);
}

/* Remove double borders when table is in wrapper */
.table-wrap .table {
  border-radius: 0;
  margin-bottom: 0;
}

.table-wrap .table--bordered,
.table-wrap .table-bordered {
  border: none;
}

/* -----------------------------------------------------------------------------
   Pagination Component
   ----------------------------------------------------------------------------- */

.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1, var(--card-bg));
  border: 1px solid var(--border-subtle, var(--border-color));
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.table-pagination__info {
  color: var(--muted-text);
  font-size: 0.8125rem;
  margin: 0;
}

.table-pagination__links {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.table-pagination__btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-color);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.table-pagination__btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
  text-decoration: none;
}

.table-pagination__btn--active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.table-pagination__btn--disabled,
.table-pagination__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.table-pagination__btn--disabled:hover {
  background: var(--card-bg);
  border-color: var(--border-color);
  color: var(--text-color);
}

/* Pagination text separator */
.table-pagination__text {
  font-size: 0.8125rem;
  color: var(--muted-text);
  padding: 0 var(--space-2);
}

/* Responsive pagination */
@media (max-width: 640px) {
  .table-pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: var(--space-3);
  }

  .table-pagination__links {
    justify-content: center;
    flex-wrap: wrap;
  }

  .table-pagination__btn {
    padding: 0.5rem 0.625rem;
  }
}

/* ==============================================================================
   BADGES
   ============================================================================== */
/* Badges — pill-shaped, subtle by default */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-default {
  background-color: var(--color-surface-alt, var(--border-color));
  color: var(--color-text-secondary, var(--text-color));
}

.badge-success {
  background-color: var(--success-color);
  color: white;
}

.badge-warning {
  background-color: var(--warning-color);
  color: white;
}

.badge-danger {
  background-color: var(--danger-color);
  color: white;
}

.badge-info {
  background-color: var(--info-color);
  color: white;
}

.badge-muted {
  background-color: var(--muted-text);
  color: white;
}

.badge-accent {
  background-color: var(--accent-color);
  color: white;
}

/* Softer badge variants */
.badge-success-soft {
  background-color: var(--success-bg);
  color: var(--success-color);
}

.badge-warning-soft {
  background-color: var(--warning-bg);
  color: var(--warning-color);
}

.badge-danger-soft {
  background-color: var(--danger-bg);
  color: var(--danger-color);
}

.badge-info-soft {
  background-color: var(--info-bg);
  color: var(--info-color);
}

/* Chunk 100: BEM-style badge variants for Plaid connection health */
.badge--success {
  background-color: var(--success-color);
  color: white;
}

.badge--warning {
  background-color: var(--warning-color);
  color: white;
}

.badge--danger {
  background-color: var(--danger-color);
  color: white;
}

.badge--secondary {
  background-color: var(--border-color);
  color: var(--text-color);
}

.badge--info {
  background-color: var(--info-color);
  color: white;
}

/* ==============================================================================
   MESSAGES + INFO BOXES
   ==============================================================================
   Chunk 34: Unified alert and info box system for consistent messaging.

   Alert Variants:
   - .alert (base) — default styling
   - .alert--success — positive outcomes, confirmations
   - .alert--warning — caution states, attention needed
   - .alert--danger — errors, destructive states
   - .alert--info — informational, neutral emphasis

   Info Box:
   - .info-box — neutral callout for supplementary information
   ============================================================================== */

/* Base alert styling */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.alert strong {
  font-weight: 600;
}

.alert p {
  margin: 0;
}

.alert p + p {
  margin-top: var(--space-2);
}

/* Alert variants (BEM modifiers) */
.alert--success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-color);
}

.alert--warning {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-color);
}

.alert--danger {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-color);
}

.alert--info {
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-color);
}

.alert--accent {
  background-color: var(--accent-light);
  border: 1px solid var(--accent-color);
  color: var(--accent-dark);
}

/* Legacy alert classes (backwards compatibility) */
.alert-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-color);
}

.alert-warning {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-color);
}

.alert-danger,
.alert-error {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-color);
}

.alert-info {
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-color);
}

.alert-accent {
  background-color: var(--accent-light);
  border: 1px solid var(--accent-color);
  color: var(--accent-dark);
}

/* Info Box - neutral informational callout */
.info-box {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1, var(--table-stripe-bg));
  border: 1px solid var(--border-subtle, var(--border-color));
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 0.9375rem;
  color: var(--text-color);
}

.info-box--highlight {
  background: var(--info-bg);
  border-color: var(--info-border);
}

.info-box p {
  margin: 0;
}

.info-box p + p {
  margin-top: var(--space-2);
}

/* Inline info box for displaying key details */
.info-box--inline {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

/* Summary box - for totals/summary sections at end of reports */
.summary-box {
  padding: var(--space-4);
  background: var(--surface-1, var(--table-stripe-bg));
  border: 2px solid var(--text-color);
  border-radius: var(--radius-md);
  margin-top: var(--space-5);
  max-width: 400px;
}

.summary-box h4 {
  margin: 0 0 var(--space-3) 0;
  font-size: 1rem;
}

.summary-box table {
  width: 100%;
}

.summary-box td {
  padding: var(--space-1) 0;
}

.summary-box td:last-child {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.summary-box__total {
  border-top: 2px solid var(--text-color);
  font-weight: 600;
}

.summary-box__total td {
  padding-top: var(--space-2);
}

/* ==============================================================================
   FIELD VALIDATION + FORM HELPERS
   ==============================================================================
   Chunk 34: Field validation states and helper text styling.
   ============================================================================== */

/* Error state for form fields */
.field-error {
  border-color: var(--danger-color) !important;
}

.field-error:focus {
  box-shadow: 0 0 0 3px var(--danger-bg) !important;
}

/* Error message below field */
.field-error-message {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.8125rem;
  color: var(--danger-color);
}

/* Hint text below field */
.field-hint {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.8125rem;
  color: var(--muted-text);
}

/* Required field indicator */
.field-required::after {
  content: " *";
  color: var(--danger-color);
}

/* ==============================================================================
   CHUNK 40.8: Inline Form Validation
   ==============================================================================
   Inline error display for form fields with focus management.
   Classes: .is-invalid, .form-group--error, .field-error (as message)
   ============================================================================== */

/* Invalid input state - red border */
.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger-color) !important;
}

.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
  border-color: var(--danger-color) !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important;
  outline: none;
}

/* Form group error state - subtle highlight on container */
.form-group--error {
  position: relative;
}

.form-group--error label {
  color: var(--danger-color);
}

/* Inline field error message (displayed below field) */
.field-error {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.8125rem;
  color: var(--danger-color);
  line-height: 1.4;
}

/* Report filter form styling (for reports that haven't been converted to filter-bar) */
.report-filter {
  padding: var(--space-4);
  background: var(--surface-1, var(--card-bg));
  border: 1px solid var(--border-subtle, var(--border-color));
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}

.report-filter label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-right: var(--space-2);
}

.report-filter input[type="date"],
.report-filter input[type="text"],
.report-filter select {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
}

.report-filter button[type="submit"],
.report-filter .btn {
  margin-left: var(--space-3);
}

/* Report period header */
.report-period {
  font-weight: 600;
  color: var(--text-strong, var(--text-color));
  margin-bottom: var(--space-4);
}

/* Report note/disclaimer */
.report-note {
  margin-top: var(--space-5);
  font-size: 0.875rem;
  color: var(--muted-text);
  font-style: italic;
}

/* Balance indicator badges */
.balance-indicator {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.balance-indicator--balanced {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-color);
}

.balance-indicator--unbalanced {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-color);
}

/* Report section headers (Income, Expenses, Assets, etc.) */
.report-section-title {
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
  font-size: 1.125rem;
  font-weight: 600;
}

.report-section-title--income {
  color: var(--success-color);
}

.report-section-title--expense {
  color: var(--danger-color);
}

.report-section-title--asset {
  color: var(--info-color);
}

.report-section-title--liability {
  color: var(--warning-color);
}

.report-section-title--equity {
  color: #660099;
}

body.theme-dark .report-section-title--equity,
body.theme-system .report-section-title--equity {
  color: #b57edc;
}

@media (prefers-color-scheme: dark) {
  body.theme-system .report-section-title--equity {
    color: #b57edc;
  }
}

/* Net result display */
.net-result {
  padding: var(--space-4);
  background: var(--surface-1, var(--table-stripe-bg));
  border: 2px solid var(--text-color);
  border-radius: var(--radius-md);
  margin-top: var(--space-5);
}

.net-result h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.net-result__value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.net-result__value--positive {
  color: var(--success-color);
}

.net-result__value--negative {
  color: var(--danger-color);
}

.net-result p {
  margin: var(--space-2) 0 0 0;
  color: var(--muted-text);
  font-size: 0.875rem;
}

/* ==============================================================================
   QUICK LINKS / NAV CHIPS
   ==============================================================================
   Chunk 31: Enhanced with subtle shadow and better visual hierarchy
   Chunk 32: Upgraded to nav-chip pill buttons
   ============================================================================== */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1, var(--card-bg));
  border: 1px solid var(--border-subtle, var(--border-color));
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.quick-links-label {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted-text);
  margin-right: var(--space-2);
}

/* Nav Chip - pill button style for navigation links */
.nav-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-color);
  background: var(--table-stripe-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-chip:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
  text-decoration: none;
}

.nav-chip:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Active state - current page indicator */
.nav-chip--active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.nav-chip--active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

/* Primary variant - for important actions */
.nav-chip--primary {
  background: var(--accent-light);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.nav-chip--primary:hover {
  background: var(--accent-color);
  color: white;
}

/* Legacy support: plain links in quick-links still work */
.quick-links a:not(.nav-chip) {
  font-size: 0.875rem;
  color: var(--link-color);
}

/* Quick links responsive - chips wrap naturally */
@media (max-width: 640px) {
  .quick-links {
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .quick-links-label {
    width: 100%;
    margin-bottom: var(--space-1);
    margin-right: 0;
  }

  .nav-chip {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* ==============================================================================
   LIST ITEMS / REPORT LINKS
   ============================================================================== */
.list-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  padding: var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.list-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-color);
}

.list-item-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 0 0 var(--space-2) 0;
}

.list-item-title a {
  color: var(--text-color);
}

.list-item-title a:hover {
  color: var(--accent-color);
}

.list-item-desc {
  color: var(--muted-text);
  font-size: 0.875rem;
  margin: 0;
}

/* ==============================================================================
   EMPTY STATES
   ==============================================================================
   Chunk 31: Warm, directive empty state styling
   ============================================================================== */
/* Friendly empty states — inviting, not sad */
.empty-state {
  padding: 2.5rem 1.5rem;
  background: var(--color-surface, var(--card-bg));
  border: 2px dashed var(--color-border, var(--border-color));
  border-radius: 10px;
  text-align: center;
  color: var(--color-text-secondary, var(--muted-text));
}

.empty-state p {
  margin: 0;
}

.empty-state p + p {
  margin-top: var(--space-2);
}

.empty-state a {
  font-weight: 500;
}

/* ==============================================================================
   TWO COLUMN GRID
   ============================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ==============================================================================
   FILTER BAR COMPONENT
   ==============================================================================
   Chunk 32: Polished filter bar with BEM-style classes.
   Modern controls look, reduced visual noise.
   ============================================================================== */
/* Filter bar — clean card-like container */
.filter-bar {
  padding: 1rem 1.25rem;
  background: var(--color-surface, var(--card-bg));
  border: 1px solid var(--color-border, var(--border-color));
  border-radius: 10px;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04), 0 1px 2px rgba(55, 53, 47, 0.02);
}

.filter-bar__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: flex-end;
}

.filter-bar__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.filter-bar__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary, var(--muted-text));
}

.filter-bar__control {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text, var(--text-color));
  background: var(--color-surface, var(--card-bg));
  border: 1px solid var(--color-border, var(--border-color));
  border-radius: 6px;
  min-width: 120px;
  height: 36px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.filter-bar__control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.14);
}

.filter-bar__control--wide {
  min-width: 160px;
}

.filter-bar__control--narrow {
  min-width: 80px;
  width: 80px;
}

.filter-bar__checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--text-color);
  cursor: pointer;
}

.filter-bar__checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.filter-bar__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-left: auto;
}

.filter-bar__btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-bar__btn--submit {
  background: var(--accent-color);
  color: white;
  border: 1px solid var(--accent-color);
}

.filter-bar__btn--submit:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.filter-bar__btn--clear {
  background: transparent;
  color: var(--muted-text);
  border: 1px solid var(--border-color);
  text-decoration: none;
}

.filter-bar__btn--clear:hover {
  color: var(--text-color);
  border-color: var(--text-color);
  text-decoration: none;
}

/* Bulk action bar (sits below filter bar) */
.bulk-action-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.bulk-action-bar__label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--info-color);
}

.bulk-action-bar__select {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-color);
}

.bulk-action-bar__btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}

.bulk-action-bar__btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.bulk-action-bar__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bulk-action-bar__count {
  font-size: 0.875rem;
  color: var(--muted-text);
}

.bulk-action-bar__hint {
  font-size: 0.8125rem;
  color: var(--muted-text);
  margin-left: auto;
}

/* Filter bar responsive */
@media (max-width: 640px) {
  .filter-bar {
    padding: var(--space-3);
  }

  .filter-bar__row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .filter-bar__group {
    width: 100%;
  }

  .filter-bar__control {
    width: 100%;
    min-width: 100%;
  }

  .filter-bar__control--narrow {
    width: 100%;
    min-width: 100%;
  }

  .filter-bar__actions {
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
  }

  .filter-bar__btn {
    flex: 1;
    text-align: center;
  }

  .bulk-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .bulk-action-bar__hint {
    margin-left: 0;
    text-align: center;
  }
}

/* Legacy support: existing filter-bar form usage */
.filter-bar form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

.filter-bar .form-row {
  margin-bottom: 0;
}

.filter-bar label {
  font-size: 0.8125rem;
}

.filter-bar input,
.filter-bar select {
  min-width: 140px;
}

/* ==============================================================================
   PAGINATION
   ============================================================================== */
.pagination {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-4);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-color);
  background: var(--card-bg);
}

.pagination a:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
  text-decoration: none;
}

.pagination .active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==============================================================================
   UTILITY CLASSES
   ============================================================================== */

/* Spacing */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }

.mr-2 { margin-right: var(--space-2); }
.ml-2 { margin-left: var(--space-2); }

.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }

/* Flexbox */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

/* Text */
.text-muted { color: var(--muted-text); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-family: ui-monospace, "Courier New", monospace; }
.font-bold { font-weight: 600; }

/* Display */
.hidden { display: none; }

/* ==============================================================================
   MONOSPACE / CODE
   ============================================================================== */
.mono,
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
}

/* ==============================================================================
   AMOUNT STYLING
   ============================================================================== */
.amount {
  font-family: ui-monospace, "Courier New", monospace;
  font-weight: 500;
}

.amount-positive {
  color: var(--success-color);
}

.amount-negative {
  color: var(--danger-color);
}

/* ==============================================================================
   STATUS INDICATORS
   ============================================================================== */
.status-posted { color: var(--success-color); }
.status-pending { color: var(--warning-color); }
.status-active { color: var(--success-color); }
.status-inactive { color: var(--muted-text); }

/* ==============================================================================
   PAGINATION BAR
   ============================================================================== */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pagination-info {
  color: var(--muted-text);
  font-size: 0.875rem;
  margin: 0;
}

.pagination-links {
  display: flex;
  gap: var(--space-2);
}

/* ==============================================================================
   AUDIT LOG SPECIFIC
   ============================================================================== */
.audit-details-cell {
  padding: var(--space-4);
  background: var(--table-stripe-bg);
}

.audit-details-cell strong {
  display: block;
  margin-bottom: var(--space-2);
}

.audit-details-pre {
  margin: 0;
  padding: var(--space-3);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.8125rem;
  max-height: 300px;
  overflow-y: auto;
}

/* ==============================================================================
   FORM CONTAINER + FORM GROUPS
   ==============================================================================
   Chunk 35: Enhanced form styling for create/edit forms.
   ============================================================================== */
.form-container {
  max-width: 520px;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-top: 0.5rem;
}

/* Form group — label + input + hint */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text, var(--text-color));
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 400px;
}

.form-group--narrow input,
.form-group--narrow select {
  max-width: 100px;
}

.form-group--wide input,
.form-group--wide select {
  max-width: 600px;
}

/* Checkbox group - flex layout for checkbox + label */
.form-group--checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-group--checkbox label {
  margin-bottom: 0;
  font-weight: normal;
}

.form-group--checkbox input[type="checkbox"] {
  width: auto;
}

/* Action link next to button */
.form-actions .cancel-link {
  color: var(--muted-text);
  text-decoration: none;
}

.form-actions .cancel-link:hover {
  color: var(--text-color);
}

/* ==============================================================================
   CHUNK 36 HELPERS — Line Items + Dimension Grid
   ==============================================================================
   Dynamic line item tables (transactions, invoices, bills) and dimension grids.
   ============================================================================== */

/* Line item inputs in editable tables */
.line-select,
.line-input {
  width: 100%;
  padding: var(--space-1);
  font-size: 0.875rem;
}

.line-input--numeric {
  text-align: right;
  font-family: var(--font-mono);
}

/* Dimension grid for transaction tagging */
.dimension-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.dimension-item {
  min-width: 180px;
  flex: 1;
  max-width: 250px;
}

.dimension-item label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 0.875rem;
}

.dimension-item select {
  width: 100%;
  padding: var(--space-1);
}

/* Status badge colors for invoices/bills */
.status-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge--draft { background: var(--muted-bg); color: var(--muted-text); }
.status-badge--sent { background: #cce5ff; color: #004085; }
.status-badge--partial { background: #fff3cd; color: #856404; }
.status-badge--paid { background: #d4edda; color: #155724; }
.status-badge--overdue { background: #f8d7da; color: #721c24; }
.status-badge--void { background: var(--muted-bg); color: var(--muted-text); text-decoration: line-through; }

/* Summary totals box for invoices/bills */
.totals-box {
  background: var(--muted-bg);
  border: 1px solid var(--border-color);
  padding: var(--space-3);
  max-width: 300px;
  margin-top: var(--space-3);
}

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

.totals-box td {
  padding: var(--space-1) 0;
}

.totals-box td:last-child {
  text-align: right;
  font-family: var(--font-mono);
}

.totals-box .totals-row--grand {
  border-top: 2px solid var(--border-color);
  font-weight: 700;
}

/* Actions box for show pages */
.actions-box {
  background: var(--muted-bg);
  border: 1px solid var(--border-color);
  padding: var(--space-3);
  margin-top: var(--space-5);
}

.actions-box h4 {
  margin: 0 0 var(--space-2) 0;
}

/* Payment form inline */
.payment-form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-end;
}

.payment-form-inline label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: var(--space-1);
}

.payment-form-inline input {
  padding: var(--space-1);
}

/* Required field indicator */
.required-mark {
  color: var(--danger-color);
}

/* Invoice/Bill line row layout */
.invoice-line-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  padding: var(--space-2);
  background: var(--muted-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.invoice-line-desc { flex: 2; min-width: 200px; }
.invoice-line-qty { width: 80px; }
.invoice-line-price { width: 100px; }
.invoice-line-total { width: 100px; }
.invoice-line-account { flex: 1; min-width: 180px; }
.invoice-line-action { width: 40px; display: flex; align-items: center; justify-content: center; }

/* Reconcile summary box - prominent totals display for reconciliation */
.reconcile-summary-box {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--muted-bg);
  border: 2px solid var(--text-color);
  border-radius: var(--radius-md);
  max-width: 400px;
}

.reconcile-summary-box table {
  width: 100%;
  border-collapse: collapse;
}

.reconcile-summary-box td {
  padding: var(--space-2) 0;
}

.reconcile-summary-box__value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

.reconcile-summary-box__diff-row {
  border-top: 2px solid var(--muted-text);
}

.reconcile-summary-box__diff {
  font-size: 1.2rem;
  font-weight: bold;
}

/* Promotable card - AI suggestion to rule promotion */
.promo-card {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-color);
  background: var(--muted-bg);
  border-radius: var(--radius-md);
}

.promo-card__header {
  margin-bottom: var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.promo-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.promo-card__meta {
  color: var(--muted-text);
  font-size: 0.9rem;
}

.promo-card__form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: var(--space-3);
  align-items: end;
}

@media (max-width: 900px) {
  .promo-card__form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .promo-card__form-grid {
    grid-template-columns: 1fr;
  }
}

.promo-card__field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted-text);
  margin-bottom: var(--space-1);
}

.promo-card__field input,
.promo-card__field select {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.promo-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin: var(--space-2) 0 0 0;
}

/* ==============================================================================
   FOCUS STATES (Accessibility)
   ==============================================================================
   Chunk 31: Consistent focus rings for keyboard navigation
   ============================================================================== */

/* Default focus ring for interactive elements */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Remove default focus outline when not using keyboard */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
.btn:focus:not(:focus-visible) {
  outline: none;
}

/* App header links focus */
.app-header-link:focus-visible,
.app-header-brand:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Quick links focus */
.quick-links a:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Metric card link focus */
.metric-link:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Table row focus for interactive rows */
.table tbody tr:focus-within {
  background-color: var(--accent-light);
}

/* ==============================================================================
   TABLE WRAPPER (Mobile Horizontal Scroll)
   ==============================================================================
   Chunk 30: Contains table overflow on mobile, prevents page-level horizontal scroll
   ============================================================================== */
/* Table wrap — card-like container wrapping tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid var(--color-border, var(--border-color));
  background: var(--color-surface, var(--card-bg));
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04), 0 1px 2px rgba(55, 53, 47, 0.02);
}

.table-wrap .table {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
}

.table-wrap .table th:first-child,
.table-wrap .table td:first-child {
  border-left: none;
}

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

/* Sticky table headers inside scroll wrapper */
.table-wrap .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface, var(--card-bg));
}

/* ==============================================================================
   RESPONSIVE BREAKPOINTS
   ==============================================================================
   Chunk 30: Mobile-Responsive Polish v1

   Breakpoints:
   - <= 1200px: Soften multi-column grids
   - <= 900px:  2-col grids -> 1-col
   - <= 640px:  Primary mobile target
   - <= 420px:  Tiny phone tweaks
   ============================================================================== */

/* -----------------------------------------------------------------------------
   <= 1200px: Large tablet / small desktop
   ----------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* -----------------------------------------------------------------------------
   <= 900px: Tablet portrait
   ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .container {
    padding: var(--space-4) var(--space-3);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
  }

  /* Quick links: smaller pills */
  .quick-links {
    gap: var(--space-2) var(--space-3);
    padding: var(--space-3);
  }

  .quick-links a {
    font-size: 0.875rem;
  }
}

/* -----------------------------------------------------------------------------
   <= 640px: Primary mobile target
   ----------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Container: tighter padding */
  .container {
    padding: var(--space-3) var(--space-2);
  }

  /* Page header: stack title/subtitle, prevent overflow */
  .page-header {
    margin-bottom: var(--space-4);
  }

  .page-title {
    font-size: 1.5rem;
    word-wrap: break-word;
  }

  .page-subtitle {
    font-size: 0.875rem;
  }

  /* Section title: smaller */
  .section-title {
    font-size: 1rem;
  }

  /* Card grid: single column, full-width metric cards */
  .card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  /* Metric cards: full width, readable numbers */
  .metric-card {
    padding: var(--space-3);
  }

  .metric-value {
    font-size: 1.75rem;
  }

  .metric-label {
    font-size: 0.8125rem;
  }

  /* Cards: tighter padding */
  .card {
    padding: var(--space-3);
  }

  .card-header {
    font-size: 0.9375rem;
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-2);
  }

  /* Buttons: ensure tappable size, wrap nicely */
  .btn {
    min-height: 44px;
    padding: 0.625rem 1rem;
  }

  .btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
  }

  /* Button groups: wrap */
  .btn-group {
    flex-wrap: wrap;
  }

  /* Quick links: wrap into pills, ensure tappable */
  .quick-links {
    gap: var(--space-2);
    padding: var(--space-2);
  }

  .quick-links-label {
    width: 100%;
    margin-bottom: var(--space-1);
  }

  .quick-links a {
    font-size: 0.8125rem;
    padding: var(--space-2) var(--space-3);
    background: var(--table-stripe-bg);
    border-radius: var(--radius-full);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  /* Forms: full-width inputs */
  .form-input,
  .form-select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-group {
    margin-bottom: var(--space-3);
  }

  /* Form actions: stack vertically */
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .form-container {
    max-width: 100%;
  }

  /* Filter bar: wrap nicely */
  .filter-bar {
    padding: var(--space-3);
  }

  .filter-bar form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar input,
  .filter-bar select {
    width: 100%;
    min-width: 100%;
  }

  /* Tables: ensure text doesn't force wide layout */
  .table {
    font-size: 0.8125rem;
  }

  .table th,
  .table td {
    padding: var(--space-2);
  }

  .table-sm th,
  .table-sm td {
    padding: var(--space-1) var(--space-2);
  }

  /* Pagination bar: stack on mobile */
  .pagination-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .pagination-links {
    width: 100%;
    justify-content: space-between;
  }

  .pagination-links .btn {
    flex: 1;
    justify-content: center;
  }

  /* Alerts: tighter padding */
  .alert {
    padding: var(--space-3);
    font-size: 0.875rem;
  }

  /* Badges: slightly smaller */
  .badge {
    font-size: 0.6875rem;
    padding: 0.2em 0.5em;
  }

  /* List items: tighter */
  .list-item {
    padding: var(--space-3);
  }

  .list-item-title {
    font-size: 1rem;
  }

  .list-item-desc {
    font-size: 0.8125rem;
  }

  /* Audit details: ensure pre doesn't overflow */
  .audit-details-pre {
    font-size: 0.75rem;
    max-height: 200px;
  }

  /* Amount styling: ensure readable */
  .amount {
    font-size: 0.875rem;
  }

  /* Utility: hide on mobile */
  .hide-mobile {
    display: none !important;
  }
}

/* -----------------------------------------------------------------------------
   <= 420px: Tiny phone tweaks
   ----------------------------------------------------------------------------- */
@media (max-width: 420px) {
  .container {
    padding: var(--space-2);
  }

  .page-title {
    font-size: 1.25rem;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  /* Even tighter table text */
  .table {
    font-size: 0.75rem;
  }

  .table th,
  .table td {
    padding: var(--space-1);
  }

  /* Quick links: even smaller */
  .quick-links a {
    font-size: 0.75rem;
    padding: var(--space-1) var(--space-2);
    min-height: 36px;
  }
}

/* ==============================================================================
   UTILITIES (v1)
   ==============================================================================
   Chunk 37: Small utility layer for common patterns.
   Use sparingly - prefer component classes where appropriate.
   ============================================================================== */

/* Typography utilities */
.u-font-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.u-tabular-nums {
  font-variant-numeric: tabular-nums;
}

.u-nowrap {
  white-space: nowrap;
}

.u-text-sm {
  font-size: 0.875rem;
}

/* Border utilities */
.u-border-top {
  border-top: 1px solid var(--border-color);
}

.u-border-bottom {
  border-bottom: 1px solid var(--border-color);
}

/* Display utilities */
.u-hidden {
  display: none;
}

/* Spacing utilities (supplement existing mt-*, mb-*, etc.) */
.u-pt-4 {
  padding-top: var(--space-4);
}

/* ==============================================================================
   DARK MODE POLISH (v1)
   ==============================================================================
   Chunk 37: Enhanced dark mode contrast and "premium feel" adjustments.
   ============================================================================== */

/* Table header contrast improvement in dark mode */
body.theme-dark .table th,
body.theme-dark .table thead th {
  background-color: var(--surface-2);
  color: var(--text-strong);
}

body.theme-dark .table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .table th,
  body.theme-system .table thead th {
    background-color: var(--surface-2);
    color: var(--text-strong);
  }

  body.theme-system .table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.04);
  }
}

/* Table calm variant: improved hover in dark mode */
body.theme-dark .table--calm tbody tr:hover {
  background-color: var(--surface-2);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .table--calm tbody tr:hover {
    background-color: var(--surface-2);
  }
}

/* Badge adjustments for dark mode - slightly softer backgrounds */
body.theme-dark .badge-success,
body.theme-dark .badge-warning,
body.theme-dark .badge-danger,
body.theme-dark .badge-info {
  filter: brightness(0.9);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .badge-success,
  body.theme-system .badge-warning,
  body.theme-system .badge-danger,
  body.theme-system .badge-info {
    filter: brightness(0.9);
  }
}

/* Focus ring visibility in dark mode - brighter accent */
body.theme-dark a:focus-visible,
body.theme-dark button:focus-visible,
body.theme-dark .btn:focus-visible,
body.theme-dark input:focus-visible,
body.theme-dark select:focus-visible,
body.theme-dark textarea:focus-visible {
  outline-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2);
}

@media (prefers-color-scheme: dark) {
  body.theme-system a:focus-visible,
  body.theme-system button:focus-visible,
  body.theme-system .btn:focus-visible,
  body.theme-system input:focus-visible,
  body.theme-system select:focus-visible,
  body.theme-system textarea:focus-visible {
    outline-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.2);
  }
}

/* Button tactile feel - subtle shadow and active state */
.btn-primary,
.btn-success,
.btn-accent {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.06);
}

.btn-primary:active,
.btn-success:active,
.btn-accent:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}

/* Card shadow improvement in dark mode */
body.theme-dark .card,
body.theme-dark .info-box,
body.theme-dark .promo-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .card,
  body.theme-system .info-box,
  body.theme-system .promo-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  }
}

/* Alert text contrast improvement in dark mode */
body.theme-dark .alert--success {
  color: #d1fae5;
}

body.theme-dark .alert--warning {
  color: #fef3c7;
}

body.theme-dark .alert--danger {
  color: #fee2e2;
}

body.theme-dark .alert--info {
  color: #e0f2fe;
}

@media (prefers-color-scheme: dark) {
  body.theme-system .alert--success {
    color: #d1fae5;
  }

  body.theme-system .alert--warning {
    color: #fef3c7;
  }

  body.theme-system .alert--danger {
    color: #fee2e2;
  }

  body.theme-system .alert--info {
    color: #e0f2fe;
  }
}

/* Status badge improvements */
body.theme-dark .status-badge--draft {
  background-color: var(--surface-2);
  color: var(--text-muted);
}

body.theme-dark .status-badge--sent {
  background-color: #1e3a5f;
  color: #93c5fd;
}

body.theme-dark .status-badge--partial {
  background-color: #78350f;
  color: #fcd34d;
}

body.theme-dark .status-badge--paid {
  background-color: #064e3b;
  color: #6ee7b7;
}

@media (prefers-color-scheme: dark) {
  body.theme-system .status-badge--draft {
    background-color: var(--surface-2);
    color: var(--text-muted);
  }

  body.theme-system .status-badge--sent {
    background-color: #1e3a5f;
    color: #93c5fd;
  }

  body.theme-system .status-badge--partial {
    background-color: #78350f;
    color: #fcd34d;
  }

  body.theme-system .status-badge--paid {
    background-color: #064e3b;
    color: #6ee7b7;
  }
}

/* ==============================================================================
   LOADING STATES + SPINNER
   ==============================================================================
   Chunk 40.3: Double-submit prevention and loading feedback.

   Usage:
   - .btn--loading: Button in loading state (shows spinner)
   - .btn--disabled: Button visually disabled during action
   - .spinner: CSS-only loading spinner (inline)
   ============================================================================== */

/* Loading spinner - CSS-only, inline-flex for button placement */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-rotate 0.75s linear infinite;
  vertical-align: middle;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Spinner sizes */
.spinner--sm {
  width: 0.75em;
  height: 0.75em;
  border-width: 1.5px;
}

.spinner--lg {
  width: 1.5em;
  height: 1.5em;
  border-width: 3px;
}

/* Button loading state */
.btn--loading {
  position: relative;
  cursor: wait;
  pointer-events: none;
}

.btn--loading .spinner {
  margin-right: var(--space-2);
}

/* Button disabled state (visual, not :disabled) */
.btn--disabled {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* Bulk action bar loading state */
.bulk-action-bar__btn.btn--loading {
  min-width: 120px; /* Prevent button width from jumping */
}

/* Table action link loading state */
.table__action.btn--loading {
  min-width: 60px;
}

/* Centered spinner for page/section loading */
.spinner-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-5);
}

.spinner-center .spinner {
  width: 2rem;
  height: 2rem;
  border-width: 3px;
  color: var(--accent-color);
}

/* Overlay loading state for cards/sections */
.loading-overlay {
  position: relative;
}

.loading-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

body.theme-dark .loading-overlay::after {
  background: rgba(15, 23, 42, 0.7);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .loading-overlay::after {
    background: rgba(15, 23, 42, 0.7);
  }
}

/* ==============================================================================
   FRIENDLY EMPTY STATES
   ==============================================================================
   Chunk 40.4: Enhanced empty states for guided onboarding.

   Usage:
   - .empty-state--card: Card-style empty state with icon, title, text, actions
   - .empty-state__icon: SVG icon container
   - .empty-state__title: Main heading
   - .empty-state__text: Explanatory text
   - .empty-state__actions: Button container
   - .empty-state__hint: Small helpful tip
   ============================================================================== */

/* Card-style empty state */
.empty-state--card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 0.5rem);
  padding: var(--space-6, 1.5rem) var(--space-8, 2rem);
  text-align: center;
  max-width: 480px;
  margin: var(--space-6, 1.5rem) auto;
}

.empty-state__icon {
  color: var(--accent-color, #0E8477);
  margin-bottom: var(--space-4, 1rem);
}

.empty-state__icon svg {
  width: 48px;
  height: 48px;
}

.empty-state__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color, #1e293b);
  margin: 0 0 var(--space-3, 0.75rem) 0;
}

.empty-state__text {
  color: var(--text-muted, #64748b);
  margin: 0 0 var(--space-5, 1.25rem) 0;
  line-height: 1.6;
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 0.75rem);
  justify-content: center;
  margin-bottom: var(--space-4, 1rem);
}

.empty-state__hint {
  font-size: 0.875rem;
  color: var(--text-muted, #64748b);
  margin: 0;
  padding-top: var(--space-3, 0.75rem);
  border-top: 1px solid var(--border-color, #e2e8f0);
}

/* Chunk 40.7: Modifier for empty state inside info-box (no margin/max-width override) */
.empty-state--inline {
  margin: 0;
  max-width: none;
}

/* Chunk 40.7: Success-colored icon modifier */
.empty-state__icon--success {
  color: var(--color-success, #10b981);
}

/* Ghost button variant */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-color, #1e293b);
}

.btn-ghost:hover {
  background: var(--surface-hover, #f1f5f9);
  border-color: var(--border-color, #e2e8f0);
}

/* Getting Started panel (for dashboard) */
/* Getting started — warm welcome banner */
.getting-started {
  background: linear-gradient(135deg, var(--color-primary, #1a6fb8) 0%, var(--color-primary-hover, #155b99) 100%);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  color: #fff;
}

.getting-started__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 var(--space-4, 1rem) 0;
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
}

.getting-started__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3, 0.75rem);
}

.getting-started__step {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius, 0.375rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  display: flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  text-decoration: none;
  color: #fff;
  transition: background 0.15s;
}

.getting-started__step:hover {
  background: rgba(255, 255, 255, 0.25);
}

.getting-started__step-num {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.getting-started__step--done .getting-started__step-num {
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-color, #0E8477);
}

.getting-started__step-text {
  font-size: 0.875rem;
  line-height: 1.3;
}

.getting-started__step--done .getting-started__step-text {
  text-decoration: line-through;
  opacity: 0.7;
}

/* Chunk 56: Books Lock Widget (Dashboard) */
.books-lock-widget {
  display: flex;
  align-items: center;
  gap: var(--space-4, 1rem);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 0.5rem);
  padding: var(--space-4, 1rem) var(--space-5, 1.25rem);
  margin-bottom: var(--space-5, 1.25rem);
  box-shadow: var(--shadow-sm);
}

.books-lock-widget__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--warning-bg, #fef3c7);
  border-radius: var(--radius-md, 0.375rem);
  color: var(--warning-color, #A75B04);
  flex-shrink: 0;
}

.books-lock-widget__content {
  flex: 1;
  min-width: 0;
}

.books-lock-widget__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-text, #6b7280);
  margin-bottom: 0.125rem;
}

.books-lock-widget__value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-color, #1f2937);
}

.books-lock-widget__value--locked {
  color: var(--warning-color, #A75B04);
}

.books-lock-widget__value--unlocked {
  color: var(--muted-text, #6b7280);
}

.books-lock-widget__link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-color, #0d9488);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.books-lock-widget__link:hover {
  text-decoration: underline;
}

/* Dark mode Books Lock widget */
body.theme-dark .books-lock-widget {
  background: var(--card-bg, #1e293b);
  border-color: var(--border-color, #334155);
}

body.theme-dark .books-lock-widget__icon {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

body.theme-dark .books-lock-widget__value--locked {
  color: #fbbf24;
}

@media (prefers-color-scheme: dark) {
  body.theme-system .books-lock-widget {
    background: var(--card-bg, #1e293b);
    border-color: var(--border-color, #334155);
  }

  body.theme-system .books-lock-widget__icon {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
  }

  body.theme-system .books-lock-widget__value--locked {
    color: #fbbf24;
  }
}

/* Dark mode adjustments */
body.theme-dark .empty-state--card {
  background: var(--card-bg, #1e293b);
  border-color: var(--border-color, #334155);
}

body.theme-dark .empty-state__title {
  color: var(--text-color, #f1f5f9);
}

body.theme-dark .btn-ghost {
  color: var(--text-color, #f1f5f9);
  border-color: var(--border-color, #334155);
}

body.theme-dark .btn-ghost:hover {
  background: var(--surface-hover, #334155);
}

@media (prefers-color-scheme: dark) {
  body.theme-system .empty-state--card {
    background: var(--card-bg, #1e293b);
    border-color: var(--border-color, #334155);
  }

  body.theme-system .empty-state__title {
    color: var(--text-color, #f1f5f9);
  }

  body.theme-system .btn-ghost {
    color: var(--text-color, #f1f5f9);
    border-color: var(--border-color, #334155);
  }

  body.theme-system .btn-ghost:hover {
    background: var(--surface-hover, #334155);
  }
}


/* ==============================================================================
   GLOBAL UI POLISH — affects ALL pages without template changes
   ==============================================================================
   These rules target common HTML patterns found across every view template.
   One CSS change = every page improved.
   ============================================================================== */

/* ---- Page titles: any <h1> inside .container looks like a real title ---- */
.container > h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text, #37352f);
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem 0;
}

/* Subtitle under h1 — "Business: ... | Switch Business" pattern */
.container > h1 + p,
.container > h1 + .text-muted {
  color: var(--color-text-secondary, #787774);
  font-size: 0.875rem;
  margin: 0 0 1.5rem 0;
}

/* ---- ALL table action links become pill buttons, not pipe-separated text ---- */
td a {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary, #1a6fb8);
  border-radius: 5px;
  text-decoration: none;
  transition: background 100ms ease;
}

td a:hover {
  background: var(--color-primary-bg, #e8f0fe);
}

/* Danger links in tables (Deactivate, Delete, Void) */
td a.text-danger {
  color: var(--color-danger, #e03e3e);
}

td a.text-danger:hover {
  background: var(--color-danger-bg, #fce8e8);
}

/* ---- ALL selects look modern ---- */
select,
.form-select {
  height: 34px;
  padding: 0 2rem 0 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--color-text, #37352f);
  background-color: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23787774' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
}

select:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary, #1a6fb8);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.14);
}

/* ---- ALL inputs look modern ---- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea {
  height: 34px;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text, #37352f);
  background-color: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 6px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea {
  height: auto;
  min-height: 80px;
  padding: 0.625rem 0.75rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary, #1a6fb8);
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.14);
}

/* ---- Filter bars: .report-filter and .form-inline ---- */
.report-filter {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04);
}

.form-inline,
.report-filter form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-inline label,
.report-filter label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary, #787774);
  margin: 0;
}

/* ---- Status text looks like badges everywhere ---- */
.text-success {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-success, #0f7b6c) !important;
}

.text-success::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success, #0f7b6c);
  display: inline-block;
}

/* ---- Hide ugly pipe separators in table cells ---- */
td {
  /* Collapse whitespace around pipes */
}

/* ---- .btn-success → primary blue (green = financial = clinical) ---- */
.btn-success {
  background-color: var(--color-primary, #1a6fb8);
  color: #ffffff;
  border-color: var(--color-primary, #1a6fb8);
  box-shadow: 0 1px 2px rgba(35, 131, 226, 0.2);
}

.btn-success:hover {
  background-color: var(--color-primary-hover, #155b99);
  border-color: var(--color-primary-hover, #155b99);
  opacity: 1;
  color: #ffffff;
}

/* ---- Sortable table header links ---- */
th a {
  color: var(--color-text-secondary, #787774);
  text-decoration: none;
  font-weight: 500;
}

th a:hover {
  color: var(--color-text, #37352f);
}

/* ---- Forms inside cards get better spacing ---- */
.card .form-group:last-child {
  margin-bottom: 0;
}

/* ---- Metric values — bigger, bolder ---- */
.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text, #37352f);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metric-label {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #787774);
  margin-top: 0.25rem;
}

.metric-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary, #1a6fb8);
}

/* ---- Nav chips (dashboard quick links) ---- */
.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary, #787774);
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 9999px;
  text-decoration: none;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.nav-chip:hover,
.nav-chip--active {
  border-color: var(--color-primary, #1a6fb8);
  color: var(--color-primary, #1a6fb8);
  background: var(--color-primary-bg, #e8f0fe);
}

/* ---- Books lock widget ---- */
.books-lock-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

/* ---- Badge variants ---- */
.badge--subtle {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: var(--color-surface-alt, #f5f3f0);
  color: var(--color-text-secondary, #787774);
  text-transform: capitalize;
  white-space: nowrap;
}

/* ---- Status dot indicators ---- */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.status-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot--active {
  color: var(--color-success, #0f7b6c);
}
.status-dot--active::before {
  background: var(--color-success, #0f7b6c);
}
.status-dot--inactive {
  color: var(--color-text-muted, #767676);
}
.status-dot--inactive::before {
  background: var(--color-text-muted, #767676);
}
.status-dot--warning {
  color: var(--color-warning, #d9730d);
}
.status-dot--warning::before {
  background: var(--color-warning, #d9730d);
}

/* ---- Page subtitle breadcrumbs: style pipe-separated links ---- */
.container > h1 + p a,
.container > h1 + .text-muted a,
.page-subtitle a {
  color: var(--color-primary, #1a6fb8);
  text-decoration: none;
  font-weight: 500;
}
.container > h1 + p a:hover,
.container > h1 + .text-muted a:hover,
.page-subtitle a:hover {
  text-decoration: underline;
}

/* ---- Standalone button paragraphs: better toolbar feel ---- */
.container > h1 + p + p > .btn:first-child,
.container > h1 + .text-muted + p > .btn:first-child {
  /* Buttons right after subtitle paragraph get proper spacing */
}

/* ---- Filter bar improvements ---- */
.filter-bar {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04);
}

.filter-bar__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-bar__group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.filter-bar__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary, #787774);
  white-space: nowrap;
  margin: 0;
}

.filter-bar__control {
  height: 34px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 6px;
  background: var(--color-surface, #ffffff);
  color: var(--color-text, #37352f);
}

select.filter-bar__control {
  padding-right: 2rem;
}

.filter-bar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-bar__btn--submit,
.filter-bar__btn.filter-bar__btn--submit {
  height: 34px;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--color-primary, #1a6fb8);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.filter-bar__btn--clear {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #787774);
  text-decoration: none;
}
.filter-bar__btn--clear:hover {
  color: var(--color-text, #37352f);
}

/* ---- Bulk action bar ---- */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface-alt, #f5f3f0);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bulk-action-bar__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary, #787774);
}

.bulk-action-bar__select {
  height: 34px;
  font-size: 0.8125rem;
}

.bulk-action-bar__btn {
  height: 34px;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--color-primary, #1a6fb8);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.bulk-action-bar__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bulk-action-bar__count {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #767676);
}

/* ---- Info boxes ---- */
.info-box {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e8e5e1);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(55, 53, 47, 0.04);
}

.info-box h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text, #37352f);
  margin-bottom: 0.5rem;
}

.info-box--highlight {
  border-left: 3px solid var(--color-primary, #1a6fb8);
}

/* ==============================================================================
   CALM UI REFRESH (Chunk 209)
   ==============================================================================
   Additive calm baseline: vertical rhythm for major layout blocks, muted text
   utility, and responsive container adjustments. Does not override or break
   existing selectors — purely additive.
   ============================================================================== */

/* Vertical rhythm — consistent spacing between major content blocks */
main,
.app-shell > main {
  padding-top: var(--space-lg);
  padding-bottom: var(--space-2xl, 4rem);
}

section + section {
  margin-top: var(--space-xl);
}

/* Muted/secondary text utility — for descriptions and helper text */
.text-muted {
  color: var(--text-muted, var(--muted-text));
}

.text-secondary {
  color: var(--text-muted, var(--muted-text));
  font-size: 0.9375rem;
}

/* Calm responsive adjustments for narrower screens */
@media (max-width: 640px) {
  .container {
    padding: var(--space-md) var(--space-md);
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  main,
  .app-shell > main {
    padding-top: var(--space-md);
    padding-bottom: var(--space-xl);
  }
}

/* ==============================================================================
   Empty-State — Guided Next Steps (Chunk 211)
   Onboarding card shown on the home page for fresh installations.
   Uses project design tokens for consistency with the rest of app.css.
   ============================================================================== */

/* Section wrapper — light background band to visually separate from hero */
.empty-state-section {
  padding: var(--space-6, 2rem) var(--space-5, 1.5rem);
  background: var(--bg-color, #faf9f7);
  border-top: 1px solid var(--border-color, #e8e5e1);
  border-bottom: 1px solid var(--border-color, #e8e5e1);
}

/* Card surface — constrained width, subtle elevation */
.empty-state-card {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-6, 2rem) var(--space-6, 2rem);
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-color, #e8e5e1);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Title — clear hierarchy, tight spacing */
.empty-state-card__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-color, #37352f);
  margin: 0 0 var(--space-2, 0.5rem);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

/* Description — secondary text below the title */
.empty-state-card__desc {
  font-size: 1rem;
  color: var(--muted-text, #787774);
  line-height: 1.6;
  margin: 0 0 var(--space-5, 1.5rem);
}

/* Ordered step list — numbered for clear sequence */
.empty-state-steps {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0 0 var(--space-5, 1.5rem);
}

/* Individual step */
.empty-state-steps__item {
  font-size: 0.95rem;
  color: var(--text-color, #37352f);
  line-height: 1.6;
  margin-bottom: var(--space-3, 0.75rem);
}

.empty-state-steps__item:last-child {
  margin-bottom: 0;
}

/* Inline code snippets inside steps */
.empty-state-steps__item code {
  font-size: 0.875em;
  background: var(--bg-color, #faf9f7);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text-color, #37352f);
}

/* Links inside steps */
.empty-state-steps__item a {
  color: var(--link-color, #1a6fb8);
  text-decoration: none;
  font-weight: 500;
}

.empty-state-steps__item a:hover {
  text-decoration: underline;
}

/* CTA button area */
.empty-state-card__actions {
  margin-top: var(--space-5, 1.5rem);
}

/* Primary CTA button (landing-btn variant used in the empty state) */
.empty-state-card__actions .landing-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
  border: none;
}

.empty-state-card__actions .landing-btn--primary {
  background: var(--accent-color, #1a6fb8);
  color: #fff;
  box-shadow: 0 1px 3px rgba(35, 131, 226, 0.3);
}

.empty-state-card__actions .landing-btn--primary:hover {
  background: var(--accent-hover, #155b99);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(35, 131, 226, 0.3);
  transform: translateY(-1px);
}

/* Responsive: tighten padding on small screens */
@media (max-width: 640px) {
  .empty-state-card {
    padding: var(--space-5, 1.5rem) var(--space-4, 1rem);
  }

  .empty-state-card__title {
    font-size: 1.15rem;
  }
}

/* ==============================================================================
   Multi-entity UI polish
   ==============================================================================
   Styles for the entity switcher control. These selectors are intentionally
   scoped to avoid unintended side effects on unrelated components.
   ============================================================================== */

/* ── Entity switcher base ────────────────────────────────────────────────── */

select[name="entity_id"],
[data-entity-switcher] select,
select[data-entity-switcher] {
  min-width: 160px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

/* ── Loading state ───────────────────────────────────────────────────────── */

/* Applied via JS while an entity switch is in progress */
select[name="entity_id"].is-loading,
[data-entity-switcher] select.is-loading,
select[data-entity-switcher].is-loading {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}

/* ── Disabled state ──────────────────────────────────────────────────────── */

select[name="entity_id"]:disabled,
[data-entity-switcher] select:disabled,
select[data-entity-switcher]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background-color: var(--bg-color, #faf9f7);
  border-color: var(--border-color, #e8e5e1);
}

/* ── Focus ring for keyboard navigation ─────────────────────────────────── */

select[name="entity_id"]:focus,
[data-entity-switcher] select:focus,
select[data-entity-switcher]:focus {
  outline: 2px solid var(--accent-color, #1a6fb8);
  outline-offset: 1px;
}
