/* =====================================================
   AfterSolves Loyalty — Dashboard
   Design System & Styles
   ===================================================== */

/* ----- Design Tokens ----- */
:root {
  /* Colors */
  --bg: #FAFAFA;
  --bg-soft: #F4F4F5;
  --bg-elevated: #FFFFFF;
  --text: #000000;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #FFFFFF;
  --glass-blur: rgba(255, 255, 255, 0.6);

  /* Accents — subtle */
  --accent: #000000;
  --accent-hover: #1A1A1A;
  --success: #34C759;
  --success-soft: rgba(52, 199, 89, 0.12);
  --warning: #F5A623;
  --warning-soft: rgba(245, 166, 35, 0.12);
  --error: #FF3B30;
  --error-soft: rgba(255, 59, 48, 0.10);
  --info: #007AFF;
  --info-soft: rgba(0, 122, 255, 0.10);

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Shadows — very subtle */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.10), 0 8px 16px rgba(0, 0, 0, 0.04);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, system-ui, sans-serif;

  /* Layout */
  --sidebar-w: 260px;
  --topnav-h: 64px;
  --max-w: 1440px;

  /* Transitions */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.20); }

/* =====================================================
   App Shell
   ===================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
  z-index: 90;
}
.sidebar-backdrop.active { opacity: 1; visibility: visible; }

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t-slow);
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 14px 14px;
  gap: 14px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 0;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 14px; font-weight: 600; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text-tertiary); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.sidebar-close { display: none; padding: 6px; border-radius: var(--r-xs); color: var(--text-secondary); }
.sidebar-close:hover { background: var(--bg-soft); }

.workspace-switch { padding: 0 4px; }
.workspace-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.workspace-btn:hover { background: rgba(255, 255, 255, 0.9); border-color: var(--border-strong); }
.workspace-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2C2C2E, #000);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.workspace-meta { flex: 1; min-width: 0; text-align: left; }
.workspace-name { display: block; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-plan { display: block; font-size: 11px; color: var(--text-tertiary); }
.workspace-caret { color: var(--text-tertiary); flex-shrink: 0; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; padding: 4px 0; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .nav-icon { color: #fff; }
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: color var(--t-fast);
}
.nav-item:hover .nav-icon { color: var(--text); }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--bg-soft);
  color: var(--text-secondary);
}
.nav-item.active .nav-badge { background: rgba(255, 255, 255, 0.18); color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #6E6E73, #1D1D1F);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-email { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-settings {
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: background var(--t-fast), color var(--t-fast);
}
.user-settings:hover { background: var(--bg-soft); color: var(--text); }

/* =====================================================
   Main column
   ===================================================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* =====================================================
   Top Navigation
   ===================================================== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topnav-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: rgba(250, 250, 250, 0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.topnav-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topnav-center { display: flex; justify-content: center; min-width: 0; }
.topnav-right { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.menu-btn { display: none; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crumb { color: var(--text-tertiary); transition: color var(--t-fast); cursor: pointer; }
.crumb:hover { color: var(--text); }
.crumb.current { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--text-tertiary); opacity: 0.5; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--text); }
.icon-btn.has-dot .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--error);
  border: 2px solid var(--bg);
}

.topnav-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  transition: background var(--t-fast);
  color: var(--text-secondary);
}
.user-pill:hover { background: rgba(255, 255, 255, 0.95); }

/* Search */
.search {
  position: relative;
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 38px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.search:focus-within {
  border-color: var(--border-strong);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.04);
}
.search-icon { color: var(--text-tertiary); flex-shrink: 0; }
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
  min-width: 0;
}
.search input::placeholder { color: var(--text-tertiary); }
.search-kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-tertiary);
  line-height: 1;
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
  z-index: 60;
}
.search-results.active { opacity: 1; visibility: visible; transform: translateY(0); }
.search-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 8px 8px 4px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--t-fast);
}
.search-result-item:hover { background: var(--bg-soft); }
.search-result-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); flex-shrink: 0; }
.search-result-text { flex: 1; min-width: 0; }
.search-result-title { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 24px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

/* =====================================================
   Page Container
   ===================================================== */
.page {
  flex: 1;
  padding: 32px;
  max-width: 100%;
  overflow-x: hidden;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title-block { min-width: 0; }
.page-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
}
.page-subtitle { font-size: 14px; color: var(--text-secondary); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #fff; border-color: var(--border-strong); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); }
.btn-danger { background: var(--error-soft); color: var(--error); border-color: transparent; }
.btn-danger:hover { background: rgba(255, 59, 48, 0.16); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* =====================================================
   Cards
   ===================================================== */
.card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-solid {
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-subtitle { font-size: 12.5px; color: var(--text-tertiary); margin-top: 2px; }
.card-body { padding: 22px; }

/* =====================================================
   Stat cards
   ===================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat-card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
}
.stat-trend.up { color: #1A8245; background: var(--success-soft); }
.stat-trend.down { color: #C4281D; background: var(--error-soft); }
.stat-trend.flat { color: var(--text-tertiary); background: var(--bg-soft); }

/* =====================================================
   Badges & Pills
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--bg-soft);
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #1A8245; }
.badge-warning { background: var(--warning-soft); color: #B8740A; }
.badge-error { background: var(--error-soft); color: #C4281D; }
.badge-info { background: var(--info-soft); color: #0050B3; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Tier pills (colored backgrounds) */
.tier-bronze { background: rgba(180, 110, 60, 0.12); color: #8B4513; }
.tier-silver { background: rgba(120, 120, 130, 0.14); color: #4A4A52; }
.tier-gold { background: rgba(210, 170, 50, 0.14); color: #8B6914; }
.tier-platinum { background: rgba(80, 90, 110, 0.14); color: #3A4252; }
.tier-vip { background: rgba(20, 20, 22, 0.10); color: #1D1D1F; }

/* =====================================================
   Tables
   ===================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--card-solid);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 720px;
}
.data-table thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover { background: var(--bg-soft); }
.data-table .cell-strong { font-weight: 600; }
.data-table .cell-muted { color: var(--text-tertiary); }
.data-table .cell-secondary { color: var(--text-secondary); }
.data-table .sortable { cursor: pointer; user-select: none; }
.data-table .sortable:hover { color: var(--text); }
.sort-icon { display: inline-block; margin-left: 4px; opacity: 0.5; }
.sort-icon.active { opacity: 1; }

.cell-avatar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-avatar .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #C7C7CC, #8E8E93);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cell-avatar .avatar-name { display: flex; flex-direction: column; min-width: 0; }
.cell-avatar .name { font-weight: 500; color: var(--text); white-space: nowrap; }
.cell-avatar .sub { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.pagination-info { font-size: 12.5px; color: var(--text-tertiary); }
.pagination-controls { display: flex; gap: 4px; align-items: center; }
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover { background: var(--bg-soft); color: var(--text); }
.page-btn.active { background: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* =====================================================
   Forms
   ===================================================== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint { font-size: 11.5px; color: var(--text-tertiary); margin-top: 5px; }
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.form-textarea { height: auto; padding: 10px 14px; resize: vertical; min-height: 88px; line-height: 1.5; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-tertiary); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-strong);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.04);
}
.form-select {
  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'%3E%3Cpath d='M7 10l5 5 5-5' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 38px;
  height: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast);
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { transform: translateX(16px); background: #fff; }

/* Checkbox */
.checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
  background: #fff;
}
.checkbox.checked { background: var(--accent); border-color: var(--accent); }
.checkbox.checked svg { opacity: 1; }
.checkbox svg { opacity: 0; color: #fff; }

/* =====================================================
   Tabs
   ===================================================== */
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* Segmented (filters) */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  gap: 2px;
}
.segment {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.segment:hover { color: var(--text); }
.segment.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* =====================================================
   Filters bar
   ===================================================== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-input {
  height: 38px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
  min-width: 180px;
}
.filter-input:focus { border-color: var(--border-strong); background: #fff; }
.filter-input::placeholder { color: var(--text-tertiary); }

/* =====================================================
   Modals
   ===================================================== */
.modal-root { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: auto;
}
.modal-backdrop.active { opacity: 1; }
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: calc(100vh - 64px);
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.active { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal.lg { max-width: 720px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 0;
}
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.modal-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

/* =====================================================
   Toast notifications
   ===================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-base), transform var(--t-base);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-icon.success { color: var(--success); }
.toast-icon.error { color: var(--error); }
.toast-icon.info { color: var(--info); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.toast-message { font-size: 12.5px; color: var(--text-secondary); }

/* =====================================================
   Empty states
   ===================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: 13px; color: var(--text-tertiary); max-width: 320px; line-height: 1.5; margin-bottom: 16px; }

/* =====================================================
   Skeleton loaders
   ===================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 0%, rgba(255, 255, 255, 0.6) 50%, var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
.skeleton-card { height: 120px; border-radius: var(--r-lg); }

/* =====================================================
   Layout utilities
   ===================================================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-tertiary { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }

/* Section spacing */
section + section { margin-top: 28px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg-soft);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--t-slow);
}
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.error { background: var(--error); }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 250;
}

/* Chart container */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

/* Activity feed */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; color: var(--text); margin-bottom: 2px; }
.activity-meta { font-size: 11.5px; color: var(--text-tertiary); }

/* Timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 6px;
  width: 1.5px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--card-solid);
  border: 2px solid var(--text-tertiary);
}
.timeline-item.active::before { border-color: var(--accent); background: var(--accent); }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.timeline-meta { font-size: 11.5px; color: var(--text-tertiary); }

/* Code block */
.code-block {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  word-break: break-all;
  line-height: 1.5;
}
.code-inline {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
}

/* Avatar group */
.avatar-group { display: inline-flex; }
.avatar-group .avatar {
  margin-left: -8px;
  border: 2px solid #fff;
}
.avatar-group .avatar:first-child { margin-left: 0; }

/* Empty link */
.link { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border-strong); transition: text-decoration-color var(--t-fast); }
.link:hover { text-decoration-color: var(--accent); }

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
  z-index: 80;
}
.dropdown-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-xs);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast);
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-soft); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-soft); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-btn { display: flex; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 20px; }
  .topnav { padding: 0 16px; }
  .topnav-center { display: none; }
  .topnav { grid-template-columns: 1fr auto; }
}

