﻿:root {
  /* ── Surfaces ── */
  --bg: #0a0a0a;
  --surface: #121212;
  --surface2: #1a1a1a;
  --surface3: #222222;
  --border: #262626;
  --border-soft: #1f1f1f;

  /* ── Brand ── */
  --accent: #4a9fd4;
  --accent2: #ff6b35;
  --accent-glow: rgba(74, 159, 212, 0.25);

  /* ── Text ── */
  --text: #f0f0f0;
  --text-secondary: #a0a0a0;
  --muted: #777;
  --muted2: #555;
  --label: #777;

  /* ── Functional ── */
  --wa: #25d366;
  --blue: #4a9fd4;
  --red: #ff4444;
  --on-accent: #0a0a0a;

  /* ── Overlay & Shadows ── */
  --overlay: rgba(0, 0, 0, 0.78);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.7);

  /* ── Toolbar ── */
  --toolbar-bg: rgba(18, 18, 18, 0.92);

  /* ── Accent variants ── */
  --accent-dim: rgba(74, 159, 212, 0.14);
  --accent-subtle: rgba(74, 159, 212, 0.07);
  --accent-border: rgba(74, 159, 212, 0.28);
  --accent-surface: rgba(74, 159, 212, 0.06);

  /* ── Badges ── */
  --badge-default-bg: #1e1e1e;
  --badge-default-color: #707070;
  --badge-default-border: #2a2a2a;
  --badge-red-bg: rgba(255, 68, 68, 0.10);
  --badge-red-color: #f87171;
  --badge-red-border: rgba(255, 68, 68, 0.18);
  --badge-green-bg: rgba(99, 153, 34, 0.10);
  --badge-green-color: #84cc16;
  --badge-green-border: rgba(99, 153, 34, 0.18);
  --badge-warning-bg: rgba(239, 159, 39, 0.10);
  --badge-warning-color: #fbbf24;
  --badge-warning-border: rgba(239, 159, 39, 0.18);
  --badge-blue-bg: rgba(55, 138, 221, 0.10);
  --badge-blue-color: #60a5fa;
  --badge-blue-border: rgba(55, 138, 221, 0.18);

  /* ── Misc ── */
  --avatar-bg: #1e1e1e;
  --avatar-color: #888;
  --row-border: #1c1c1c;
  --card-header-border: #1e1e1e;
  --card-title-ui: #5a5a5a;
  --empty-color: #3a3a3a;
  --error-bg: rgba(255, 68, 68, 0.08);
  --error-border: rgba(255, 68, 68, 0.16);
  --error-color: #f87171;
  --pill-done-bg: rgba(100, 100, 100, 0.18);
  --cal-upcoming-color: #fff;

  /* ── Spacing Scale (4pt) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ── Radius Scale ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* ── Typography Scale ── */
  --text-xs: 10px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 26px;
  --text-2xl: 32px;
  --text-3xl: 40px;

  /* ── Transition ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-base: 200ms var(--ease-out);
  --transition-slow: 300ms var(--ease-out);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.55;
  font-size: var(--text-base);
  transition: background 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

/* ── Improved Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Selection ── */
::selection { background: var(--accent-dim); color: var(--accent); }

/* ── Focus Ring (global) ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

body.light-theme {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --surface3: #e8edf3;
  --border: #dde3ec;
  --border-soft: #e8edf3;
  --text: #0f172a;
  --text-secondary: #64748b;
  --muted: #64748b;
  --muted2: #94a3b8;
  --label: #475569;
  --on-accent: #ffffff;
  --overlay: rgba(15, 23, 42, 0.45);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 48px rgba(15, 23, 42, 0.14);
  --toolbar-bg: rgba(255, 255, 255, 0.94);
  --accent-dim: rgba(55, 138, 221, 0.12);
  --accent-subtle: rgba(55, 138, 221, 0.06);
  --accent-border: rgba(55, 138, 221, 0.28);
  --accent-surface: rgba(55, 138, 221, 0.04);
  --badge-default-bg: #f1f5f9;
  --badge-default-color: #64748b;
  --badge-default-border: #dde3ec;
  --badge-red-bg: #fef2f2;
  --badge-red-color: #dc2626;
  --badge-red-border: #fecaca;
  --badge-green-bg: #f0fdf4;
  --badge-green-color: #15803d;
  --badge-green-border: #bbf7d0;
  --badge-warning-bg: #fffbeb;
  --badge-warning-color: #b45309;
  --badge-warning-border: #fde68a;
  --badge-blue-bg: #eff6ff;
  --badge-blue-color: #2563eb;
  --badge-blue-border: #bfdbfe;
  --avatar-bg: #e2e8f0;
  --avatar-color: #475569;
  --row-border: #e8edf3;
  --card-header-border: #e8edf3;
  --card-title-ui: #94a3b8;
  --empty-color: #94a3b8;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-color: #dc2626;
  --pill-done-bg: rgba(100, 116, 139, 0.12);
  --cal-upcoming-color: #c2410c;
  --accent-readable: color-mix(in srgb, var(--accent) 55%, #0f172a);
  --accent-glow: rgba(55, 138, 221, 0.18);
  background: var(--bg);
}

/* ═══════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════ */
body.light-theme header { box-shadow: var(--shadow-sm); }
body.light-theme nav { box-shadow: var(--shadow-sm); }

body.light-theme .card,
body.light-theme .stat-card,
body.light-theme .booking-summary-card,
body.light-theme .booking-list-item,
body.light-theme .list-item,
body.light-theme .folder-list,
body.light-theme .canvas-container {
  box-shadow: var(--shadow-sm);
}

body.light-theme .stat-val,
body.light-theme .booking-price,
body.light-theme .booking-summary-value:not(.booking-summary-value-danger),
body.light-theme .rev-val,
body.light-theme .bar-val,
body.light-theme .svc-price,
body.light-theme .quote-amt,
body.light-theme .timer-display { color: var(--accent-readable); }

body.light-theme .tab-btn.active { color: var(--accent-readable); }
body.light-theme .booking-date { color: var(--accent-readable); }
body.light-theme .sticky-sub-header { background: var(--bg); }
body.light-theme .modal { box-shadow: var(--shadow-lg); }
body.light-theme .ai-window { box-shadow: var(--shadow-lg); }

