/* ============================================================
   AffiliateMatrix CRM — Master Stylesheet
   File 17/20
   Fonts: Syne (headings) + DM Sans (body) + DM Mono (code)
   ============================================================ */

/* ─── CSS Variables ───────────────────────────────────────── */
:root {
  --bg:          #0a0f1e;
  --bg2:         #0f1629;
  --surface:     #111827;
  --surface2:    #1a2235;
  --border:      #1f2d45;
  --border2:     #243048;
  --text:        #e2e8f0;
  --text2:       #94a3b8;
  --muted:       #4b5a72;
  --accent:      #6366f1;
  --accent-h:    #4f46e5;
  --accent2:     #8b5cf6;
  --green:       #10b981;
  --green-bg:    #052e16;
  --red:         #ef4444;
  --red-bg:      #2d0a0a;
  --orange:      #f59e0b;
  --orange-bg:   #2d1700;
  --blue:        #3b82f6;
  --blue-bg:     #0a1628;
  --teal:        #14b8a6;
  --purple:      #8b5cf6;
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:   0 8px 48px rgba(0,0,0,.6);
  --transition:  all .2s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
  --bg:       #f1f5f9;
  --bg2:      #e2e8f0;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;
  --text:     #0f172a;
  --text2:    #475569;
  --muted:    #94a3b8;
  --shadow:   0 4px 24px rgba(0,0,0,.08);
  --shadow-lg:0 8px 48px rgba(0,0,0,.12);
}

/* ─── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: 'DM Mono', monospace; font-size: .85em; }

/* ─── Login Screen Theme Toggle ─────────────────────────────── */
.login-theme-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1100;
  box-shadow: var(--shadow);
}
.login-theme-btn:hover { background: var(--surface2); transform: scale(1.1); }

/* ─── Login Screen ────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,.06) 0%, transparent 50%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp .4s ease;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  gap: 4px;
}

.brand-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(99,102,241,.6));
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}

.brand-sub, .brand-tag {
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ─── App Shell Layout ────────────────────────────────────── */
.admin-body, .webmaster-body {
  display: flex;
  min-height: 100vh;
}

/* #app-shell is the real flex container for sidebar + main-content.
   It is a flex item inside body (.admin-body/.webmaster-body) so it
   needs flex:1 to fill the full viewport width, and min-height:100vh
   so its internal column layout fills the full height. */
#app-shell {
  flex: 1;
  min-width: 0;          /* allow shrink in body's flex-row — prevents wide tables pushing layout */
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header .brand-icon { font-size: 1.6rem; margin-bottom: 0; filter: none; }
.sidebar-header .brand-name { font-size: 1.05rem; font-family: 'Syne', sans-serif; font-weight: 700; }
.sidebar-header .brand-sub  { font-size: .65rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.15); color: var(--accent); font-weight: 600; }
.nav-item.active .nav-icon { filter: none; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-toggle, .btn-logout {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.theme-toggle:hover { background: var(--surface2); }
.btn-logout { color: var(--red); border-color: rgba(239,68,68,.3); }
.btn-logout:hover { background: var(--red-bg); }

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;           /* allow column to shrink — critical for table scroll */
  min-height: 100vh;
  overflow-x: hidden;     /* prevent wide tables from pushing the layout */
  transition: margin-left .3s ease;
}

/* ─── Top Bar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamburger {
  background: none; border: none; color: var(--text2);
  font-size: 1.25rem; cursor: pointer; padding: 4px;
  display: none;
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

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

/* ─── Notification Dropdown ─────────────────────────────────────────────── */
.notif-wrapper {
  position: relative;
}
.notif-bell {
  cursor: pointer;
  font-size: 1.1rem;
  position: relative;
  padding: 6px 8px;
  border-radius: 8px;
  transition: var(--transition);
  user-select: none;
}
.notif-bell:hover { background: var(--surface2); }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: notifSlide .18s ease;
}
.notif-dropdown.open { display: flex; }

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

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-header-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .02em;
}
.notif-mark-all {
  font-size: .72rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  transition: opacity .15s;
}
.notif-mark-all:hover { opacity: .7; }

