@import url('./theme.css');

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

/* Utility — must be early so component-level display rules can override when needed */
.hidden { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #232744; }

a       { color: inherit; text-decoration: none; }
button  { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Client picker overlay ────────────────────────────────────────────────── */
.picker-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.picker-overlay.hidden { display: none; }

.picker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}

.picker-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.picker-logo__icon {
  width: 38px; height: 38px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 16px rgba(109,40,217,0.4);
}

.picker-logo__title { font-size: 17px; font-weight: 700; }
.picker-logo__sub   { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.07em; }

.picker-heading {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.025em;
}

.picker-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  color: var(--text);
}

.picker-item:hover {
  border-color: rgba(14,165,233,0.45);
  background: rgba(14,165,233,0.05);
}

.picker-item__name {
  font-size: 14px;
  font-weight: 600;
}

.picker-item__key {
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
  margin-top: 2px;
}

.picker-item__arrow {
  font-size: 18px;
  color: var(--text-dim);
}

.picker-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 11px;
}

.picker-divider::before,
.picker-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.picker-input-row {
  display: flex;
  gap: 8px;
}

.picker-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.picker-input::placeholder { color: var(--text-dim); }
.picker-input:focus { border-color: rgba(14,165,233,0.5); box-shadow: 0 0 0 3px rgba(14,165,233,0.08); }

.picker-btn {
  padding: 10px 18px;
  background: var(--gradient);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 20px rgba(109,40,217,0.3);
}

.picker-btn:hover { opacity: 0.88; box-shadow: 0 0 30px rgba(109,40,217,0.45); }

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

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #09090f;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  overflow-y: auto;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(109,40,217,0.45);
}

.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.logo-tag  { font-size: 10px; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 1px; }

.sidebar__nav { padding: 18px 10px; flex: 1; overflow-y: auto; }

.nav-section { margin-bottom: 28px; }

.nav-section__title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0 10px;
  margin-bottom: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.nav-item.active {
  background: rgba(109,40,217,0.10);
  color: #c4b5fd;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, #a78bfa, #6d28d9);
  border-radius: 0 3px 3px 0;
}

.nav-item.active .icon svg { stroke: #c4b5fd; }

.nav-item .icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-item .icon svg { width: 15px; height: 15px; stroke-width: 1.75; }

.sidebar__footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 2.5s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0.25;} }

/* ── Client badge (sidebar) ───────────────────────────────────────────────── */
.client-badge {
  margin: 10px 10px 0;
  padding: 10px 12px;
  background: rgba(109,40,217,0.07);
  border: 1px solid rgba(109,40,217,0.18);
  border-radius: var(--radius-sm);
}

.client-badge__label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.client-badge__name {
  font-size: 12.5px;
  font-weight: 700;
  color: #c4b5fd;
}

.client-badge__key {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: rgba(8,10,16,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 5;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02), 0 4px 24px rgba(0,0,0,0.3);
}

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

.page-title    { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.page-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.topbar__right { display: flex; align-items: center; gap: 10px; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  transition: all 0.15s;
}
.refresh-btn svg { width: 13px; height: 13px; }
.refresh-btn:hover { color: var(--text); border-color: rgba(14,165,233,0.3); background: rgba(14,165,233,0.05); }

.switch-client-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(109,40,217,0.08);
  border: 1px solid rgba(109,40,217,0.2);
  border-radius: var(--radius-sm);
  color: #c4b5fd;
  font-size: 12px; font-weight: 600;
  transition: all 0.15s;
}
.switch-client-btn svg { width: 13px; height: 13px; }
.switch-client-btn:hover { background: rgba(109,40,217,0.15); border-color: rgba(109,40,217,0.35); }

.last-updated { font-size: 11.5px; color: var(--text-dim); }

/* ── Content ──────────────────────────────────────────────────────────────── */
.content { padding: 28px 30px 52px; display: flex; flex-direction: column; gap: 0; }

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-bottom: 20px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover {
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  transform: translateY(-1px);
}

