/* =========================================================================
   Reset & Baseline Zero-CLS Defaults (Mobile-First & Touch-Optimized)
   ========================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* Dynamic viewport height for mobile browser chrome */
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  /* Static radial gradient avoids mobile GPU repaint lag caused by background-attachment: fixed */
  background: radial-gradient(circle at 15% 10%, rgba(6, 182, 212, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(139, 92, 246, 0.04) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
    var(--bg-primary);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Scrollbar customization (Desktop pointers only) */
@media (pointer: fine) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--bg-card-elevated);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-secondary);
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
  }
}

/* =========================================================================
   Shell Header & Safe-Area Navigation
   ========================================================================= */
.app-header {
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(7, 9, 14, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: env(safe-area-inset-top) max(var(--space-4), env(safe-area-inset-right)) 0 max(var(--space-4), env(safe-area-inset-left));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--accent-cyan-glow);
  color: #fff;
  font-weight: 700;
  font-size: var(--font-size-md);
}

.brand-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-tag {
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-weight: 600;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* =========================================================================
   Touch-Friendly Buttons (44px WCAG Minimum Tap Targets on Touch)
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: var(--bevel-inset-highlight), var(--bevel-shadow);
  user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
  }
}

.btn:active {
  transform: scale(0.98) translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 16px var(--accent-cyan-glow), var(--bevel-inset-highlight);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #0891b2);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.45);
  }
}

.btn-emerald {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 16px var(--accent-emerald-glow);
}

@media (hover: hover) {
  .btn-emerald:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  }
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-secondary);
}

.btn-ghost:active,
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-icon {
  padding: 0.45rem;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.35);
}

/* Command Palette Trigger Pill */
.cmd-trigger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  background: rgba(14, 20, 32, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--bevel-inset-highlight);
  touch-action: manipulation;
}

.kbd-shortcut {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Mandatory Legal Disclaimer Notice Banner */
.disclaimer-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, rgba(20, 26, 41, 0.9) 50%, rgba(245, 158, 11, 0.08) 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  color: #fbbf24;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-2);
  text-align: left;
  line-height: 1.4;
}

.disclaimer-banner svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

/* =========================================================================
   Main Bento Grid Layout
   ========================================================================= */
.app-container {
  max-width: var(--max-content-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
  align-items: stretch;
}

/* Beveled Cards */
.bento-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border-top: 1px solid var(--border-beveled-top);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-beveled-bottom);
  box-shadow: var(--bevel-inset-highlight), var(--bevel-shadow);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  contain: paint layout;
  min-width: 0;
  /* Prevents grid blowout from child tables/charts */
}

/* Bento Sizing Grid Classes (Mobile-First Default: Full Width) */
.col-span-12,
.col-span-8,
.col-span-7,
.col-span-6,
.col-span-5,
.col-span-4,
.col-span-3 {
  grid-column: span 12;
}

/* Zero-CLS Min-Height guarantees */
.card-kpi {
  min-height: 120px;
}

.card-chart-cashflow {
  min-height: 300px;
}

.card-chart-ring {
  min-height: 300px;
}

.card-ledger {
  min-height: 440px;
}

/* Card Header */
.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.card-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* KPI Card Typography (Fluid scaling with clamp) */
.kpi-value {
  font-size: clamp(1.5rem, 6vw, var(--font-size-3xl));
  font-weight: 800;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  margin-top: auto;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.kpi-subtext {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.kpi-delta-positive {
  color: var(--accent-emerald);
}

.kpi-delta-negative {
  color: var(--accent-rose);
}

.kpi-delta-neutral {
  color: var(--accent-cyan);
}

/* =========================================================================
   Canvas Viewports (Touch & Pointer Safe)
   ========================================================================= */
.canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas.telemetry-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: pan-y;
  /* Allows vertical page scroll while permitting horizontal chart scrubbing */
}

.canvas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(13, 17, 26, 0.95);
  border: 1px solid var(--border-active);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  color: var(--text-primary);
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 120ms ease;
  z-index: 20;
  white-space: nowrap;
  max-width: 90vw;
}

.canvas-tooltip.active {
  opacity: 1;
}

/* =========================================================================
   Ledger & Table Controls (16px Inputs Prevent iOS Safari Auto-Zoom)
   ========================================================================= */
.ledger-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-group::-webkit-scrollbar {
  display: none;
}

.input-search,
.select-filter,
.date-filter {
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 42px;
  padding: 0.5rem 0.85rem;
  color: var(--text-primary);
  font-size: 16px;
  /* Prevents iOS Safari zoom on input focus */
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.input-search {
  width: 100%;
}

.input-search:focus,
.select-filter:focus,
.date-filter:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

/* Ledger Table with Horizontal Momentum Scroll & Edge Fade Cue */
.table-wrapper {
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 280px;
  position: relative;
  margin: 0 calc(var(--space-4) * -1);
  padding: 0 var(--space-4);
}

.ledger-table {
  width: 100%;
  min-width: 580px;
  /* Prevents cramped column wrapping on narrow screens */
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
  text-align: left;
}

.ledger-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 5;
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}

