/* ═══════════════════════════════════════════════════════════════
   CAA FINANCIAL DESIGN SYSTEM — OpenAI-Inspired
   Master tokens + base components. Load FIRST.
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ─── Typography ─── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --text-xs: 0.75rem; --text-sm: 0.8125rem; --text-base: 0.875rem;
  --text-md: 1rem; --text-lg: 1.125rem; --text-xl: 1.25rem;
  --text-2xl: 1.5rem; --text-3xl: 1.875rem;
  --leading-tight: 1.25; --leading-normal: 1.5;
  --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;

  /* ─── Spacing (4px grid) ─── */
  --space-0: 0; --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;
  --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  /* ─── Backgrounds (layered depth) ─── */
  --bg-base: #0a0a0a; --bg-surface: #141414; --bg-elevated: #1e1e1e;
  --bg-overlay: #262626; --bg-hover: rgba(255,255,255,0.04);
  --bg-active: rgba(255,255,255,0.08); --bg-input: #1a1a1a; --bg-sidebar: #0f0f0f;

  /* ─── Text ─── */
  --text-primary: #ececec; --text-secondary: #a1a1a1;
  --text-tertiary: #737373; --text-muted: #525252; --text-inverse: #0a0a0a;

  /* ─── Borders ─── */
  --border-subtle: rgba(255,255,255,0.06); --border-default: rgba(255,255,255,0.1);
  --border-strong: rgba(255,255,255,0.16); --border-focus: #10a37f;

  /* ─── Accent (OpenAI teal) ─── */
  --accent: #10a37f; --accent-hover: #1a7f64;
  --accent-muted: rgba(16,163,127,0.15); --accent-text: #34d399;

  /* ─── Semantic ─── */
  --success: #22c55e; --success-muted: rgba(34,197,94,0.12);
  --warning: #f59e0b; --warning-muted: rgba(245,158,11,0.12);
  --error: #ef4444; --error-muted: rgba(239,68,68,0.12);
  --info: #3b82f6; --info-muted: rgba(59,130,246,0.12);
  --purple: #a855f7; --purple-muted: rgba(168,85,247,0.12);
  --orange: #f97316; --orange-muted: rgba(249,115,22,0.12);

  /* ─── Radius / Shadows / Transitions ─── */
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --radius-xl: 16px; --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  --ease-default: cubic-bezier(0.4,0,0.2,1); --ease-out: cubic-bezier(0,0,0.2,1);
  --duration-fast: 100ms; --duration-normal: 200ms; --duration-slow: 300ms;

  /* ─── Layout ─── */
  --sidebar-width: 260px; --sidebar-collapsed: 64px;
  --header-height: 56px; --content-max-width: 1400px; --panel-padding: var(--space-6);
}

/* ─── Reset ─── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-sans); font-size: var(--text-base); line-height: var(--leading-normal);
  color: var(--text-primary); background: var(--bg-base); -webkit-font-smoothing: antialiased; min-height: 100vh; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
::selection { background: var(--accent-muted); color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ─── Cards ─── */
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: var(--space-6); transition: border-color var(--duration-normal) var(--ease-default); }
.card:hover { border-color: var(--border-default); }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-5); }
.stat-label { font-size: var(--text-xs); color: var(--text-tertiary); font-weight: var(--weight-medium);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-1); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); color: var(--text-primary); }
.stat-change { font-size: var(--text-sm); margin-top: var(--space-1); }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm); font-weight: var(--weight-medium); border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer; font-family: var(--font-sans); white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-default); background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-default); }
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-destructive { background: var(--error); color: #fff; border-color: var(--error); }
.btn-destructive:hover { background: #dc2626; }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-md); }

/* ─── Inputs ─── */
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  font-family: var(--font-sans); color: var(--text-primary); background: var(--bg-input);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast); outline: none; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg-surface); }

/* ─── Tables ─── */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; padding: var(--space-3) var(--space-4); color: var(--text-tertiary);
  font-weight: var(--weight-medium); font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--border-default); }
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.table tr:hover td { background: var(--bg-hover); }
.table tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-medium); border-radius: var(--radius-full); }
.badge-success { background: var(--success-muted); color: var(--success); }
.badge-warning { background: var(--warning-muted); color: var(--warning); }
.badge-error { background: var(--error-muted); color: var(--error); }
.badge-info { background: var(--info-muted); color: var(--info); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); }
.badge-accent { background: var(--accent-muted); color: var(--accent-text); }
.badge-purple { background: var(--purple-muted); color: var(--purple); }

/* ─── Progress Bars ─── */
.progress { height: 6px; background: var(--bg-elevated); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease-out); }
.progress-fill.accent { background: var(--accent); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.error { background: var(--error); }

/* ─── Tabs ─── */
.tabs { display: flex; gap: var(--space-1); padding: var(--space-1); background: var(--bg-elevated);
  border-radius: var(--radius-md); width: fit-content; }
.tab { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-tertiary); border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--duration-fast); border: none; background: none; font-family: var(--font-sans); }
.tab:hover { color: var(--text-secondary); }
.tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* ─── Modals ─── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-xl);
  padding: var(--space-6); max-width: 560px; width: 90%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-xl); }
.modal-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6);
  padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: var(--space-16) var(--space-8); }
.empty-state .icon { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.3; }
.empty-state .title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state .desc { font-size: var(--text-sm); color: var(--text-tertiary); max-width: 400px; margin: 0 auto; }

/* ─── Layout Utilities ─── */
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

/* ─── Animations ─── */
.fade-in { animation: fadeIn 0.25s var(--ease-default); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
