/* ============================================================
   TellerPro SaaS — Design System
   ============================================================ */

/* ============================================================
   STYLING CONVENTIONS FOR NEW PAGES/REPORTS
   ============================================================

   CSS CLASSES TO USE:
   - Text colors: text-green-600, text-red-600, text-blue-600, text-purple-600, text-orange-600, text-teal-600
   - Badge colors: bg-green-100 text-green-800, bg-red-100 text-red-800, bg-yellow-100 text-yellow-800, bg-blue-100 text-blue-800, bg-purple-100 text-purple-800, bg-gray-100 text-gray-800
   - Footer rows: bg-gray-50
   - Utility classes: grid-2, grid-3, grid-4, gap-2, gap-3, gap-4, mb-6, p-4, text-sm, text-muted, text-2xl, font-bold, font-semibold, text-center, text-left, text-right

   LAYOUT STRUCTURE:
   - Page header: page-header class with back link, title, subtitle, export/print buttons
   - Filters: card with card-header, card-title, form-group, form-control classes
   - Summary cards: grid-4 layout with card class
   - Tables: data-table class with thead, tbody, tfoot, wrapped in overflow-x-auto

   HELPER FUNCTIONS:
   - Currency: money() function (NOT formatCurrency)
   - Numbers: number_format()
   - Escaping: e()
   - Dates: date() with strtotime()

   COMMON ELEMENTS:
   - Cards: card, card-header, card-title
   - Buttons: btn, btn-primary, btn-secondary, btn-outline, btn-ghost
   - Forms: form-group, form-label, form-control
   - Badges: badge with color classes
   - Links: text-blue-600 hover:underline
   - Pagination: paginationLinks() function

   CHART.JS:
   - Include CDN: <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary:        #6366f1; /* Indigo 500 */
  --primary-dark:   #4f46e5;
  --primary-light:  #818cf8;
  --primary-glass:  rgba(99,102,241,0.08);

  --accent:         #06b6d4;
  --accent-dark:    #0891b2;
  --accent-warm:    #f59e0b;
  --accent-rose:    #fb7185;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #06b6d4 58%, #10b981 100%);
  --gradient-soft:  linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(6,182,212,0.10) 50%, rgba(16,185,129,0.10) 100%);
  --gradient-warm:  linear-gradient(135deg, rgba(245,158,11,0.14) 0%, rgba(251,113,133,0.12) 100%);
  --gradient-card:  linear-gradient(145deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 62%, rgba(236,254,255,0.84) 100%);

  /* Light Theme Base */
  --bg-base:        #eff4ef;
  --bg-surface:     #ffffff;
  --bg-card:        #ffffff;
  --bg-raised:      #f1f5f9;
  --bg-hover:       #f8fafc;

  /* Glass Effects (adapted for light theme) */
  --glass-bg:       rgba(255,255,255,0.7);
  --glass-border:   rgba(0,0,0,0.06);
  --glass-blur:     blur(12px);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-accent:    #4f46e5;

  /* Borders */
  --border:         rgba(0,0,0,0.06);
  --border-soft:    rgba(0,0,0,0.03);

  /* Sidebar */
  --sidebar-w:      260px;
  --sidebar-bg:     #ffffff;

  /* Shadows (softer for light theme) */
  --shadow-sm:      0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:      0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:      0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow:    0 0 20px rgba(99,102,241,0.1);

  /* Transitions */
  --transition:     0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow:0.4s cubic-bezier(0.4,0,0.2,1);

  /* Radius */
  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full:9999px;

  /* Font */
  --font:       'Inter', system-ui, -apple-system, sans-serif;

  /* Layout */
  --topbar-h:   64px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:15px; scroll-behavior:smooth; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color:       var(--text-primary);
  line-height: 1.6;
  min-height:  100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }
img { max-width:100%; }
ul { list-style:none; }
button, input, select, textarea { font-family: inherit; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width:16px; height:16px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius:8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.6); border: 3px solid transparent; background-clip: content-box; }

/* Firefox Scrollbar */
* { scrollbar-width: thick; scrollbar-color: rgba(99,102,241,0.4) rgba(0, 0, 0, 0.05); }

/* ── App Layout ─────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.98) 52%, rgba(236,254,255,0.92) 100%);
  border-right: 1px solid #e2e8f0;
  box-shadow: 10px 0 28px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  color: #334155;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.88), rgba(238,242,255,0.72)),
    var(--gradient-soft);
}

.sidebar-collapse-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all var(--transition);
  z-index: 10;
}

.sidebar-collapse-btn:hover {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: var(--primary);
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
}

.sidebar.collapsed .sidebar-collapse-btn {
  right: 50%;
  transform: translate(50%, -50%);
}

.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-logo-content {
  transition: opacity var(--transition), width var(--transition);
  flex: 1;
}

.sidebar.collapsed .sidebar-logo-content {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0 !important;
  border-right: none;
}

.app-wrapper.sidebar-collapsed .main-content {
  margin-left: 0 !important;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .nav-sub-items,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-logo-sub {
  opacity: 0;
  width: 0;
  overflow: hidden;
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 14px 0;
  margin: 0 8px;
  border-radius: 8px;
  transition: background var(--transition);
}

.sidebar.collapsed .nav-item:hover {
  background: #eef2ff;
}

.sidebar.collapsed .nav-item svg {
  margin: 0;
  width: 24px;
  height: 24px;
}

.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 20px 0;
}

.sidebar.collapsed .sidebar-logo img,
.sidebar.collapsed .sidebar-logo > div:first-child {
  margin: 0 auto;
  width: 40px;
  height: 40px;
}

.sidebar.collapsed .sidebar-collapse-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 0 8px 8px 0;
  z-index: 200;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar.collapsed .sidebar-collapse-btn:hover {
  background: var(--primary-dark);
  width: 40px;
}

.sidebar-logo img {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.sidebar-logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo-sub {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 1px;
  font-weight: 500;
}

.sidebar-section {
  padding: 14px 12px 6px;
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  padding: 7px 10px;
  margin-bottom: 7px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(238,242,255,0.92), rgba(236,254,255,0.82));
  border: 1px solid rgba(199,210,254,0.42);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  color: #1e1b4b;
  box-shadow: inset 0 0 0 1px #dbe4ff;
}

.nav-item.active {
  background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 62%, #ecfdf5 100%);
  color: #3730a3;
  box-shadow: inset 0 0 0 1px #c7d2fe, 0 8px 18px rgba(99,102,241,0.12);
  font-weight: 700;
}

.nav-sub-items {
  padding-left: 10px;
  margin-top: 5px;
  margin-left: 10px;
  border-left: 1px solid #e2e8f0;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  padding-left: 24px;
  border-radius: 8px;
  color: #64748b;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
}

.nav-sub-item:hover {
  color: #1f2937;
  background: linear-gradient(135deg, #f8fafc, #f0fdfa);
}

.nav-sub-item.active {
  color: #3730a3;
  background: linear-gradient(135deg, #eef2ff, #ecfeff);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px #dbe4ff;
}

.nav-sub-item::before {
  content: '';
  position: absolute;
  left: 11px; top: 16px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item svg { width:18px; height:18px; flex-shrink:0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background: rgba(248,250,252,0.78);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background var(--transition);
  cursor: pointer;
}

.sidebar-user:hover { background: linear-gradient(135deg, #eef2ff, #ecfeff); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items:center; justify-content:center;
  font-weight: 700; font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 700; color: #1f2937; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(248,250,252,0.92)),
    var(--gradient-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 50;
  backdrop-filter: blur(14px);
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  flex:1;
  background: linear-gradient(135deg, #0f172a, #4f46e5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-actions { display:flex; align-items:center; gap:12px; }

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--border);
  display: flex; align-items:center; justify-content:center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  color: var(--text-secondary);
}

.topbar-btn:hover {
  background: linear-gradient(135deg, #eef2ff, #ecfeff);
  color: var(--primary-dark);
  border-color: #c7d2fe;
}
.topbar-btn svg { width:18px; height:18px; }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
  padding: 28px 28px 40px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--gradient-brand);
  opacity: 0.68;
  pointer-events: none;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(15,23,42,0.08); border-color: rgba(99,102,241,0.22); }

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle { font-size: 0.8rem; color: var(--text-muted); }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

.stat-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 72%, #ecfeff 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

.stats-grid .stat-card.stat-card-compact {
  flex-direction: column;
  gap: 10px;
}

.stats-grid .stat-card.stat-card-compact .stat-icon {
  width: 34px;
  height: 34px;
}

.stats-grid .stat-card.stat-card-compact .stat-info {
  width: 100%;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--gradient-brand);
  opacity: 0.05;
  transform: translate(30%, -30%);
}

.stat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.1); border-color: var(--glass-border); }

.stat-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}

.stat-icon svg { width:18px; height:18px; }
.stat-icon.primary { background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(6,182,212,0.16)); color: var(--primary-dark); }
.stat-icon.success { background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(6,182,212,0.12)); color: #047857; }
.stat-icon.warning { background: linear-gradient(135deg, rgba(245,158,11,0.20), rgba(251,113,133,0.12)); color: #b45309; }
.stat-icon.danger  { background: linear-gradient(135deg, rgba(239,68,68,0.16), rgba(251,113,133,0.14)); color: #b91c1c; }
.stat-icon.accent  { background: linear-gradient(135deg, rgba(6,182,212,0.18), rgba(99,102,241,0.12)); color: #0e7490; }

.stat-info { flex: 1; min-width: 0; overflow: hidden; }
.stat-label { font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; margin-bottom: 4px; }
.stat-value {
  --stat-value-size: clamp(0.78rem, 1.05vw, 1rem);
  display: block;
  max-width: 100%;
  font-size: var(--stat-value-size);
  font-weight: 800;
  line-height: 1.12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  letter-spacing: 0;
  word-break: keep-all;
  overflow-wrap: normal;
}
.stat-change { font-size: 0.68rem; margin-top: 5px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.45); }
.btn-primary:active { transform: translateY(0); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(6,182,212,0.3);
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(6,182,212,0.4); }

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}
.btn-success:hover { transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239,68,68,0.3);
}
.btn-danger:hover { transform: translateY(-1px); }

.btn-outline {
  background: rgba(255,255,255,0.72);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: linear-gradient(135deg, #eef2ff, #ecfeff); color: var(--primary-dark); border-color: #c7d2fe; }

.btn-ghost {
  background: linear-gradient(135deg, rgba(255,255,255,0.82), rgba(248,250,252,0.84));
  color: var(--text-secondary);
}
.btn-ghost:hover { background: linear-gradient(135deg, #f8fafc, #ecfeff); color: var(--text-primary); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 9px; width: 38px; height: 38px; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: all var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  background: var(--bg-hover);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: 0.76rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 0.76rem; color: var(--danger); margin-top: 5px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.input-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all var(--transition);
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.input-group-text {
  padding: 10px 12px;
  background: var(--bg-hover);
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex; align-items: center;
  white-space: nowrap;
}

.input-group .form-control { border: none; border-radius: 0; }
.input-group .form-control:focus { box-shadow: none; }

/* ── Toggle / Switch ────────────────────────────────────────── */
.form-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-input { display: none; }
.switch-track {
  width: 44px; height: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}