body.light-theme input:focus,
body.light-theme select:focus,
body.light-theme textarea:focus,
body.light-theme .search-input:focus {
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

body.light-theme .pill-confirmed,
body.light-theme .pill-paid { background: var(--accent-dim); color: var(--accent-readable); }
body.light-theme .pill-pending { background: rgba(255, 107, 53, 0.12); }
body.light-theme .pill-done { background: var(--pill-done-bg); }
body.light-theme .pill-unpaid { background: rgba(220, 38, 38, 0.1); }
body.light-theme .pill-job,
body.light-theme .pill-active { background: rgba(55, 138, 221, 0.1); }
body.light-theme .pill-completed { background: rgba(46, 204, 113, 0.1); }
body.light-theme .pill-invoiced { background: rgba(155, 89, 182, 0.1); }
body.light-theme .pill-reviewed { background: var(--accent-dim); color: var(--accent-readable); }
body.light-theme .svc-item.selected { background: var(--accent-subtle); }

body.light-theme .quote-total-bar {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
}

body.light-theme .booking-list-item {
  background: linear-gradient(180deg, rgba(55, 138, 221, 0.03), transparent), var(--surface);
}
body.light-theme .booking-list-item:hover { border-color: var(--accent-border); }

body.light-theme .sync-badge.saving,
body.light-theme .sync-badge.connecting {
  background: var(--accent-subtle);
  border-color: var(--accent-border);
}

body.light-theme .cal-day.upcoming {
  background: rgba(255, 107, 53, 0.12);
  color: var(--cal-upcoming-color);
  border-color: rgba(255, 107, 53, 0.32);
  box-shadow: none;
}

body.light-theme .cal-day.worked {
  background: var(--accent-dim);
  color: var(--accent-readable);
}

body.light-theme .filter-btn.active { background: var(--accent-subtle); }
body.light-theme .btn-ghost:hover { background: var(--surface2); }
body.light-theme .vh-badge { background: var(--accent-dim); color: var(--accent-readable); }

body.light-theme .ai-fab { box-shadow: 0 4px 16px rgba(55, 138, 221, 0.22); }
body.light-theme .ai-fab:hover { box-shadow: 0 6px 24px rgba(55, 138, 221, 0.32); }
body.light-theme .ai-window {
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--accent-border);
}
body.light-theme .ai-header {
  background: linear-gradient(135deg, var(--accent-dim) 0%, transparent 100%);
}
body.light-theme .ai-send-btn:hover { background: var(--accent); color: #fff; }
body.light-theme .ai-input-wrap:focus-within { box-shadow: 0 0 0 3px var(--accent-subtle); }
body.light-theme .theme-swatch.active { border-color: var(--text); }
body.light-theme .section-order-icon { color: var(--accent-readable); }
body.light-theme .settings-card { box-shadow: var(--shadow-sm); }
body.light-theme .diag-item { background: var(--surface); }

/* ═══════════════════════════════════════════
   BASE FORM ELEMENTS
   ═══════════════════════════════════════════ */
input,
select,
textarea,
button {
  font-family: inherit;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--space-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(18, 18, 18, 0.92);
}

body.light-theme header {
  background: rgba(255, 255, 255, 0.92);
}

.header-undo-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.header-undo-btns .btn {
  padding: 6px 8px;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.header-undo-btns .btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

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

.logo img {
  height: 38px;
  width: 38px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.logo-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text);
}

.logo-sub {
  font-size: 8px;
  letter-spacing: 2.5px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.sync-badge {
  font-size: 10.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-base);
  user-select: none;
  white-space: nowrap;
}

.sync-badge.synced { color: var(--text); border-color: var(--border); }
.sync-badge.saving,
.sync-badge.connecting {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-subtle);
}
.sync-badge.offline {
  color: var(--red);
  border-color: rgba(255, 68, 68, 0.3);
  background: rgba(255, 68, 68, 0.08);
}

/* Live / status dots — static, no animation */
.sync-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.live-dot {
  background: #22c55e;
  box-shadow: 0 0 3px rgba(34,197,94,0.4);
}

.sync-dot.saving-dot {
  background: var(--accent);
}

.sync-dot.connecting-dot {
  background: var(--accent);
  opacity: 0.4;
}

.sync-dot.offline-dot {
  background: var(--red);
}

/* Brief flash when new data arrives */
.sync-badge.sync-flash {
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34,197,94,0.15);
  transition: border-color 0.3s, box-shadow 0.3s;
}

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: sticky;
  top: 60px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
  transition: top var(--transition-base);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(18, 18, 18, 0.88);
}

body.light-theme nav {
  background: rgba(255, 255, 255, 0.88);
}

nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 12px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  background: none;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  min-height: 44px;
}

.tab-btn i { font-size: 15px; }

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

i.fa-solid,
i.fa-brands,
i.fa-regular {
  font-size: 16px;
  display: inline-block;
  vertical-align: middle;
}

/* Nav zone divider — subtle vertical bar between sections */
.nav-divider {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 11px 4px;
  align-self: center;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ─── Mode Toggle Switch ─── */
.header-center {
  display: flex;
  align-items: center;
}

.mode-switch {
  display: inline-flex;
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  cursor: pointer;
  user-select: none;
}

.mode-option {
  padding: 6px 14px;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: 7px;
  color: var(--muted);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.mode-option i { font-size: 13px; }
.mode-option.active { color: var(--on-accent); }

.mode-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: 7px;
  transition: transform 0.25s var(--ease-in-out);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.mode-option[data-mode="business"].active ~ .mode-slider { transform: translateX(0); }
.mode-option[data-mode="personal"].active ~ .mode-slider { transform: translateX(100%); }

/* Header layout refinements */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 20px;
}

#invoice-container {
  display: none;
}

/* ─── SIDEBAR NAVIGATION LAYOUT ─── */
body.nav-sidebar nav {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: 220px;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-bottom: none;
  border-right: 1px solid var(--border);
  padding: var(--space-2) 0;
  z-index: 100;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--surface);
}

body.nav-sidebar nav::-webkit-scrollbar { display: block; width: 4px; }
body.nav-sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

body.nav-sidebar .tab-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  font-weight: 500;
  border-bottom: none;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 1px var(--space-2);
  width: calc(100% - 16px);
  text-align: left;
  transition: all var(--transition-fast);
}

body.nav-sidebar .tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