.notif-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: rgba(99,102,241,.06); }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.notif-icon.type-conversion  { background: rgba(16,185,129,.15); }
.notif-icon.type-fraud        { background: rgba(239,68,68,.15); }
.notif-icon.type-payout       { background: rgba(245,158,11,.15); }
.notif-icon.type-publisher    { background: rgba(99,102,241,.15); }
.notif-icon.type-automation   { background: rgba(139,92,246,.15); }
.notif-icon.type-system       { background: rgba(107,114,128,.15); }
.notif-icon.type-default      { background: var(--surface2); }

.notif-body { flex: 1; min-width: 0; }
.notif-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-msg {
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time {
  font-size: .68rem;
  color: var(--muted);
  margin-top: 5px;
  opacity: .7;
}

.notif-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}
.notif-empty-icon { font-size: 2rem; margin-bottom: 10px; opacity: .5; }

.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  flex-shrink: 0;
}
.notif-footer a {
  font-size: .75rem;
  color: var(--accent);
  text-decoration: none;
}
.notif-footer a:hover { text-decoration: underline; }

.notif-loading {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
}

.admin-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
}

/* ─── Page Content ────────────────────────────────────────── */
.page-content {
  flex: 1;
  min-width: 0;           /* constrain width in flex-column parent */
  padding: 24px;
  animation: fadeIn .2s ease;
}

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

.page-h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}

/* ─── Stat Cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border2);
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::before { background: var(--accent); }

.stat-card.accent-blue::before  { background: var(--blue); }
.stat-card.accent-green::before { background: var(--green); }
.stat-card.accent-purple::before{ background: var(--purple); }
.stat-card.accent-orange::before{ background: var(--orange); }
.stat-card.accent-teal::before  { background: var(--teal); }
.stat-card.accent-red::before   { background: var(--red); }

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-sub {
  font-size: .75rem;
  color: var(--muted);
}

/* ─── Chart Cards ─────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card.chart-wide { grid-column: span 1; }

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}

.chart-controls {
  display: flex;
  gap: 4px;
}

.chart-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .75rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.chart-btn:hover, .chart-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── Tables Row ──────────────────────────────────────────── */
.tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ─── Table Card ──────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;       /* horizontal scroll for wide tables */
  overflow-y: hidden;     /* keep border-radius clipping vertically */
}

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

.table-title {
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}

.table-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.data-table td strong { color: var(--text); }

