/**
 * ============================================================
 * Blue Tide Digital Studio — Design System
 * ============================================================
 * CSS Variables, tokens, components, utilities.
 * Light + Dark mode. 8px spacing scale. Inter font.
 * ============================================================
 */

/* ── Google Fonts ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── CSS Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens: Light Theme ───────────────────────── */
:root,
[data-theme="light"] {
  /* Brand */
  --brand-primary:     #0b3a66;
  --brand-accent:      #0077ff;
  --brand-gradient:    linear-gradient(135deg, #00bcd4, #0077ff);
  --brand-gradient-h:  linear-gradient(90deg, #00bcd4, #0077ff);

  /* Surfaces */
  --bg-app:            #f6f8fc;
  --bg-card:           #ffffff;
  --bg-sidebar:        rgba(255,255,255,0.85);
  --bg-input:          #ffffff;
  --bg-hover:          #f0f2f5;
  --bg-active:         #e8f0fe;

  /* Text */
  --text-main:         #111827;
  --text-secondary:    #6B7280;
  --text-muted:        #9CA3AF;
  --text-inverse:      #ffffff;

  /* Borders */
  --border-subtle:     rgba(17,24,39,0.06);
  --border-default:    rgba(17,24,39,0.1);

  /* Status colors */
  --success:           #22C55E;
  --success-bg:        #ECFDF5;
  --warning:           #F59E0B;
  --warning-bg:        #FFFBEB;
  --danger:            #EF4444;
  --danger-bg:         #FEF2F2;
  --info:              #3B82F6;
  --info-bg:           #EFF6FF;

  /* Accent (used in charts/badges) */
  --accent-primary:    #0077ff;
  --accent-secondary:  #00bcd4;

  /* Button */
  --btn-bg:            #f3f4f6;
  --btn-hover:         #e5e7eb;
  --btn-primary-bg:    var(--brand-primary);
  --btn-primary-hover: #0a2f52;

  /* Shadows */
  --shadow-xs:         0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:         0 2px 8px rgba(0,0,0,0.04);
  --shadow-card:       0 8px 24px rgba(0,0,0,0.05);
  --shadow-hover:      0 14px 36px rgba(0,0,0,0.08);
  --shadow-modal:      0 24px 64px rgba(0,0,0,0.12);
  --shadow-glow:       0 0 24px rgba(0,119,255,0.15);

  /* Typography */
  --font-main:         'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:         'SF Mono', 'Fira Code', monospace;

  /* Border Radius */
  --radius-xs:         6px;
  --radius-sm:         8px;
  --radius-md:         12px;
  --radius-lg:         16px;
  --radius-xl:         20px;
  --radius-pill:       999px;

  /* Spacing (8px scale) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Transitions */
  --transition-fast:   all 120ms ease;
  --transition-smooth: all 180ms ease;
  --transition-slow:   all 300ms ease;

  /* Sidebar width */
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;
  --right-panel-width: 360px;
}

/* ── Dark Theme ───────────────────────────────────────── */
[data-theme="dark"] {
  --bg-app:            #0f1117;
  --bg-card:           #1a1d26;
  --bg-sidebar:        rgba(26,29,38,0.92);
  --bg-input:          #252830;
  --bg-hover:          #252830;
  --bg-active:         #1e3a5f;

  --text-main:         #f0f2f5;
  --text-secondary:    #9CA3AF;
  --text-muted:        #6B7280;
  --text-inverse:      #111827;

  --border-subtle:     rgba(255,255,255,0.06);
  --border-default:    rgba(255,255,255,0.1);

  --btn-bg:            #252830;
  --btn-hover:         #2f323c;

  --shadow-card:       0 8px 24px rgba(0,0,0,0.2);
  --shadow-hover:      0 14px 36px rgba(0,0,0,0.3);
  --shadow-modal:      0 24px 64px rgba(0,0,0,0.4);
}

/* ── Base ─────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: var(--font-main);
  background: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Reduced motion */
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Layout ───────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--right-panel-width);
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: var(--sp-6) var(--sp-4);
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  z-index: 50;
  transition: width 0.3s cubic-bezier(0.22,1,0.36,1), padding 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 99px; }

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  padding: var(--sp-6) var(--sp-2);
}
.sidebar.collapsed .nav-text,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-header,
.sidebar.collapsed .sidebar-tree { display: none; }

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-2);
}

.brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}

.brand-text {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
}

.brand-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nav items */
.nav-section { display: flex; flex-direction: column; gap: var(--sp-1); }

.nav-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand-gradient);
  border-radius: 0 99px 99px 0;
}

.nav-item i { font-size: 1.125rem; flex-shrink: 0; }

.sidebar-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: var(--sp-4);
  border-left: 1px solid var(--border-subtle);
  margin-left: var(--sp-4);
}

.sidebar-tree .nav-item { font-size: 0.8125rem; padding: var(--sp-1) var(--sp-3); }

.sidebar-tree .nav-item i {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar-tree .workspace-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: 34px;
}

.sidebar-tree .workspace-item:hover {
  background: var(--btn-hover);
}

.sidebar-tree .workspace-item.active {
  background: var(--accent-primary);
  color: #fff;
}

.sidebar-tree .workspace-item.active i {
  color: #fff;
}

/* ── Workspace Page Styles ──────────────────────────────── */
.workspace-title-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.workspace-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.workspace-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.ws-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  text-align: center;
}

.ws-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.ws-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.ws-deal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-fast);
  cursor: pointer;
  gap: var(--sp-3);
}

.ws-deal-row:hover {
  background: var(--hover-bg);
  border-color: var(--accent-primary);
}

.ws-deal-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.ws-filter.active {
  background: var(--accent-primary);
  color: #fff;
}

/* Workspace Clients Grid */
.workspace-clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.ws-client-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  transition: var(--transition-fast);
}

.ws-client-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ws-client-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.ws-client-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.ws-client-stats {
  display: flex;
  gap: var(--sp-4);
}

.ws-client-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
}

#btn-sidebar-collapse {
  width: 28px; height: 28px; border: none; background: var(--btn-bg);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted);
  display: grid; place-items: center; transition: var(--transition-fast);
}
#btn-sidebar-collapse:hover { background: var(--btn-hover); color: var(--text-main); }

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  overflow-y: auto;
  max-height: 100vh;
}

/* ── Header ───────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
}

.search-container {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-10);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
  font-family: var(--font-main);
  font-size: 0.875rem;
  color: var(--text-main);
  transition: var(--transition-smooth);
  outline: none;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  box-shadow: 0 0 0 3px rgba(0,119,255,0.15);
  border-color: var(--accent-primary);
}

.search-icon {
  position: absolute;
  left: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.search-shortcut {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

/* Search Results Dropdown */
#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 100;
  display: none;
  max-height: 320px;
  overflow-y: auto;
}
#search-results.active { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  transition: var(--transition-fast);
}
.search-result-item:hover { background: var(--bg-hover); }

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

/* ── Card System ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ── Dashboard Grid ───────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-6);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* ── Revenue Section ──────────────────────────────────── */
.revenue-section { display: flex; flex-direction: column; gap: var(--sp-2); }

.revenue-header {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-main);
}

.big-number-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.big-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.growth-badge {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--btn-bg); color: var(--text-secondary); font-size: 0.6875rem; padding: 2px 8px; border-radius: var(--radius-pill); }
.badge-filled  { background: var(--brand-primary); color: white; }
.badge-dark    { background: var(--text-main); color: var(--text-inverse); font-size: 0.6875rem; padding: 2px 8px; border-radius: var(--radius-pill); }

.revenue-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.revenue-bar-container {
  display: flex;
  height: 48px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: visible;
  gap: 3px;
}

/* Segment tooltip */
.segment-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, 0);
  background: var(--text-main);
  color: var(--text-inverse);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.segment-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: var(--text-main);
}

/* ── Stat Cards ───────────────────────────────────────── */
#kpi-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
  cursor: pointer;
  animation: fadeSlideUp 0.5s ease both;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.stat-card:active { transform: translateY(-1px) scale(0.99); }

