/* ============================================================
   Knightz Mail — Design System v2.0
   Modern Glass & Depth Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Brand Colors */
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #818cf8;
  --primary-muted:  #eef2ff;
  --primary-glow:   rgba(99, 102, 241, 0.18);
  --accent:         #14b8a6;
  --accent-dark:    #0d9488;
  --accent-light:   #5eead4;
  --accent-muted:   #f0fdfa;

  /* Semantic Colors */
  --success:        #10b981;
  --success-dark:   #059669;
  --success-muted:  #ecfdf5;
  --warning:        #f59e0b;
  --warning-muted:  #fffbeb;
  --danger:         #ef4444;
  --danger-dark:    #dc2626;
  --danger-muted:   #fef2f2;
  --info:           #3b82f6;
  --info-muted:     #eff6ff;

  /* Neutrals */
  --bg-base:        #f1f5f9;
  --bg-card:        #ffffff;
  --bg-subtle:      #f8fafc;
  --bg-glass:       rgba(255, 255, 255, 0.80);
  --border:         #e2e8f0;
  --border-soft:    #f1f5f9;
  --border-focus:   rgba(99, 102, 241, 0.40);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Shadows */
  --shadow-xs:      0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm:      0 2px 8px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:      0 4px 16px rgba(15, 23, 42, 0.09), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg:      0 8px 32px rgba(15, 23, 42, 0.11), 0 4px 8px rgba(15, 23, 42, 0.06);
  --shadow-xl:      0 20px 50px rgba(15, 23, 42, 0.14), 0 8px 16px rgba(15, 23, 42, 0.08);
  --shadow-primary: 0 4px 16px rgba(99, 102, 241, 0.30);
  --shadow-primary-lg: 0 8px 28px rgba(99, 102, 241, 0.35);
  --shadow-accent:  0 4px 16px rgba(20, 184, 166, 0.30);
  --shadow-success: 0 4px 14px rgba(16, 185, 129, 0.28);
  --shadow-danger:  0 4px 14px rgba(239, 68, 68, 0.28);

  /* Border Radius */
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-3xl:  32px;
  --radius-full: 9999px;

  /* Spacing */
  --spacing-xs:  8px;
  --spacing-sm:  16px;
  --spacing-md:  24px;
  --spacing-lg:  32px;
  --spacing-xl:  48px;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-xs:   11px;
  --font-sm:   13px;
  --font-base: 15px;
  --font-md:   17px;
  --font-lg:   20px;
  --font-xl:   26px;
  --font-2xl:  32px;
  --font-3xl:  44px;

  /* Transitions */
  --transition:       all 0.20s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:  all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring:all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --gradient-accent:  linear-gradient(135deg, #14b8a6 0%, #0ea5e9 100%);
  --gradient-warm:    linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
  --gradient-bg:      linear-gradient(145deg, #6366f1 0%, #8b5cf6 55%, #a78bfa 100%);
  --gradient-header:  linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --gradient-card:    linear-gradient(160deg, rgba(99,102,241,0.06) 0%, rgba(139,92,246,0.04) 100%);
}

/* ============================================================
   BASE RESET
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover { color: var(--primary-dark); }

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

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}
.container-sm { max-width: 640px;  margin: 0 auto; }
.container-md { max-width: 920px;  margin: 0 auto; }
.container-lg { max-width: 1100px; margin: 0 auto; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--font-2xl); }
h2 { font-size: var(--font-xl); }
h3 { font-size: var(--font-lg); }
h4 { font-size: var(--font-md); }
h5 { font-size: var(--font-base); }
h6 { font-size: var(--font-sm); }

.text-xs       { font-size: var(--font-xs); }
.text-sm       { font-size: var(--font-sm); }
.text-base     { font-size: var(--font-base); }
.text-md       { font-size: var(--font-md); }
.text-lg       { font-size: var(--font-lg); }
.text-primary  { color: var(--text-primary); }
.text-secondary{ color: var(--text-secondary); }
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-accent   { color: var(--accent); }
.text-brand    { color: var(--primary); }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-extrabold{ font-weight: 800; }

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
  -webkit-user-select: none;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
  border-radius: inherit;
}

.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active::after { background: rgba(0,0,0,0.06); }

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

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

/* Primary */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary-lg);
  color: var(--text-inverse);
}
.btn-primary:active { transform: translateY(0); }

