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

:root {
  --bg:          #0d0f12;
  --bg-2:        #131619;
  --bg-3:        #1a1d22;
  --bg-4:        #20242b;
  --border:      #2a2f38;
  --border-2:    #333a45;
  --text:        #e8eaed;
  --text-1:      #e8eaed;
  --text-2:      #9aa3b0;
  --text-3:      #5a6478;
  --accent:      #3b82f6;
  --accent-2:    #2563eb;
  --accent-dim:  #1d3a6e;
  --green:       #22c55e;
  --green-dim:   #14532d;
  --red:         #ef4444;
  --red-dim:     #7f1d1d;
  --yellow:      #f59e0b;
  --yellow-dim:  #78350f;
  --purple:      #a78bfa;
  --purple-dim:  #3b1f6e;
  --sidebar-w:   232px;
  --radius:      8px;
  --radius-lg:   12px;
  --topbar-h:    52px;
  --content-px:  1.75rem;
}

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}

/* ── Light mode ────────────────────────────────────────────────────────── */
html.light {
  --bg:          #f4f5f7;
  --bg-2:        #ffffff;
  --bg-3:        #f8f9fb;
  --bg-4:        #eef0f3;
  --border:      #e2e5ea;
  --border-2:    #c8cdd6;
  --text:        #111827;
  --text-1:      #111827;
  --text-2:      #4b5563;
  --text-3:      #9ca3af;
  --accent:      #2563eb;
  --accent-2:    #1d4ed8;
  --accent-dim:  #dbeafe;
  --green:       #16a34a;
  --green-dim:   #dcfce7;
  --red:         #dc2626;
  --red-dim:     #fee2e2;
  --yellow:      #d97706;
  --yellow-dim:  #fef3c7;
  --purple:      #7c3aed;
  --purple-dim:  #ede9fe;
}

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

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: .875rem .625rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section-label {
  font-size: .63rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 .625rem;
  margin-bottom: .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-size: .855rem;
  font-weight: 400;
  transition: background .12s, color .12s;
  margin-bottom: .1rem;
  cursor: pointer;
}

