/* ==========================================================================
   Quality Air Sync Audit - Production Design System v3.0
   ========================================================================== */

:root {
  /* Obsidian Dark (Default) */
  --bg-base: #090a0c;
  --bg-surface: #111317;
  --bg-surface-hover: #181a20;
  --bg-elevated: #1e2027;
  --bg-active-row: rgba(59, 130, 246, 0.08);
  --bg-zebra: rgba(255, 255, 255, 0.015);

  --border: #1f2229;
  --border-focus: #3b82f6;

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;

  --status-success: #22c55e;
  --status-success-bg: rgba(34, 197, 94, 0.1);
  --status-danger: #ef4444;
  --status-danger-bg: rgba(239, 68, 68, 0.12);
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.12);

  --highlight-bg: rgba(250, 204, 21, 0.18);
  --highlight-text: #fde047;

  /* JSON Syntax Highlighting */
  --json-key: #93c5fd;
  --json-string: #86efac;
  --json-number: #fde047;
  --json-bool: #f472b6;
  --json-null: #a1a1aa;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  --shadow-drawer: -6px 0 24px rgba(0, 0, 0, 0.6);
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  /* Alpine Light */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --bg-active-row: rgba(37, 99, 235, 0.06);
  --bg-zebra: rgba(0, 0, 0, 0.018);

  --border: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;

  --status-success: #16a34a;
  --status-success-bg: rgba(22, 163, 74, 0.08);
  --status-danger: #dc2626;
  --status-danger-bg: #fee2e2;
  --status-warning: #d97706;
  --status-warning-bg: #fef3c7;

  --highlight-bg: rgba(234, 179, 8, 0.2);
  --highlight-text: #854d0e;

  /* JSON Syntax Highlighting (Light) */
  --json-key: #1e40af;
  --json-string: #15803d;
  --json-number: #b45309;
  --json-bool: #be185d;
  --json-null: #64748b;

  --shadow-drawer: -6px 0 24px rgba(0, 0, 0, 0.08);
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-normal { font-weight: 400; }
.hidden { display: none !important; }

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ==========================================================================
   Top Navbar
   ========================================================================== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  padding: 0 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 1.5rem;
  z-index: 20;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  white-space: nowrap;
}

.brand-name {
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.brand-sep {
  color: var(--text-subtle);
  font-weight: 300;
}

.brand-sub {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Search Box */
.nav-center {
  flex: 1;
  max-width: 440px;
}

.search-box {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-ico {
  position: absolute;
  left: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-subtle);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 32px;
  padding: 0 1.8rem 0 2rem;
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 120ms ease;
}

.search-box input:focus {
  border-color: var(--border-focus);
}

.search-clear-btn {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.15rem;
}

.search-clear-btn:hover {
  color: var(--text-main);
}

/* Nav Right */
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  height: 32px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-outline {
  background-color: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-subtle);
}

.btn-ghost {
  background: none;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-hover);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn-xs {
  height: 26px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.caret-ico {
  font-size: 0.55rem;
  margin-left: 0.1rem;
}

/* Theme Icons */
[data-theme="dark"] .icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: block; }
[data-theme="light"] .icon-dark { display: block; }
[data-theme="light"] .icon-light { display: none; }

/* Export Dropdown */
.export-container {
  position: relative;
}

.dropdown-popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.35rem;
  width: 210px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  display: none;
  flex-direction: column;
  padding: 0.25rem;
  z-index: 50;
}

.dropdown-popover.active {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--bg-surface-hover);
}

/* ==========================================================================
   Sub-Bar (Filters + Pagination)
   ========================================================================== */
.sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  padding: 0 1.5rem;
  background-color: var(--bg-base);
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  overflow: hidden;
}

.sub-bar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: nowrap;
}

.sub-bar-divider {
  width: 1px;
  height: 16px;
  background-color: var(--border);
  flex-shrink: 0;
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.clean-select {
  height: 30px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.775rem;
  font-weight: 500;
  padding: 0 0.5rem;
  cursor: pointer;
  outline: none;
  transition: border-color 120ms ease;
}

.clean-select:focus, .clean-select:hover {
  border-color: var(--border-focus);
}

/* Date Range & Calendar Picker */
.date-filter-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.calendar-picker-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.calendar-icon-btn {
  height: 30px;
  width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  outline: none;
  transition: all 120ms ease;
}

.calendar-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.calendar-icon-btn.active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.hidden-date-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.date-clear-btn {
  height: 24px;
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 120ms ease;
  margin-left: -0.1rem;
}

.date-clear-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-surface-hover);
}

