/* ═══════════════════════════════════════════════════════════════════
   AutoChase Design System — Responsive Dark + Light
   ═══════════════════════════════════════════════════════════════════ */

/* ── LIGHT THEME (default) ──────────────────────────────────────── */
:root,
[data-theme="light"] {
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-1:    #ffffff;
  --surface-2:    #f0f0f4;
  --surface-3:    #e8e8ef;
  --border:       rgba(0,0,0,0.07);
  --border-2:     rgba(0,0,0,0.13);
  --text:         #111118;
  --text-1:       #111118;
  --text-2:       #555568;
  --text-3:       #9999aa;
  --text-muted:   #555568;
  --accent:       #6c63ff;
  --accent-light: #5550ee;
  --accent-dim:   rgba(108,99,255,0.10);
  --accent-glow:  rgba(108,99,255,0.20);
  --green:        #16a34a;
  --green-dim:    rgba(22,163,74,0.10);
  --amber:        #d97706;
  --amber-dim:    rgba(217,119,6,0.10);
  --red:          #dc2626;
  --red-dim:      rgba(220,38,38,0.10);
  --blue:         #2563eb;
  --blue-dim:     rgba(37,99,235,0.10);
  --shadow:       0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.15);
  --sidebar-w:    220px;
  --radius:       10px;
  --radius-lg:    16px;
  --font:         'DM Sans', sans-serif;
  --mono:         'DM Mono', monospace;
  color-scheme: light;
}

/* ── DARK THEME ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0d0d10;
  --surface:      #16161a;
  --surface-1:    #16161a;
  --surface-2:    #1e1e24;
  --surface-3:    #26262e;
  --border:       rgba(255,255,255,0.07);
  --border-2:     rgba(255,255,255,0.12);
  --text:         #f0f0f2;
  --text-1:       #f0f0f2;
  --text-2:       #8a8a9a;
  --text-3:       #555568;
  --text-muted:   #8a8a9a;
  --accent:       #6c63ff;
  --accent-light: #8b84ff;
  --accent-dim:   rgba(108,99,255,0.15);
  --accent-glow:  rgba(108,99,255,0.25);
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.12);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245,158,11,0.12);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.12);
  --blue:         #3b82f6;
  --blue-dim:     rgba(59,130,246,0.12);
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}

/* ═══════════════════════════════════════════════════════════════════
   AUTH
   ═══════════════════════════════════════════════════════════════════ */
body.auth-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh;
  background-image: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(108,99,255,0.18), transparent);
  padding: 1.5rem;
}
body.auth-page footer { display: none; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 2.5rem;
  width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.auth-logo .brand-icon { font-size: 28px; }
.auth-logo .brand-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.auth-title { font-size: 1.4rem; font-weight: 600; margin-bottom: .4rem; }
.auth-sub   { color: var(--text-2); font-size: .95rem; margin-bottom: 2rem; }
.auth-link  { text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--text-2); }
.auth-link a { color: var(--accent-light); text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 18px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: .9rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  margin-bottom: 1.25rem;
}
.btn-google:hover { background: var(--surface-3); box-shadow: 0 1px 8px rgba(0,0,0,.15); }
[data-theme="light"] .btn-google { background: #fff; }
[data-theme="light"] .btn-google:hover { background: #f8f8f8; }

.auth-divider {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem; color: var(--text-3); font-size: .82rem;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-2); }

/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR  — Arc-style: icon-only by default, hover/drag to expand
   ═══════════════════════════════════════════════════════════════════ */

/* Base sidebar (always in collapsed/icon-only state by default) */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w, 60px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1rem .625rem;
  z-index: 200;
  overflow: hidden;
  /* Smooth expand/collapse, but NOT during drag */
  transition: width .2s cubic-bezier(.4,0,.2,1),
              box-shadow .2s,
              transform .25s cubic-bezier(.4,0,.2,1),
              background .2s, border-color .2s;
}

/* While dragging: disable width transition for instant feedback */
.sidebar.is-resizing { transition: transform .25s cubic-bezier(.4,0,.2,1) !important; }
body.is-resizing { cursor: col-resize !important; user-select: none !important; }
body.is-resizing .app-content { transition: none !important; }