/* Accent */
.btn-accent {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: var(--shadow-accent);
}
.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.40);
  color: var(--text-inverse);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-card);
  color: var(--primary);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--primary-muted);
  border-color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border);
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: var(--text-inverse);
  box-shadow: var(--shadow-danger);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.40);
  color: var(--text-inverse);
}

/* Success */
.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: var(--text-inverse);
  box-shadow: var(--shadow-success);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.40);
  color: var(--text-inverse);
}

/* Sizes */
.btn-xs  { padding: 5px 12px; font-size: var(--font-xs); border-radius: var(--radius-sm); gap: 4px; }
.btn-sm  { padding: 7px 16px; font-size: var(--font-sm); border-radius: var(--radius-sm); }
.btn-lg  { padding: 14px 30px; font-size: var(--font-md); border-radius: var(--radius-lg); }
.btn-xl  { padding: 16px 36px; font-size: var(--font-lg); border-radius: var(--radius-lg); }
.btn-full{ width: 100%; }
.btn-icon{ padding: 10px; aspect-ratio: 1; border-radius: var(--radius-md); }
.btn-icon.btn-sm { padding: 7px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition-slow);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 18px var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  background: var(--bg-subtle);
}

.card-body { padding: var(--spacing-lg); }

.card-footer {
  padding: 16px var(--spacing-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* Card variants */
.card-branded { border-top: 3px solid var(--primary); }
.card-accent-top { border-top: 3px solid var(--accent); }

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 8px 32px rgba(15,23,42,0.10), inset 0 1px 0 rgba(255,255,255,0.6);
}

.card-gradient {
  background: linear-gradient(160deg, #fff 0%, var(--primary-muted) 100%);
  border: 1px solid rgba(99,102,241,0.12);
}

.card-elevated {
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.card-hover {
  cursor: pointer;
  transition: var(--transition-slow);
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

/* Card with gradient header */
.card-header-gradient {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  border-bottom: none;
}
.card-header-gradient * { color: var(--text-inverse); }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: var(--spacing-md); }

.form-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

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

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: var(--transition);
  line-height: 1.5;
  appearance: none;
}

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

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

.form-control:disabled {
  background: var(--bg-subtle);
  cursor: not-allowed;
  opacity: 0.65;
}

.form-control.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}

.form-control.is-success {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

/* Input with icon */
.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  font-size: 16px;
}

.input-wrapper .input-icon-right {
  left: auto;
  right: 14px;
  pointer-events: auto;
  cursor: pointer;
}
.input-wrapper .input-icon-right:hover { color: var(--primary); }

.input-wrapper .form-control.has-icon      { padding-left: 42px; }
.input-wrapper .form-control.has-icon-right{ padding-right: 42px; }

/* Select */
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Textarea */
textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* Checkbox & Radio */
.check-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check-group input[type="checkbox"],
.check-group input[type="radio"] {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  appearance: none;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  flex-shrink: 0;
  position: relative;
}

.check-group input[type="radio"] { border-radius: 50%; }

.check-group input[type="checkbox"]:checked,
.check-group input[type="radio"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.check-group input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.check-group input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: white;
  border-radius: 50%;
}

.form-hint  { font-size: var(--font-sm); color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: var(--font-sm); color: var(--danger);     margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.form-success{ font-size: var(--font-sm); color: var(--success);   margin-top: 5px; }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.badge-primary  { background: var(--primary-muted); color: var(--primary-dark); }
.badge-accent   { background: var(--accent-muted);  color: var(--accent-dark); }
.badge-success  { background: var(--success-muted); color: var(--success-dark); }
.badge-warning  { background: var(--warning-muted); color: #92400e; }
.badge-danger   { background: var(--danger-muted);  color: var(--danger-dark); }
.badge-info     { background: var(--info-muted);    color: #1d4ed8; }
.badge-neutral  { background: var(--border-soft);   color: var(--text-secondary); }
.badge-dark     { background: var(--text-primary);  color: #fff; }

/* Pulse badge for "live" indicators */
.badge-live {
  background: var(--danger-muted);
  color: var(--danger);
  position: relative;
}
.badge-live::before {
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  line-height: 1.55;
}

.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-muted); color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: var(--warning-muted); color: #78350f; border-color: #fde68a; }
.alert-danger  { background: var(--danger-muted);  color: #7f1d1d; border-color: #fecaca; }
.alert-info    { background: var(--info-muted);    color: #1e3a8a; border-color: #bfdbfe; }
.alert-primary { background: var(--primary-muted); color: var(--primary-dark); border-color: rgba(99,102,241,0.25); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.table th {
  background: var(--bg-subtle);
  padding: 13px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover td { background: rgba(99,102,241,0.03); }
.table-striped tbody tr:nth-child(even) td { background: var(--bg-subtle); }

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(99,102,241,0.15);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
  background: var(--primary-muted);
}

.stat-value {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 5px;
  font-weight: 500;
}

.stat-change {
  font-size: var(--font-xs);
  font-weight: 600;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   DIVIDER
   ============================================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: var(--font-sm);
  margin: var(--spacing-md) 0;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   LOADER / SPINNER
   ============================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(99,102,241,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

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

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 50%, var(--border-soft) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 40%; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-btn { height: 40px; width: 120px; border-radius: var(--radius-md); }

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

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 18px var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.page-header-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}

.page-header-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.page-header-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--primary-muted);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary-muted);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: var(--font-xs);
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-weight: 700;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--spacing-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--primary); background: var(--primary-muted); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-muted); }

/* Pill tabs */
.tabs-pill {
  display: flex;
  gap: 6px;
  border-bottom: none;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 5px;
  width: fit-content;
}
.tabs-pill .tab {
  border-bottom: none;
  border-radius: var(--radius-md);
  margin-bottom: 0;
  padding: 8px 18px;
}
.tabs-pill .tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing-md);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-sm { max-width: 380px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  padding: 20px var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h3 { font-size: var(--font-md); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  transition: var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--danger-muted); color: var(--danger); }

.modal-body   { padding: var(--spacing-lg); }
.modal-footer {
  padding: 16px var(--spacing-lg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 40px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.toast-success::before { background: var(--success); }
.toast-error::before   { background: var(--danger); }
.toast-warning::before { background: var(--warning); }
.toast-info::before    { background: var(--info); }

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: var(--font-sm); color: var(--text-primary); }
.toast-message { font-size: var(--font-sm); color: var(--text-secondary); margin-top: 2px; }
.toast-close {
  width: 24px; height: 24px;
  border-radius: var(--radius-xs);
  border: none; background: none;
  cursor: pointer; color: var(--text-muted);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.toast-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

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

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-bar.accent   { background: var(--gradient-accent); }
.progress-bar.success  { background: linear-gradient(90deg, #10b981, #059669); }
.progress-bar.warning  { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-bar.danger   { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-bar.animated { animation: progress-stripe 1.2s linear infinite; background-size: 30px 100%; }

.progress-sm { height: 4px; }
.progress-lg { height: 12px; }
.progress-xl { height: 18px; border-radius: var(--radius-sm); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px var(--spacing-lg);
  color: var(--text-secondary);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-size: var(--font-md);
  color: var(--text-primary);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  max-width: 320px;
  margin: 0 auto 20px;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  font-size: var(--font-xs);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  font-family: var(--font-family);
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page {
  min-height: 100vh;
  background: var(--gradient-bg);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139,92,246,0.30) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 60% 80%, rgba(167,139,250,0.20) 0%, transparent 50%);
  pointer-events: none;
}

.auth-page::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='1' fill='rgba(255,255,255,0.07)'/%3E%3C/svg%3E");
  animation: bgDrift 30s linear infinite;
  pointer-events: none;
  opacity: 0.5;
}

@keyframes bgDrift {
  from { transform: translate(0, 0); }
  to   { transform: translate(60px, 60px); }
}

.auth-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 64px rgba(15,23,42,0.20), 0 8px 24px rgba(99,102,241,0.15);
  overflow: hidden;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255,255,255,0.6);
}

.auth-header {
  background: var(--gradient-primary);
  padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
  text-align: center;
  color: var(--text-inverse);
  position: relative;
  overflow: hidden;
}

.auth-header::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 65%);
  pointer-events: none;
}

.auth-logo {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.20);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 14px;
  border: 2px solid rgba(255,255,255,0.30);
  backdrop-filter: blur(4px);
}

.auth-header h1 {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--text-inverse);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.auth-header p {
  font-size: var(--font-sm);
  opacity: 0.85;
  color: var(--text-inverse);
}

.auth-body { padding: var(--spacing-lg); }

.auth-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--bg-subtle);
  transition: var(--transition);
  line-height: 1.5;
}
.auth-input::placeholder { color: var(--text-muted); }
.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.auth-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.auth-footer {
  padding: 16px var(--spacing-lg);
  background: var(--bg-subtle);
  text-align: center;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

/* ============================================================
   HERO / LANDING
   ============================================================ */
.hero-section {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  padding: 64px 52px;
  box-shadow: var(--shadow-xl);
  text-align: center;
  margin-bottom: var(--spacing-lg);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.hero-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  pointer-events: none;
}

.hero-section h1 {
  font-size: var(--font-3xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.hero-section .subtitle {
  font-size: var(--font-md);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  position: relative;
  z-index: 1;
}

/* ============================================================
   FEATURE CARDS
   ============================================================ */
.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.35s ease;
  transform-origin: left;
}
.feature-card:hover::before { transform: scaleX(1); }
.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(99,102,241,0.15);
}

/* ============================================================
   BACK BUTTON
   ============================================================ */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 600;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-xs);
}
.back-button:hover {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary-light);
  transform: translateX(-2px);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
  gap: 12px;
  flex-wrap: wrap;
}
.section-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary-muted);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 16px;
}