body.nav-sidebar .tab-btn.active {
  border-bottom-color: transparent;
  border-left-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

body.nav-sidebar .nav-divider {
  width: calc(100% - 32px);
  height: 1px;
  margin: var(--space-2) var(--space-4);
}

body.nav-sidebar main {
  margin-left: 220px;
  max-width: calc(1100px - 0px);
  width: calc(100% - 220px);
  padding: 0 24px 20px;
}

@media (max-width: 768px) {
  body.nav-sidebar nav { width: 180px; }
  body.nav-sidebar main { margin-left: 180px; width: calc(100% - 180px); }
}

@media (max-width: 599px) {
  body.nav-sidebar nav {
    position: static;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
    background: var(--surface);
  }
  body.nav-sidebar .tab-btn {
    width: auto;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin: 0;
    padding: 12px 14px;
  }
  body.nav-sidebar .tab-btn.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  body.nav-sidebar .nav-divider { width: 1px; height: 22px; margin: 11px 4px; }
  body.nav-sidebar main { margin-left: 0; width: 100%; }
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1;
  margin-top: 0;
  margin-bottom: 0;
  letter-spacing: -0.02em;
}

.section-sub {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: 0;
  line-height: 1.3;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--accent-border);
}

.card-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--card-title-ui);
  margin-bottom: var(--space-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.stat-negative::before,
.stat-card.is-negative::before {
  background: var(--red);
}

.stat-label {
  font-size: var(--text-xs);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.stat-val {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-negative,
.ui-stat-negative {
  color: var(--red);
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.ui-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--avatar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--avatar-color);
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.ui-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.3px;
  transition: all var(--transition-fast);
}

.ui-badge-default {
  background: var(--badge-default-bg);
  color: var(--badge-default-color);
  border: 0.5px solid var(--badge-default-border);
}

.ui-badge-red {
  background: var(--badge-red-bg);
  color: var(--badge-red-color);
  border: 0.5px solid var(--badge-red-border);
}

.ui-badge-green {
  background: var(--badge-green-bg);
  color: var(--badge-green-color);
  border: 0.5px solid var(--badge-green-border);
}

.ui-badge-warning {
  background: var(--badge-warning-bg);
  color: var(--badge-warning-color);
  border: 0.5px solid var(--badge-warning-border);
}

.ui-badge-blue {
  background: var(--badge-blue-bg);
  color: var(--badge-blue-color);
  border: 0.5px solid var(--badge-blue-border);
}

.ui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-5);
  gap: var(--space-3);
  color: var(--empty-color);
}

.ui-empty i { font-size: 32px; opacity: 0.6; }
.ui-empty span { font-size: var(--text-sm); }

.ui-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
  border-bottom: 0.5px solid var(--card-header-border);
}

.ui-card-title {
  font-size: var(--text-xs);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--card-title-ui);
  font-weight: 600;
}

.ui-list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 0.5px solid var(--row-border);
  transition: background var(--transition-fast);
}

.ui-list-row:last-child { border-bottom: none; padding-bottom: 0; }

.ui-list-row-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--label);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}

input,
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-base);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  outline: none;
  margin-bottom: var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent-border);
}

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

select option { background: var(--surface2); color: var(--text); }

textarea {
  resize: vertical;
  min-height: 70px;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
  letter-spacing: 0.2px;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

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

.btn-wa {
  background: var(--wa);
  color: #fff;
}

.btn-wa:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.25);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--error-bg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 11px;
  min-height: 32px;
}

.booking-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
  transition: border-color var(--transition-fast);
}

.booking-item:hover {
  border-color: var(--accent-border);
}

.booking-list-item {
  align-items: stretch;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0)), var(--surface);
  border-color: var(--border);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.booking-select {
  align-self: center;
  flex: 0 0 auto;
  height: 18px;
  margin: 0;
  width: 18px;
  accent-color: var(--accent);
}

.booking-date {
  font-size: 11px;
  color: var(--accent);
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  line-height: 1.5;
  flex-shrink: 0;
}

.booking-date small {
  color: var(--muted);
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.booking-info { flex: 1; min-width: 140px; }

.booking-name {
  font-weight: 700;
  font-size: var(--text-base);
  margin-bottom: 3px;
}

.booking-price {
  color: var(--accent);
  display: inline-block;
  font-weight: 800;
  margin-left: var(--space-2);
}

.booking-detail {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 2px;
}

.booking-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.booking-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.booking-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast);
}

.booking-summary-card:hover { border-color: var(--accent-border); }

.booking-summary-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.booking-summary-value {
  color: var(--accent);
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.booking-summary-value-danger { color: var(--red); }

.booking-search-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}

.booking-search-wrap i {
  color: var(--muted);
  left: 12px;
  pointer-events: none;
  position: absolute;
  top: 12px;
}

.booking-search-wrap .search-input { padding-left: 38px; }

.booking-controls {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  gap: var(--space-1);
}

.pill {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.pill-confirmed,
.pill-paid {
  background: var(--accent-dim);
  color: var(--accent);
}

.pill-pending {
  background: rgba(255, 107, 53, 0.14);
  color: var(--accent2);
}

.pill-done {
  background: var(--pill-done-bg);
  color: var(--muted);
}

.pill-unpaid {
  background: rgba(255, 68, 68, 0.12);
  color: var(--red);
}

.pill-job,
.pill-active {
  background: rgba(74, 159, 212, 0.14);
  color: var(--accent);
}

.pill-completed {
  background: rgba(46, 204, 113, 0.14);
  color: #4ade80;
}

.pill-invoiced {
  background: rgba(155, 89, 182, 0.14);
  color: #c084fc;
}

.pill-reviewed {
  background: var(--accent-dim);
  color: var(--accent);
}

.svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.svc-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.svc-item:hover { border-color: var(--accent-border); }

.svc-item.selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.svc-name { font-weight: 600; font-size: var(--text-sm); margin-bottom: 3px; }

.svc-price {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent);
}

.svc-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}

.quote-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.quote-amt {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.quote-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-family: 'DM Mono', monospace;
  font-size: var(--text-sm);
  white-space: pre-wrap;
  line-height: 1.7;
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.cal-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 700;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.cal-nav button:hover {
  border-color: var(--accent-border);
  background: var(--surface);
}

.cal-nav .cal-month-label {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
}

.cal-hdr {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 4px;
}

.cal-day-name {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid transparent;
  position: relative;
  flex-direction: column;
  gap: 2px;
  transition: all var(--transition-fast);
  min-height: 40px;
  cursor: pointer;
}

.cal-day:hover {
  border-color: var(--accent-border);
  background: var(--accent-surface);
}

.cal-day.worked {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 700;
}

.cal-day.upcoming {
  background: rgba(255, 107, 53, 0.16);
  color: var(--cal-upcoming-color);
  border-color: rgba(255, 107, 53, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.1);
  font-weight: 800;
}

.cal-day.upcoming::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.6);
}