.nav-item:hover  { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item svg    { flex-shrink: 0; opacity: .7; transition: opacity .12s; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

/* Notification dot on nav items */
.nav-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.nav-dot--warn { background: var(--yellow); }

.sidebar-footer {
  padding: .75rem .875rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

.user-info     { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }

.user-avatar {
  width: 28px; height: 28px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; min-width: 0; }

.user-name {
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.4;
}

.user-badge {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 99px;
  display: inline-block;
  margin-top: 1px;
  line-height: 1.5;
}

.badge-admin      { background: #7c3aed33; color: #a78bfa; }
.badge-free       { background: var(--bg-4); color: var(--text-3); }
.badge-basic      { background: var(--accent-dim); color: var(--accent); }
.badge-pro        { background: #065f4633; color: #34d399; }
.badge-enterprise { background: #78350f33; color: #fbbf24; }

html.light .badge-admin      { background: #ede9fe; color: #7c3aed; }
html.light .badge-basic      { background: #dbeafe; color: #2563eb; }
html.light .badge-pro        { background: #d1fae5; color: #059669; }
html.light .badge-enterprise { background: #fef3c7; color: #d97706; }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-3);
  padding: .35rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
  line-height: 0;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }
.logout-form { display: flex; }

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

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--content-px);
  gap: .875rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: .25rem;
  border-radius: var(--radius);
  line-height: 0;
}

.topbar-title {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

/* Conversions pill */
.topbar-pill {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .28rem .7rem;
}
.topbar-pill__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.topbar-pill__value {
  font-size: .75rem;
  font-weight: 600;
  color: var(--green);
  font-family: 'DM Mono', monospace;
}

/* Icon-only button */
.btn-icon {
  width: 30px; height: 30px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s, color .15s;
  flex-shrink: 0;
  line-height: 0;
}
.btn-icon:hover { background: var(--bg-4); color: var(--text); }

/* ── Main content ──────────────────────────────────────────────────────── */
.main-content {
  padding: 1.5rem var(--content-px);
  flex: 1;
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }

.page-header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--text);
  line-height: 1.3;
}

.page-header p, .page-subtitle {
  font-size: .84rem;
  color: var(--text-2);
  margin-top: .2rem;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Flash messages ────────────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .84rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.flash svg      { flex-shrink: 0; }
.flash-success  { background: var(--green-dim);  color: var(--green);  border: 1px solid #16a34a44; }
.flash-error    { background: var(--red-dim);    color: var(--red);    border: 1px solid #dc262644; }
.flash-info     { background: var(--accent-dim); color: var(--accent); border: 1px solid #3b82f644; }

/* ── Dashboard KPI grid ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

/* ── Stat / KPI cards ──────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border-2);
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  border-radius: 3px 3px 0 0;
}

.stat-card--accent::before { background: var(--accent); }
.stat-card--green::before  { background: var(--green); }
.stat-card--warn::before   { background: var(--yellow); }
.stat-card--red::before    { background: var(--red); }
.stat-card--purple::before { background: var(--purple); }

.stat-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: .5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -.03em;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  line-height: 1.1;
}

.stat-sub {
  font-size: .73rem;
  color: var(--text-3);
  margin-top: .4rem;
}

.stat-card--accent .stat-value { color: var(--accent); }
.stat-card--green  .stat-value { color: var(--green); }
.stat-card--warn   .stat-value { color: var(--yellow); }
.stat-card--red    .stat-value { color: var(--red); }
.stat-card--purple .stat-value { color: var(--purple); }

/* ── Filter bar ────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.day-picker {
  display: flex;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.day-btn {
  padding: .35rem .75rem;
  font-size: .78rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.day-btn:hover  { color: var(--text); background: var(--bg-4); }
.day-btn.active { background: var(--accent); color: #fff; }

.day-picker__sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

.date-input {
  padding: .3rem .5rem;
  font-size: .75rem;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-2);
  font-family: inherit;
  cursor: pointer;
  outline: none;
  width: 130px;
}
.date-input:last-of-type { border-left: none; }

.date-sep {
  padding: .35rem .2rem;
  font-size: .75rem;
  color: var(--text-3);
  line-height: 1.8;
  user-select: none;
}

.filter-status {
  font-size: .75rem;
  color: var(--text-3);
}

/* ── Charts section ────────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.side-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-legend {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}

.legend-item {
  font-size: .72rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: .3rem;
}
.legend-item::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.legend-item--blue::before   { background: #3b82f6; }
.legend-item--green::before  { background: #22c55e; }
.legend-item--purple::before { background: #a78bfa; }

/* Fraud breakdown */
.fraud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .28rem 0;
}
.fraud-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Quota */
.quota-labels {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-2);
  margin-bottom: .4rem;
}

/* ── Bottom grid ───────────────────────────────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}

/* App list rows */
.app-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem 1rem;
  text-decoration: none;
  transition: background .12s;
}
.app-row:hover { background: var(--bg-3); }

.app-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.app-meta { min-width: 0; flex: 1; }

.app-name {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bundle {
  font-size: .68rem;
  color: var(--text-3);
}

.card-action-link {
  font-size: .75rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: opacity .15s;
}
.card-action-link:hover { opacity: .75; }

/* Mono table cells */
.mono-cell {
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.card-title    { font-size: .875rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.card-body     { padding: 1.25rem; }

.section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.section-title { font-size: .875rem; font-weight: 600; color: var(--text); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

.data-table thead th {
  text-align: left;
  padding: .55rem 1rem;
  font-size: .67rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  white-space: nowrap;
}

.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-3); }

.data-table tbody td {
  padding: .65rem 1rem;
  color: var(--text-2);
  vertical-align: middle;
}

.data-table tbody td a { color: var(--accent); text-decoration: none; }
.data-table tbody td a:hover { text-decoration: underline; }

/* ── Badges / Pills ────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .67rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: 99px;
  line-height: 1.6;
}

.pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.pill-green  { background: var(--green-dim);  color: var(--green); }
.pill-red    { background: var(--red-dim);    color: var(--red); }
.pill-yellow { background: var(--yellow-dim); color: var(--yellow); }
.pill-blue   { background: var(--accent-dim); color: var(--accent); }
.pill-gray   { background: var(--bg-4);       color: var(--text-3); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .95rem;
  border-radius: var(--radius);
  font-size: .84rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary           { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-2); border-color: var(--accent-2); }

.btn-secondary         { background: var(--bg-4); color: var(--text); border-color: var(--border); }
.btn-secondary:hover   { border-color: var(--border-2); }

.btn-danger            { background: transparent; color: var(--red); border-color: var(--red-dim); }
.btn-danger:hover      { background: var(--red-dim); }

.btn-sm   { padding: .32rem .7rem; font-size: .78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: .375rem;
}

.form-input, .form-control {
  width: 100%;
  padding: .52rem .875rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
  appearance: none;
}

.form-input:focus, .form-control:focus { border-color: var(--accent); }
.form-input::placeholder, .form-control::placeholder { color: var(--text-3); }
select.form-input, select.form-control { cursor: pointer; }

.form-hint  { font-size: .74rem; color: var(--text-3); margin-top: .3rem; }
.form-error { font-size: .74rem; color: var(--red);    margin-top: .3rem; }

/* ── Top-up price box ──────────────────────────────────────────────────── */
.price-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem;
  margin-bottom: 1rem;
}

.price-row {
  display: flex;
  justify-content: space-between;
  font-size: .84rem;
  color: var(--text-2);
  padding: .25rem 0;
}
.price-row:not(:last-child) { border-bottom: none; }
.price-row--total {
  border-top: 1px solid var(--border);
  margin-top: .35rem;
  padding-top: .6rem;
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
}

.price-val { color: var(--text); font-weight: 500; }

/* ── Mono / Code ───────────────────────────────────────────────────────── */
.mono {
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-2);
  border: 1px solid var(--border);
  word-break: break-all;
}

pre.code-block {
  font-family: 'DM Mono', monospace;
  font-size: .8rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre;
}

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .375rem; justify-content: center; padding: 1rem; }

.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: .8rem;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}

.page-btn:hover   { border-color: var(--border-2); color: var(--text); }
.page-btn.current { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; }

.empty-icon {
  width: 48px; height: 48px;
  background: var(--bg-3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: var(--text-3);
}

.empty-state h3 { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.empty-state p  { font-size: .83rem; color: var(--text-2); margin-bottom: 1.25rem; }

/* ── Filters (section-level) ───────────────────────────────────────────── */
.filters {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}

.filters .form-input,
.filters .form-control {
  width: auto;
  min-width: 150px;
  padding: .38rem .7rem;
  font-size: .81rem;
}

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  transform: translateY(10px) scale(.99);
  transition: transform .2s;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: .9rem; font-weight: 600; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  font-size: 1.25rem;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }

.modal-body { padding: 1.25rem; }

/* ── Progress bar ──────────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-4);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s ease;
}

.progress-fill--green  { background: var(--green); }
.progress-fill--yellow { background: var(--yellow); }
.progress-fill--red    { background: var(--red); }

/* ── SDK Docs ──────────────────────────────────────────────────────────── */
.sdk-tabs {
  display: flex;
  gap: .5rem;
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  overflow-x: auto;
}

.sdk-tab {
  padding: .7rem 1rem;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
  transition: color .15s;
}

.sdk-tab:hover { color: var(--text-2); }
.sdk-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.sdk-panel { display: none; padding: 1.5rem 1.25rem; }
.sdk-panel.active { display: block; }

.sdk-step { display: flex; gap: 1rem; margin-bottom: 1.5rem; align-items: flex-start; }

.sdk-step-num {
  width: 22px; height: 22px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}

.sdk-step-body h4 { font-size: .875rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.sdk-step-body p  { font-size: .83rem; color: var(--text-2); margin-bottom: .625rem; }

/* ── Auth pages ────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 2rem;
}

.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: 1.75rem;
  display: flex; align-items: center; gap: .625rem;
}

.auth-logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

.auth-footer {
  font-size: .81rem;
  color: var(--text-2);
  margin-top: 1.25rem;
  text-align: center;
}

.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Error page ────────────────────────────────────────────────────────── */
.error-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 1rem; text-align: center; padding: 2rem;
}

.error-code {
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: -.05em;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  line-height: 1;
}

.error-msg { font-size: 1rem; color: var(--text-2); }

/* ── Collapsible nav groups ─────────────────────────────────────────────── */
.nav-group { margin-bottom: .1rem; }

.nav-parent {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.nav-parent.open .nav-chevron { transform: rotate(180deg); }

.nav-children {
  display: none;
  padding-left: .5rem;
  margin-top: .1rem;
}

.nav-children.open { display: block; }

/* Children: hide the icon slot entirely so spacing is clean */
.nav-child {
  font-size: .82rem !important;
  padding: .38rem .65rem .38rem 1.6rem !important;
  position: relative;
}

.nav-child::before {
  content: '';
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background .12s;
}

.nav-child.active::before { background: var(--accent); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .chart-grid  { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .kpi-grid    { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.5); }
  .topbar-menu  { display: flex; }
  .main-wrap    { margin-left: 0; }
  .main-content { padding: 1.25rem; }
  :root { --content-px: 1.25rem; }
}

@media (max-width: 600px) {
  .kpi-grid     { grid-template-columns: 1fr 1fr; }
  .stat-grid    { grid-template-columns: 1fr 1fr; }
  .stat-value   { font-size: 1.4rem; }
  .main-content { padding: 1rem; }
  :root { --content-px: 1rem; }
}