/* ============================================================
   GRADIENT HEADER STRIP (page card headers)
   ============================================================ */
.gradient-header {
  background: var(--gradient-primary);
  padding: var(--spacing-md) var(--spacing-lg);
  color: white;
  position: relative;
  overflow: hidden;
}
.gradient-header::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 65%);
  pointer-events: none;
}
.gradient-header h2, .gradient-header h3,
.gradient-header p, .gradient-header span {
  color: white;
  position: relative;
  z-index: 1;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--text-primary);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar .search-icon { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  border: 2px solid var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 52px; height: 52px; font-size: 20px; }
.avatar-xl { width: 72px; height: 72px; font-size: 28px; }

/* ============================================================
   CHIP / TAG
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-muted); }
.chip.active { background: var(--primary-muted); border-color: var(--primary); color: var(--primary); }
.chip-remove {
  cursor: pointer;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--border);
  font-size: 10px;
}
.chip-remove:hover { background: var(--danger); color: white; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: var(--font-family);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-muted); }
.page-btn.active { background: var(--gradient-primary); color: white; border-color: transparent; box-shadow: var(--shadow-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   COPY BUTTON
   ============================================================ */
.copy-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: var(--font-sm);
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
}
.copy-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 5px 12px;
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.copy-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-muted); }
.copy-btn.copied { border-color: var(--success); color: var(--success); background: var(--success-muted); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes bounceSoft {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-slide-up   { animation: slideUp   0.4s cubic-bezier(0.4, 0, 0.2, 1) both; }
.animate-slide-down { animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; }
.animate-fade-in    { animation: fadeIn    0.35s ease both; }
.animate-scale-in   { animation: scaleIn   0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.animate-pulse      { animation: pulse     2s ease infinite; }

/* Stagger delay utilities */
.delay-100 { animation-delay: 0.10s; }
.delay-200 { animation-delay: 0.20s; }
.delay-300 { animation-delay: 0.30s; }
.delay-400 { animation-delay: 0.40s; }
.delay-500 { animation-delay: 0.50s; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.grid     { display: grid; }
.block    { display: block; }

.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

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

.w-full  { width: 100%; }
.w-auto  { width: auto; }
.h-full  { height: 100%; }

.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }

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

.mx-auto { margin-left: auto; margin-right: auto; }
.ml-auto { margin-left: auto; }

.p-3 { padding: 12px; } .p-4 { padding: 16px; }
.p-5 { padding: 20px; } .p-6 { padding: 24px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }

.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.border       { border: 1px solid var(--border); }
.border-top   { border-top: 1px solid var(--border); }
.border-bottom{ border-bottom: 1px solid var(--border); }

.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.relative  { position: relative; }
.absolute  { position: absolute; }
.sticky    { position: sticky; top: 0; z-index: 10; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   SCROLLBAR (Webkit)
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   APP TOP BAR (Shared navigation for sub-pages)
   ============================================================ */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
  animation: topbarSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes topbarSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.app-topbar-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
}

/* Brand / home link */
.app-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: var(--font-sm);
  transition: var(--transition);
  flex-shrink: 0;
}
.app-topbar-brand:hover { color: var(--primary); }
.app-topbar-brand:hover .app-topbar-brand-icon { background: var(--primary); }

.app-topbar-brand-icon {
  width: 28px;
  height: 28px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: var(--transition);
}

.app-topbar-brand-name {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.app-topbar-sep {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.app-topbar-page-title {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.app-topbar-start {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

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

/* Balance display (hidden in topbar, kept for backward compat) */
.app-topbar-balance {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--primary-muted);
  color: var(--primary-dark);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 700;
  white-space: nowrap;
}

/* Level badge pill */
.app-topbar-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--font-xs);
  color: var(--text-inverse);
  background: #6b7280;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.app-topbar-level-badge:hover {
  filter: brightness(1.1);
}

/* Profile button */
.app-topbar-user { position: relative; }

.app-topbar-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}
.app-topbar-profile-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-muted);
  color: var(--primary);
}