.cal-day.today.upcoming {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(74, 159, 212, 0.3), 0 0 14px rgba(255, 107, 53, 0.15);
}

.cal-job-count {
  font-size: 9px;
  line-height: 1;
  color: var(--accent2);
  font-weight: 800;
}

.cal-day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.cal-day.faded { opacity: 0.2; }

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: border-color var(--transition-fast);
}

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

.list-info { flex: 1; }

.list-name {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 2px;
}

.list-sub {
  font-size: var(--text-sm);
  color: var(--muted);
}

.goal-bg {
  background: var(--surface2);
  border-radius: var(--radius-full);
  height: 12px;
  overflow: hidden;
  margin: var(--space-2) 0 6px;
}

.goal-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent2)));
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease-out);
}

.rev-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
}

.rev-row:last-child { border-bottom: none; }
.rev-row:hover { background: var(--accent-surface); }

.rev-label { color: var(--muted); }

.rev-val {
  font-weight: 700;
  color: var(--accent);
}

/* Period bar — shown above stats grid */
.rv-custom-picker {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.rv-custom-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.rv-custom-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 130px;
}

.rv-custom-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.rv-selects { display: flex; gap: 6px; }

.rv-selects select {
  flex: 1;
  margin-bottom: 0;
  padding: 8px 10px;
  font-size: var(--text-sm);
}

.rv-custom-arrow {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
  margin-top: 18px;
  flex-shrink: 0;
}

.rv-quick-presets { display: flex; flex-wrap: wrap; gap: 6px; }

.rv-preset-btn {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  transition: all var(--transition-fast);
}

.rv-preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.rv-custom-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  display: block;
}

.rv-period-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 4px;
  flex-wrap: wrap;
}

.rv-period-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 3px 10px;
  border-radius: 20px;
}

.rv-period-summary {
  font-size: 12px;
  color: var(--muted);
}

/* % change badge on stat cards */
.rv-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  vertical-align: middle;
}

.rv-change-up {
  background: rgba(100, 200, 80, 0.14);
  color: #4ade80;
}

.rv-change-down {
  background: rgba(255, 68, 68, 0.12);
  color: var(--red);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.bar-label {
  font-size: var(--text-sm);
  color: var(--muted);
  min-width: 100px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-bg {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 75%, var(--accent2)));
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease-out);
}

.bar-val {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent);
  min-width: 55px;
  text-align: right;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: overlay-in 0.2s var(--ease-out);
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s var(--ease-out);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: var(--space-5);
  letter-spacing: -0.02em;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition-base);
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  text-align: center;
  padding: var(--space-10) var(--space-5);
  color: var(--muted);
}

.empty-icon {
  font-size: 44px;
  margin-bottom: var(--space-2);
  opacity: 0.6;
}

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

.ml-auto { margin-left: auto; }

.filter-btn {
  padding: 7px 14px;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  transition: all var(--transition-fast);
  min-height: 36px;
}

.filter-btn:hover {
  border-color: var(--accent-border);
  color: var(--text);
}

.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-base);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  outline: none;
  margin-bottom: var(--space-4);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:hover { border-color: var(--accent-border); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.sticky-sub-header {
  position: sticky;
  top: 100px;
  background: var(--bg);
  z-index: 80;
  padding: var(--space-3) 0 2px 0;
  margin-bottom: var(--space-3);
  transition: top var(--transition-base);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 768px) {
  .sticky-sub-header { top: calc(56px + 42px); }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .sticky-sub-header { top: calc(60px + 40px); }
}

.loader {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: var(--text-base);
}

/* Strategy Center */
.strategy-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-5);
  height: calc(100dvh - 200px);
  min-height: 500px;
}

.folder-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.folder-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.folder-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.folder-item.active {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.folder-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}

.folder-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.folder-item:hover .folder-actions { opacity: 1; }

.canvas-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.canvas-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  z-index: 10;
}

.canvas-toolbar {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: var(--toolbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  padding: var(--space-2);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 100;
  box-shadow: var(--shadow-lg);
  max-height: 85%;
  overflow-y: auto;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-toolbar::-webkit-scrollbar { display: none; }

.toolbar-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  color: var(--muted);
  cursor: grab;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  padding-bottom: 4px;
}

.toolbar-drag-handle:active {
  cursor: grabbing;
}

.toolbar-drag-handle i {
  font-size: 10px;
  letter-spacing: 2px;
}

.tool-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.tool-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.tool-btn.color-indicator {
  border: 2px solid var(--border);
}

.tool-btn.active {
  background: var(--accent);
  color: var(--on-accent);
}

.canvas-area {
  flex: 1;
  position: relative;
  cursor: grab;
  overflow: hidden;
  touch-action: none;
}

.canvas-area:active {
  cursor: grabbing;
}

.canvas-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  width: 100%;
  height: 100%;
}

.canvas-content svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  width: 10000px;
  height: 10000px;
}

.canvas-content svg path {
  pointer-events: stroke;
  cursor: pointer;
}

.node {
  position: absolute;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: move;
  user-select: none;
  min-width: 120px;
  box-shadow: var(--shadow-md);
  z-index: 5;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.node.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-border);
}

.node-text {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  outline: none;
  min-height: 20px;
  cursor: text;
}

.node.node-sticky {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
}

.node.node-sticky .node-text { color: var(--on-accent); }

.node.priority-high {
  border-color: var(--accent2);
  background: rgba(255, 107, 53, 0.1);
}

.node.priority-med {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.node.priority-low {
  border-color: var(--accent-border);
  background: var(--accent-subtle);
}

.node-actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 5px;
}

.node-delete {
  position: static;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--red);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.node-add-child {
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.node-color-cycle {
  width: 20px;
  height: 20px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.node:hover .node-delete,
.node:hover .node-add-child,
.node:hover .node-color-cycle {
  opacity: 1;
}

.timer-display {
  font-family: 'DM Mono', monospace;
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  margin: var(--space-5) 0;
  letter-spacing: -0.03em;
}

.timer-history {
  margin-top: var(--space-5);
  max-height: 300px;
  overflow-y: auto;
}

/* Settings */
.settings-group {
  margin-bottom: var(--space-8);
}

.settings-group-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: var(--text-xs);
  font-weight: 700;
  gap: var(--space-2);
  letter-spacing: 1.2px;
  margin-bottom: var(--space-3);
  text-transform: uppercase;
}

.settings-group-label i {
  color: var(--accent);
  font-size: 13px;
}

.settings-card .card-title { margin-bottom: 0; }
.settings-card label { margin-top: 0; }

.settings-card-header {
  align-items: flex-start;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.settings-row {
  align-items: center;
  display: flex;
  gap: var(--space-4);
  justify-content: space-between;
}

.settings-row-stack {
  align-items: flex-start;
  flex-direction: column;
}

.settings-row-text { flex: 1; min-width: 0; }

.settings-row-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 3px;
}

.settings-row-desc {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  margin-bottom: 0;
}

.settings-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.settings-divider {
  background: var(--border);
  height: 1px;
  margin: 16px 0;
}

.settings-hint-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 0;
  margin-top: -8px;
}