.stat-card-dark {
  background: var(--text-main);
  color: var(--text-inverse);
  border-color: transparent;
}
.stat-card-dark .text-secondary { color: rgba(255,255,255,0.5) !important; }
.stat-card-dark .text-muted { color: rgba(255,255,255,0.3) !important; }
.stat-card-dark .trend-down { color: #FCA5A5 !important; }
.stat-card-dark .trend-up { color: #86EFAC !important; }

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
}

.stat-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.trend-up   { color: var(--success); font-size: 0.75rem; font-weight: 600; margin-top: var(--sp-1); }
.trend-down { color: var(--danger);  font-size: 0.75rem; font-weight: 600; margin-top: var(--sp-1); }

/* ── Platform Row ─────────────────────────────────────── */
.platform-row {
  padding: var(--sp-2) 0;
  transition: var(--transition-fast);
  border-radius: var(--radius-sm);
}
.platform-row:hover { background: var(--bg-hover); padding: var(--sp-2); margin: 0 calc(-1 * var(--sp-2)); }

.platform-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

/* ── Chart Area ───────────────────────────────────────── */
.chart-tooltip {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: var(--text-inverse);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 10;
}

/* ── Right Panel ──────────────────────────────────────── */
.right-panel {
  background: var(--bg-app);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  border-left: 1px solid var(--border-subtle);
  overflow-y: auto;
  max-height: 100vh;
}

/* Tabs */
.tabs-row {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}

.tab-btn {
  cursor: pointer;
  padding: var(--sp-1) 0;
  position: relative;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition-fast);
  border: none;
  background: none;
  font-family: var(--font-main);
}

.tab-btn:hover { color: var(--text-secondary); }

.tab-btn.active {
  color: var(--text-main);
  font-weight: 700;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--brand-gradient-h);
  border-radius: 99px;
}

.tab-content { display: none; flex-direction: column; gap: var(--sp-4); }
.tab-content.active { display: flex; animation: fadeIn 0.2s ease; }

/* Sales person row */
.sales-person-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.sales-person-row:hover {
  background: var(--bg-hover);
}

.sales-person-row > .flex { width: 100%; }

.progress-mini { margin-top: var(--sp-1); }

/* Tags */
.tags-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.tag {
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-subtle);
}

/* Card platform highlight */
.card-platform-highlight {
  padding: var(--sp-6);
  border-radius: var(--radius-xl);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  background: var(--brand-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-card); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  background: var(--btn-bg);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-ghost:hover { background: var(--btn-hover); color: var(--text-main); }
.btn-ghost.active { background: var(--bg-active); color: var(--accent-primary); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm   { padding: var(--sp-1) var(--sp-3); font-size: 0.75rem; }
.btn-xs   { padding: 2px var(--sp-2); font-size: 0.6875rem; }
.btn-full { width: 100%; justify-content: center; }

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--btn-bg);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 1.125rem;
  position: relative;
}

.btn-icon:hover { background: var(--btn-hover); color: var(--text-main); }

/* ── Avatars ──────────────────────────────────────────── */
.avatar-xs { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.avatar-md { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.avatar-lg { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }

.avatars-row { display: flex; }
.avatars-row .avatar-sm { margin-left: -8px; border: 2px solid var(--bg-app); }
.avatars-row .avatar-sm:first-child { margin-left: 0; }

/* ── Notification Panel ───────────────────────────────── */
.notification-wrapper { position: relative; }

#notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-app);
  z-index: 1;
}

#notifications-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  z-index: 100;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

#notifications-panel.active { display: block; animation: fadeSlideDown 0.2s ease; }

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}

.notification-header h4 { font-size: 0.875rem; font-weight: 600; }

.notification-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  transition: var(--transition-fast);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
}

.notification-item:hover { background: var(--bg-hover); }
.notification-item.unread { background: var(--info-bg); }
[data-theme="dark"] .notification-item.unread { background: rgba(59,130,246,0.1); }

.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.notification-dot.success { background: var(--success); }
.notification-dot.warning { background: var(--warning); }
.notification-dot.info    { background: var(--info); }

/* ── User Dropdown ────────────────────────────────────── */
.user-menu-wrapper { position: relative; }

#user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  z-index: 100;
  display: none;
}

#user-dropdown.active { display: block; animation: fadeSlideDown 0.2s ease; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--text-main); }
.dropdown-item.active { color: var(--accent-primary); font-weight: 600; }

/* ── Filter Dropdown ──────────────────────────────────── */
.filter-wrapper { position: relative; }

.filter-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 50;
  display: none;
  padding: var(--sp-1);
}