/* Issues Only Toggle */
.toggle-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 30px;
  padding: 0 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
  flex-shrink: 0;
}

.toggle-pill-btn:hover {
  color: var(--status-danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.toggle-pill-btn.active {
  background-color: var(--status-danger-bg);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--status-danger);
  font-weight: 600;
}

.sub-bar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-shrink: 0;
}

.pagination-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

/* Page Size Selector */
.page-size-select {
  height: 26px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0 0.3rem;
  cursor: pointer;
  outline: none;
  transition: border-color 120ms ease;
}

.page-size-select:focus {
  border-color: var(--border-focus);
}

/* ==========================================================================
   Summary Stats Ribbon
   ========================================================================== */
.stats-ribbon {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.775rem;
  color: var(--text-muted);
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot.total { background-color: var(--accent); }
.stat-dot.synced { background-color: var(--status-success); }
.stat-dot.issues { background-color: var(--status-danger); }

.stat-val {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-size: 0.8125rem;
}

.stat-label {
  font-weight: 400;
}

.stat-sep {
  width: 1px;
  height: 14px;
  background-color: var(--border);
  flex-shrink: 0;
}

/* ==========================================================================
   Error Summary Bar
   ========================================================================== */
.error-summary-bar {
  padding: 0.75rem 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.error-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.error-summary-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--status-danger);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.error-summary-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.error-summary-cards {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.error-summary-cards::-webkit-scrollbar {
  height: 0;
}

.error-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 120ms ease;
  min-width: 145px;
  flex-shrink: 0;
}

.error-card:hover {
  border-color: var(--status-danger);
  background-color: var(--status-danger-bg);
}

.error-card.active {
  border-color: var(--status-danger);
  background-color: var(--status-danger-bg);
}

.error-card-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-card-count {
  font-size: 1rem;
  font-weight: 700;
  color: var(--status-danger);
  font-family: var(--font-mono);
}

.error-card-object {
  font-size: 0.6rem;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Loading Skeleton
   ========================================================================== */
.skeleton-container {
  padding: 0.5rem 0;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.skeleton-cell {
  height: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-cell.sm { width: 60px; }
.skeleton-cell.md { width: 160px; }
.skeleton-cell.lg { width: 260px; }
.skeleton-cell.xl { width: 100px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Load Error State */
.load-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--status-danger);
  text-align: center;
}

.load-error i {
  font-size: 2rem;
  opacity: 0.7;
}

.load-error p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.load-error button {
  margin-top: 0.5rem;
}

/* ==========================================================================
   Ledger Data Table
   ========================================================================== */
.ledger-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.ledger-table th {
  position: sticky;
  top: 0;
  background-color: var(--bg-base);
  padding: 0.65rem 1.5rem;
  font-weight: 500;
  font-size: 0.725rem;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  user-select: none;
  white-space: nowrap;
}

.ledger-table th.sortable {
  cursor: pointer;
}

.ledger-table th.sortable:hover {
  color: var(--text-main);
}

.sort-ico {
  font-size: 0.65rem;
  margin-left: 0.25rem;
  color: var(--text-subtle);
}

.sort-ico.active {
  color: var(--accent);
}

.ledger-table td {
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

/* Allow name column to wrap if needed */
.ledger-table td.cell-name {
  white-space: normal;
  word-break: break-word;
  min-width: 180px;
  max-width: 360px;
}

.ledger-table td.cell-nowrap {
  white-space: nowrap;
}

.ledger-table tbody tr {
  cursor: pointer;
  transition: background-color 80ms ease;
}

/* Zebra striping */
.ledger-table tbody tr:nth-child(even) {
  background-color: var(--bg-zebra);
}

.ledger-table tbody tr:hover {
  background-color: var(--bg-surface);
}

.ledger-table tbody tr.selected {
  background-color: var(--bg-active-row);
  box-shadow: inset 3px 0 0 var(--accent);
}

.text-center { text-align: center; }

.ledger-table th.cell-status,
.ledger-table td.cell-status {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  padding: 0.7rem 0.5rem 0.7rem 1.25rem;
  text-align: center;
}

/* Status Dot */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.status-dot.synced { background-color: var(--status-success); box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.status-dot.failed { background-color: var(--status-danger); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.status-dot.held { background-color: var(--status-warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }

/* Inline Salesforce Link (on record name) */
.sf-link-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 0.625rem;
  margin-left: 0.35rem;
  opacity: 0.5;
  transition: all 120ms ease;
  vertical-align: middle;
  padding: 2px 4px;
  border-radius: 3px;
}

.sf-link-inline:hover {
  opacity: 1;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent-hover);
  text-decoration: none;
}

/* Org Identification Badge (Admin Mode) */
.badge-org {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--bg-surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
  font-family: var(--font-mono);
}

.badge-org.qualityair {
  background-color: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-org.expresselectric {
  background-color: rgba(234, 179, 8, 0.12);
  color: #facc15;
  border-color: rgba(234, 179, 8, 0.3);
}

.badge-org.mfs {
  background-color: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Inactive Exception Badge */
.badge-inactive {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background-color: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
  margin-left: 0.4rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Show SF link more prominently on row hover */
.ledger-table tbody tr:hover .sf-link-inline {
  opacity: 0.85;
}

/* Failed/Held row left border accent */
.ledger-table tbody tr.row-failed {
  box-shadow: inset 3px 0 0 var(--status-danger);
}

.ledger-table tbody tr.row-held {
  box-shadow: inset 3px 0 0 var(--status-warning);
}

/* Search Highlight */
mark, .search-mark {
  background-color: var(--highlight-bg);
  color: var(--highlight-text);
  border-radius: 2px;
  padding: 0 2px;
}

/* Empty State */
.empty-state {
  padding: 6rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-subtle);
}

.empty-ico {
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
}

/* ==========================================================================
   Footer Status Bar
   ========================================================================== */
.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1.5rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  font-size: 0.725rem;
  color: var(--text-subtle);
}

.kbd-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.kbd-shortcuts kbd {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-base);
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.footer-version {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-subtle);
  opacity: 0.6;
}

/* ==========================================================================
   Drawer (Record Inspector)
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 70;
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer.active {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.drawer-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Error Banner in Drawer */
.drawer-error-banner {
  background-color: var(--status-danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.error-banner-ico {
  color: var(--status-danger);
  font-size: 1.1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.error-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.error-banner-type {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--status-danger);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.error-banner-msg {
  font-size: 0.75rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* Resolution Banner in Drawer */
.drawer-resolution-banner {
  background-color: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.resolution-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.resolution-ico {
  color: var(--status-success);
  font-size: 0.875rem;
}

.resolution-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--status-success);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.resolution-text {
  font-size: 0.8125rem;
  color: var(--text-main);
  line-height: 1.5;
}

.resolution-sf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.15rem;
  transition: color 120ms ease;
}

.resolution-sf-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Amount Card */
.drawer-amount-card {
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.amount-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.amount-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.amount-entity {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Meta Grid */
.drawer-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.meta-label {
  font-size: 0.6875rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.meta-val {
  font-size: 0.8125rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Sections */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.section-title {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Collapsible Section (JSON) */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.35rem 0;
  user-select: none;
}

.collapsible-header:hover .section-title {
  color: var(--text-main);
}

.collapsible-chevron {
  font-size: 0.625rem;
  color: var(--text-subtle);
  transition: transform 180ms ease;
}

.collapsible-header.open .collapsible-chevron {
  transform: rotate(180deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms ease;
}

.collapsible-body.open {
  max-height: 500px;
}

/* IDs */
.id-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  gap: 0.5rem;
}

.id-label {
  color: var(--text-subtle);
}

.id-val {
  flex: 1;
  text-align: right;
  color: var(--text-main);
  word-break: break-all;
}

/* Line Items */
.lines-feed {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.line-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-base);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* JSON Box */
.json-box {
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  max-height: 280px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.json-key { color: var(--json-key); font-weight: 600; }
.json-string { color: var(--json-string); }
.json-number { color: var(--json-number); }
.json-bool { color: var(--json-bool); }
.json-null { color: var(--json-null); font-style: italic; }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: var(--text-main);
  color: var(--bg-base);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .sub-bar {
    height: auto;
    min-height: 48px;
    max-height: none;
    overflow: visible;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .sub-bar-left {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .sub-bar-divider {
    display: none;
  }

  .error-summary-cards {
    flex-wrap: wrap;
  }

  .error-card {
    min-width: 140px;
  }

  .stats-ribbon {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
  }

  .nav-center {
    max-width: none;
    order: 3;
    flex-basis: 100%;
  }

  .ledger-table td, .ledger-table th {
    padding: 0.5rem 0.75rem;
  }

  .drawer {
    width: 100vw;
    max-width: 100vw;
  }

  .error-card {
    min-width: 120px;
  }

  .stat-sep {
    display: none;
  }
}
