/* ============================================================================
   AdTags Admin Panel — Dark Theme Design System
   Version: 1.0
   ============================================================================ */

/* ─── SELF-HOSTED INTER FONT ─── */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/static/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/static/fonts/inter-700.woff2') format('woff2'); }

/* ─── DESIGN TOKENS ─── */
:root {
  --bg: #0b0f19;
  --bg2: #111827;
  --surface: #1a1f2e;
  --surface2: #232a3b;
  --border: #2a3146;
  --border-light: #333b52;
  --text: #e2e8f0;
  --text-dim: #8892a8;
  --text-muted: #5a6478;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, .25);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --cyan: #06b6d4;
  --purple: #a855f7;
  --pink: #ec4899;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .18);
  --shadow: 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .35);
  --transition: .2s ease;
  --transition-fast: .15s ease;
  --logo-filter: invert(1) brightness(2);
  --topbar-bg: rgba(11, 15, 25, .85);
  --date-scheme: dark;
  --date-icon-filter: invert(0.7);
  --file-upload-bg: rgba(17, 24, 39, .4);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235a6478' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.5l-5-5h10l-5 5z'/%3E%3C/svg%3E");
}

/* ─── LIGHT THEME ─── */
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg2: #ffffff;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #1e293b;
  --text-dim: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .06);
  --shadow: 0 4px 14px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .12);
  --logo-filter: none;
  --topbar-bg: rgba(241, 245, 249, .9);
  --date-scheme: light;
  --date-icon-filter: none;
  --file-upload-bg: rgba(241, 245, 249, .6);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.5l-5-5h10l-5 5z'/%3E%3C/svg%3E");
}

/* Light theme overrides for hardcoded colors */
[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
}
[data-theme="light"] .nav-item.active {
  color: var(--accent);
  background: rgba(99, 102, 241, .08);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .15);
}
[data-theme="light"] .user-avatar {
  color: #fff;
}
[data-theme="light"] .login-page {
  background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, .06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, .04) 0%, transparent 50%),
              var(--bg);
}
[data-theme="light"] .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
[data-theme="light"] .stat-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
[data-theme="light"] .modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, .15);
}
[data-theme="light"] .toast {
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
}
[data-theme="light"] .theme-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 12px rgba(0,0,0,.15);
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}


/* ============================================================================
   1. RESET & BODY
   ============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html:not([data-theme="light"]) { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::selection {
  background: var(--accent);
  color: #fff;
}


/* ============================================================================
   2. SIDEBAR
   ============================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

/* ─── Sidebar Brand ─── */
.sidebar-brand {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* ─── Sidebar Navigation ─── */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item i {
  font-size: 19px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(99, 102, 241, .15);
  color: var(--accent);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(6, 182, 212, .08));
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .25);
}

.nav-item.active i {
  color: var(--accent);
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
}

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

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Mobile Toggle ─── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.mobile-toggle:hover {
  background: var(--surface2);
  border-color: var(--border-light);
}

/* Mobile overlay when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 99;
}

.sidebar-overlay.open {
  display: block;
}


/* ============================================================================
   3. MAIN CONTENT
   ============================================================================ */
.main {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


/* ============================================================================
   4. TOPBAR
   ============================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 18px 32px;
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.impersonate-bar {
  width: 100%;
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .3);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.impersonate-bar i { font-size: 18px; }

.topbar-left h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.topbar-left .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar-left .breadcrumb a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.topbar-left .breadcrumb a:hover {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}


/* ============================================================================
   5. BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn i {
  font-size: 16px;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #7c7ff7, #6366f1);
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Ghost */
.btn-ghost {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface2);
}

/* Success */
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, .25);
}

.btn-success:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 6px 20px rgba(16, 185, 129, .3);
  transform: translateY(-1px);
}

.btn-success:active {
  transform: translateY(0);
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, .25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 6px 20px rgba(239, 68, 68, .3);
  transform: translateY(-1px);
}

.btn-danger:active {
  transform: translateY(0);
}

/* Warning */
.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, .25);
}

.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 6px 20px rgba(245, 158, 11, .3);
  transform: translateY(-1px);
}

.btn-warning:active {
  transform: translateY(0);
}