/* ── Icon-only (collapsed) state ────────────────────────────────── */
/* Applied when NOT hovered/expanded so labels are hidden */
.sidebar.is-collapsed:not(.is-hover-open) {
  width: 60px !important;
}
.sidebar.is-collapsed:not(.is-hover-open) .nav-label,
.sidebar.is-collapsed:not(.is-hover-open) .brand-name,
.sidebar.is-collapsed:not(.is-hover-open) .user-meta,
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-upgrade,
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-actions,
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-collapse-btn { display: none !important; }
.sidebar.is-collapsed:not(.is-hover-open) .nav-link {
  justify-content: center; padding: 10px 0; gap: 0; border-radius: var(--radius);
}
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-brand {
  justify-content: center; padding: .5rem 0 1.5rem;
}
.sidebar.is-collapsed:not(.is-hover-open) .user-info-link { justify-content: center; }
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-footer {
  flex-wrap: wrap; justify-content: center; gap: 4px; padding-top: .875rem;
}

/* Tooltip on collapsed icons */
.sidebar.is-collapsed:not(.is-hover-open) .nav-link { position: relative; }
.sidebar.is-collapsed:not(.is-hover-open) .nav-link::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--surface-3); color: var(--text-1);
  border: 1px solid var(--border-2); border-radius: 7px;
  padding: .35rem .7rem; font-size: .78rem; font-weight: 500;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s .08s;
  box-shadow: var(--shadow); z-index: 9999;
}
.sidebar.is-collapsed:not(.is-hover-open) .nav-link:hover::after { opacity: 1; }

/* ── Hover-expand (floats over content, doesn't push it) ─────────── */
.sidebar.is-collapsed.is-hover-open {
  width: var(--sidebar-expanded-w, 220px) !important;
  box-shadow: 6px 0 32px rgba(0,0,0,.35);
  border-right-color: var(--border-2);
  padding: 1rem .75rem;
}
/* Frosted glass feel on hover-open */
[data-theme="dark"] .sidebar.is-collapsed.is-hover-open {
  background: rgba(22,22,26,.97);
  backdrop-filter: blur(16px);
}
[data-theme="light"] .sidebar.is-collapsed.is-hover-open {
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(16px);
}

/* ── Expanded (permanently pinned) state ─────────────────────────── */
.sidebar:not(.is-collapsed) {
  padding: 1rem .75rem;
}

/* ── Resize handle ───────────────────────────────────────────────── */
.sidebar-resize {
  position: absolute; top: 0; right: -5px; bottom: 0;
  width: 10px; cursor: col-resize; z-index: 10;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-resize::after {
  content: '';
  width: 3px; height: 36px; border-radius: 2px;
  background: transparent;
  transition: background .18s, height .18s, opacity .18s;
  opacity: 0;
}
.sidebar-resize:hover::after,
.sidebar.is-resizing .sidebar-resize::after {
  background: var(--accent); height: 56px; opacity: .85;
}

/* ── Collapse/pin toggle button ─────────────────────────────────── */
.sidebar-collapse-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; margin-left: auto;
  transition: color .15s, background .15s;
}
.sidebar-collapse-btn:hover { color: var(--text-1); background: var(--surface-3); }
.sidebar-collapse-btn svg { transition: transform .2s cubic-bezier(.4,0,.2,1); }
.sidebar.is-collapsed .sidebar-collapse-btn { display: none; } /* hidden when collapsed */

/* ── Brand row ───────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: .25rem .25rem 1.25rem; min-height: 44px;
}
.brand-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.brand-name { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; flex: 1; }

/* ── Nav ─────────────────────────────────────────────────────────── */
.sidebar-nav { list-style: none; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav li + li { margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--text-2); text-decoration: none;
  font-size: .875rem; font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover  { background: var(--surface-3); color: var(--text-1); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-light); }
.nav-link svg    { flex-shrink: 0; opacity: .8; }