/* Avatar circle */
.app-topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.app-topbar-avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.app-topbar-profile-label { line-height: 1; }

.app-topbar-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.app-topbar-profile-btn[aria-expanded="true"] .app-topbar-chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.app-topbar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: dropdownIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.app-topbar-dropdown.hidden { display: none; }

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.app-topbar-dropdown-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.app-topbar-dropdown-info {
  min-width: 0;
  flex: 1;
}

.app-topbar-dropdown-id {
  font-weight: 700;
  font-size: var(--font-base);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar-dropdown-balance {
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 3px;
}

.app-topbar-dropdown-body { padding: 6px; }

.app-topbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition);
  text-align: left;
}
.app-topbar-dropdown-item:hover {
  background: var(--primary-muted);
  color: var(--primary);
}
.app-topbar-dropdown-item svg { flex-shrink: 0; color: var(--text-muted); }
.app-topbar-dropdown-item:hover svg { color: var(--primary); }

.app-topbar-dropdown-danger { color: var(--danger); }
.app-topbar-dropdown-danger:hover { background: var(--danger-muted); color: var(--danger); }
.app-topbar-dropdown-danger svg { color: var(--danger); }
.app-topbar-dropdown-danger:hover svg { color: var(--danger); }

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

/* Body padding when topbar is present — reset body padding so topbar is flush */
body.has-topbar {
  padding: 0 !important;
}
/* Give .container proper spacing when topbar is present */
body.has-topbar .container {
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-xl);
  max-width: 1300px;
  margin: 0 auto;
}