/* Colored top border per card type */
.stat-card::before { content: ''; position: absolute; top:0;left:0;right:0; height:2px; }
.stat-card--blue::before   { background: linear-gradient(90deg, var(--blue),   #38bdf8); }
.stat-card--green::before  { background: linear-gradient(90deg, var(--green),  #34d399); }
.stat-card--red::before    { background: linear-gradient(90deg, var(--red),    #fb7185); }
.stat-card--purple::before { background: linear-gradient(90deg, var(--purple), #ddd6fe); }
.stat-card--cyan::before   { background: linear-gradient(90deg, var(--cyan),   #67e8f9); }
.stat-card--indigo::before { background: linear-gradient(90deg, var(--indigo), #8b5cf6); }

.stat-card__label  { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.09em; color:var(--text-dim); margin-bottom:10px; }
.stat-card__value  { font-size:30px; font-weight:800; color:var(--text); letter-spacing:-.035em; line-height:1; margin-bottom:8px; }
.stat-card__sub    { display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--text-dim); }
.stat-card__icon   {
  position: absolute; right: 16px; top: 18px;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 9px;
}
.stat-card__icon svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* Colored icon backgrounds */
.stat-card--blue   .stat-card__icon { background: rgba(14,165,233,0.1); }
.stat-card--green  .stat-card__icon { background: rgba(16,185,129,0.1); }
.stat-card--red    .stat-card__icon { background: rgba(244,63,94,0.1); }
.stat-card--purple .stat-card__icon { background: rgba(167,139,250,0.1); }
.stat-card--cyan   .stat-card__icon { background: rgba(34,211,238,0.1); }
.stat-card--indigo .stat-card__icon { background: rgba(109,40,217,0.12); }

.stat-card--blue   .stat-card__icon svg { stroke: var(--blue);   opacity: 0.8; }
.stat-card--green  .stat-card__icon svg { stroke: var(--green);  opacity: 0.8; }
.stat-card--red    .stat-card__icon svg { stroke: var(--red);    opacity: 0.8; }
.stat-card--purple .stat-card__icon svg { stroke: var(--purple); opacity: 0.8; }
.stat-card--cyan   .stat-card__icon svg { stroke: var(--cyan);   opacity: 0.8; }
.stat-card--indigo .stat-card__icon svg { stroke: #8b5cf6;       opacity: 0.8; }

.badge-delta { display:inline-flex; align-items:center; gap:3px; font-size:11px; font-weight:700; padding:2px 6px; border-radius:5px; }
.badge-delta--up   { background:rgba(16,185,129,0.12);  color:var(--green); }
.badge-delta--down { background:rgba(244,63,94,0.12);   color:var(--red);   }

.mini-bar-wrap { margin-top:12px; height:3px; background:var(--surface-2); border-radius:99px; overflow:hidden; }
.mini-bar { height:100%; border-radius:99px; transition:width 0.7s ease; }
.mini-bar--blue   { background: linear-gradient(90deg, var(--blue),   #38bdf8); }
.mini-bar--green  { background: linear-gradient(90deg, var(--green),  #34d399); }
.mini-bar--red    { background: linear-gradient(90deg, var(--red),    #fb7185); }
.mini-bar--purple { background: linear-gradient(90deg, var(--purple), #ddd6fe); }
.mini-bar--cyan   { background: linear-gradient(90deg, var(--cyan),   #67e8f9); }
.mini-bar--indigo { background: linear-gradient(90deg, var(--indigo), #8b5cf6); }

/* ── Insights row (Strategy | eSIM donut | Hourly) ───────────────────────── */
.insights-row { display:grid; grid-template-columns:1fr 1fr 1.2fr; gap:14px; align-items:stretch; }

/* ── Strategy breakdown ───────────────────────────────────────────────────── */
.strategy-list { display: flex; flex-direction: column; gap: 12px; padding-top: 2px; }
.strategy-item__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.strategy-item__label  { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.strategy-item__count  { font-size: 12px; font-weight: 700; color: var(--text); }
.strategy-item__bar-track { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 3px; }
.strategy-item__bar-fill  { height: 100%; border-radius: 99px; transition: width 0.8s ease; }
.strategy-item__pct  { font-size: 11px; font-weight: 700; text-align: right; }

/* ── Brands + Geo row ────────────────────────────────────────────────────── */
.brands-geo-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:stretch; }
.geo-card-body  { display:flex; flex-direction:column; gap:16px; }

/* ── Charts row ───────────────────────────────────────────────────────────── */
.charts-row { display:grid; grid-template-columns:1fr 1fr 1.6fr; gap:14px; align-items:start; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: rgba(255,255,255,0.07); box-shadow: 0 8px 36px rgba(0,0,0,0.32); }

.card__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  gap: 10px;
}
.card__title  { font-size:13px; font-weight:700; color:var(--text); line-height:1.3; letter-spacing:-0.01em; }

.card__badge { font-size:10px; font-weight:700; padding:3px 8px; border-radius:5px; text-transform:uppercase; letter-spacing:.06em; }
.card__badge--green  { background:rgba(16,185,129,0.12);  color:var(--green);  }
.card__badge--blue   { background:rgba(14,165,233,0.12);  color:var(--blue);   }
.card__badge--yellow { background:rgba(245,158,11,0.12);  color:var(--yellow); }
.card__badge--red    { background:rgba(244,63,94,0.12);   color:var(--red);    }

.chart-container { position:relative; display:flex; align-items:center; justify-content:center; }
.chart-container--line { height: 200px; }

.donut-wrap { position: relative; width: 200px; height: 200px; flex-shrink: 0; }

.donut-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}

.donut-center__value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.035em; }
.donut-center__label { font-size: 10px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }

.donut-legend { margin-top:16px; display:flex; flex-direction:column; gap:8px; }

.legend-item { display:flex; align-items:center; justify-content:space-between; font-size:12.5px; }
.legend-item__left { display:flex; align-items:center; gap:8px; color:var(--text-muted); }
.legend-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.legend-item__value { font-weight:700; color:var(--text); }

.brand-legend { margin-top:14px; display:flex; flex-direction:column; gap:8px; }
.brand-row { display:flex; align-items:center; gap:8px; }
.brand-row__name { font-size: 12px; color: var(--text-muted); width: 80px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-row__bar-wrap { flex:1; height:5px; background:var(--surface-2); border-radius:99px; overflow:hidden; }
.brand-row__bar { height:100%; border-radius:99px; transition:width 0.8s ease; }
.brand-row__pct { font-size:11px; font-weight:700; color:var(--text); width:30px; text-align:right; flex-shrink:0; }

/* ── Tables row ───────────────────────────────────────────────────────────── */
.tables-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:stretch; }

table { width:100%; border-collapse:collapse; min-width: 0; }

th {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim);
  padding: 0 12px 10px 0; text-align: left;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
th:last-child { padding-right: 0; }
th.right   { text-align: right; padding-right: 0; padding-left: 12px; }
th.center  { text-align: center; }

td {
  padding: 10px 12px 10px 0; font-size: 13px; color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft); vertical-align: middle;
}
td:last-child { padding-right: 0; }
td.right { text-align: right; padding-right: 0; padding-left: 12px; }

tr:last-child td { border-bottom: none; }
tr:hover td { color: var(--text); background: rgba(255,255,255,0.012); }

/* Alternating row tint */
tbody tr:nth-child(even) td { background: rgba(255,255,255,0.007); }
tbody tr:nth-child(even):hover td { background: rgba(255,255,255,0.012); }

.td-device { display:flex; align-items:center; gap:10px; }
.device-icon { width:28px; height:28px; border-radius:7px; display:flex; align-items:center; justify-content:center; font-size:14px; flex-shrink:0; }
.device-name  { font-size:13px; font-weight:600; color:var(--text); }
.device-brand { font-size:11px; color:var(--text-dim); }

.pill { display:inline-flex; align-items:center; gap:4px; font-size:10.5px; font-weight:700; padding:3px 8px; border-radius:99px; }
.pill--green  { background:rgba(16,185,129,0.09); color:var(--green);  border:1px solid rgba(16,185,129,0.18);  }
.pill--red    { background:rgba(244,63,94,0.09);  color:var(--red);    border:1px solid rgba(244,63,94,0.18);   }

.req-bar-wrap { display:flex; align-items:center; gap:8px; }
.req-bar-track { width:60px; height:4px; background:var(--surface-2); border-radius:99px; overflow:hidden; flex-shrink:0; }
.req-bar-fill { height:100%; border-radius:99px; background:var(--blue); }
.req-num { font-size:13px; font-weight:600; color:var(--text); }

/* ── Events feed ──────────────────────────────────────────────────────────── */
.events-feed              { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: -4px; }
.events-feed table        { min-width: 680px; width: 100%; table-layout: fixed; }
.events-feed td           { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.events-feed th           { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Column widths — device column takes remaining space */
.events-feed .col-time     { width: 62px; }
.events-feed .col-esim     { width: 86px; }
.events-feed .col-strategy { width: 106px; }
.events-feed .col-conf     { width: 72px; }
.events-feed .col-region   { width: 88px; }
.events-feed .col-bot      { width: 68px; }
.events-feed .col-expand   { width: 28px; }

/* Per-column cell styling */
.ev-row td:nth-child(1) { color: var(--text-dim); }
.ev-row td:nth-child(2) { overflow: visible; white-space: normal; }  /* Device: 2-line */
.ev-row td:nth-child(5) { font-weight: 700; }
.ev-row td:nth-child(6) { color: var(--text-muted); }
.ev-row td:nth-child(7),
.ev-row td:nth-child(8) { text-align: center; color: var(--text-dim); }

/* Admin global events table has an extra Company column */
#section-events .events-feed table { min-width: 780px; }
.ev-row                  { cursor:pointer; }
.ev-row:hover td         { background:rgba(109,40,217,0.04); }
.ev-chevron              { display:inline-block; transition:transform .15s; font-size:9px; color:var(--text-dim); }

/* Detail row — hidden by default, revealed on click */
.ev-detail .ev-detail__body { display:none; }
.ev-detail--open .ev-detail__body { display:block; }
.ev-detail__body {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border-soft);
  overflow: hidden;
}

/* Section block (Device / eSIM / Network / Environment) */
.ev-section {}
.ev-section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.ev-section-header + .ev-section { border-top: 1px solid var(--border); }
.ev-section-header__icon { display:flex; align-items:center; color: var(--text-dim); }
.ev-section-header__label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim);
}
.ev-section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 640px) { .ev-section-grid { grid-template-columns: repeat(2, 1fr); } }

.ev-detail__item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  min-width: 0;
}
.ev-detail__item--full { grid-column: 1 / -1; }
.ev-detail__label {
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim);
}
.ev-detail__val {
  font-size: 13px; color: var(--text);
  line-height: 1.5; overflow-wrap: break-word; word-break: break-word;
}
.ev-detail__val--mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px; word-break: break-all;
  background: rgba(255,255,255,0.04);
  padding: 4px 8px; border-radius: 6px;
  display: inline-block; width: 100%;
}
.ev-hash-link {
  cursor: pointer; color: var(--text);
  transition: color .15s;
}
.ev-hash-link:hover { color: var(--accent, #6d28d9); }

/* ── Intelligence Panel ───────────────────────────────────────────────────── */
.intel-panel {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99,102,241,0.04) 0%, rgba(29,126,248,0.03) 100%);
}
.intel-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.intel-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-dim);
}
.intel-badge--pro {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; padding: 2px 7px; border-radius: 999px;
  background: linear-gradient(90deg,#6366f1,#3b82f6);
  color: #fff;
}
/* Scores */
.intel-scores {
  display: flex; gap: 12px; margin-bottom: 14px;
  padding: 12px 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.intel-scores-locked {
  font-size: 12px; color: var(--text-dim);
  padding: 10px 14px; border: 1px dashed var(--border-mid);
  border-radius: var(--radius-sm); margin-bottom: 14px;
}
.intel-score { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.intel-score__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text);
  display: flex; flex-direction: column; gap: 1px;
}
.intel-score__sub {
  font-size: 9px; font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--text-dim);
}
.intel-score__bar-wrap {
  height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden;
}
.intel-score__bar {
  height: 100%; border-radius: 999px; transition: width .4s ease;
}
.intel-score__val {
  font-size: 13px; font-weight: 700; line-height: 1;
}
/* Sections */
.intel-section { margin-bottom: 12px; }
.intel-section:last-child { margin-bottom: 0; }
.intel-section__label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-dim); margin-bottom: 6px;
}
/* Derived badges */
.intel-derived { display: flex; flex-wrap: wrap; gap: 6px; }
.intel-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px;
}
/* Insight chips */
.intel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.intel-chip {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500; padding: 3px 10px;
  border-radius: 999px; border: 1px solid transparent;
}
/* Decision cards */
.intel-decisions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.intel-dec {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.intel-dec__label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text);
}
.intel-dec__sub {
  font-size: 9px; color: var(--text-dim); line-height: 1.3; margin-bottom: 4px;
}
.intel-dec__val {
  font-size: 11px; font-weight: 700; line-height: 1.3;
}
.intel-dec--locked { opacity: 0.5; }
.intel-dec__val--locked { color: var(--text-dim); font-size: 10px; }
.intel-badge--locked {
  font-size: 10px; font-weight: 500; padding: 3px 10px;
  border-radius: 999px; border: 1px dashed var(--border-mid);
  color: var(--text-dim); background: transparent;
}
/* Profile block */
.intel-section--profile { margin-bottom: 10px; }
.intel-profile-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.intel-profile-reasoning {
  font-size: 11px; color: var(--text-muted); line-height: 1.5;
  padding: 6px 10px; background: var(--surface-2); border-radius: 6px;
}
/* Headline */
.intel-headline {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  line-height: 1.4; margin-bottom: 12px; padding: 8px 10px;
  background: var(--surface-2); border-radius: 6px;
  border-left: 2px solid var(--accent);
}
/* Recommendation callout */
.intel-recommendation {
  margin-top: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: 8px;
  border: 1px solid var(--border-mid);
}
/* Risk context */
.intel-risk-ctx {
  font-size: 12px; color: var(--text-secondary); line-height: 1.5;
  padding: 8px 10px; background: var(--surface-2); border-radius: 6px;
}
@media (max-width: 700px) {
  .intel-scores { flex-direction: column; }
  .intel-decisions { grid-template-columns: repeat(2, 1fr); }
}

/* ── Dash section grouping ────────────────────────────────────────────────── */
.dash-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 32px;
}
.dash-section:first-child { margin-top: 0; }

/* standalone cards between sections */
.dash-card-row {
  margin-top: 24px;
}
.dash-card-row:first-child { margin-top: 0; }

/* ── Section divider label ────────────────────────────────────────────────── */
.section-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
}

/* ── Geo row ──────────────────────────────────────────────────────────────── */
.geo-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; }

.geo-list { display:flex; flex-direction:column; gap:10px; }
.geo-item { display:flex; align-items:center; gap:12px; }
.geo-flag { font-size:18px; }
.geo-info { flex:1; }
.geo-name { font-size:13px; font-weight:600; color:var(--text); margin-bottom:4px; }
.geo-bar-track { height:3px; background:var(--surface-2); border-radius:99px; overflow:hidden; }
.geo-bar-fill { height:100%; border-radius:99px; }
.geo-count { font-size:13px; font-weight:700; color:var(--text); white-space:nowrap; }
.geo-pct   { font-size:10.5px; color:var(--text-dim); }

/* ── Emulator banner ──────────────────────────────────────────────────────── */
.emulator-banner {
  background: rgba(245,158,11,0.04);
  border: 1px solid rgba(245,158,11,0.18);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
}

.emulator-icon  { font-size:28px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.emulator-icon svg { width: 28px; height: 28px; stroke: var(--yellow); opacity: 0.8; }
.emulator-text  { flex:1; }
.emulator-title { font-size:14px; font-weight:700; color:var(--yellow); margin-bottom:3px; }
.emulator-desc  { font-size:12px; color:var(--text-dim); }
.emulator-stats { display:flex; gap:24px; }
.emulator-stat  { text-align:right; }
.emulator-stat__value { font-size:22px; font-weight:800; color:var(--text); letter-spacing:-.025em; }
.emulator-stat__label { font-size:10.5px; color:var(--text-dim); text-transform:uppercase; letter-spacing:.06em; }

/* ── Usage & Plan card ────────────────────────────────────────────────────── */
.usage-body  { display: flex; flex-direction: column; gap: 20px; }
.usage-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }

.usage-stat__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-bottom: 6px; }
.usage-stat__value { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -.035em; line-height: 1.1; }

.usage-bar-section { display: flex; flex-direction: column; gap: 8px; }
.usage-bar-track { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.usage-bar-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), #38bdf8); transition: width 0.8s ease, background 0.4s ease; }
.usage-bar-fill--warning { background: linear-gradient(90deg, var(--yellow), #fbbf24); }
.usage-bar-fill--danger  { background: linear-gradient(90deg, var(--red), #fb7185); }
.usage-bar-fill--safe    { background: linear-gradient(90deg, var(--green), #34d399); }

.usage-bar-labels { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-dim); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding: 14px 30px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-dim);
}

/* ── Loading overlay ──────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: opacity 0.4s ease;
}

.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 36px; height: 36px;
  border: 2px solid var(--border);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Mobile sidebar overlay ──────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9;
}
.sidebar-overlay.active { display: block; }

/* Mobile sidebar toggle button (shown in topbar on mobile) */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sidebar-toggle:hover { color: var(--text); background: var(--surface-3); border-color: rgba(255,255,255,0.1); }
.sidebar-toggle svg { width: 16px; height: 16px; }

/* ── Responsive — 1280px ─────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .insights-row { grid-template-columns: 1fr 1fr; }
  .insights-row .card:nth-child(3) { grid-column: span 2; }
  .brands-geo-row { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive — 1100px ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr 1fr; }
  .charts-row .card:nth-child(3) { grid-column: span 2; }
}

/* ── Responsive — 960px (tablet / small laptop) ──────────────────────────── */
@media (max-width: 960px) {
  /* Sidebar: hide by default, show when toggled */
  .sidebar {
    display: none;
    position: fixed;
    z-index: 20;
  }
  .sidebar.sidebar--open { display: flex; }

  .sidebar-toggle { display: flex; }
  .main { margin-left: 0 !important; }

  .content { padding: 20px 18px 44px; }
  .topbar  { padding: 0 18px; }

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

  .charts-row, .tables-row, .geo-row,
  .insights-row, .brands-geo-row { grid-template-columns: 1fr; }
  .charts-row .card:nth-child(3),
  .insights-row .card:nth-child(3) { grid-column: span 1; }

  .dash-section { margin-top: 24px; }

  /* Devices page: full-width single column */
  .geo-page-layout { grid-template-columns: 1fr; }
  .geo-sidebar-card { max-height: 400px; }
  #geoMap { height: 380px; }

  /* Admin table: allow horizontal scroll */
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Hide less important admin table columns on tablet */
  .admin-table .col-hide-tablet { display: none; }
}

/* ── Responsive — 600px ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Admin section-label with inline search: stack vertically */
  #section-companies .section-label { flex-wrap: wrap; gap: 10px; }
  .admin-search { min-width: 0; width: 100%; }

  .topbar { height: auto; min-height: 56px; padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar__right { gap: 6px; }
  .last-updated { display: none; }

  /* Icon-only buttons on small screens */
  .refresh-btn .btn-label,
  .switch-client-btn .btn-label { display: none; }
  .refresh-btn,
  .switch-client-btn { padding: 6px 10px; min-width: 34px; justify-content: center; }

  .emulator-banner { flex-wrap: wrap; gap: 12px; }
  .emulator-stats  { margin-left: auto; }

  .usage-stats { grid-template-columns: repeat(2, 1fr); }
  .footer { padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 4px; }

  /* Compact stat cards */
  .stat-card { padding: 14px 16px 12px; }
  .stat-card__value { font-size: 26px; }

  /* Compact cards */
  .card { padding: 16px; }
  .card__header { margin-bottom: 12px; padding-bottom: 11px; }

  /* Pagination: compact on mobile */
  .pagination { padding: 12px 16px; gap: 10px; }
  .pagination__btn { padding: 6px 12px; font-size: 11px; }

  /* Modal: full-width */
  .modal { max-width: calc(100vw - 32px); margin: 16px; }

  /* Hide less important admin table columns on mobile */
  .admin-table .col-hide-mobile { display: none; }

  /* Tables: tighter on mobile */
  th, td { padding-right: 6px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-section { margin-top: 20px; gap: 12px; }
}

/* ── Responsive — 480px (small phones) ──────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid  { grid-template-columns: 1fr; }
  .usage-stats { grid-template-columns: 1fr; }

  .content { padding: 14px 12px; gap: 14px; }
  .stat-card__value { font-size: 24px; }

  .emulator-banner { flex-direction: column; align-items: flex-start; }
  .emulator-stats  { margin-left: 0; gap: 20px; }

  .sdk-apikey-box { flex-direction: column; align-items: flex-start; gap: 8px; }
  .sdk-copy-btn   { align-self: flex-end; }
  .sdk-limits-row { flex-direction: column; gap: 12px; }
}

/* ── Responsive — 380px (very small phones) ─────────────────────────────── */
@media (max-width: 380px) {
  .topbar__left .page-title { font-size: 14px; }
  .modal { max-width: calc(100vw - 16px); margin: 8px; }
  .modal__body { padding: 16px; }
  .modal__footer { padding: 12px 16px; }
}

/* ── Auth pages (login / register) ───────────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 50% at 50% -5%, rgba(109,40,217,0.14) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 100%, rgba(14,165,233,0.06) 0%, transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(109,40,217,0.06);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.auth-logo__icon {
  width: 42px; height: 42px;
  background: var(--gradient);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff;
  box-shadow: 0 4px 18px rgba(109,40,217,0.45);
}
.auth-logo__title  { font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.auth-logo__sub    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.auth-heading    { font-size: 21px; font-weight: 700; color: var(--text); margin-bottom: 6px; letter-spacing: -0.025em; }
.auth-subheading { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }

.auth-error {
  background: rgba(244,63,94,0.08);
  border: 1px solid rgba(244,63,94,0.22);
  color: #fda4af;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-success {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.22);
  color: #6ee7b7;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-form   { display: flex; flex-direction: column; gap: 16px; }
.auth-field  { display: flex; flex-direction: column; gap: 6px; }
.auth-label  { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.auth-label__hint { font-weight: 400; color: var(--text-dim); }

.auth-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.auth-input:focus {
  border-color: rgba(109,40,217,0.6);
  box-shadow: 0 0 0 3px rgba(109,40,217,0.10);
}

.auth-btn {
  background: var(--gradient-btn);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 11px;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity .15s, box-shadow .15s;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 18px rgba(109,40,217,0.4);
}
.auth-btn:hover    { opacity: 0.92; box-shadow: 0 6px 24px rgba(109,40,217,0.52); }
.auth-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.auth-switch { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 20px; }
.auth-switch a { color: #a78bfa; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ── SDK Integration card ────────────────────────────────────────────────── */
.sdk-card { margin-top: 4px; }

.sdk-body   { padding: 0 4px; }
.sdk-desc   { font-size: 13px; color: var(--text-muted); line-height: 1.65; margin-bottom: 20px; }
.sdk-desc code { color: #a78bfa; background: rgba(109,40,217,.1); padding: 1px 5px; border-radius: 4px; }

.sdk-apikey-row    { margin-bottom: 20px; }
.sdk-apikey-label  { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.sdk-apikey-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.sdk-apikey-box code { font-size: 13px; color: var(--green); font-family: 'Fira Code','Cascadia Code',monospace; flex: 1; word-break: break-all; }

.sdk-copy-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.sdk-copy-btn:hover { background: rgba(109,40,217,0.15); color: #c4b5fd; border-color: rgba(109,40,217,0.35); }

.sdk-snippet-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sdk-snippet-wrap { position: relative; }
.sdk-snippet {
  background: #04060c;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: #a78bfa;
  font-family: 'Fira Code','Cascadia Code','Consolas',ui-monospace,monospace;
  font-size: 12px;
  line-height: 1.7;
  padding: 16px 18px;
  white-space: pre-wrap;
  word-break: break-all;
}
.sdk-copy-btn--snippet {
  position: absolute;
  top: 10px;
  right: 10px;
}

.sdk-limits-row {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.sdk-limits-item  { display: flex; flex-direction: column; gap: 4px; }
.sdk-limits-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); font-weight: 600; }
.sdk-limits-value { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── Admin panel ─────────────────────────────────────────────────────────── */

/* Sidebar admin variant */
.sidebar--admin { border-right-color: rgba(244,63,94,.2); }
.logo-icon--admin { background: linear-gradient(135deg, #dc2626 0%, #a855f7 100%); }
.logo-tag--admin  { color: #f87171; }
.admin-badge {
  display: inline-block;
  background: rgba(244,63,94,.12);
  color: #fca5a5;
  border: 1px solid rgba(244,63,94,.25);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  padding: 2px 6px;
  margin-top: 4px;
}

/* ── Admin section containers ────────────────────────────────────────────── */
#section-overview,
#section-companies,
#section-events {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#section-overview .section-label,
#section-companies .section-label,
#section-events .section-label {
  margin-bottom: 0;
}
#section-overview .plans-grid { margin-bottom: 0; }

/* stats-grid--5: responsive flex grid */
.stats-grid--5 {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.stats-grid--5 > * {
  flex: 1 1 calc(20% - 12px);
  min-width: 0;
}
@media (max-width: 1100px) {
  .stats-grid--5 > * { flex: 1 1 calc(33.333% - 10px); }
}
@media (max-width: 600px) {
  .stats-grid--5 > * { flex: 1 1 calc(50% - 7px); }
}
@media (max-width: 400px) {
  .stats-grid--5 > * { flex: 1 1 100%; }
}

/* Plans breakdown grid */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) {
  .plans-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .plans-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .plan-card {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 0;
  }
  .plan-card__label {
    flex: 1;
    font-size: 12px;
    margin-bottom: 0;
  }
  .plan-card__value {
    font-size: 22px;
    margin: auto;
    line-height: 1;
  }
  .plan-card__limit {
    font-size: 11px;
    text-align: right;
    white-space: nowrap;
  }
}

.plan-card {
  border-radius: var(--radius);
  padding: 20px 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.plan-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.plan-card--gray::before   { background: linear-gradient(90deg, #6b7280, #9ca3af); }
.plan-card--blue::before   { background: linear-gradient(90deg, var(--blue), #38bdf8); }
.plan-card--green::before  { background: linear-gradient(90deg, var(--green), #34d399); }
.plan-card--purple::before { background: linear-gradient(90deg, var(--purple), #ddd6fe); }

.plan-card__label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.plan-card__value { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1.1; }
.plan-card__limit { font-size: 11px; color: var(--text-dim); }

.plan-card--gray   .plan-card__label { color: #6b7280; }
.plan-card--blue   .plan-card__label { color: var(--blue); }
.plan-card--green  .plan-card__label { color: var(--green); }
.plan-card--purple .plan-card__label { color: var(--purple); }

/* Section label with inline search (admin) */
.admin-search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  outline: none;
  min-width: 220px;
  transition: border-color .15s, box-shadow .15s;
}
.admin-search:focus { border-color: rgba(109,40,217,0.5); box-shadow: 0 0 0 3px rgba(109,40,217,0.08); }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim); padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(109,40,217,0.04); }
.admin-empty { text-align: center; color: var(--text-dim); padding: 36px 0 !important; font-size: 13px; }

/* ── Filter Bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, color .15s;
}
.filter-toggle:hover { border-color: var(--brand); color: var(--text); }
.filter-toggle input[type="checkbox"] { accent-color: var(--brand); width: 14px; height: 14px; cursor: pointer; }
.filter-input, .filter-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  outline: none;
  height: 34px;
  transition: border-color .15s, box-shadow .15s;
}
.filter-input { min-width: 200px; }
.filter-select { min-width: 160px; cursor: pointer; }
.filter-input::placeholder { color: var(--text-dim); }
.filter-input:focus, .filter-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,126,248,0.12);
}
.filter-pills { display: flex; gap: 6px; align-items: center; }
.filter-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 0 13px;
  height: 34px;
  cursor: pointer;
  transition: all .15s;
}
.filter-pill:hover { border-color: var(--brand); color: var(--text); }
.filter-pill--active {
  background: rgba(29,126,248,0.14);
  border-color: rgba(29,126,248,0.4);
  color: var(--brand);
}
.filter-clear {
  color: var(--text-dim);
  font-size: 12px;
  padding: 0 8px;
  height: 34px;
  transition: color .15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.filter-clear:hover { color: var(--red); }
.filter-locked {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border-mid);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  opacity: 0.7;
}
@media (max-width: 600px) {
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-input { min-width: 0; width: 100%; }
  .filter-select { min-width: 0; flex: 1; }
  .filter-toggle { width: 100%; }
}

/* Plan badge in table */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}
.plan-badge__limit { font-weight: 400; opacity: .7; }
.plan-badge--gray   { background: rgba(107,114,128,.12); color: #9ca3af; }
.plan-badge--blue   { background: rgba(14,165,233,.12);  color: #38bdf8; }
.plan-badge--green  { background: rgba(16,185,129,.12);  color: #34d399; }
.plan-badge--purple { background: rgba(167,139,250,.12); color: #ddd6fe; }

/* API key cell */
.apikey-cell {
  font-family: 'Fira Code','Cascadia Code',monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
}

/* Action buttons in table */
.action-btn {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  margin: 0 2px;
  transition: background .15s, color .15s, border-color .15s;
}
.action-btn--edit   { background: rgba(109,40,217,.09); color: #a78bfa; border-color: rgba(109,40,217,.2); }
.action-btn--edit:hover   { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.action-btn--delete { background: rgba(244,63,94,.09); color: var(--red); border-color: rgba(244,63,94,.2); }
.action-btn--delete:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid #1e2238;
  border-radius: var(--radius);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal--sm { max-width: 400px; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 0;
}
.modal__title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.modal__close {
  font-size: 16px; color: var(--text-dim); cursor: pointer; padding: 4px;
  border-radius: 5px; transition: color .15s, background .15s;
}
.modal__close:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.modal__body   { padding: 20px 24px; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 0 24px 22px;
}
.modal__regenkey {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 4px;
}

/* Modal buttons */
.btn-primary   {
  background: var(--gradient-btn); color:#fff; border:none; border-radius:7px;
  font-size:13px; font-weight:600; font-family:inherit; padding:9px 18px; cursor:pointer;
  transition:opacity .15s, box-shadow .15s;
  box-shadow: 0 3px 12px rgba(109,40,217,0.35);
}
.btn-primary:hover   { opacity:.9; box-shadow: 0 4px 18px rgba(109,40,217,0.48); }
.btn-primary:disabled { opacity:.45; cursor:not-allowed; box-shadow:none; }
.btn-secondary {
  background: rgba(255,255,255,0.04); color:var(--text-muted);
  border:1px solid var(--border); border-radius:6px; font-size:13px; font-weight:600;
  padding:9px 18px; cursor:pointer; transition:background .15s, color .15s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.btn-danger    {
  background: rgba(244,63,94,.12); color:var(--red);
  border:1px solid rgba(244,63,94,.28); border-radius:6px;
  font-size:13px; font-weight:700; padding:9px 18px; cursor:pointer; transition:background .15s;
}
.btn-danger:hover { background: var(--red); color:#fff; border-color:var(--red); }
.btn-danger:disabled { opacity:.45; cursor:not-allowed; }

.btn-regen {
  background: rgba(245,158,11,.09); color:var(--yellow); border:1px solid rgba(245,158,11,.22);
  border-radius:5px; font-size:11px; font-weight:700; padding:5px 10px; cursor:pointer; white-space:nowrap;
  transition:background .15s, color .15s;
}
.btn-regen:hover { background: var(--yellow); color:#000; }

/* ─────────────────────────────────────────────
   Pages (SPA routing)
───────────────────────────────────────────── */
.page          { display: none; }
.page--active  { display: flex; flex-direction: column; gap: 0; }

/* ─────────────────────────────────────────────
   Devices page — pagination
───────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 700px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
}
.pagination__btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pagination__btn:hover:not(:disabled) {
  background: rgba(109,40,217,0.1);
  color: #c4b5fd;
  border-color: rgba(109,40,217,0.3);
}
.pagination__btn:disabled {
  opacity: .3;
  cursor: not-allowed;
}
.pagination__info {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 120px;
  text-align: center;
}

/* ─────────────────────────────────────────────
   Geography page — layout
───────────────────────────────────────────── */
.geo-page-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 900px) {
  .geo-page-layout { grid-template-columns: 1fr; }
}

.geo-map-card { overflow: hidden; }

#geoMap {
  height: 520px;
  background: #000;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

/* Country list sidebar */
.geo-sidebar-card .card__header { margin-bottom: 0; padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.geo-sidebar-card { max-height: 580px; display: flex; flex-direction: column; overflow: hidden; }
#geoCountryList  { overflow-y: auto; flex: 1; padding-top: 4px; }

.geo-country-row {
  display: grid;
  grid-template-columns: 28px 1fr 60px auto;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(26,30,46,0.5);
  transition: background .15s;
}
.geo-country-row:last-child { border-bottom: none; }
.geo-country-row--clickable { cursor: pointer; }
.geo-country-row--clickable:hover { background: rgba(109,40,217,0.05); }

.geo-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.04);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}
.geo-rank-badge--top {
  background: transparent;
  font-size: 14px;
  width: 20px;
  height: 20px;
}

.geo-country-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.geo-country-bar-wrap {
  height: 3px;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  overflow: hidden;
}
.geo-country-bar {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}
.geo-country-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.geo-country-pct {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
}

/* Geo sidebar header with back button */
.geo-sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.geo-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(109,40,217,0.09);
  border: 1px solid rgba(109,40,217,0.22);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.geo-back-btn:hover { background: rgba(109,40,217,0.18); }

/* ── Billing page ─────────────────────────────────────────────────────────── */
.billing-current-card {
  padding: 24px;
  margin-bottom: 0;
}
.billing-current-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.billing-plan-name  { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.billing-plan-price { font-size: 14px; color: var(--text-dim); margin-top: 4px; }

.billing-success-banner {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 8px;
  font-size: 13px;
  color: #86efac;
  font-weight: 500;
}

.billing-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.billing-plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color .15s, transform .15s;
}
.billing-plan-card:hover { transform: translateY(-2px); }

.billing-plan-card--blue   { border-color: rgba(99,102,241,0.3); }
.billing-plan-card--purple { border-color: rgba(139,92,246,0.3); }
.billing-plan-card--orange { border-color: rgba(249,115,22,0.3); }
.billing-plan-card--blue:hover   { border-color: rgba(99,102,241,0.55); }
.billing-plan-card--purple:hover { border-color: rgba(139,92,246,0.55); }
.billing-plan-card--orange:hover { border-color: rgba(249,115,22,0.55); }

.bpc-header { display: flex; align-items: baseline; justify-content: space-between; }
.bpc-name   { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.bpc-price  { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.bpc-price span { font-size: 13px; font-weight: 500; color: var(--text-dim); }

.bpc-features {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 7px;
  flex: 1;
}
.bpc-features li {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
}
.bpc-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #6366f1;
  font-weight: 700;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 7px 14px;
  height: 34px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn--primary {
  background: var(--gradient-btn);
  color: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(29,126,248,0.3);
}
.btn--primary:hover { opacity: .9; }
.btn--secondary {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--secondary:hover { background: rgba(255,255,255,0.08); color: var(--text); border-color: var(--border-mid); }
.btn--sm { font-size: 12px; padding: 0 11px; height: 28px; gap: 5px; }

.btn--outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn--outline:hover { border-color: rgba(255,255,255,0.25); color: var(--text-primary); }