.switch-track::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: all var(--transition);
}
.switch-input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch-input:checked + .switch-track::after { left: 22px; background: #fff; }
.switch-label { font-size: 0.88rem; color: var(--text-secondary); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  padding: 13px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
}

tbody tr:hover { background: linear-gradient(135deg, rgba(238,242,255,0.54), rgba(236,254,255,0.48)); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 13px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td strong { color: var(--text-primary); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: linear-gradient(135deg, rgba(16,185,129,0.16), rgba(6,182,212,0.10)); color: #047857; }
.badge-warning  { background: linear-gradient(135deg, rgba(245,158,11,0.18), rgba(251,113,133,0.10)); color: #b45309; }
.badge-danger   { background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(251,113,133,0.12)); color: #b91c1c; }
.badge-info     { background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(6,182,212,0.12)); color: #1d4ed8; }
.badge-primary  { background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(6,182,212,0.10)); color: var(--primary-dark); }
.badge-muted    { background: rgba(100,116,139,0.15);color: var(--text-muted); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  display: flex; align-items:center; justify-content:center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.modal-close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease forwards;
  cursor: pointer;
}

.toast.removing { animation: slideOut 0.3s ease forwards; }

.toast-icon { width:20px; height:20px; flex-shrink:0; margin-top:1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    .toast-icon { color: var(--info); }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

.toast-title   { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0);   opacity: 1; }
  to   { transform: translateX(120%);opacity: 0; }
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  border: none;
  background: transparent;
}

.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab-btn:hover:not(.active) { color: var(--text-secondary); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Search / Filter Bar ────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-card.card {
  padding: 0;
  overflow: hidden;
}

.filter-card:hover {
  transform: none;
}

.filter-card > .card-header,
.filter-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.filter-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.filter-card-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}

.filter-card-title .card-title {
  margin: 0;
}

.filter-card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-panel {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
}

.filter-form {
  padding: 16px;
}

.filter-panel .filter-form {
  padding: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-grid-compact {
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(135px, 1fr)) auto;
}

.filter-grid .form-group {
  min-width: 0;
  margin-bottom: 0;
}

.filter-field-wide {
  grid-column: span 2;
}

.filter-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  align-self: end;
}

.filter-actions .btn,
.filter-grid .form-group > .btn,
.filter-grid .form-group > a.btn {
  min-height: 42px;
  justify-content: center;
  white-space: nowrap;
}

.filter-actions svg {
  width: 14px;
  height: 14px;
}

.filter-grid .form-group > .form-label:first-child:last-child {
  display: none;
}

.filter-grid .form-group .form-label:empty {
  display: none;
}

.filter-grid .form-group .form-label {
  line-height: 1.2;
}

.filter-search {
  position: relative;
}

.filter-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-search .form-control {
  padding-left: 38px;
}

.card form[method="GET"] > .responsive-grid,
.card form[method="get"] > .responsive-grid,
.card form[method="GET"] > .grid-3,
.card form[method="get"] > .grid-3,
.card form[method="GET"] > .grid-4,
.card form[method="get"] > .grid-4 {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 12px;
  align-items: end;
}

.card form[method="GET"] > .responsive-grid .form-group,
.card form[method="get"] > .responsive-grid .form-group,
.card form[method="GET"] > .grid-3 .form-group,
.card form[method="get"] > .grid-3 .form-group,
.card form[method="GET"] > .grid-4 .form-group,
.card form[method="get"] > .grid-4 .form-group {
  min-width: 0;
  margin-bottom: 0;
}

.card form[method="GET"] > .responsive-grid .form-group > .btn,
.card form[method="get"] > .responsive-grid .form-group > .btn,
.card form[method="GET"] > .responsive-grid .form-group > a.btn,
.card form[method="get"] > .responsive-grid .form-group > a.btn,
.card form[method="GET"] > .grid-3 .form-group > .btn,
.card form[method="get"] > .grid-3 .form-group > .btn,
.card form[method="GET"] > .grid-3 .form-group > a.btn,
.card form[method="get"] > .grid-3 .form-group > a.btn,
.card form[method="GET"] > .grid-4 .form-group > .btn,
.card form[method="get"] > .grid-4 .form-group > .btn,
.card form[method="GET"] > .grid-4 .form-group > a.btn,
.card form[method="get"] > .grid-4 .form-group > a.btn {
  min-height: 42px;
  justify-content: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-box.w-full {
  max-width: 100%;
}

.search-box svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}

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

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}