.settings-hint {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 0;
}

.settings-hint a {
  color: var(--accent);
  text-decoration: none;
}

.settings-hint a:hover {
  text-decoration: underline;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.settings-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  height: 120px;
  margin-bottom: 12px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

.settings-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-toggle {
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  position: relative;
}

.settings-toggle input {
  height: 0;
  margin: 0;
  opacity: 0;
  position: absolute;
  width: 0;
}

.settings-toggle-track {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  display: block;
  height: 28px;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  width: 48px;
}

.settings-toggle-track::after {
  background: var(--muted);
  border-radius: 50%;
  content: '';
  height: 20px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform var(--transition-fast), background var(--transition-fast);
  width: 20px;
}

.settings-toggle input:checked + .settings-toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.settings-toggle input:checked + .settings-toggle-track::after {
  background: var(--accent);
  transform: translateX(20px);
}

.settings-toggle input:focus-visible + .settings-toggle-track {
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* Settings input auto-save styles */
.settings-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  max-width: 260px;
  min-width: 0;
  padding: 9px 12px;
  text-align: right;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}
.settings-input-short {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  max-width: 120px;
  min-width: 0;
  padding: 9px 12px;
  text-align: right;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-input-short:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

/* Currency select dropdown — dark theme */
.settings-input select,
select.settings-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}
select.settings-input optgroup {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 0;
}
select.settings-input option {
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  padding: 6px 8px;
}

.theme-swatch {
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  height: 36px;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  width: 36px;
}

.theme-swatch:hover {
  transform: scale(1.08);
}

.theme-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

body.light-theme .theme-swatch.active {
  border-color: var(--text);
}

.diag-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: var(--space-4) 0;
}

.diag-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--transition-fast);
}

.diag-item:hover { border-color: var(--accent-border); }

.diag-item-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  font-weight: 600;
  gap: 6px;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.diag-status {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
}

.diag-status-pending { color: var(--muted); }
.diag-status-ok { color: var(--badge-green-color); }
.diag-status-warn { color: var(--badge-warning-color); }
.diag-status-error { color: var(--error-color); }

.settings-subheading {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: var(--space-4) 0 var(--space-2);
  text-transform: uppercase;
}

.settings-subheading:first-child { margin-top: 0; }

.section-order-item {
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  transition: border-color var(--transition-fast);
}

.section-order-item:hover { border-color: var(--accent-border); }

.section-order-icon {
  color: var(--accent);
  flex-shrink: 0;
  text-align: center;
  width: 24px;
}

.section-order-actions {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  margin-left: auto;
}

body.light-theme .section-order-icon {
  color: var(--accent-readable);
}

body.light-theme .settings-card {
  box-shadow: var(--shadow-sm);
}

body.light-theme .diag-item {
  background: var(--surface);
}

/* Preview Mode */
body.preview-mode .preview-blur {
  display: inline-block;
  filter: blur(6px) !important;
  pointer-events: none !important;
  user-select: none !important;
}

/* Version History */
.vh-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.vh-item:hover {
  border-color: var(--accent-border);
  background: var(--surface);
}

.vh-meta { flex: 1; }

.vh-time {
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: 2px;
}

.vh-desc {
  font-size: 11px;
  color: var(--muted);
}

.vh-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}

/* ── AI Assistant Styles ───────────────────────────────────── */

/* FAB */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px var(--accent-glow);
  cursor: pointer;
  z-index: 800;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border: none;
  outline: none;
}

.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(74, 159, 212, 0.55);
}

.ai-fab:active { transform: scale(0.95); }

/* Notification dot on FAB */
.ai-fab-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent2);
  border: 2px solid var(--bg);
  display: none;
}

/* Window */
.ai-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100dvh - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--accent-border);
  z-index: 901;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s var(--ease-out), transform 0.22s var(--ease-out);
}

.ai-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Backdrop — mobile only, but defined globally */
.ai-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 900;
  opacity: 0;
  transition: opacity 0.22s ease;
}

body.ai-open .ai-backdrop {
  display: block;
  opacity: 1;
}

/* Header */
.ai-header {
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--accent-dim) 0%, transparent 60%), var(--surface2);
  flex-shrink: 0;
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

.ai-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ai-header-name {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--text);
}

.ai-header-status {
  font-size: 11px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.ai-header-status.thinking::before {
  animation: ai-status-pulse 1s infinite ease-in-out;
}

@keyframes ai-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Chat area */
.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scroll-behavior: smooth;
}

.ai-chat::-webkit-scrollbar {
  width: 4px;
}

.ai-chat::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Message bubbles */
.ai-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  animation: ai-msg-in 0.18s ease;
}

@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.ai-msg.bot {
  align-self: flex-start;
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

/* Markdown-lite inside bot bubbles */
.ai-msg.bot strong { color: var(--accent); font-weight: 700; }
.ai-msg.bot em { color: var(--muted); font-style: italic; }
.ai-msg.bot code {
  font-family: 'Courier New', monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.ai-msg.bot ul, .ai-msg.bot ol {
  margin: 6px 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ai-msg.bot p + p { margin-top: 6px; }

/* Typing indicator */
.ai-msg.bot.thinking {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
}

.ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: ai-typing 1.2s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-typing {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.4; }
  40%            { transform: scale(1);    opacity: 1; }
}

/* Date separator */
.ai-date-sep {
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface2);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

/* Input area */
.ai-input-area {
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.ai-input-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px var(--space-3) 5px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ai-input-toolbar::-webkit-scrollbar { display: none; }

.ai-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  min-height: 30px;
}

.ai-toolbar-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.ai-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}

.ai-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  transition: border-color var(--transition-fast);
}

.ai-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.ai-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  margin: 0;
  padding: 9px 0;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
}

.ai-input-wrap input::placeholder { color: var(--muted); }

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: background var(--transition-fast), transform 0.12s var(--ease-out);
}