.filter-dropdown.active { display: block; animation: fadeSlideDown 0.15s ease; }

.filter-item {
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.8125rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-item:hover { background: var(--bg-hover); }
.filter-item.selected { font-weight: 600; color: var(--accent-primary); background: var(--bg-active); }

/* ── Date Range Dropdown ──────────────────────────────── */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 50;
  display: none;
  padding: var(--sp-1);
}
.dropdown-panel.active { display: block; animation: fadeSlideDown 0.15s ease; }

/* ── Modal ────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#modal-overlay.active { display: block; opacity: 1; }

#modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  z-index: 201;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
  opacity: 0;
  transition: all 0.2s ease;
}

#modal.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title { font-size: 1.125rem; font-weight: 700; }

#modal-content { padding: var(--sp-6); }

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

/* ── Filter Drawer ────────────────────────────────────── */
#filter-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  height: 100vh;
  background: var(--bg-card);
  box-shadow: var(--shadow-modal);
  z-index: 150;
  transition: right 0.3s cubic-bezier(0.22,1,0.36,1);
  display: flex;
  flex-direction: column;
}

#filter-drawer.active { right: 0; }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-header h3 { font-size: 1rem; font-weight: 700; }

.drawer-body { padding: var(--sp-6); flex: 1; overflow-y: auto; }

/* ── Form Elements ────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.form-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--font-main);
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0,119,255,0.1);
}

select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m1 1.5 5 5 5-5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  font-size: 0.875rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

/* ── Table ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table thead tr {
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td { padding: var(--sp-3) var(--sp-4); font-size: 0.875rem; }

.table-row {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition-fast);
}

.table-row:hover { background: var(--bg-hover); }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Toast Notifications ──────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 300;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  max-width: 360px;
}

.toast.show { transform: translateX(0); }

.toast-success i { color: var(--success); }
.toast-warning i { color: var(--warning); }
.toast-danger  i { color: var(--danger); }
.toast-info    i { color: var(--info); }

/* ── Login Screen ─────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--sp-10);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border-subtle);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

/* ── Plans Grid ───────────────────────────────────────── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.plan-card { text-align: center; }
.plan-current { border-color: var(--accent-primary); box-shadow: var(--shadow-glow); }

.plan-features {
  list-style: none;
  padding: 0;
  text-align: left;
  font-size: 0.8125rem;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}

/* ── Balance Sheet Section ────────────────────────────── */
.bs-section {
  margin-bottom: var(--sp-4);
}

.bs-section:last-child { margin-bottom: 0; }

/* ── Deal Group (Deals Page) ──────────────────────────── */
.deal-group {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--sp-3);
}

.deal-group:last-child { border-bottom: none; }

/* ── Settings Grid ────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}

/* ── Activity Timeline ────────────────────────────────── */
.activity-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 8px;
  flex-shrink: 0;
}

.activity-dot.deal    { background: var(--info); }
.activity-dot.system  { background: var(--success); }
.activity-dot.revenue { background: #0077ff; }
.activity-dot.alert   { background: var(--warning); }

.activity-content { flex: 1; }
.activity-content > div:first-child { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: 0.8125rem; }

/* ── AI Styles ────────────────────────────────────────── */
.ai-icon {
  width: 32px;
  height: 32px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.125rem;
}

.ai-summary-card { border-left: 3px solid var(--accent-primary); }

.risk-item {
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}

.risk-item.high   { border-left-color: var(--danger);  background: var(--danger-bg); }
.risk-item.medium { border-left-color: var(--warning); background: var(--warning-bg); }
.risk-item.low    { border-left-color: var(--info);    background: var(--info-bg); }

[data-theme="dark"] .risk-item.high   { background: rgba(239,68,68,0.1); }
[data-theme="dark"] .risk-item.medium { background: rgba(245,158,11,0.1); }
[data-theme="dark"] .risk-item.low    { background: rgba(59,130,246,0.1); }

.ai-report-card { border-left: 3px solid var(--success); font-family: var(--font-mono); font-size: 0.8125rem; }

/* ── SPA Page Sections ────────────────────────────────── */
.page-section {
  display: none;
  animation: fadeSlideUp 0.35s ease both;
}

.page-section.active { display: block; }

/* ── Animations ───────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes staggerIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Stagger cards */
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 60ms; }
.stat-card:nth-child(3) { animation-delay: 120ms; }
.stat-card:nth-child(4) { animation-delay: 180ms; }
.stat-card:nth-child(5) { animation-delay: 240ms; }
.stat-card:nth-child(6) { animation-delay: 300ms; }