@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 16px; }
  .page-title { font-size: 22px; }
  .card-pad, .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .modal { max-width: calc(100vw - 24px); border-radius: var(--r-lg); }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; max-width: none; width: 100%; }
  .breadcrumbs { font-size: 12px; }
  .topnav-right .icon-btn { width: 34px; height: 34px; }
  .segmented { width: 100%; overflow-x: auto; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .user-pill .user-avatar { width: 28px; height: 28px; }
  .user-pill svg { display: none; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .page { padding: 14px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions .btn { width: 100%; }
  .topnav { padding: 0 12px; height: 56px; }
  .topnav-left { gap: 8px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-input { width: 100%; min-width: 0; }
  .data-table thead th,
  .data-table tbody td { padding: 10px 12px; font-size: 12px; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; }
}

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

/* Print */
@media print {
  .sidebar, .topnav, .toast-container, .modal-root { display: none; }
  .app-shell { display: block; }
  .page { padding: 0; }
  .card, .stat-card { box-shadow: none; border: 1px solid #ccc; }
}

/* =====================================================
   Additional component styles
   ===================================================== */

/* Bar list (used in charts) */
.barlist { display: flex; flex-direction: column; gap: 14px; }
.barlist-item { display: flex; flex-direction: column; gap: 6px; }
.barlist-row { display: flex; justify-content: space-between; align-items: center; }
.barlist-label { font-size: 13px; font-weight: 500; color: var(--text); }
.barlist-value { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Avatar md */
.avatar.md { width: 36px; height: 36px; font-size: 12px; }

/* Settings nav active state */
.dropdown-item.active { background: var(--accent) !important; color: #fff !important; }

/* Card solid padded */
.card-solid.card-pad { padding: 16px; }

/* Tabs nav inside customer detail */
#customerTabs .tab { padding: 8px 14px; }

/* Make sure topnav menu-btn visible on mobile */
@media (max-width: 1024px) {
  .menu-btn { display: flex !important; }
}

/* Hide search kbd on small screens */
@media (max-width: 768px) {
  .search-kbd { display: none; }
  .search { max-width: 100% !important; }
}

/* Improve table responsiveness */
.table-wrap { -webkit-overflow-scrolling: touch; }

/* Settings sidebar */
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.settings-nav-item:hover { background: var(--bg-soft); color: var(--text); }
.settings-nav-item.active { background: var(--accent); color: #fff; }

/* Color input fix */
input[type="color"].form-input { padding: 4px; cursor: pointer; }

/* Checkbox in tables */
.data-table .checkbox { margin: 0 auto; }

/* Hover effect for clickable rows */
.data-table tbody tr[data-customer] { cursor: pointer; }

/* Voucher code style */
.code-inline { font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace; font-size: 11.5px; padding: 2px 7px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; color: var(--text); white-space: nowrap; }

/* Footer */
.footer {
  margin-top: 32px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}