/* ── Upgrade banner ──────────────────────────────────────────────── */
.sidebar-upgrade {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem;
  background: linear-gradient(135deg,rgba(108,99,255,.18),rgba(167,139,250,.1));
  border: 1px solid rgba(108,99,255,.3); border-radius: 8px; text-decoration: none;
  margin-bottom: .5rem; transition: background .15s; overflow: hidden;
}
.sidebar-upgrade:hover { background: linear-gradient(135deg,rgba(108,99,255,.28),rgba(167,139,250,.18)); }
.upgrade-text { flex: 1; min-width: 0; overflow: hidden; }
.upgrade-text-title { font-size: .75rem; font-weight: 700; color: #a78bfa; white-space: nowrap; }
.upgrade-text-sub   { font-size: .68rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Footer ──────────────────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: .75rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.sidebar-user-row {
  display: flex; align-items: center; gap: 4px;
}
.user-info-link {
  display: flex; align-items: center; gap: 9px; flex: 1;
  text-decoration: none; border-radius: var(--radius);
  padding: 6px 8px; transition: background .15s;
  min-width: 0; overflow: hidden;
}
.user-info-link:hover { background: var(--surface-3); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent-light);
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 1.5px solid rgba(108,99,255,.3);
}
.user-meta { flex: 1; min-width: 0; overflow: hidden; }
.user-name { display: block; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-1); }
.user-role { display: block; font-size: .7rem; color: var(--text-3); }
.sidebar-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px;
  text-decoration: none;
  transition: color .15s, background .15s; flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent-light); background: var(--accent-dim); }
a.icon-btn:hover { color: var(--red); background: var(--red-dim); }

/* collapsed: hide actions row, show only avatar */
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-user-row { justify-content: center; }
.sidebar.is-collapsed:not(.is-hover-open) .sidebar-actions { display: none; }
.sidebar.is-collapsed:not(.is-hover-open) .user-info-link { padding: 0; flex: 0 0 auto; pointer-events: none; }

/* legacy compat */
.logout-btn { color: var(--text-3); display: flex; padding: 5px; border-radius: 6px; transition: color .15s, background .15s; flex-shrink: 0; }
.logout-btn:hover { color: var(--red); background: var(--red-dim); }
.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); display: flex; padding: 5px;
  border-radius: 6px; transition: color .15s, background .15s; flex-shrink: 0;
}
.theme-toggle:hover { color: var(--accent-light); background: var(--accent-dim); }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE TOP BAR
   ═══════════════════════════════════════════════════════════════════ */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 150;
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between; padding: 0 1rem;
}
.mobile-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1rem; }
.hamburger {
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; background: none; border: none; cursor: pointer;
  border-radius: 6px; padding: 6px; transition: background .15s;
}
.hamburger:hover { background: var(--surface-3); }
.hamburger span { display: block; height: 2px; background: var(--text-2); border-radius: 2px; transition: transform .2s, opacity .2s; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 190;
  backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.app-content {
  margin-left: var(--sidebar-w, 60px);
  min-height: 100vh;
  padding: 2rem 2.5rem;
  transition: margin-left .2s cubic-bezier(.4,0,.2,1);
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap;
}
.page-title    { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-2); font-size: .875rem; margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════════════
   STATS
   ═══════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-2); }
.stat-label { font-size: .75rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--text-3); margin-top: .25rem; }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-value.red   { color: var(--red);   }

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-family: var(--font); font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: opacity .15s, transform .1s, background .15s;
  white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: var(--surface-2); color: var(--text-1); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-outline   { background: transparent; color: var(--text-1); border: 1px solid var(--border-2); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost     { background: transparent; color: var(--text-2); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-1); }
.btn-success   { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,.25); }
.btn-success:hover { opacity: .85; }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { opacity: .85; }
.btn-sm  { padding: 5px 12px; font-size: .78rem; }
.btn-lg  { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; }

/* ═══════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600; letter-spacing: .02em; }
.badge-pending   { background: var(--blue-dim);   color: var(--blue);   }
.badge-overdue   { background: var(--red-dim);    color: var(--red);    }
.badge-paid      { background: var(--green-dim);  color: var(--green);  }
.badge-cancelled { background: var(--surface-3);  color: var(--text-3); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ═══════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap;
}
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  padding: 5px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2);
  font-family: var(--font); font-size: .82rem; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.filter-pill:hover { background: var(--surface-3); color: var(--text-1); }
.filter-pill.active { background: var(--accent-dim); border-color: rgba(108,99,255,.3); color: var(--accent-light); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 1.25rem;
  font-size: .72rem; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 1.25rem; font-size: .875rem;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* Legacy table (no class) */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 1.25rem; font-size: .72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 1.25rem; font-size: .875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