.ledger-table td {
  padding: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.ledger-table .col-date {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  width: 100px;
  white-space: nowrap;
}

.ledger-table .col-desc {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 150px;
}

.ledger-table .col-category {
  width: 130px;
  white-space: nowrap;
}

.ledger-table .col-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  width: 115px;
  white-space: nowrap;
}

.ledger-table .col-actions {
  text-align: right;
  width: 84px;
  white-space: nowrap;
}

.badge-category {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.amt-income {
  color: var(--accent-emerald);
}

.amt-expense {
  color: var(--text-primary);
}

/* Pagination / Footer Bar */
.ledger-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

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

/* =========================================================================
   Mobile Bottom-Sheet Modals (Transforms to Centered Modal on Tablet+)
   ========================================================================= */
.modal-backdrop,
.tutorial-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  /* Bottom sheet anchor on mobile */
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  padding: 0;
}

.modal-backdrop.open,
.tutorial-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-window,
.tutorial-window {
  width: 100%;
  max-width: 100%;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-beveled-top);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85), var(--bevel-inset-highlight);
  padding: var(--space-5) var(--space-4) max(var(--space-5), env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.tutorial-window {
  background: linear-gradient(145deg, rgba(16, 22, 38, 0.99), rgba(9, 12, 20, 0.99));
  border-top-color: rgba(6, 182, 212, 0.45);
}

.modal-backdrop.open .modal-window,
.tutorial-backdrop.open .tutorial-window {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-select {
  width: 100%;
  min-height: 44px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: var(--text-primary);
  font-size: 16px;
  /* Prevents iOS auto-zoom */
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.modal-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.modal-footer .btn {
  width: 100%;
}

/* =========================================================================
   Command Palette Overlay (Full-Width Top Sheet on Mobile)
   ========================================================================= */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(var(--space-3), env(safe-area-inset-top)) var(--space-3) var(--space-3);
  z-index: var(--z-command-palette);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.cmd-palette-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette {
  width: 100%;
  max-width: 620px;
  background: rgba(15, 20, 31, 0.99);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px -15px rgba(6, 182, 212, 0.25);
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform var(--transition-normal);
}

.cmd-palette-backdrop.open .cmd-palette {
  transform: translateY(0);
}

.cmd-input-container {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  /* Prevents iOS zoom */
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-width: 0;
}

.cmd-input::placeholder {
  color: var(--text-dim);
}

.cmd-list {
  max-height: 52dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2);
  list-style: none;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  gap: var(--space-2);
}

.cmd-item.selected,
.cmd-item:active {
  background: rgba(6, 182, 212, 0.18);
  color: #fff;
}

.cmd-item-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.cmd-shortcut {
  display: none;
  /* Hidden on touch devices */
}

.cmd-help {
  padding: var(--space-2) var(--space-4);
  background: rgba(9, 12, 19, 0.6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: space-between;
}

/* =========================================================================
   Toast Notification System (Full-Width Mobile Stack)
   ========================================================================= */
.toast-container {
  position: fixed;
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  left: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  width: 100%;
  animation: toastIn 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.toast-success {
  border-color: var(--accent-emerald);
}

.toast.toast-error {
  border-color: var(--accent-rose);
}

.toast.toast-info {
  border-color: var(--accent-cyan);
}

/* =========================================================================
   App Footer & Onboarding Tutorial
   ========================================================================= */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  padding: var(--space-5) var(--space-4) max(var(--space-5), env(safe-area-inset-bottom));
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  text-align: center;
}

.footer-disclaimer {
  max-width: 800px;
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  line-height: 1.6;
}

.footer-copy {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.agent-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.agent-avatar-orb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 18px var(--accent-cyan-glow);
  flex-shrink: 0;
}

.agent-avatar-orb::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px dashed rgba(6, 182, 212, 0.5);
  animation: agentSpin 12s linear infinite;
}

@keyframes agentSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.agent-avatar-inner {
  font-size: 18px;
  color: #fff;
  user-select: none;
}

.agent-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agent-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.agent-role {
  font-size: var(--font-size-xs);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 500;
}

.tutorial-step-indicator {
  margin-left: auto;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.agent-speech-bubble {
  background: rgba(13, 17, 26, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.agent-speech-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.agent-speech-body {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.tutorial-disclaimer-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-left: 4px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-xs);
  color: #fbbf24;
  line-height: 1.5;
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.tutorial-disclaimer-box strong {
  color: #fef08a;
}

.tutorial-checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.tutorial-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.tutorial-checklist-item svg {
  flex-shrink: 0;
  color: var(--accent-cyan);
  margin-top: 2px;
}

.tutorial-progress-bar {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-4);
}

.progress-dot {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.progress-dot.active {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.progress-dot.completed {
  background: var(--accent-emerald);
}

.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.tutorial-spotlight-active {
  outline: 2px solid var(--accent-cyan) !important;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.5), inset 0 0 15px rgba(6, 182, 212, 0.15) !important;
  animation: tutorialSpotlightPulse 2s infinite ease-in-out;
  position: relative;
  z-index: 100 !important;
}

@keyframes tutorialSpotlightPulse {

  0%,
  100% {
    outline-color: var(--accent-cyan);
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.45);
  }

  50% {
    outline-color: var(--accent-violet);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.65);
  }
}

/* =========================================================================
   Small Phone Compact Refinements (< 480px)
   ========================================================================= */
@media (max-width: 479px) {

  .brand-title,
  .kbd-shortcut,
  .cmd-trigger-text {
    display: none;
  }

  .cmd-trigger-btn {
    padding: 0.45rem 0.65rem;
  }
}

/* =========================================================================
   Tablet & Desktop Progressive Enhancements (min-width breakpoints)
   ========================================================================= */
@media (min-width: 640px) {
  .col-span-3 {
    grid-column: span 6;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  /* Centered Dialog Modals instead of Mobile Bottom Sheets */
  .modal-backdrop,
  .tutorial-backdrop {
    align-items: center;
    padding: var(--space-4);
  }

  .modal-window {
    max-width: 580px;
    border: 1px solid var(--border-beveled-top);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transform: scale(0.96) translateY(8px);
  }

  .tutorial-window {
    max-width: 640px;
    border: 1px solid rgba(6, 182, 212, 0.35);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transform: scale(0.96) translateY(10px);
  }

  .modal-backdrop.open .modal-window,
  .tutorial-backdrop.open .tutorial-window {
    transform: scale(1) translateY(0);
  }

  .modal-footer {
    flex-direction: row;
    justify-content: flex-end;
  }

  .modal-footer .btn {
    width: auto;
  }

  .toast-container {
    left: auto;
    right: var(--space-6);
    bottom: var(--space-6);
  }

  .toast {
    min-width: 280px;
    width: auto;
  }
}

@media (min-width: 768px) {
  .app-header {
    padding: 0 var(--space-6);
  }

  .app-container {
    padding: var(--space-6);
    gap: var(--space-6);
  }

  .bento-grid {
    gap: var(--space-6);
  }

  .bento-card {
    padding: var(--space-5);
  }

  .col-span-6 {
    grid-column: span 6;
  }

  .card-kpi {
    min-height: 140px;
  }

  .card-chart-cashflow,
  .card-chart-ring {
    min-height: 380px;
  }

  .card-ledger {
    min-height: 520px;
  }

  .canvas-container {
    min-height: 280px;
  }

  .disclaimer-banner {
    align-items: center;
    text-align: center;
    padding: var(--space-2) var(--space-6);
  }

  .ledger-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .input-search {
    min-width: 240px;
    width: auto;
    font-size: var(--font-size-sm);
  }

  .select-filter,
  .date-filter,
  .form-input,
  .form-select {
    font-size: var(--font-size-sm);
  }

  .table-wrapper {
    margin: 0;
    padding: 0;
  }

  .cmd-palette-backdrop {
    padding-top: 12vh;
  }

  .cmd-shortcut {
    display: inline-block;
  }
}

@media (min-width: 1201px) {
  .col-span-8 {
    grid-column: span 8;
  }

  .col-span-7 {
    grid-column: span 7;
  }

  .col-span-5 {
    grid-column: span 5;
  }

  .col-span-4 {
    grid-column: span 4;
  }

  .col-span-3 {
    grid-column: span 3;
  }
}

/* =========================================================================
   Dedicated High-Fidelity Print & PDF Styles
   ========================================================================= */
@media print {
  body {
    background: #ffffff !important;
    color: #111827 !important;
  }

  .app-header,
  .header-actions,
  .disclaimer-banner,
  .cmd-trigger-btn,
  .ledger-toolbar,
  .col-actions,
  .pagination-controls,
  .btn,
  .modal-backdrop,
  .cmd-palette-backdrop,
  .toast-container,
  .tutorial-backdrop {
    display: none !important;
  }

  .app-container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .bento-card {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
    color: #111827 !important;
    break-inside: avoid;
    margin-bottom: 16px;
  }

  .card-title,
  .kpi-value {
    color: #111827 !important;
  }

  .ledger-table th {
    background: #f3f4f6 !important;
    color: #374151 !important;
  }

  .ledger-table td {
    color: #1f2937 !important;
    border-bottom: 1px solid #e5e7eb !important;
  }

  .print-only-header {
    display: block !important;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #111827;
  }

  .footer-disclaimer {
    color: #6b7280 !important;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
  }
}

.print-only-header {
  display: none;
}