/* Page wrapper for sub-pages */
.page-wrapper {
  max-width: 1300px;
  margin: 0 auto;
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-xl);
  animation: pageEntry 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes pageEntry {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Improved card header gradient */
.card-header-gradient {
  background: var(--gradient-primary);
  padding: 28px 32px;
  color: white;
  position: relative;
  overflow: hidden;
}
.card-header-gradient::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 65%);
  pointer-events: none;
}
.card-header-gradient h1,
.card-header-gradient h2,
.card-header-gradient h3,
.card-header-gradient p,
.card-header-gradient span {
  color: white;
  position: relative;
  z-index: 1;
}
.card-header-gradient .header-icon {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

/* Section header with accent bar */
.section-heading {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.section-heading::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Info bar (email count, stats strip) */
.info-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--primary-muted);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary);
  font-size: var(--font-sm);
  color: var(--primary-dark);
  font-weight: 600;
  margin-bottom: 16px;
}

/* Improved dropdown style */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: dropdownIn 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
}
.dropdown-item:hover { background: var(--primary-muted); color: var(--primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-info-item { padding: 10px 14px; font-size: var(--font-sm); }

/* ============================================================
   UNIFIED PAGE HERO
   ============================================================ */
.page-hero {
  background: #111827;
  width: 100%;
}

.page-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.page-hero-icon {
  width: 44px;
  height: 44px;
  background: rgba(99, 102, 241, 0.18);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #818cf8;
  flex-shrink: 0;
}

.page-hero-title {
  font-size: 22px;
  font-weight: 800;
  color: #f1f5f9;
  margin: 0 0 2px;
  letter-spacing: -0.3px;
}

.page-hero-sub {
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
}

.page-hero-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   TOPBAR QUICK LINKS (desktop)
   ============================================================ */
.app-topbar-quicklinks {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-topbar-quicklink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}

.app-topbar-quicklink:hover {
  background: var(--primary-muted);
  color: var(--primary);
}

.app-topbar-quicklink svg {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: var(--transition);
}

.app-topbar-quicklink:hover svg {
  color: var(--primary);
}

/* ============================================================
   TOPBAR HAMBURGER + MOBILE MENU
   ============================================================ */
.app-topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.app-topbar-hamburger:hover {
  border-color: var(--primary-light);
  background: var(--primary-muted);
}

.app-topbar-hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  position: relative;
  transition: var(--transition);
}

.app-topbar-hamburger span::before,
.app-topbar-hamburger span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

.app-topbar-hamburger span::before { top: -5px; }
.app-topbar-hamburger span::after  { top: 5px; }

.app-topbar-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.app-topbar-mobile-overlay.active {
  display: block;
  opacity: 1;
}

.app-topbar-mobile-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  background: var(--bg-card);
  z-index: 999;
  box-shadow: var(--shadow-xl);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.app-topbar-mobile-menu.active {
  right: 0;
}

.app-topbar-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.app-topbar-mobile-header h3 {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.app-topbar-mobile-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid var(--border);
}

.app-topbar-mobile-close:hover {
  background: var(--danger-muted);
  color: var(--danger);
}

.app-topbar-mobile-body {
  padding: 8px;
  flex: 1;
}

.app-topbar-mobile-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
}