/* ── Sidebar Overlay (mobile) ─────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active { display: block; opacity: 1; }

.mobile-menu-btn { display: none !important; }

/* ── Utility Classes ──────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }

.text-xs    { font-size: 0.6875rem; }
.text-sm    { font-size: 0.8125rem; }
.text-base  { font-size: 0.875rem; }
.text-lg    { font-size: 1.125rem; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.text-main      { color: var(--text-main); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-primary   { color: var(--accent-primary); }

.clickable { cursor: pointer; }
.w-full    { width: 100%; }

/* ── Responsive ───────────────────────────────────────── */

/* ── Tablet landscape / small desktop ──────────────────── */
@media (max-width: 1200px) {
  .app-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .right-panel {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--sp-4);
    max-height: none;
    overflow-y: visible;
  }
  .plans-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Tablet portrait ───────────────────────────────────── */
@media (max-width: 900px) {
  #kpi-cards { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .details-grid { grid-template-columns: 1fr; }
  .workspace-stats { grid-template-columns: repeat(3, 1fr); }
  .workspace-clients-grid { grid-template-columns: repeat(2, 1fr); }
  .right-panel { padding: var(--sp-4); }
  .tabs-row { gap: var(--sp-3); }
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Layout — single column, no right panel overlap */
  .app-layout {
    grid-template-columns: 1fr;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Sidebar — off-screen drawer */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    transition: left 0.3s cubic-bezier(0.22,1,0.36,1);
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    padding: var(--sp-4) var(--sp-3);
  }
  .sidebar.active { left: 0; }

  /* Show hamburger menu */
  .mobile-menu-btn { display: flex !important; }

  /* Sidebar items — bigger touch targets */
  .nav-item {
    padding: var(--sp-2) var(--sp-3);
    min-height: 40px;
    font-size: 0.875rem;
  }
  .nav-header { padding: var(--sp-2) var(--sp-3); }

  .sidebar-tree {
    padding-left: var(--sp-3);
    margin-left: var(--sp-3);
  }
  .sidebar-tree .workspace-item {
    padding: var(--sp-2) var(--sp-3);
    min-height: 40px;
    font-size: 0.875rem;
  }

  /* Sidebar collapse button — hide on mobile */
  #btn-sidebar-collapse { display: none; }

  /* Right panel — stack below */
  .right-panel {
    grid-column: 1;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    max-height: none;
    overflow-y: visible;
    padding: var(--sp-4);
  }

  /* Header — row layout, compact */
  .header {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--sp-2);
    padding: 0;
  }

  .search-container {
    max-width: 100%;
    flex: 1;
    min-width: 0;
  }
  .search-shortcut { display: none; }
  .search-input { font-size: 0.8125rem; padding-left: var(--sp-8); }

  /* Header actions — compact */
  .header-actions {
    gap: var(--sp-2);
    flex-shrink: 0;
  }
  .avatars-row { display: none; }
  #btn-export span { display: none; }

  /* Main content — tighter padding */
  .main-content {
    padding: var(--sp-3);
    max-height: none;
    gap: var(--sp-4);
  }

  /* KPI cards — single column */
  #kpi-cards { grid-template-columns: 1fr; }

  /* Dashboard grid — force full width */
  .dashboard-grid {
    gap: var(--sp-3);
    grid-template-columns: 1fr;
  }
  .dashboard-grid > * {
    grid-column: span 1 !important;
  }

  /* Page title */
  .page-title { font-size: 1.25rem; }
  .big-number { font-size: 1.75rem; }

  /* Revenue bar — allow wrap */
  .big-number-row {
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  /* Card header rows — wrap on small screens */
  .card > .flex.justify-between {
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  /* Revenue meta text — wrap */
  .revenue-meta { word-break: break-word; }

  /* Plans */
  .plans-grid { grid-template-columns: 1fr; }

  /* Tables — horizontal scroll */
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table th,
  .data-table td { white-space: nowrap; padding: var(--sp-2) var(--sp-3); font-size: 0.8125rem; }

  /* Cards — tighter padding */
  .card { padding: var(--sp-4); border-radius: var(--radius-md); }

  /* Financial stats rows — wrap */
  .flex.gap-6 { flex-wrap: wrap; }

  /* Notifications panel — full-ish width */
  #notifications-panel { width: calc(100vw - 24px); right: -8px; max-height: 60vh; }

  /* Modal — better mobile sizing */
  #modal { width: calc(100% - 24px); max-width: none; max-height: 85vh; }

  /* Filter drawer — fit screen */
  #filter-drawer { width: calc(100vw - 40px); max-width: 320px; }

  /* Toast — full width */
  #toast-container { bottom: var(--sp-3); right: var(--sp-3); left: var(--sp-3); }
  .toast { max-width: 100%; }

  /* Workspace mobile */
  .workspace-stats { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
  .workspace-stats .ws-stat-card:last-child { grid-column: 1 / -1; }
  .workspace-clients-grid { grid-template-columns: 1fr; }

  /* Financial stats flex rows */
  .flex.gap-4 { flex-wrap: wrap; gap: var(--sp-3); }
  .ws-deal-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }
  .ws-deal-meta {
    width: 100%;
    justify-content: space-between;
  }
  .workspace-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }
  .workspace-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  #workspace-status-filters {
    flex-wrap: wrap;
    gap: var(--sp-1);
  }
  #workspace-status-filters .ws-filter {
    font-size: 0.75rem;
    padding: var(--sp-1) var(--sp-2);
  }

  /* Stat cards — tighter */
  .stat-card { padding: var(--sp-4); }
  .stat-card-value { font-size: 1.25rem; }

  /* Sales person row */
  .sales-person-row { padding: var(--sp-2); }

  /* Right panel tabs — scrollable */
  .tabs-row {
    gap: var(--sp-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sp-1);
  }
  .tab-btn { white-space: nowrap; font-size: 0.8125rem; }

  /* Login card — respect small screens */
  .login-card { margin: var(--sp-4); padding: var(--sp-6); max-width: calc(100vw - 32px); }

  /* Org switcher */
  #org-switcher-dropdown { width: 100%; }

  /* Deal rows on mobile */
  .deal-group .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: var(--sp-2);
  }

  /* Progress bars — ensure visible */
  .progress-mini { min-width: 80px; }

  /* AI insights cards */
  .ai-summary-card { padding: var(--sp-3); }
  .risk-item { padding: var(--sp-2); font-size: 0.8125rem; }
}