.ai-send-btn:hover { filter: brightness(1.1); }
.ai-send-btn:active { transform: scale(0.92); }

/* Thread tabs */
.ai-tabs-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px 0;
  background: var(--surface2);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.ai-tabs-bar::-webkit-scrollbar { display: none; }

.ai-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 11px;
  border-radius: 8px 8px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
  transition: color 0.15s, background 0.15s;
  max-width: 120px;
  flex-shrink: 0;
  margin-bottom: -1px;
  background: transparent;
}

.ai-tab:hover { color: var(--text); background: var(--surface); }

.ai-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

.ai-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.ai-tab-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.12s;
  flex-shrink: 0;
}

.ai-tab-close:hover { color: var(--red); }

.ai-tab-new {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  margin-left: 2px;
}

.ai-tab-new:hover { color: var(--accent); background: var(--accent-dim); }

/* Memory panel */
.ai-memory-panel {
  display: none;
  flex-direction: column;
  gap: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  max-height: 200px;
  flex-shrink: 0;
}

.ai-memory-panel.open { display: flex; }

.ai-memory-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.ai-memory-hint {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-left: auto;
}

.ai-memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-memory-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 2px;
  line-height: 1.5;
}

.ai-memory-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.ai-memory-text {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

.ai-memory-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color 0.12s;
}

.ai-memory-del:hover { color: var(--red); }

.ai-memory-add {
  display: flex;
  gap: 6px;
  padding: 6px 10px 8px;
  border-top: 1px solid var(--border);
}

.ai-memory-add input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  margin: 0;
}

.ai-memory-add input:focus { border-color: var(--accent-border); }

.ai-memory-add button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Quick prompts */
.ai-quick-prompts {
  display: none;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-quick-prompts.open { display: flex; }

.ai-qp-chip {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.ai-qp-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Empty state */
.ai-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ai-empty-state i {
  font-size: 28px;
  color: var(--accent);
  opacity: 0.6;
}

/* Icon button in header */
.ai-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}

.ai-icon-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* Stop / clear buttons in header */
.ai-stop-btn {
  display: none;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 15px;
  transition: background 0.15s;
}

.ai-stop-btn:hover { background: rgba(255, 68, 68, 0.12); }

.ai-clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 13px;
  transition: color 0.15s, background 0.15s;
}

.ai-clear-btn:hover { color: var(--text); background: var(--surface); }

.ai-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 8px;
  font-size: 16px;
  transition: color 0.15s, background 0.15s;
}

.ai-close-btn:hover { color: var(--text); background: var(--surface); }

/* Glow overlay */
.ai-glow-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 799;
  box-shadow: inset 0 0 0px transparent;
  transition: box-shadow 0.6s ease;
}

.ai-glow-overlay.active {
  box-shadow: inset 0 0 80px rgba(74, 159, 212, 0.18);
  animation: ai-glow-pulse 2.5s infinite ease-in-out;
}

@keyframes ai-glow-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ============================================================
   RESPONSIVE DESIGN — full device coverage
   Mobile-first: base styles → tablet → desktop → wide
   ============================================================ */

