/* ============================================================
   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;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;

  /* Light Theme Base */
  --bg-base:        #f8fafc;
  --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: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

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

.sidebar-collapse-btn:hover {
  background: var(--border);
  color: var(--text);
}

.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: var(--glass-bg);
}

.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;
}

.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: var(--text-muted);
  margin-top: 1px;
  font-weight: 500;
}

.sidebar-section {
  padding: 16px 12px 8px;
}

.sidebar-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-glass);
  color: var(--primary-light);
}

.nav-sub-items {
  padding-left: 12px;
  margin-top: 4px;
}

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

.nav-sub-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-sub-item.active {
  color: var(--primary-light);
  font-weight: 600;
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  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 var(--border);
}

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

.sidebar-user:hover { background: var(--glass-bg); }

.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: 600; 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: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 50;
}

.topbar-title { font-size: 1.05rem; font-weight: 700; flex:1; }

.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: var(--bg-raised); color: var(--text-primary); }
.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(--bg-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);
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.08); border-color: var(--glass-border); }

.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(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  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;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100px;
  border-radius: 50%;
  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: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}

.stat-icon svg { width:24px; height:24px; }
.stat-icon.primary { background: var(--primary-glass); color: var(--primary-light); }
.stat-icon.success { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.danger  { background: rgba(239,68,68,0.15);  color: var(--danger); }
.stat-icon.accent  { background: rgba(6,182,212,0.15);  color: var(--accent); }

.stat-info { flex: 1; overflow: hidden; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.1rem; font-weight: 800; line-height: 1.2; word-break: break-word; overflow-wrap: break-word; }
.stat-change { font-size: 0.75rem; margin-top: 4px; }
.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: linear-gradient(135deg, var(--primary), var(--primary-dark));
  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: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--glass-bg); color: var(--text-primary); border-color: var(--glass-border); }

.btn-ghost {
  background: var(--glass-bg);
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-raised); 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: var(--bg-surface);
  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: var(--glass-bg); }
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: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge-warning  { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-danger   { background: rgba(239,68,68,0.15);  color: #fca5a5; }
.badge-info     { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-primary  { background: var(--primary-glass);  color: var(--primary-light); }
.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;
}

.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: rgba(16,185,129,0.1);  border: 1px solid rgba(16,185,129,0.2);  color: #6ee7b7; }
.alert-error   { background: rgba(239,68,68,0.1);   border: 1px solid rgba(239,68,68,0.2);   color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.1);  border: 1px solid rgba(245,158,11,0.2);  color: #fcd34d; }
.alert-info    { background: rgba(59,130,246,0.1);  border: 1px solid rgba(59,130,246,0.2);  color: #93c5fd; }

/* ── 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); }
}

@media (max-width: 768px) {
  /* Mobile menu button visibility */
  .mobile-menu-btn { display: flex !important; }
  
  /* Sidebar */
  .sidebar { 
    transform: translateX(-100%); 
    width: 280px;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  
  /* 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 {
    opacity: 1;
    pointer-events: all;
  }
  
  /* Layout */
  .page-content { padding: 16px; }
  .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: 16px; }
  .card-glass { padding: 16px; }
  
  /* Topbar */
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 0.95rem; }
  .topbar-actions { gap: 8px; }
  .topbar-btn { width: 36px; height: 36px; }
  
  /* Tables */
  .table-wrapper { 
    border-radius: var(--radius); 
    margin: 0 -16px;
    width: calc(100% + 32px);
  }
  thead th { padding: 10px 12px; font-size: 0.7rem; }
  tbody td { padding: 10px 12px; font-size: 0.82rem; }
  
  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .form-control { padding: 12px 14px; font-size: 16px; } /* Prevent zoom on iOS */
  
  /* Buttons */
  .btn { padding: 12px 16px; font-size: 0.9rem; }
  .btn-sm { padding: 8px 12px; font-size: 0.85rem; }
  
  /* Filter bar */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  
  /* 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: 16px; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  :root { --topbar-h: 56px; }
  
  /* Layout */
  .page-content { padding: 12px; }
  .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: 260px; }
  
  /* Typography */
  .page-header h1 { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.8rem; }
  .card-title { font-size: 0.9rem; }
  
  /* Cards */
  .card { padding: 14px; border-radius: var(--radius); }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  
  /* Tables */
  .table-wrapper { margin: 0 -12px; width: calc(100% + 24px); }
  thead th { padding: 8px 10px; font-size: 0.68rem; }
  tbody td { padding: 8px 10px; font-size: 0.8rem; }
  
  /* Forms */
  .form-group { margin-bottom: 14px; }
  .form-label { font-size: 0.8rem; margin-bottom: 6px; }
  .form-control { padding: 11px 12px; }
  
  /* Buttons */
  .btn { padding: 11px 14px; font-size: 0.88rem; width: 100%; justify-content: center; }
  .btn-sm { padding: 8px 12px; font-size: 0.82rem; }
  .page-header .btn { width: auto; }
  .topbar-actions .btn { width: auto; }
  
  /* 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: 14px; gap: 12px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .stat-value { font-size: 1.3rem; }
  
  /* 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); }
}

/* ── 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); }