.pagination a, .pagination span {
  width: 36px; height: 36px;
  display: flex; align-items:center; justify-content:center;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.pagination a:hover { background: var(--glass-bg); color: var(--text-primary); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Alert ──────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert svg { width:18px; height:18px; flex-shrink:0; margin-top:1px; }
.alert-success { background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(236,253,245,0.92)); border: 1px solid rgba(16,185,129,0.2); color: #047857; }
.alert-error   { background: linear-gradient(135deg, rgba(239,68,68,0.10), rgba(255,241,242,0.92)); border: 1px solid rgba(239,68,68,0.2); color: #b91c1c; }
.alert-warning { background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(255,251,235,0.94)); border: 1px solid rgba(245,158,11,0.2); color: #b45309; }
.alert-info    { background: linear-gradient(135deg, rgba(59,130,246,0.11), rgba(236,254,255,0.92)); border: 1px solid rgba(59,130,246,0.2); color: #1d4ed8; }

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(99,102,241,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items:center; justify-content:center;
  z-index: 999;
}

/* ── Plan Usage Bar ────────────────────────────────────────── */
.usage-bar-wrap { margin-bottom: 16px; }
.usage-bar-label { display:flex; justify-content:space-between; font-size:0.78rem; color:var(--text-secondary); margin-bottom:5px; }
.usage-bar-track { height:6px; background:var(--bg-raised); border-radius:var(--radius-full); overflow:hidden; }
.usage-bar-fill  { height:100%; border-radius:var(--radius-full); background:linear-gradient(90deg,var(--primary),var(--accent)); transition:width 0.6s ease; }
.usage-bar-fill.warn   { background:linear-gradient(90deg,var(--warning),#f97316); }
.usage-bar-fill.danger { background:linear-gradient(90deg,var(--danger),#dc2626); }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg { width:56px; height:56px; margin-bottom:16px; opacity:0.4; }
.empty-state h3  { font-size:1rem; font-weight:600; color:var(--text-secondary); margin-bottom:6px; }
.empty-state p   { font-size:0.85rem; }

/* ── Plan badges (pricing page) ─────────────────────────────── */
.plan-popular {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 0.72rem; font-weight: 700;
  padding: 3px 14px; border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .filter-grid,
  .filter-grid-compact,
  .card form[method="GET"] > .responsive-grid,
  .card form[method="get"] > .responsive-grid,
  .card form[method="GET"] > .grid-3,
  .card form[method="get"] > .grid-3,
  .card form[method="GET"] > .grid-4,
  .card form[method="get"] > .grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .filter-field-wide {
    grid-column: span 2;
  }
  .filter-actions {
    grid-column: span 3;
  }
}

@media (max-width: 768px) {
  /* Mobile menu button visibility */
  .mobile-menu-btn { display: flex !important; }
  
  /* Sidebar */
  .sidebar { 
    transform: translateX(-100%); 
    width: min(82vw, 280px);
    z-index: 150;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-logo { padding: 14px 16px; min-height: 58px; }
  .sidebar-logo img,
  .sidebar-logo > div:first-child { width: 32px !important; height: 32px !important; }
  .sidebar-logo-text { font-size: 1rem; max-width: 150px; }
  .sidebar-logo-sub,
  .sidebar-collapse-btn,
  .sidebar-plan-usage { display: none !important; }
  .sidebar-section { padding: 10px 10px 4px; }
  .sidebar-section-label {
    padding: 6px 9px;
    margin-bottom: 6px;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
  }
  .nav-item { padding: 9px 10px; font-size: 0.88rem; gap: 8px; }
  .nav-sub-items { padding-left: 8px; margin-top: 2px; }
  .nav-sub-item { padding: 8px 10px 8px 24px; font-size: 0.82rem; }
  .nav-item svg { width: 17px; height: 17px; }
  .sidebar-footer { padding: 10px; margin-top: 8px; }
  .sidebar-user { padding: 8px 10px; }
  .user-avatar { width: 30px; height: 30px; }
  
  /* Sidebar overlay */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }
  .sidebar.open + .main-content + .sidebar-overlay,
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: all;
  }
  
  /* Layout */
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  
  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header > div { width: 100%; }
  .page-header .flex { justify-content: flex-start; }
  
  /* Cards */
  .card { padding: 12px; border-radius: var(--radius-sm); }
  .card-glass { padding: 12px; }
  .card-header { margin-bottom: 12px; }
  
  /* Topbar */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-title {
    min-width: 0;
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .topbar-btn { width: 34px; height: 34px; }
  .topbar-pos-btn { padding: 8px 10px; min-height: 34px; }
  
  /* Tables */
  .table-wrapper { 
    border-radius: var(--radius); 
    margin: 0 -12px;
    width: calc(100% + 24px);
  }
  thead th { padding: 8px 9px; font-size: 0.66rem; }
  tbody td { padding: 8px 9px; font-size: 0.78rem; }
  
  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .form-control {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 16px;
  } /* Prevent zoom on iOS */
  
  /* Buttons */
  .btn { padding: 10px 13px; font-size: 0.86rem; }
  .btn-sm { padding: 7px 10px; font-size: 0.8rem; }
  
  /* Filter bar */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  .filter-card > .card-header,
  .filter-card-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .filter-card-meta {
    white-space: normal;
  }
  .filter-form {
    padding: 12px;
  }
  .filter-grid,
  .filter-grid-compact,
  .card form[method="GET"] > .responsive-grid,
  .card form[method="get"] > .responsive-grid,
  .card form[method="GET"] > .grid-3,
  .card form[method="get"] > .grid-3,
  .card form[method="GET"] > .grid-4,
  .card form[method="get"] > .grid-4 {
    grid-template-columns: 1fr;
  }
  .filter-field-wide,
  .filter-actions {
    grid-column: auto;
  }
  .filter-actions {
    justify-content: stretch;
  }
  .filter-actions .btn {
    flex: 1;
  }
  
  /* Tabs */
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tab-btn { white-space: nowrap; }
  
  /* Pagination */
  .pagination a, .pagination span { width: 32px; height: 32px; font-size: 0.8rem; }
  
  /* Modals */
  .modal { 
    max-width: 95%; 
    margin: 16px;
    max-height: calc(100vh - 32px);
  }
  .modal-header { padding: 16px 20px; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 14px 20px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; }
  
  /* Toast notifications */
  .toast-container { 
    top: 10px; right: 10px; left: 10px; 
    max-width: none; 
  }
  .toast { padding: 12px 16px; }
  
  /* Alert */
  .alert { padding: 12px 16px; font-size: 0.85rem; }
  
  /* Stat cards */
  .stat-card { padding: 11px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-value { --stat-value-size: clamp(0.76rem, 3.5vw, 0.95rem); }
}

@media (max-width: 480px) {
  :root { --topbar-h: 56px; }
  
  /* Layout */
  .page-content { padding: 10px; }
  .stats-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  
  /* Sidebar */
  .sidebar { width: min(86vw, 250px); }
  .sidebar-section-label { display: none; }
  .sidebar-section { padding: 6px 9px; }
  .nav-item { padding: 9px 10px; font-size: 0.84rem; }
  .nav-sub-item { padding: 7px 9px 7px 24px; font-size: 0.79rem; }
  .sidebar-footer .user-role { display: none; }
  
  /* Typography */
  .page-header h1 { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.8rem; }
  .card-title { font-size: 0.9rem; }
  
  /* Cards */
  .card { padding: 11px; border-radius: var(--radius-sm); }
  .card-header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
  
  /* Tables */
  .table-wrapper { margin: 0 -10px; width: calc(100% + 20px); }
  thead th { padding: 7px 8px; font-size: 0.64rem; }
  tbody td { padding: 7px 8px; font-size: 0.76rem; }
  
  /* Forms */
  .form-group { margin-bottom: 11px; }
  .form-label { font-size: 0.8rem; margin-bottom: 6px; }
  .form-control { min-height: 40px; padding: 9px 11px; }
  .filter-card > .card-header,
  .filter-card-header {
    padding: 11px 12px;
  }
  .filter-form {
    padding: 11px;
  }
  .filter-actions {
    flex-direction: column;
  }
  
  /* Buttons */
  .btn { padding: 10px 12px; font-size: 0.84rem; width: 100%; justify-content: center; }
  .btn-sm { padding: 7px 10px; font-size: 0.78rem; }
  .page-header .btn { width: auto; }
  .topbar-actions .btn { width: auto; }
  .topbar-pos-btn { display: none; }
  .topbar-title { font-size: 0.84rem; }
  .mobile-menu-btn,
  .topbar-btn { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }
  
  /* Input group */
  .input-group { flex-direction: column; }
  .input-group-text { 
    border-right: 1px solid var(--border); 
    border-bottom: none;
    padding: 8px 12px;
  }
  .input-group .form-control { border-radius: var(--radius-sm); }
  
  /* Badges */
  .badge { padding: 2px 8px; font-size: 0.68rem; }
  
  /* Pagination */
  .pagination { gap: 4px; }
  .pagination a, .pagination span { width: 30px; height: 30px; font-size: 0.75rem; }
  
  /* Modals */
  .modal { 
    margin: 8px;
    max-height: calc(100vh - 16px);
    border-radius: var(--radius);
  }
  .modal-header { padding: 14px 16px; }
  .modal-title { font-size: 0.95rem; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  
  /* Toast */
  .toast { padding: 10px 14px; font-size: 0.8rem; }
  .toast-icon { width: 18px; height: 18px; }
  
  /* Stat cards */
  .stat-card { padding: 10px; gap: 9px; }
  .stat-icon { width: 30px; height: 30px; }
  .stat-icon svg { width: 17px; height: 17px; }
  .stat-value { --stat-value-size: clamp(0.74rem, 4.5vw, 0.92rem); }
  
  /* Empty state */
  .empty-state { padding: 40px 16px; }
  .empty-state svg { width: 48px; height: 48px; }
  
  /* Usage bar */
  .usage-bar-label { font-size: 0.75rem; }
  
  /* Sidebar footer */
  .sidebar-footer { padding: 12px; }
  .sidebar-user { padding: 8px 10px; }
  .user-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
  .user-name { font-size: 0.8rem; }
  .user-role { font-size: 0.68rem; }
  
  /* Search dropdown */
  .search-dropdown { max-height: 250px; }
  .search-item { padding: 8px 12px; }
}

/* Hide mobile menu button on desktop */
.mobile-menu-btn { display: none; }

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn, .topbar-btn, .nav-item, .nav-sub-item, .tab-btn {
    min-height: 44px;
    min-width: 44px;
  }
  .pagination a, .pagination span {
    min-width: 44px;
    min-height: 44px;
  }
  .topbar-btn {
    width: 44px;
    height: 44px;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar { width: 260px; }
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Responsive Utilities (Auto-Fit for All Pages) ─────────── */
.btn-responsive { display: inline-flex; align-items: center; gap: 8px; }
.btn-text { display: inline; }
.btn-icon-only { display: inline-flex; align-items: center; justify-content: center; }
.responsive-card { transition: padding var(--transition); }
.responsive-actions { display: flex; gap: 8px; }
.responsive-title { transition: font-size var(--transition); }
.responsive-date { white-space: nowrap; }

/* Table column visibility classes for responsive design */
.col-ref, .col-date, .col-location, .col-mode, .col-status, .col-items, .col-user, .col-actions {
  transition: display var(--transition);
}

/* Extra Small Screens (phones, < 576px) */
@media (max-width: 575.98px) {
  .page-header { flex-direction: column; align-items: flex-start !important; gap: 16px; }
  .responsive-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .btn-responsive { flex: 1; min-width: 0; justify-content: center; padding: 10px 12px; font-size: 0.8rem; }
  .btn-text { display: none; }
  .btn-responsive svg { margin: 0; }
  .responsive-title { font-size: 1.2rem !important; }
  .responsive-card { padding: 16px !important; border-radius: 8px !important; }
  .card-header { margin-bottom: 16px !important; }
  .card-title { font-size: 0.9rem !important; }
  
  /* Hide less important columns on mobile */
  .col-location, .col-mode, .col-user { display: none; }
  
  /* Compact table cells */
  thead th, tbody td { padding: 10px 8px !important; font-size: 0.8rem !important; }
  thead th { font-size: 0.7rem !important; letter-spacing: 0.05em !important; }
  .responsive-date { font-size: 0.75rem !important; }
  .badge { padding: 2px 8px !important; font-size: 0.68rem !important; }
  
  /* Touch-friendly action buttons */
  .btn-icon-only { padding: 8px !important; min-width: 36px !important; min-height: 36px !important; }
  .btn-icon-only svg { width: 16px !important; height: 16px !important; }
  
  /* Compact pagination */
  .responsive-pagination { padding: 12px !important; flex-direction: column; gap: 12px; }
  .pagination a, .pagination span { width: 32px !important; height: 32px !important; font-size: 0.8rem !important; }
}

/* Small Screens (landscape phones, 576px - 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .page-header { flex-wrap: wrap; gap: 12px; }
  .btn-responsive { padding: 10px 14px; font-size: 0.85rem; }
  .responsive-card { padding: 18px !important; }
  .col-location { display: none; }
  thead th, tbody td { padding: 11px 12px !important; }
  .btn-icon-only { padding: 7px !important; }
}

/* Medium Screens (tablets, 768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .responsive-card { padding: 20px !important; }
  thead th, tbody td { padding: 12px 14px !important; }
  .btn-responsive { padding: 10px 16px; }
}

/* Large Screens (desktops, >= 992px) */
@media (min-width: 992px) {
  .btn-text { display: inline; }
  .btn-responsive { padding: 10px 20px; }
}

/* Extra Large Screens (large desktops, >= 1200px) */
@media (min-width: 1200px) {
  .responsive-card { padding: 24px !important; }
}

/* Print Styles */
@media print {
  .page-header, .responsive-pagination, .col-actions { display: none !important; }
  .card { border: none !important; box-shadow: none !important; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.flex  { display: flex; }
.flex-1 { flex:1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
@media (min-width: 1024px) {
  .invoice-grid-layout { grid-template-columns: 3fr 1fr; }
  .purchase-grid-layout { grid-template-columns: 2fr 1fr; }
}
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary-color { color: var(--primary-light); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm  { font-size: 0.82rem; }
.text-xs  { font-size: 0.72rem; }
.text-lg  { font-size: 1.1rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-0  { padding: 0 !important; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }
.truncate { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.inline-block { display: inline-block; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.mt-6 { margin-top: 24px; }
.border-b { border-bottom: 1px solid var(--border); }
.border-soft { border-color: var(--border-soft); }
.border-t-2 { border-top: 2px solid; }
.border-primary { border-color: var(--primary); }
.text-primary { color: var(--primary); }
.search-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.search-item:hover { background: var(--bg-hover); }