/* ── Tablet (600px – 1023px) ─────────────────────────────── */
@media (min-width: 600px) and (max-width: 1023px) {
  header {
    padding: 0 20px;
    height: 60px;
  }

  nav {
    top: 60px;
    padding: 0 8px;
  }

  main {
    padding: 0 16px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .grid2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .booking-summary-strip {
    grid-template-columns: repeat(4, 1fr);
  }

  .modal {
    max-width: 540px;
    margin: 24px auto;
  }

  .strategy-grid {
    grid-template-columns: 200px 1fr;
    height: calc(100vh - 180px);
  }

  .svc-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ai-window {
    width: 400px;
    right: 20px;
    bottom: 84px;
  }

  /* Booking list — side-by-side on tablet */
  .booking-actions {
    flex-wrap: wrap;
    gap: 5px;
  }

  .rv-custom-row {
    flex-wrap: nowrap;
  }
}

/* ── Desktop (1024px+) ───────────────────────────────────── */
@media (min-width: 1024px) {
  header {
    padding: 0 32px;
  }

  nav {
    padding: 0 16px;
  }

  main {
    padding: 0 24px;
    max-width: 1200px;
  }

  .stats-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
  }

  .grid2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .booking-summary-strip {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  /* Booking list row — horizontal layout */
  .booking-list-item {
    flex-wrap: nowrap;
  }

  .booking-info {
    min-width: 200px;
  }

  .booking-actions {
    flex-wrap: nowrap;
    margin-left: auto;
    margin-top: 0;
  }

  .modal {
    max-width: 560px;
  }

  .strategy-grid {
    grid-template-columns: 260px 1fr;
    height: calc(100vh - 160px);
  }

  .svc-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .ai-window {
    width: 420px;
    right: 28px;
    bottom: 88px;
    height: 600px;
  }

  /* Wider filter bars don't wrap */
  .booking-controls {
    flex-wrap: nowrap;
  }

  .rv-custom-row {
    flex-wrap: nowrap;
  }

  .cal-nav {
    flex-direction: row;
  }

  .cal-nav button {
    width: auto;
  }
}

/* ── Wide screens (1400px+) ──────────────────────────────── */
@media (min-width: 1400px) {
  main {
    max-width: 1400px;
    padding: 0 40px;
  }

  .stats-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
  }

  .stat-val {
    font-size: 36px;
  }

  .grid2 {
    gap: 24px;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {

  /* Header adjustments */
  header {
    padding: 0 12px;
    height: 56px;
    /* Safe area for notched phones (landscape too) */
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .logo-name {
    font-size: 16px;
  }

  /* Navigation improvements */
  nav {
    padding: 0 12px;
    gap: 6px;
    top: 56px;
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: none;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .tab-btn {
    padding: 10px 8px;
    font-size: 11px;
    min-width: max-content;
    flex: 0 0 auto;
    justify-content: center;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    white-space: nowrap;
    text-align: center;
    line-height: 1.15;
  }

  .tab-btn i {
    font-size: 14px;
  }

  /* Main content adjustments */
  main {
    padding: 0 12px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .section-title {
    font-size: 24px;
    margin-bottom: 2px;
  }

  .section-sub {
    font-size: 12px;
    margin-bottom: 0;
  }

  /* Grid layouts for mobile */
  .grid2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Card adjustments */
  .card {
    padding: 16px;
    margin-bottom: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  /* Form improvements — prevents iOS zoom on focus */
  input,
  select,
  textarea {
    font-size: 16px;
    padding: 12px 13px;
  }

  /* Booking items mobile layout */
  .booking-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }

  .booking-date {
    min-width: auto;
    align-self: flex-start;
  }

  .booking-info {
    min-width: auto;
    width: 100%;
  }

  .booking-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .booking-actions .btn {
    flex: 1;
    min-width: 80px;
  }

  .booking-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Modal adjustments */
  .overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal {
    margin: 0;
    padding: 20px;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 100%;
  }

  .modal-title {
    font-size: 20px;
  }

  /* Button adjustments */
  .btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Table responsiveness */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Calendar mobile */
  .cal-nav {
    flex-direction: row;
    gap: 8px;
  }

  .cal-nav button {
    padding: 6px 12px;
  }

  /* Service grid mobile */
  .svc-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .svc-item {
    padding: 10px;
  }

  .svc-name {
    font-size: 12px;
  }

  .svc-price {
    font-size: 18px;
  }

  /* Dashboard cards mobile */
  .stat-val {
    font-size: 26px;
  }

  .stat-label {
    font-size: 9px;
  }

  /* Strategy grid stacks on mobile */
  .strategy-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .folder-list {
    max-height: 180px;
    overflow-y: auto;
  }

  /* Revenue custom picker */
  .rv-custom-row {
    flex-direction: column;
    gap: 10px;
  }

  .rv-custom-arrow {
    transform: rotate(90deg);
    margin-top: 0;
    align-self: center;
  }

  .ai-window {
    left: 10px;
    right: 10px;
    bottom: 82px;
    width: auto;
    max-width: none;
    height: min(560px, calc(100dvh - 108px));
    max-height: calc(100dvh - 108px);
    border-radius: 18px;
  }

  nav {
    -ms-overflow-style: none;
  }
}

@media (max-width: 480px) {

  /* Extra small screens */
  .section-title {
    font-size: 20px;
  }

  .logo-name {
    font-size: 14px;
  }

  .tab-btn {
    padding: 8px 6px;
    font-size: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-val {
    font-size: 22px;
  }

  .booking-actions .btn {
    flex: 1 1 45%;
    min-width: 70px;
  }

  .modal {
    padding: 16px;
    border-radius: 14px 14px 0 0;
  }

  .svc-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .booking-summary-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .booking-summary-value {
    font-size: 18px;
  }

  .quote-amt {
    font-size: 26px;
  }

  /* AI bottom sheet on small screens */
  .ai-window {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 75vh;
    max-height: 75vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .ai-window.open {
    transform: translateY(0);
    opacity: 1;
  }

  .ai-fab {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
  }

  /* Show backdrop on mobile */
  .ai-backdrop {
    display: block;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease;
  }

  body.ai-open .ai-backdrop {
    pointer-events: all;
    opacity: 1;
  }
}

/* ── Touch device optimizations ──────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .btn:active {
    transform: scale(0.98);
  }

  .tab-btn:hover {
    background: transparent;
  }

  /* 44px minimum touch targets (Apple HIG / WCAG) */
  .btn,
  .tab-btn,
  .filter-btn,
  .tool-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Larger tap targets for nav items */
  .tab-btn {
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Landscape phone ─────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    height: 48px;
  }

  nav {
    top: 48px;
  }

  .sticky-sub-header {
    top: calc(48px + 40px);
  }

  main {
    padding: 0 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .ai-window {
    height: min(320px, calc(100dvh - 100px));
    bottom: 60px;
  }

  .ai-fab {
    bottom: 10px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .modal {
    max-height: 94vh;
    border-radius: 12px;
    align-self: center;
  }

  .overlay {
    align-items: center;
  }
}


/* Extracted Inline Styles */
.extracted-style-1 {
  margin-bottom: 16px
}

.extracted-style-2 {
  margin-bottom: 0
}

.extracted-style-3 {
  margin-bottom: 8px;
  gap: 6px;
  flex-wrap: wrap
}

.extracted-style-4 {
  width: auto;
  margin-bottom: 0;
  padding: 4px 8px;
  height: 30px
}

.extracted-style-5 {
  font-weight: 700;
  font-size: 15px
}

.extracted-style-6 {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px
}

.extracted-style-7 {
  margin-top: 8px
}

.extracted-style-8 {
  display: none
}

.extracted-style-9 {
  font-size: 13px;
  font-weight: 600
}

.extracted-style-10 {
  font-size: 11px;
  color: var(--muted)
}

.extracted-style-11 {
  font-size: 40px;
  margin-bottom: 8px;
}

.extracted-style-12 {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px
}

.extracted-style-13 {
  margin-bottom: 12px;
  gap: 6px;
  flex-wrap: wrap
}

.extracted-style-14 {
  position: relative;
  height: 220px;
  width: 100%;
}

.extracted-style-15 {
  display: block;
}

.extracted-style-16 {
  display: none;
}

.extracted-style-17 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px
}

.extracted-style-18 {
  font-weight: 700
}

.extracted-style-19 {
  font-size: 12px;
  color: var(--muted);
  margin-right: 10px
}

.extracted-style-20 {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0
}

.extracted-style-21 {
  max-width: 500px;
  margin: 0 auto
}

.extracted-style-22 {
  justify-content: center;
  gap: 15px
}

.extracted-style-23 {
  margin-top: 20px
}

.extracted-style-24 {
  margin-bottom: 14px
}

.extracted-style-25 {
  margin-bottom: 0;
  max-width: 180px
}

.extracted-style-26 {
  justify-content: space-between
}

.extracted-style-27 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 0
}

.extracted-style-28 {
  margin-top: -6px;
  margin-bottom: 12px
}

.extracted-style-29 {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 0
}

.extracted-style-30 {
  color: var(--accent)
}

.extracted-style-31 {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border)
}

.extracted-style-32 {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px
}

.extracted-style-33 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px
}

.extracted-style-34 {
  font-size: 12px;
  font-family: monospace;
  background: var(--surface2);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px
}

.extracted-style-35 {
  gap: 10px
}

.extracted-style-36 {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.extracted-style-37 {
  width: 100%;
  height: 120px;
  margin-bottom: 12px;
  font-family: monospace;
  font-size: 12px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}

.extracted-style-38 {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px
}

.extracted-style-39 {
  color: var(--muted);
  font-size: 11px
}

.extracted-style-40 {
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 14px;
}

.extracted-style-41 {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.extracted-style-42 {
  font-size: 32px;
  color: var(--border);
  margin-bottom: 14px;
  cursor: pointer;
  display: flex;
  gap: 8px;
}

.extracted-style-43 {
  padding: 40px;
  background: white;
  color: black;
  font-family: 'DM Sans', sans-serif;
  width: 800px;
  position: absolute;
  top: -9999px;
}

.extracted-style-44 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 40px;
}

.extracted-style-45 {
  margin: 0;
  font-weight: 800;
  font-size: 28px;
}

.extracted-style-46 {
  margin: 0;
  color: #555;
}

.extracted-style-47 {
  text-align: right;
}

.extracted-style-48 {
  margin: 0;
  font-size: 20px;
}

.extracted-style-49 {
  margin-bottom: 30px;
}

.extracted-style-50 {
  margin: 0 0 10px 0;
  font-size: 16px;
  color: #555;
  text-transform: uppercase;
}

.extracted-style-51 {
  margin: 0;
  font-weight: 700;
  font-size: 18px;
}

.extracted-style-52 {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

.extracted-style-53 {
  border-bottom: 2px solid #222;
}

.extracted-style-54 {
  text-align: left;
  padding: 10px 0;
  font-size: 14px;
  color: #555;
  text-transform: uppercase;
}

.extracted-style-55 {
  text-align: right;
  padding: 10px 0;
  font-size: 14px;
  color: #555;
  text-transform: uppercase;
}

.extracted-style-56 {
  border-bottom: 1px solid #eee;
}

.extracted-style-57 {
  padding: 15px 0;
  font-weight: 600;
}

.extracted-style-58 {
  text-align: right;
  padding: 15px 0;
}

.extracted-style-59 {
  display: flex;
  justify-content: flex-end;
}

.extracted-style-60 {
  width: 300px;
}

.extracted-style-61 {
  display: flex;
  justify-content: space-between;
  padding-top: 15px;
  border-top: 2px solid #222;
  font-weight: 800;
  font-size: 20px;
}

.extracted-style-62 {
  margin-top: 60px;
  text-align: center;
  color: #888;
  font-size: 12px;
}

.extracted-style-63 {
  max-width: 540px
}

.extracted-style-64 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px
}

.extracted-style-65 {
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 16px
}

.extracted-style-66 {
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap
}

.extracted-style-67 {
  margin-bottom: 18px
}

.extracted-style-68 {
  font-weight: 800;
  font-size: 14px;
}

.extracted-style-69 {
  color: var(--accent);
  font-size: 14px
}

.extracted-style-70 {
  gap: 5px
}

.extracted-style-71 {
  display: none;
  color: var(--red)
}


/* Extracted Inline Styles (Pass 2) */
.extracted-style-100 {
  margin-left: auto;
  display: none
}

.extracted-style-101 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer
}

.extracted-style-102 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #42f590;
  border: none;
  cursor: pointer
}

.extracted-style-103 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #42b0f5;
  border: none;
  cursor: pointer
}

.extracted-style-104 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #b042f5;
  border: none;
  cursor: pointer
}

.extracted-style-105 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f54278;
  border: none;
  cursor: pointer
}