.td-client-name  { font-weight: 600; }
.td-client-email { color: var(--text-2); font-size: .82rem; }
.td-amount       { font-family: var(--mono); font-weight: 500; }
.td-actions      { display: flex; gap: 6px; }

.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-icon  { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
.empty-desc  { color: var(--text-2); font-size: .9rem; margin-bottom: 1.5rem; }

/* ═══════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════ */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.form-section { margin-bottom: 1.75rem; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title { font-size: .75rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row.full { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }

label { font-size: .85rem; font-weight: 500; color: var(--text-2); }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], select, textarea, .form-input {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--text); font-family: var(--font); font-size: .9rem;
  width: 100%; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus, .form-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
select option { background: var(--surface-2); color: var(--text); }
textarea { resize: vertical; min-height: 100px; }

.form-check { display: flex; align-items: flex-start; gap: 12px; padding: 1rem 1.25rem; background: var(--accent-dim); border: 1px solid rgba(108,99,255,.2); border-radius: var(--radius); cursor: pointer; }
.form-check input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.form-check-label { font-size: .9rem; color: var(--text); }
.form-check-label span { display: block; color: var(--text-2); font-size: .82rem; margin-top: 2px; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.errorlist { list-style: none; margin: 4px 0 0; }
.errorlist li { color: var(--red); font-size: .82rem; }

/* ═══════════════════════════════════════════════════════════════════
   DETAIL CARDS
   ═══════════════════════════════════════════════════════════════════ */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.detail-card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.detail-card-title { font-size: .95rem; font-weight: 700; }
.detail-rows { display: flex; flex-direction: column; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: .85rem 1.5rem; border-bottom: 1px solid var(--border); gap: 1rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row-label { font-size: .85rem; color: var(--text-2); flex-shrink: 0; }
.detail-row-value { font-size: .875rem; font-weight: 500; text-align: right; }
.amount-display { padding: 1.5rem; background: var(--accent-dim); border-bottom: 1px solid rgba(108,99,255,.15); }
.amount-label { font-size: .75rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.amount-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.04em; color: var(--accent-light); font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════════════
   REMINDER / CHASE
   ═══════════════════════════════════════════════════════════════════ */
.reminder-item { display: flex; align-items: flex-start; gap: 12px; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.reminder-item:last-child { border-bottom: none; }
.reminder-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.reminder-dot.sent    { background: var(--green); }
.reminder-dot.failed  { background: var(--red);   }
.reminder-dot.pending { background: var(--amber);  }
.reminder-type { font-size: .875rem; font-weight: 600; }
.reminder-meta { font-size: .8rem; color: var(--text-2); }
.chase-action-panel { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.overdue-warning { background: var(--red-dim); border: 1px solid rgba(239,68,68,.2); border-radius: var(--radius); padding: .75rem 1rem; font-size: .875rem; color: var(--red); margin: 0 1.5rem 1rem; }

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS (bottom-right)
   ═══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column-reverse;
  gap: .6rem;
  z-index: 9999;
  max-width: 380px;
  width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1.125rem;
  border-radius: 12px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.15);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
  border: 1px solid;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  animation: toastProgress linear forwards;
  animation-duration: var(--toast-duration, 4s);
  transform-origin: left;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(.95); max-height: 0; padding: 0; margin: 0; }
}
@keyframes toastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; line-height: 1.45; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: currentColor; opacity: .5; font-size: 1rem;
  line-height: 1; padding: 0; flex-shrink: 0; margin-top: 1px;
  transition: opacity .15s;
}
.toast-close:hover { opacity: 1; }
.toast-msg { flex: 1; line-height: 1.45; }
.toast-hiding { animation: toastOut .35s ease forwards; }

.toast-success {
  background: rgba(22,163,74,.12);
  border-color: rgba(34,197,94,.3);
  color: var(--green);
}
.toast-success::before { background: var(--green); }

.toast-error {
  background: rgba(220,38,38,.12);
  border-color: rgba(239,68,68,.3);
  color: var(--red);
}
.toast-error::before { background: var(--red); }

.toast-warning {
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.3);
  color: var(--amber);
}
.toast-warning::before { background: var(--amber); }

.toast-info {
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.3);
  color: var(--blue);
}
.toast-info::before { background: var(--blue); }

[data-theme="light"] .toast { box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08); }

/* ═══════════════════════════════════════════════════════════════════
   ONBOARDING
   ═══════════════════════════════════════════════════════════════════ */