/* Small */
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
  gap: 5px;
}

.btn-sm i {
  font-size: 14px;
}

/* Icon-only button */
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  gap: 0;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.btn-icon i {
  margin: 0;
}

/* Button spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

/* Button group */
.btn-group {
  display: flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: 10px 0 0 10px;
}

.btn-group .btn:last-child {
  border-radius: 0 10px 10px 0;
}


/* ============================================================================
   6. CARDS
   ============================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 18px;
  overflow: hidden;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: var(--border-light);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-head-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-content {
  padding: 22px;
}

.card-content:empty {
  padding: 0;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-success {
  background: rgba(16, 185, 129, .12);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, .12);
  color: var(--danger);
}

.badge-warning {
  background: rgba(245, 158, 11, .12);
  color: var(--warning);
}

.badge-info {
  background: rgba(59, 130, 246, .12);
  color: var(--info);
}

.badge-secondary {
  background: rgba(107, 114, 128, .12);
  color: #6b7280;
}

.badge-active {
  background: rgba(16, 185, 129, .12);
  color: var(--success);
}

.badge-inactive {
  background: rgba(90, 100, 120, .15);
  color: var(--text-muted);
}


/* ============================================================================
   7. STATS CARDS (Dashboard)
   ============================================================================ */
.page-body {
  padding: 28px 32px;
  flex: 1;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

/* 5-column layout for reports stats */
.stats-row.stats-5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1100px) {
  .stats-row.stats-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .stats-row.stats-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-row.stats-5 {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition), transform var(--transition);
}

.stats-5 .stat-card {
  padding: 12px 14px;
  gap: 10px;
}

.stats-5 .stat-icon {
  width: 36px;
  height: 36px;
  font-size: 17px;
  border-radius: 8px;
}

.stats-5 .stat-value {
  font-size: 17px;
}

.stats-5 .stat-label {
  font-size: 10px;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--danger);
}


/* ============================================================================
   8. DATA TABLES
   ============================================================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 14px 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

.data-table thead th:first-child {
  padding-left: 22px;
}

.data-table thead th:last-child {
  padding-right: 22px;
}

.data-table thead th.sortable,
.data-table thead th.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table thead th.sortable:hover,
.data-table thead th.sortable-th:hover {
  color: var(--accent);
}

.data-table thead th.sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: .3;
}

.data-table thead th.sortable.asc::after {
  border-top: 0;
  border-bottom: 4px solid currentColor;
  opacity: .8;
}

.data-table thead th.sortable.desc::after {
  opacity: .8;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody td:first-child {
  padding-left: 22px;
}

.data-table tbody td:last-child {
  padding-right: 22px;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--surface2);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Clickable rows */
.data-table tbody tr.clickable {
  cursor: pointer;
}

/* Table actions column */
.data-table .actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.data-table .actions .btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.data-table .actions .btn i {
  font-size: 15px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state i {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: .5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin-bottom: 20px;
}


/* ============================================================================
   9. PAGINATION
   ============================================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.page-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(99, 102, 241, .08);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
  font-weight: 600;
}

.page-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

.page-btn i {
  font-size: 16px;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 8px;
  white-space: nowrap;
}

.page-size-select {
  margin-left: 12px;
}


/* ============================================================================
   10. FILTER / TOOLBAR BAR
   ============================================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

/* Equal-width filter grids for reports */
.filter-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

.filter-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.filter-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.filter-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1100px) {
  .filter-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .filter-grid-3,
  .filter-grid-4,
  .filter-grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .filter-grid-3,
  .filter-grid-4,
  .filter-grid-5 {
    grid-template-columns: 1fr;
  }
}

.filter-bar-right {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Search box with icon inside */
.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 40px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input:focus + i,
.search-box input:focus ~ i {
  color: var(--accent);
}

/* Filter select dropdown */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 36px 9px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-dim);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 140px;
}

.filter-select:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-select option {
  background: var(--bg2);
  color: var(--text);
}


/* ============================================================================
   11. FORMS
   ============================================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

/* Alias: .grid mirrors .form-grid for backward compat */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid .full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .3px;
}