/* ── Small phones ──────────────────────────────────────── */
@media (max-width: 480px) {
  .main-content { padding: var(--sp-2); gap: var(--sp-3); }
  .header-actions { gap: var(--sp-1); }
  .btn-icon { width: 32px; height: 32px; font-size: 1rem; }
  .login-card { margin: var(--sp-2); padding: var(--sp-4); }
  .page-title { font-size: 1.125rem; }
  .big-number { font-size: 1.5rem; }
  .card { padding: var(--sp-3); }
  .card-title { font-size: 0.8125rem; }
  #kpi-cards { gap: var(--sp-2); }
  .stat-card { padding: var(--sp-3); }
  .stat-card-value { font-size: 1.125rem; }

  /* Workspace — single col stats */
  .workspace-stats { grid-template-columns: 1fr; }
  .ws-stat-card { padding: var(--sp-3); }
  .ws-stat-value { font-size: 1rem; }
  .ws-client-stats { flex-wrap: wrap; gap: var(--sp-2); }

  /* Revenue bar segments — stack label */
  .revenue-bar-container { height: 36px; }

  /* Modal */
  #modal { width: calc(100% - 16px); }
  .modal-header { padding: var(--sp-3) var(--sp-4); }
  #modal-content { padding: var(--sp-4); }

  /* Filter drawer — full screen */
  #filter-drawer { width: 100vw; max-width: 100vw; right: -100vw; }
  #filter-drawer.active { right: 0; }

  /* User dropdown */
  #user-dropdown { width: calc(100vw - 24px); right: -8px; }

  /* Search results */
  #search-results { max-height: 240px; }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
  .sidebar, .right-panel, .header, #toast-container, #modal-overlay, #modal, #filter-drawer, #login-screen { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .main-content { max-height: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