.onboarding-banner {
  background: var(--accent-dim); border: 1px solid rgba(108,99,255,.25);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.onboarding-content { display: flex; align-items: center; gap: 1rem; }
.onboarding-icon  { font-size: 1.75rem; flex-shrink: 0; }
.onboarding-title { font-weight: 600; font-size: .95rem; margin-bottom: .5rem; }
.onboarding-steps { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.onboarding-step  { font-size: .85rem; color: var(--text-2); }
.onboarding-step a { color: var(--accent-light); text-decoration: none; font-weight: 500; }
.onboarding-step a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════
   CLIENT CARDS
   ═══════════════════════════════════════════════════════════════════ */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.client-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.client-card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.client-card-top { display: flex; align-items: flex-start; gap: .875rem; }
.client-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-dim); color: var(--accent-light);
  font-size: .9rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: -.02em;
}
.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 1rem; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-company { font-size: .8rem; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-email { font-size: .8rem; color: var(--accent-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-stats { display: flex; gap: 1rem; padding-top: .875rem; border-top: 1px solid var(--border); }
.client-stat { flex: 1; }
.client-stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: .2rem; }
.client-stat-value { font-size: .95rem; font-weight: 700; color: var(--text-1); }
.client-actions { display: flex; gap: .5rem; padding-top: .875rem; border-top: 1px solid var(--border); }
.client-actions .btn { flex: 1; justify-content: center; }

/* ═══════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--border); }
.text-muted  { color: var(--text-2); }
.text-mono   { font-family: var(--mono); }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-2       { gap: .5rem; }
.gap-3       { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════ */

/* ── Desktop default: sidebar in icon-only mode ───────────────────
   content has 60px left margin; sidebar floats over on hover       */
@media (min-width: 901px) {
  /* When pinned/expanded, content shifts naturally via --sidebar-w */
  /* Nothing extra needed — JS sets --sidebar-w = ICON_W or pinnedW */
}

/* ── Tablet/Mobile: full-screen overlay sidebar ────────────────── */
@media (max-width: 900px) {
  /* Hide desktop resize affordances */
  .sidebar-resize { display: none; }

  /* On mobile the sidebar always shows full labels */
  .sidebar,
  .sidebar.is-collapsed,
  .sidebar.is-hover-open {
    width: 260px !important;
    transform: translateX(-100%);
    box-shadow: none;
    padding: 1.25rem 1rem;
    backdrop-filter: none;
    /* Undo collapsed overrides so labels show in mobile overlay */
  }
  /* Force labels visible in mobile overlay */
  .sidebar .nav-label,
  .sidebar .brand-name,
  .sidebar .user-meta,
  .sidebar .sidebar-upgrade,
  .sidebar .sidebar-actions,
  .sidebar .sidebar-collapse-btn { display: flex !important; }
  .sidebar .nav-link { justify-content: flex-start !important; padding: 9px 10px !important; gap: 10px !important; }
  .sidebar .sidebar-brand { justify-content: flex-start !important; padding: .5rem .5rem 1.25rem !important; }
  .sidebar .user-info-link { justify-content: flex-start !important; padding: 6px 8px !important; pointer-events: auto !important; flex: 1 !important; }
  .sidebar .sidebar-footer { flex-direction: column !important; gap: .5rem !important; }
  .sidebar .sidebar-user-row { flex-direction: row !important; }
  /* Tooltips off on mobile */
  .sidebar .nav-link::after { display: none !important; }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }
  .mobile-topbar { display: flex; }
  .app-content   { margin-left: 0 !important; padding: 5rem 1.5rem 2rem; transition: none; }
  .detail-grid   { grid-template-columns: 1fr; }
  .form-row      { grid-template-columns: 1fr; }
  .page-title    { font-size: 1.35rem; }
}

/* ── Phone ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .app-content { padding: 5rem 1rem 2rem; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn, .page-header > div:last-child { width: 100%; justify-content: center; }
  .client-grid { grid-template-columns: 1fr; }
  .table-card  { border-radius: var(--radius); }
  .toast-container { bottom: 1rem; right: .75rem; left: .75rem; max-width: 100%; width: auto; }
  .filter-pills { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
}

/* ── Small phone ────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar, .sidebar.is-collapsed { width: 85vw !important; }
}