.field label .required {
  color: var(--danger);
  margin-left: 2px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
}

.field input[type="date"] {
  color-scheme: var(--date-scheme);
  cursor: pointer;
}
.field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-icon-filter);
  cursor: pointer;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ─── Theme Swatches ─── */
.theme-swatches {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.theme-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  color: #fff;
  font-size: 16px;
}
.theme-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(255,255,255,.1);
}
.theme-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 12px rgba(255,255,255,.2);
}

/* ─── Mode Toggle ─── */
.mode-toggle {
  display: flex;
  gap: 8px;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s ease;
}
.mode-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}
.mode-btn.active {
  border-color: var(--accent);
  background: rgba(99,102,241,.08);
  color: var(--accent);
}
.mode-btn i {
  font-size: 18px;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.field .field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -2px;
}

.field .field-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: -2px;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}

/* Field row — inline fields */
.field-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.field-row .field {
  flex: 1;
}

/* Password wrapper */
.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 42px;
}

.pw-toggle {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0 10px 10px 0;
  transition: color var(--transition-fast);
}

.pw-toggle:hover {
  color: var(--text);
}

/* Checkbox field */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-dim);
}

.checkbox-field input[type="checkbox"] {
  display: none;
}

.checkbox-field .checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox-field .checkmark::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  transform: scale(0);
  transition: transform var(--transition-fast);
}

.checkbox-field input[type="checkbox"]:checked + .checkmark {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .1);
}

.checkbox-field input[type="checkbox"]:checked + .checkmark::after {
  transform: scale(1);
}

.checkbox-field:hover .checkmark {
  border-color: var(--border-light);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  display: none;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle .slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition-fast);
}

.toggle input:checked + .slider {
  background: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(18px);
}

/* File upload drop zone */
.file-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--file-upload-bg);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.file-upload:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .04);
}

.file-upload.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .08);
}

.file-upload i {
  font-size: 32px;
  color: var(--text-muted);
}

.file-upload p {
  font-size: 13px;
  color: var(--text-dim);
}

.file-upload span {
  font-size: 11px;
  color: var(--text-muted);
}


/* ============================================================================
   12. MODALS
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .2s ease;
}

.modal-overlay.open {
  display: flex;
  opacity: 1;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
  transform: translateY(8px) scale(.98);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

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

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-header .modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-header .modal-close:hover {
  color: var(--text);
  background: var(--border);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Small modal variant */
.modal.modal-sm {
  max-width: 440px;
}

/* Large modal variant */
.modal.modal-lg {
  max-width: 900px;
}

/* Confirmation dialog */
.modal-confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.modal-confirm-text {
  text-align: center;
  margin-bottom: 8px;
}

.modal-confirm-text h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-confirm-text p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}


/* ============================================================================
   13. TOASTS
   ============================================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .3s cubic-bezier(.4, 0, .2, 1);
  min-width: 320px;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
  pointer-events: auto;
}

.toast i {
  font-size: 20px;
  flex-shrink: 0;
}

.toast span {
  flex: 1;
  line-height: 1.4;
}

.toast-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, .15), rgba(16, 185, 129, .05));
  border: 1px solid rgba(16, 185, 129, .25);
  color: var(--success);
}

.toast-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, .15), rgba(239, 68, 68, .05));
  border: 1px solid rgba(239, 68, 68, .25);
  color: var(--danger);
}

.toast-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, .15), rgba(245, 158, 11, .05));
  border: 1px solid rgba(245, 158, 11, .25);
  color: var(--warning);
}

.toast-close {
  margin-left: auto;
  background: 0;
  border: 0;
  color: inherit;
  opacity: .5;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

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

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


/* ============================================================================
   14. LOGIN PAGE
   ============================================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, .08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, .06) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 40px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
}

.login-card .field {
  margin-bottom: 16px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  margin-top: 8px;
}

.login-divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--accent);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.login-footer a:hover {
  color: #818cf8;
}

.login-error {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ============================================================================
   15. UTILITY CLASSES
   ============================================================================ */