.loading-cell, .empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 32px !important;
  font-size: .875rem;
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.badge-active    { background: rgba(16,185,129,.15); color: var(--green); }
.badge-pending   { background: rgba(245,158,11,.15);  color: var(--orange); }
.badge-processing{ background: rgba(245,158,11,.15);  color: var(--orange); }
.badge-paused    { background: rgba(75,85,99,.2);     color: #9ca3af; }
.badge-rejected  { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-cancelled { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-suspended { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-banned    { background: rgba(239,68,68,.25);   color: #ff6060; }
.badge-approved  { background: rgba(16,185,129,.15);  color: var(--green); }
.badge-fraud     { background: rgba(239,68,68,.2);    color: var(--red); }
.badge-spam      { background: rgba(239,68,68,.2);    color: var(--red); }
.badge-wrong-number { background: rgba(251,146,60,.2); color: #fb923c; }
.badge-sent      { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-failed    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-paid      { background: rgba(16,185,129,.15);  color: var(--green); }
.badge-model     { background: rgba(99,102,241,.15);  color: var(--accent); }

/* ─── Fraud Score ─────────────────────────────────────────── */
.fraud-score { font-family: 'DM Mono', monospace; font-weight: 600; font-size: .8rem; }
.fs-0 { color: var(--green); }
.fs-1 { color: var(--green); }
.fs-2 { color: var(--orange); }
.fs-3 { color: var(--orange); }
.fs-4 { color: var(--red); }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-input::placeholder { color: var(--muted); }

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

.code-input {
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--accent-h); transform: translateY(-1px); }

.btn-secondary {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-secondary:hover { background: var(--surface2); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-danger:hover { background: rgba(239,68,68,.2); }

.btn-full { width: 100%; justify-content: center; }

.btn-sm {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .75rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--border); color: var(--text); }
.btn-sm-green { color: var(--green); border-color: rgba(16,185,129,.3); }
.btn-sm-green:hover { background: var(--green-bg); }
.btn-sm-danger { color: var(--red); border-color: rgba(239,68,68,.3); }
.btn-sm-danger:hover { background: var(--red-bg); }

/* ─── Modals ──────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp .2s ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.modal-header button {
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; padding: 4px;
  border-radius: 6px; transition: var(--transition);
}
.modal-header button:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 24px; }

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

/* ─── Alerts ──────────────────────────────────────────────── */
.alert-error {
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .875rem;
  margin-bottom: 16px;
}

.alert-success {
  background: var(--green-bg);
  border: 1px solid rgba(16,185,129,.3);
  color: #6ee7b7;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .875rem;
  margin-bottom: 16px;
}

/* ─── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.page-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.page-btn:hover, .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Activity Feed ───────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  border-left: 3px solid var(--border2);
  transition: var(--transition);
}
.feed-item:hover { border-left-color: var(--accent); }
.feed-item.feed-conversion { border-left-color: var(--green); }
.feed-item.feed-lead { border-left-color: var(--blue); }

.feed-icon { font-size: 1rem; flex-shrink: 0; }
.feed-details { flex: 1; color: var(--text2); line-height: 1.4; }
.feed-details strong { color: var(--text); }
.feed-status { font-size: .7rem; font-weight: 600; text-transform: uppercase; }
.feed-time { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.profit-badge { background: rgba(16,185,129,.15); color: var(--green); padding: 2px 6px; border-radius: 4px; font-size: .7rem; font-weight: 700; margin-left: 6px; }

/* ─── Docs Page ───────────────────────────────────────────── */
/* ─── Documentation / Guide Styles ──────────────────────────── */
/* ─── Documentation Layout ───────────────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  align-items: start;
  max-width: 1100px;
}

/* Sticky sidebar nav */
.docs-nav {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 0 18px;
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.docs-nav::-webkit-scrollbar { width: 3px; }
.docs-nav::-webkit-scrollbar-thumb { background: var(--border); }

.docs-nav-title {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  padding: 0 18px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.docs-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  font-size: .8rem;
  color: var(--text2);
  text-decoration: none;
  line-height: 1.3;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.docs-nav a:hover { color: var(--text); background: var(--surface2); }
.docs-nav a.active {
  color: var(--accent);
  background: rgba(99,102,241,.08);
  border-left-color: var(--accent);
  font-weight: 600;
}
.docs-nav-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 18px;
}
.docs-nav-icon { font-size: .9rem; flex-shrink: 0; }

/* Main content column */
.docs-body { min-width: 0; }

.doc-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.doc-section:last-child { margin-bottom: 0; }

.doc-section h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.doc-section h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  margin: 22px 0 9px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.doc-section h3:first-of-type { margin-top: 4px; }
.doc-section h4 {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text2);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.doc-section p {
  color: var(--text2);
  font-size: .875rem;
  line-height: 1.8;
  margin-bottom: .9rem;
}
.doc-section p:last-child { margin-bottom: 0; }
.doc-section ul, .doc-section ol {
  padding-left: 1.5rem;
  color: var(--text2);
  font-size: .875rem;
  line-height: 1.8;
  margin-bottom: .9rem;
}
.doc-section li { margin-bottom: 5px; }
.doc-section li strong { color: var(--text); }
.doc-section code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  color: var(--accent2);
}
.doc-section a { color: var(--accent); text-decoration: none; }
.doc-section a:hover { text-decoration: underline; }

/* Callout boxes */
.doc-tip, .doc-warn, .doc-danger, .doc-info {
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 14px 0;
  font-size: .855rem;
  color: var(--text2);
  line-height: 1.7;
  display: flex;
  gap: 10px;
}
.doc-tip    { background: rgba(16,185,129,.07);  border-left: 3px solid var(--green); }
.doc-warn   { background: rgba(245,158,11,.07);  border-left: 3px solid #f59e0b; }
.doc-danger { background: rgba(239,68,68,.07);   border-left: 3px solid var(--red); }
.doc-info   { background: rgba(99,102,241,.07);  border-left: 3px solid var(--accent); }
.doc-tip .doc-icon, .doc-warn .doc-icon, .doc-danger .doc-icon, .doc-info .doc-icon {
  font-size: 1rem; flex-shrink: 0; margin-top: 1px;
}
.doc-tip strong    { color: var(--green); }
.doc-warn strong   { color: #f59e0b; }
.doc-danger strong { color: var(--red); }
.doc-info strong   { color: var(--accent); }

/* Code blocks */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
  color: var(--green);
  white-space: pre;
  overflow-x: auto;
  line-height: 1.65;
  margin: 10px 0;
}
.code-block .cm { color: var(--muted); }
.code-block .ck { color: var(--accent2); }
.code-block .cv { color: #f59e0b; }

/* Tables */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .825rem;
  margin: 12px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.doc-table th {
  text-align: left;
  padding: 9px 14px;
  background: var(--bg);
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.doc-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: top;
  line-height: 1.55;
}
.doc-table td strong { color: var(--text); }
.doc-table td code  { font-size: .75rem; }
.doc-table td:first-child { white-space: nowrap; }
.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover td { background: var(--surface2); }
.doc-table-mono td:first-child {
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  color: var(--accent2);
}

/* Steps */
.steps-list { display: flex; flex-direction: column; gap: 14px; margin: 14px 0; }
.step-item  { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
  letter-spacing: -.01em;
}
.step-num.green  { background: var(--green); }
.step-num.yellow { background: #f59e0b; }
.step-num.red    { background: var(--red); }
.step-num.gray   { background: var(--muted); }
.step-item > div { color: var(--text2); font-size: .875rem; line-height: 1.7; }
.step-item > div strong { color: var(--text); display: block; margin-bottom: 3px; font-size: .9rem; font-weight: 700; }

/* Metric grid */
.doc-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
  gap: 12px;
  margin: 14px 0;
}
.doc-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.doc-metric-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 5px; }
.doc-metric-value { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.doc-metric-desc  { font-size: .75rem; color: var(--text2); margin-top: 4px; line-height: 1.4; }

/* Badge row */
.doc-badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; align-items: center; }
.doc-badge-row .badge { font-size: .73rem; }

/* Responsive: collapse sidebar on narrow screens */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: none; }
}

/* ─── Filters Bar ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filters-bar .form-input { width: auto; }

/* ─── Search Input ────────────────────────────────────────── */
.search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  color: var(--text);
  font-size: .8rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  min-width: 200px;
}
.search-input:focus { border-color: var(--accent); }

.filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  color: var(--text);
  font-size: .8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ─── Token Code ──────────────────────────────────────────── */
.token-code {
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  color: var(--teal);
  background: rgba(20,184,166,.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── Offer Campaign Cards (Webmaster) ─────────────────────── */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.offer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.offer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.offer-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

.offer-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.offer-card-title { font-family: 'Syne', sans-serif; font-size: .95rem; font-weight: 700; color: var(--text); }
.offer-card-body { color: var(--text2); font-size: .8rem; line-height: 1.8; margin-bottom: 16px; }
.offer-card-row { display: flex; justify-content: space-between; }
.offer-card-label { color: var(--muted); }
.offer-card-val { color: var(--text); font-weight: 600; }
.payout-big { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; color: var(--green); }
.offer-card-footer { display: flex; gap: 8px; margin-top: 12px; }

/* ─── Balance Widgets ─────────────────────────────────────── */
.balance-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 24px; }
.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.balance-amount { font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800; margin: 8px 0 4px; }
.balance-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

/* ─── Tracking Link Widget ────────────────────────────────── */
.tracking-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.tracking-url-box {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.tracking-url-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--teal);
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  outline: none;
}

/* ─── Date Filter ─────────────────────────────────────────── */
.date-filter select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text);
  font-size: .8rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

/* ─── Toast Notifications ─────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .85rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideInRight .3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--blue); }

/* ─── Loading Spinner ─────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--muted);
  font-size: .875rem;
}
.loading-spinner::before {
  content: '';
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 12px;
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes fadeIn        { from { opacity:0 }              to { opacity:1 } }
@keyframes fadeInUp      { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:none } }
@keyframes slideInRight  { from { opacity:0; transform:translateX(20px) } to { opacity:1; transform:none } }
@keyframes spin          { to { transform: rotate(360deg) } }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .charts-row  { grid-template-columns: 1fr; }
  .tables-row  { grid-template-columns: 1fr; }
  .balance-grid{ grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .balance-grid{ grid-template-columns: 1fr; }
  .offers-grid { grid-template-columns: 1fr; }
  .modal-content { margin: 0; max-height: 100vh; border-radius: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: .95rem; }
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   LOGIN REFINEMENTS — pixel-match reference designs
   (scoped to login screens only; overrides earlier declarations)
   ============================================================ */

/* Per-portal background vignettes */
.admin-body      .login-overlay,
.webmaster-body  .login-overlay,
body             .login-overlay { background: #0a0f1e; }

.admin-body .login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(234,88,12,.35) 0%, rgba(120,40,0,.22) 35%, transparent 70%),
    #0a0f1e;
}
.webmaster-body .login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(16,185,129,.30) 0%, rgba(4,60,40,.22) 35%, transparent 70%),
    #0a0f1e;
}
#sa-login.login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(239,68,68,.30) 0%, rgba(80,0,0,.22) 35%, transparent 70%),
    #0a0f1e;
}