.extracted-style-106 {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f5a442;
  border: none;
  cursor: pointer
}

/* ================================================================
   RESPONSIVE — ALL DEVICES
   ================================================================ */

/* ── Phone (< 600px) ─────────────────────────────────────── */
@media (max-width: 599px) {
  header {
    padding: 0 12px;
    height: 52px;
  }

  .logo img {
    height: 28px;
  }

  .logo-name {
    font-size: 15px;
  }

  .logo-sub {
    font-size: 9px;
  }

  .mode-switch {
    font-size: 11px;
    padding: 2px 8px;
  }

  .header-center {
    display: none;
  }

  .header-right {
    gap: 4px;
  }

  .sync-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  nav {
    top: 52px;
    padding: 0 6px;
  }

  main {
    padding: 0 10px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .section-title {
    font-size: 18px;
  }

  .section-sub {
    font-size: 11px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-val {
    font-size: 20px;
  }

  .grid2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .booking-summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .booking-controls {
    flex-wrap: wrap;
    gap: 4px;
  }

  .filter-btn {
    font-size: 11px;
    padding: 5px 10px;
  }

  .booking-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .booking-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    align-self: flex-end;
  }

  .overlay.open {
    align-items: flex-end;
  }

  .svc-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .settings-row input,
  .settings-row select {
    width: 100%;
    max-width: 100%;
  }

  .settings-actions {
    flex-direction: column;
  }

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

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

  .theme-swatches {
    justify-content: flex-start;
  }

  .strategy-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100dvh - 180px);
  }

  .folder-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding: 8px;
    max-height: none;
  }

  .folder-item {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 8px 12px;
  }

  .canvas-toolbar {
    left: 4px;
    gap: 8px;
    padding: 6px;
    border-radius: 12px;
  }

  .tool-btn {
    width: 32px;
    height: 32px;
  }

  .rev-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .ai-window {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 74px;
    border-radius: 16px 16px 4px 4px;
  }

  .ai-fab {
    bottom: 16px;
    right: 12px;
    width: 48px;
    height: 48px;
  }

  .rv-custom-row {
    flex-direction: column;
  }

  .calendar-header {
    font-size: 14px;
  }

  .cal-day {
    font-size: 11px;
    padding: 4px 2px;
  }

  .card {
    padding: 14px 16px;
  }

  .card-title {
    font-size: 13px;
  }

  .list-item {
    flex-wrap: wrap;
    gap: 6px;
  }

  .list-item .btn {
    font-size: 10px;
  }

  /* Auth screen */
  #auth-screen-inner .card {
    max-width: 320px;
    padding: 20px 16px;
  }
}

/* ── Tablet (600px - 1023px) ──────────────────────────────── */
@media (min-width: 600px) and (max-width: 1023px) {
  main {
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .svc-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Desktop (1024px+) ────────────────────────────────────── */
@media (min-width: 1024px) {
  main {
    padding-bottom: calc(36px + env(safe-area-inset-bottom));
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .svc-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Extra large screens ──────────────────────────────────── */
@media (min-width: 1600px) {
  main {
    max-width: 1400px;
    margin: 0 auto;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

/* ── Touch-friendly ───────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .btn, button, .filter-btn, .tool-btn {
    min-height: 44px;
  }

  .list-item {
    padding: 12px 0;
  }

  input, select, textarea {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }
}

/* ── Safe area insets (iPhone notch / Dynamic Island) ────── */
@supports (padding: env(safe-area-inset-top)) {
  header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }

  nav {
    top: calc(56px + env(safe-area-inset-top));
  }

  main {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .modal {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ai-fab {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