.app-topbar-mobile-item:hover {
  background: var(--primary-muted);
  color: var(--primary);
}

.app-topbar-mobile-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.app-topbar-mobile-item:hover svg {
  color: var(--primary);
}

.app-topbar-mobile-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 14px;
}

.app-topbar-mobile-item.danger {
  color: var(--danger);
}

.app-topbar-mobile-item.danger:hover {
  background: var(--danger-muted);
}

.app-topbar-mobile-item.danger svg {
  color: var(--danger);
}

@media (max-width: 768px) {
  .app-topbar-quicklinks { display: none; }
  .app-topbar-hamburger  { display: flex; }
  .app-topbar-balance    { display: none; }
  .app-topbar-page-title { display: none; }
  .app-topbar-sep        { display: none; }

  .page-hero-inner {
    padding: 20px 16px;
  }

  .page-hero-title {
    font-size: 18px;
  }

  .page-hero-sub {
    font-size: 12px;
  }

  .page-hero-icon {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 480px) {
  .page-hero-inner {
    padding: 16px;
    gap: 12px;
  }

  .page-hero-title {
    font-size: 16px;
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --font-3xl: 36px;
    --font-2xl: 28px;
  }
}

@media (max-width: 768px) {
  :root {
    --spacing-md: 16px;
    --spacing-lg: 20px;
    --font-3xl: 30px;
    --font-2xl: 26px;
    --font-xl: 22px;
  }

  h1 { font-size: var(--font-xl); }
  h2 { font-size: var(--font-lg); }

  .hero-section { padding: 36px 20px; }
  .hero-section h1 { font-size: var(--font-2xl); letter-spacing: -0.01em; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .modal-overlay { padding: 12px; }
  .modal { border-radius: var(--radius-xl); }

  .toast-container { top: 12px; right: 12px; width: calc(100% - 24px); }

  .tabs { overflow-x: auto; }
  .tab  { padding: 9px 14px; }
}

@media (max-width: 480px) {
  :root {
    --spacing-lg: 16px;
  }
  .stats-grid { grid-template-columns: 1fr; }
  .btn-lg { padding: 12px 22px; font-size: var(--font-base); }
  .btn-xl { padding: 13px 26px; font-size: var(--font-md); }
  .hero-section { padding: 28px 16px; }
  .card-body { padding: var(--spacing-md); }
}