/* Light mode — keep the same warm vignettes so the backdrop matches the reference light shots */
[data-theme="light"] .admin-body .login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(234,88,12,.55) 0%, rgba(120,40,0,.35) 35%, rgba(20,10,5,.9) 80%),
    #1a0b04;
}
[data-theme="light"] .webmaster-body .login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(16,185,129,.45) 0%, rgba(4,60,40,.35) 35%, rgba(5,20,15,.9) 80%),
    #04140e;
}
[data-theme="light"] #sa-login.login-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(239,68,68,.45) 0%, rgba(80,0,0,.35) 35%, rgba(20,5,5,.9) 80%),
    #1a0505;
}

/* Card — tighten spacing + soften radius */
.login-card {
  padding: 40px 40px 32px;
  border-radius: 16px;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
[data-theme="light"] .login-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

/* Brand block — icon tile + title + subtitle */
.login-brand { margin-bottom: 28px; gap: 10px; }

.login-card .brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 6px;
  filter: none;
  border: 1px solid transparent;
}
.admin-body     .login-card .brand-icon { background: rgba(234,88,12,.18); color: #fb923c; border-color: rgba(234,88,12,.35); }
.webmaster-body .login-card .brand-icon { background: rgba(16,185,129,.18); color: #34d399; border-color: rgba(16,185,129,.35); }
#sa-login       .login-card .brand-icon { background: rgba(239,68,68,.18); color: #f87171; border-color: rgba(239,68,68,.35); }

[data-theme="light"] .admin-body     .login-card .brand-icon { background: #ffedd5; color: #ea580c; border-color: #fed7aa; }
[data-theme="light"] .webmaster-body .login-card .brand-icon { background: #d1fae5; color: #059669; border-color: #a7f3d0; }
[data-theme="light"] #sa-login       .login-card .brand-icon { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

.login-card .brand-name {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.01em;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.login-card .brand-tag {
  font-size: .9rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text2);
  font-weight: 400;
}

/* Form labels & inputs on login — larger and clearer than the admin table forms */
.login-card .form-group { margin-bottom: 18px; }
.login-card .form-group label {
  font-size: .82rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 8px;
}
.login-card .form-input {
  padding: 12px 14px 12px 42px;
  font-size: .9rem;
  border-radius: 10px;
  background: var(--bg);
  border-color: var(--border);
}
[data-theme="light"] .login-card .form-input {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #0f172a;
}

/* Icon-in-input wrapper */
.login-card .input-wrap { position: relative; }
.login-card .input-wrap > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

/* Primary CTA — per-portal color */
.login-card .btn-primary {
  margin-top: 6px;
  padding: 13px 18px;
  font-size: .95rem;
  font-weight: 600;
  border-radius: 10px;
  gap: 0;
}
.admin-body     .login-card .btn-primary { background: #ea580c; border-color: #ea580c; }
.admin-body     .login-card .btn-primary:hover { background: #c2410c; }
.webmaster-body .login-card .btn-primary { background: #10b981; border-color: #10b981; }
.webmaster-body .login-card .btn-primary:hover { background: #059669; }
#sa-login       .login-card .btn-primary { background: #dc2626 !important; border-color: #dc2626 !important; }
#sa-login       .login-card .btn-primary:hover { background: #b91c1c !important; }

[data-theme="light"] .admin-body     .login-card .btn-primary { background: #fdba74; border-color: #fdba74; color: #fff; }
[data-theme="light"] .webmaster-body .login-card .btn-primary { background: #6ee7b7; border-color: #6ee7b7; color: #fff; }

/* Back-to-portal + footer helper */
.login-card .login-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  font-size: .85rem;
  color: var(--text2);
  text-decoration: none;
  transition: color .15s;
}
.login-card .login-back:hover { color: var(--text); }
.login-card .login-back svg { width: 14px; height: 14px; }

.login-card .login-footer {
  text-align: center;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--muted);
}
[data-theme="light"] .login-card .login-footer { border-top-color: #e2e8f0; }

/* Theme toggle — match the reference round pill */
.login-theme-btn {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  color: var(--text);
}
[data-theme="light"] .login-theme-btn {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.25);
  color: #fff;
}

/* Responsive — login screen on small devices */
@media (max-width: 520px) {
  .login-card { padding: 32px 24px 24px; border-radius: 14px; margin: 16px; }
  .login-card .brand-name { font-size: 1.5rem; }
  .login-theme-btn { top: 14px; right: 14px; width: 38px; height: 38px; }
}

/* ============================================================
   DASHBOARD REFINEMENTS — pixel-match reference design
   (Sidebar logo tile, green active nav, topbar w/ search+theme,
    refined stat cards. Scoped to .admin-body / .webmaster-body.)
   ============================================================ */

/* ─── Sidebar header — green logo tile ──────────────────────── */
.sidebar-header { padding: 22px 20px 20px; gap: 12px; }

.sidebar-header .brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(16,185,129,.15);
  border: 1px solid rgba(16,185,129,.3);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin: 0;
  flex-shrink: 0;
  filter: none;
}
[data-theme="light"] .sidebar-header .brand-icon {
  background: #d1fae5;
  border-color: #a7f3d0;
  color: #059669;
}

.sidebar-header .brand-name {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.sidebar-header .brand-sub {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-top: 2px;
}

/* ─── Sidebar nav — green active state, hide section labels ──── */
.sidebar-nav { padding: 16px 12px; }

.sidebar-nav .nav-section-label { display: none; }

.nav-item {
  padding: 11px 14px;
  font-size: .9rem;
  border-radius: 10px;
  margin-bottom: 4px;
  gap: 12px;
}
.nav-item .nav-icon {
  font-size: 1.05rem;
  width: 22px;
  opacity: .75;
}
.nav-item.active {
  background: rgba(16,185,129,.12);
  color: #10b981;
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }

[data-theme="light"] .nav-item.active {
  background: #d1fae5;
  color: #059669;
}

/* ─── Sidebar footer — hide theme button (it lives in topbar now) ─ */
.sidebar-footer .theme-toggle { display: none; }

.sidebar-footer {
  padding: 14px 16px 18px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.sidebar-footer .admin-avatar-mini {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.sidebar-footer .btn-logout {
  flex: 1;
  text-align: left;
  padding: 8px 12px;
  font-size: .85rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text2);
}
.sidebar-footer .btn-logout:hover { background: transparent; color: var(--red); }

/* ─── Topbar — title left, search center, actions right ─────── */
.topbar {
  height: 68px;
  padding: 0 28px;
  gap: 20px;
}
.topbar-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
  flex: 0 0 auto;
  min-width: 220px;
}

.topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.topbar-search > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 10px 40px;
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search input:focus { border-color: var(--border2); }
[data-theme="light"] .topbar-search input { background: #f8fafc; }

.topbar-actions { gap: 14px; }

.topbar-theme-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.topbar-theme-btn:hover { background: var(--surface2); color: var(--text); }
.topbar-theme-btn svg { width: 18px; height: 18px; }

.notif-bell {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text2);
}
.notif-bell:hover { color: var(--text); }

.admin-avatar {
  width: 34px;
  height: 34px;
  font-size: .78rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* ─── Page content / header refinements ──────────────────────── */
.page-content { padding: 28px 32px; }

.page-header { margin-bottom: 22px; }
.page-h1 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ─── Stat cards — match reference layout ────────────────────── */
.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 22px 20px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}
.stat-card::before { display: none; }
.stat-card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border2);
}

.stat-card .stat-value {
  order: 2;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0;
  margin-top: auto;
}
.stat-card .stat-label {
  order: 3;
  font-size: .82rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text2);
  margin: 0;
}
.stat-card .stat-sub {
  order: 4;
  font-size: .72rem;
  color: var(--muted);
  margin-top: 2px;
}

[data-theme="light"] .stat-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

/* ─── Chart cards refinement ─────────────────────────────────── */
.charts-row .card,
.card {
  border-radius: 14px;
}
[data-theme="light"] .card { background: #ffffff; border-color: #e2e8f0; }

/* ─── Mobile / tablet responsive tweaks ──────────────────────── */
@media (max-width: 1024px) {
  .topbar-search { max-width: 320px; }
  .topbar-title { min-width: 0; font-size: 1.15rem; }
}
@media (max-width: 768px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar-search { display: none; }
  .page-content { padding: 18px 16px; }
  .stat-card { min-height: 120px; padding: 18px; }
  .stat-card .stat-value { font-size: 1.55rem; }
}

/* ═══════════════ SUPER ADMIN DASHBOARD REFINEMENTS ═══════════════ */
.sa-brand-wrap { display: flex; align-items: center; gap: 12px; }
.sa-brand-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(239,68,68,.15); color: #f87171;
  border: 1px solid rgba(239,68,68,.3);
}
.sa-brand-icon svg { width: 20px; height: 20px; }
[data-theme="light"] .sa-brand-icon {
  background: rgba(220,38,38,.12); color: #dc2626;
  border-color: rgba(220,38,38,.3);
}
.sa-header-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.sa-icon-btn {
  background: none; border: none; color: var(--text2);
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.sa-icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.sa-icon-btn svg { width: 20px; height: 20px; }
[data-theme="light"] .sa-icon-btn:hover { background: rgba(0,0,0,.05); }
.sa-signout-btn {
  background: none; border: none; color: #f87171;
  font-size: .9rem; font-weight: 500; cursor: pointer;
  padding: 8px 12px; border-radius: 8px;
  transition: background .15s;
}
.sa-signout-btn:hover { background: rgba(239,68,68,.1); }
[data-theme="light"] .sa-signout-btn { color: #dc2626; }

/* SA stat cards refined */
.sa-stat {
  padding: 22px 20px !important;
  border-radius: 14px !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 140px !important;
}
.sa-stat::before { display: none !important; }
.sa-stat .sa-stat-value,
.sa-stat > .value {
  order: 2;
  font-size: 1.85rem !important;
  margin-top: auto;
  text-transform: none !important;
}
.sa-stat .sa-stat-label,
.sa-stat > .label {
  order: 3;
  font-size: .82rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--text2);
}