/* ─── Text Colors ─── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-dim     { color: var(--text-dim) !important; }
.text-accent  { color: var(--accent) !important; }
.text-cyan    { color: var(--cyan) !important; }
.text-purple  { color: var(--purple) !important; }
.text-pink    { color: var(--pink) !important; }

/* ─── Spacing ─── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 16px; }

.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.mr-3 { margin-right: 16px; }

.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

/* ─── Flexbox ─── */
.flex {
  display: flex;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }

/* ─── Display ─── */
.hidden {
  display: none !important;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

/* ─── Text ─── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Width ─── */
.w-full { width: 100%; }

/* ─── Overflow ─── */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }


/* ============================================================================
   16. LOADING STATE
   ============================================================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
}

.loader {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.loader-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loader-text {
  font-size: 13px;
  color: var(--text-muted);
}

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

/* Drill-down / expandable rows */
.expandable-row { cursor: pointer; }
.expandable-row:hover { background: var(--surface2, var(--bg2)); }
.expand-toggle i { transition: transform .2s; }
.drill-down-row td { background: var(--surface1, var(--bg2)); border-left: 3px solid var(--accent); padding: 0 !important; }
.drill-down-container { max-height: 340px; overflow-y: auto; }
.drill-down-container .data-table { font-size: 12px; }
.drill-down-container .data-table tr:last-child td { border-bottom: none; }

/* Date preset buttons */
.date-preset-btn { font-size: 12px !important; padding: 4px 12px !important; border-radius: 16px !important; border: 1px solid var(--border) !important; background: transparent !important; color: var(--text-muted) !important; transition: all .15s; }
.date-preset-btn:hover { border-color: var(--accent) !important; color: var(--accent) !important; }
.date-preset-btn.active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }

/* Table footer totals */
.table-totals-row td { border-top: 2px solid var(--accent) !important; background: var(--bg2); font-size: 13px; padding: 10px 12px !important; }

/* Searchable Select */
.ss-wrap { position: relative; min-width: 140px; }
.field .ss-wrap { width: 100%; }
.ss-display { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-dim); transition: border-color .15s, box-shadow .15s; min-height: 38px; gap: 8px; white-space: nowrap; }
.ss-display:hover { border-color: var(--border-light); color: var(--text); }
.ss-arrow { font-size: 14px; color: var(--text-muted); transition: transform .2s; flex-shrink: 0; }
.ss-wrap.ss-open .ss-arrow { transform: rotate(180deg); }
.ss-dropdown { display: none; position: fixed; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 9999; overflow: hidden; }
.ss-dropdown.open { display: block; }
.ss-search { width: 100%; padding: 10px 12px; border: none; border-bottom: 1px solid var(--border); background: var(--bg2); color: var(--text); font-size: 13px; outline: none; box-sizing: border-box; }
.ss-search::placeholder { color: var(--text-muted); }
.ss-list { max-height: 220px; overflow-y: auto; padding: 4px 0; }
.ss-option { padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text); transition: background .1s; }
.ss-option:hover { background: var(--bg2); }
.ss-option-active { background: rgba(99,102,241,.1); color: var(--accent); font-weight: 500; }
.ss-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* Click-to-filter links in data table */
.filter-link { color: var(--accent); text-decoration: none; cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .15s; }
.filter-link:hover { border-bottom-color: var(--accent); }

/* Skeleton shimmer placeholder */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface2) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: 8px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-heading {
  height: 22px;
  width: 40%;
  margin-bottom: 16px;
  border-radius: 4px;
}

.skeleton-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
}

.skeleton-card {
  height: 120px;
  border-radius: 14px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Inline loading dots */
.loading-dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}


/* ============================================================================
   17. RESPONSIVE
   ============================================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, .4);
  }

  .mobile-toggle {
    display: flex;
  }

  .main {
    margin-left: 0;
  }

  .topbar,
  .page-body {
    padding-left: 24px;
    padding-right: 24px;
  }

  .topbar {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .form-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar-right {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .search-box {
    max-width: none;
    min-width: auto;
  }

  .table-wrap {
    margin: 0 -22px;
    padding: 0;
    border-radius: 0;
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    margin: 10px;
    border-radius: 14px;
  }

  .login-card {
    padding: 28px 24px;
  }

  .field-row {
    flex-direction: column;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-right {
    width: 100%;
  }

  .topbar-right .btn {
    flex: 1;
    justify-content: center;
  }

  .page-body {
    padding: 20px 16px;
  }

  .card-head {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .card-content {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header,
  .modal-footer {
    padding: 14px 16px;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .toast {
    min-width: auto;
    max-width: calc(100vw - 40px);
  }
}


/* ============================================================================
   18. TABS
   ============================================================================ */
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text-dim);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab i {
  margin-right: 6px;
  font-size: 15px;
  vertical-align: middle;
}

