/* ============================================
   ContaFlow — SaaS Accounting Dashboard
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a56db;
  --primary-dark: #1240a8;
  --primary-light: #e1ecff;
  --primary-50: #eff6ff;
  --accent: #0ea5e9;
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --info: #6366f1;

  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-hover: #f9fafb;
  --border: #e5e7eb;
  --border-light: #f3f4f6;

  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #1a56db;
  --sidebar-hover: #1e293b;
  --sidebar-width: 260px;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 36px; height: 36px;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 16px;
  overflow: hidden;
}

.sidebar-brand { font-size: 18px; font-weight: 700; color: #f1f5f9; letter-spacing: -0.3px; }
.sidebar-brand span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-section { padding: 8px 20px; margin-top: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #475569; font-weight: 600; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
  background: rgba(26, 86, 219, 0.12);
  color: #ffffff;
  border-left-color: var(--primary);
}
.nav-item.active .nav-icon { color: var(--primary); }

.nav-icon { width: 20px; height: 20px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: #64748b; }

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: 6px;
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); }

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

.topbar-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }
.topbar-btn .badge {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.page-content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); background: var(--surface-hover); }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.income { background: var(--success-bg); color: var(--success); }
.stat-icon.expense { background: var(--danger-bg); color: var(--danger); }
.stat-icon.invoice { background: var(--primary-light); color: var(--primary); }
.stat-icon.client { background: var(--warning-bg); color: var(--warning); }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; line-height: 1.2; }
.stat-change { font-size: 11px; margin-top: 4px; font-weight: 500; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Data Grid ── */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.chart-container { position: relative; height: 300px; }

/* ── Tables ── */
.table-responsive { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-default { background: #f3f4f6; color: #374151; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

.btn-group { display: flex; gap: 8px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { min-height: 80px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-append {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: none;
  cursor: pointer; color: var(--text-muted);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-lg { max-width: 800px; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-box {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  transition: border-color var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
}
.pagination button {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Toast / Alert ── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  min-width: 300px;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s ease;
  font-size: 13px;
}
.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Loading ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-overlay .spinner { width: 40px; height: 40px; border-width: 3px; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 48px; height: 48px;
  background: transparent;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 800;
  overflow: hidden;
}
.login-logo-text { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.login-logo-text span { color: var(--primary); }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.login-card .form-control { padding: 12px 16px; font-size: 14px; }
.login-card .btn-primary { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; border-radius: var(--radius-sm); justify-content: center; text-align: center; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ── Invoice Items ── */
.invoice-items-table { margin: 16px 0; }
.invoice-items-table input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
}
.invoice-items-table input:focus { outline: none; border-color: var(--primary); }

.items-total-row {
  display: flex;
  justify-content: flex-end;
  padding: 16px 0;
}
.items-total-box {
  min-width: 280px;
}
.items-total-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.items-total-line.grand {
  border-top: 2px solid var(--primary);
  padding-top: 10px;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--transition);
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 2px;
  background: var(--primary);
}

/* ── Responsive ── */

/* Tablet */
@media (max-width: 1024px) {
  .data-grid { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 768px) {
  html { font-size: 13px; }

  /* Sidebar: off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
  }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }

  /* Topbar */
  .topbar {
    padding: 0 12px;
    height: 56px;
  }
  .topbar-title { font-size: 16px; }
  .topbar-subtitle { display: none; }
  .topbar-btn { width: 34px; height: 34px; }

  /* Content */
  .page-content { padding: 12px; }

  /* Stats */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }

  /* Cards */
  .card { border-radius: 8px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 14px 16px; }
  .card-title { font-size: 14px; }

  /* Data grid */
  .data-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
  .form-group { margin-bottom: 14px; }
  .form-control { padding: 10px 12px; font-size: 14px; }

  /* Toolbar */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .toolbar-left, .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
  }
  .toolbar-right { justify-content: flex-start; }
  .search-box { max-width: 100%; }

  /* Buttons mobile */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-sm { padding: 7px 10px; font-size: 12px; }
  .btn-group { flex-wrap: wrap; gap: 4px; }

  /* Tables: responsive cards on mobile */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  thead th { padding: 10px 12px; font-size: 10px; }
  tbody td { padding: 10px 12px; font-size: 12px; }

  /* Modal */
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal {
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }
  .modal-lg { max-width: 100%; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .modal-title { font-size: 15px; }

  /* Invoice items in modal */
  .invoice-items-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .invoice-items-table table { min-width: 500px; }
  .items-total-row { justify-content: stretch; }
  .items-total-box { min-width: auto; width: 100%; }

  /* Pagination */
  .pagination button { width: 30px; height: 30px; font-size: 11px; }

  /* Toast */
  .toast-container { right: 8px; left: 8px; top: 64px; }
  .toast { min-width: auto; max-width: 100%; }

  /* Login */
  .login-card { padding: 28px 20px; max-width: 100%; }
  .login-logo-icon { width: 40px; height: 40px; font-size: 18px; }
  .login-logo-text { font-size: 22px; }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 14px; font-size: 12px; white-space: nowrap; }

  /* Charts */
  .chart-container { height: 220px; }
}

/* Small phones */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 16px; }

  .topbar-title { font-size: 14px; }
  .page-content { padding: 10px; }

  .login-card { padding: 20px 16px; }
  .login-logo-text { font-size: 20px; }
  .login-subtitle { font-size: 12px; }

  .card-header { padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-body { padding: 12px 14px; }

  .btn { padding: 9px 12px; font-size: 12px; }
  .btn-group { gap: 3px; }

  .modal-overlay { padding: 0; }
  .modal { max-height: 90vh; border-radius: 12px 12px 0 0; }

  .sidebar-user { padding: 6px 8px; }
  .sidebar-user-name { font-size: 12px; }
  .sidebar-user-role { font-size: 10px; }

  /* Grid layouts inside modals */
  .modal [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Backdrop for mobile ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.active { display: block; }

/* ── Utility ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; justify-content: center; }
.font-mono { font-family: var(--font-mono); }