.tab .tab-badge {
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(99, 102, 241, .12);
  color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-panel {
  padding: 20px 0;
}


/* ============================================================================
   EXTRAS — Additional polish components
   ============================================================================ */

/* ─── Divider ─── */
.divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Avatar ─── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.avatar-accent {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
}

.avatar-cyan {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
}

.avatar-success {
  background: linear-gradient(135deg, var(--success), #059669);
}

.avatar-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
}

.avatar-purple {
  background: linear-gradient(135deg, var(--purple), #7c3aed);
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 6px;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 18px;
  border-radius: 12px;
}

/* ─── Tag / Chip ─── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.tag-closable .tag-close {
  margin-left: 2px;
  cursor: pointer;
  opacity: .6;
  transition: opacity var(--transition-fast);
  font-size: 14px;
  line-height: 1;
}

.tag-closable .tag-close:hover {
  opacity: 1;
}

/* ─── Tooltip ─── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 600;
  box-shadow: var(--shadow);
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* ─── Progress bar ─── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width .4s ease;
}

.progress-bar-success {
  background: linear-gradient(90deg, var(--success), #34d399);
}

.progress-bar-danger {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.progress-bar-warning {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}

/* ─── Dropdown Menu ─── */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(.98);
  transition: all .15s cubic-bezier(.4, 0, .2, 1);
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.dropdown-item i {
  font-size: 17px;
  width: 20px;
  text-align: center;
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, .08);
}

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

/* ─── Key-value info row ─── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row .info-label {
  color: var(--text-muted);
  font-weight: 500;
}

.info-row .info-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

/* ─── Code block ─── */
.code-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text-dim);
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .9em;
  padding: 2px 6px;
  background: var(--surface2);
  border-radius: 4px;
  color: var(--cyan);
}

/* ─── Fade-in animation for page load ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp .4s cubic-bezier(.4, 0, .2, 1) both;
}

.fade-in-up:nth-child(1) { animation-delay: 0s; }
.fade-in-up:nth-child(2) { animation-delay: .05s; }
.fade-in-up:nth-child(3) { animation-delay: .1s; }
.fade-in-up:nth-child(4) { animation-delay: .15s; }
.fade-in-up:nth-child(5) { animation-delay: .2s; }
.fade-in-up:nth-child(6) { animation-delay: .25s; }

/* ─── Focus ring for accessibility ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Print styles ─── */
@media print {
  .sidebar,
  .mobile-toggle,
  .topbar,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main {
    margin-left: 0 !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ── Live Dot Indicator ── */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.live-dot-active {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── Typeahead / Autocomplete ── */
.typeahead-wrap { position: relative; }
.typeahead-wrap input {
  width: 100%; padding: 9px 14px 9px 40px; font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.typeahead-wrap input::placeholder { color: var(--text-muted); }
.typeahead-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.typeahead-wrap > i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 17px; color: var(--text-muted); pointer-events: none;
}
.typeahead-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  max-height: 220px; overflow-y: auto; z-index: 60;
  box-shadow: 0 8px 32px rgba(0,0,0,.35); display: none;
}
.typeahead-dropdown.open { display: block; }
.typeahead-option {
  padding: 9px 14px; font-size: 13px; cursor: pointer;
  transition: background .1s;
}
.typeahead-option:hover { background: var(--surface2); }
.typeahead-empty { padding: 12px 14px; font-size: 12px; color: var(--text-muted); }

/* ── Filter Chips ── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  background: rgba(99,102,241,.12); color: var(--accent);
  border-radius: 6px; white-space: nowrap;
}
.filter-chip button {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; opacity: .7; padding: 0;
}
.filter-chip button:hover { opacity: 1; }
