/* ======================================================================
   GlideAPI — Customer Portal
   Design System: DESIGN.md (Vercel/Linear-tier restraint)
   Flat surfaces, hairline borders, one accent, monochrome primary.
   Light theme = default :root. Dark theme = :root[data-theme="dark"].
   ====================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens — Light theme (default) ──────────────────────────────── */
:root {
  --bg:             #fafafa;
  --bg-subtle:      #f4f4f5;
  --surface:        #ffffff;
  --surface-hover:  #f7f7f7;
  --surface-raised: #ffffff;
  --border:         #e4e4e7;
  --border-strong:  #d4d4d8;
  --text:           #171717;
  --text-secondary: #525252;
  --text-tertiary:  #8f8f8f;

  --accent:         #239784;
  --accent-hover:   #1d4ed8;
  --accent-soft:    color-mix(in srgb, var(--accent) 12%, transparent);

  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;

  --btn-primary-bg:    #171717;
  --btn-primary-text:  #ffffff;
  --btn-primary-hover: #383838;

  --shadow-border:       0 0 0 1px var(--border);
  --shadow-border-hover: 0 0 0 1px var(--border-strong);
  --shadow-modal:        0 0 0 1px rgba(0,0,0,0.08), 0 8px 30px rgba(0,0,0,0.12);
  --focus-ring:          0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --sp-xxs: 4px;
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 40px;
  --sp-3xl: 64px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 999px;

  /* Legacy aliases consumed by app.js (syncThemeColors / chart colors) */
  --ink: var(--text);
  --body: var(--text-secondary);
  --mute: var(--text-secondary);
  --faint: var(--text-tertiary);
  --hairline: var(--border);
  --link: var(--accent);
  --green: var(--success);
  --error: var(--danger);
  --on-primary: var(--btn-primary-text);

  color-scheme: light;
}

/* ── Tokens — Dark theme ─────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg:             #07131b;
  --bg-subtle:      #0b1e29;
  --surface:        #102733;
  --surface-hover:  #15313e;
  --surface-raised: #183743;
  --border:         #234450;
  --border-strong:  #315b66;
  --text:           #e8f5f2;
  --text-secondary: #9bb8b2;
  --text-tertiary:  #66857f;

  --accent:         #2bb7a4;
  --accent-hover:   #239784;

  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;

  --btn-primary-bg:    #e8f5f2;
  --btn-primary-text:  #07131b;
  --btn-primary-hover: #ffffff;

  --shadow-modal: 0 0 0 1px var(--border), 0 8px 30px rgba(0,0,0,0.35);

  color-scheme: dark;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Brand ───────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  text-decoration: none;
}
.logo-mark {
  width: 158px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* light theme (default): invert the white wordmark so it reads as black */
  filter: invert(1);
}
:root[data-theme="dark"] .logo-mark img {
  /* white wordmark asset shows as-is on dark */
  filter: none;
}
.brand-ai {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 40px; padding: 0 20px; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.btn-primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-hover); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  height: auto;
}
.btn-link:hover { text-decoration: underline; }

/* ── Console Shell ───────────────────────────────────────────────── */
.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: var(--bg);
}

.mobile-console-bar,
.sidebar-backdrop { display: none; }

.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-sm);
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  z-index: 30;
}
.portal-sidebar .brand {
  min-height: 44px;
  padding: 4px 8px 12px;
}
.portal-sidebar .logo-mark { width: 158px; height: 38px; }
.portal-sidebar .brand-ai { font-size: 13px; font-weight: 600; }

.portal-sidebar .tab-nav {
  display: grid;
  align-content: start;
  gap: var(--sp-xxs);
  padding: var(--sp-xs) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.portal-sidebar .tab-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.portal-sidebar .tab-nav button svg { width: 16px; height: 16px; flex-shrink: 0; }
.portal-sidebar .tab-nav button:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.portal-sidebar .tab-nav button.active {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-account {
  display: grid;
  gap: 10px;
  padding: var(--sp-sm) 8px 4px;
}
.sidebar-account .nav-user {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.sidebar-account .user-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-account .user-id-pill {
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-legal {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.sidebar-legal a {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-legal a:hover { color: var(--text); }
.sidebar-company {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.4;
}
.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xs);
}
.sidebar-actions .btn {
  width: 100%;
  padding-inline: 8px;
}

/* ── Main Content ────────────────────────────────────────────────── */
.main-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-lg) clamp(16px, 3vw, 24px) var(--sp-3xl);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Hero Card ───────────────────────────────────────────────────── */
.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--sp-lg);
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
}
.hero-card h1 {
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0 var(--sp-xs);
}
.hero-card p { color: var(--text-secondary); max-width: 620px; }
.eyebrow {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.hero-meta {
  align-self: start;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  padding: var(--sp-md);
}
.meta-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.copy-row {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
}
.copy-row:last-child { margin-bottom: 0; }
.copy-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 10px;
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

/* ── Stat Cards ──────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}
.stat-card {
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xxs);
}
.stat-card-graph {
  position: relative;
  min-height: 180px;
  gap: var(--sp-xs);
}
.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-sm);
}
.stat-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value.positive { color: var(--success); }
.stat-value.zero { color: var(--danger); }
.stat-card-graph .stat-value { margin-top: 8px; }
.stat-card-graph .stat-value.positive,
.stat-card-graph .stat-value.zero { color: var(--text); }
.stat-subline {
  min-height: 18px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-tertiary);
}
.stat-mini-chart {
  position: relative;
  height: 52px;
  margin-top: auto;
}
.stat-mini-chart canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── Panel ───────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}
.panel-header h2 {
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

/* ── Chip / Badge ────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.chip.ok-chip,
.ok-chip {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  box-shadow: none;
}

/* ── Charts ──────────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 240px;
}
.chart-container canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ── Key List ────────────────────────────────────────────────────── */
.key-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}
.key-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-border);
  transition: box-shadow .15s ease;
}
.key-row:hover { box-shadow: var(--shadow-border-hover); }
.key-badge {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.key-badge.active { background: var(--success); }
.key-badge.disabled { background: var(--danger); }
.key-info { flex: 1; min-width: 0; }
.key-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.key-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
  margin-top: 2px;
}
.key-meta-text {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.key-policy {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}
.key-actions { display: flex; gap: 6px; }

.new-key-reveal {
  padding: var(--sp-md);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-sm);
  margin-top: var(--sp-sm);
}
.new-key-reveal .key-full {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  margin: var(--sp-xs) 0;
  padding: var(--sp-xs) var(--sp-sm);
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-xs);
}
.new-key-reveal .warn {
  font-size: 13px;
  color: var(--warning);
  margin-top: var(--sp-xs);
}

/* ── Tables ──────────────────────────────────────────────────────── */
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.usage-table th {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  padding: var(--sp-sm);
  border-bottom: 1px solid var(--border);
}
.usage-table td {
  padding: var(--sp-sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.usage-table tr:last-child td { border-bottom: none; }
.usage-table td code {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* ── Balance Card ────────────────────────────────────────────────── */
.balance-card {
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  padding: var(--sp-xl);
  text-align: center;
  margin-bottom: var(--sp-md);
}
.balance-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-xs);
}
.balance-amount {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.balance-amount.positive { color: var(--success); }
.balance-amount.zero { color: var(--danger); }
.balance-note {
  margin-top: var(--sp-sm);
  font-size: 13px;
  color: var(--text-tertiary);
}
.topup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-xs);
  margin-top: var(--sp-lg);
  width: 100%;
}

.topup-panel {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  display: grid;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  text-align: left;
}
.topup-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-sm);
}
.topup-panel-head strong { color: var(--text); font-size: 14px; }
.topup-panel-head span { color: var(--text-secondary); font-size: 13px; }

.topup-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-xs);
}
.topup-choice-grid.plan-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.topup-choice {
  min-height: 42px;
  box-shadow: var(--shadow-border);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow .15s ease, background-color .15s ease;
}
.topup-choice:hover { box-shadow: var(--shadow-border-hover); }
.plan-choice {
  display: flex;
  min-height: 68px;
  padding: 12px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
}
.plan-choice strong { color: var(--text); font-size: 15px; line-height: 1.2; }
.plan-choice span { color: var(--text-secondary); font-size: 13px; line-height: 1.3; }
.plan-badge {
  display: inline-flex;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.subscription-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-border);
}
.subscription-status-card > div { display: grid; gap: 3px; }
.subscription-status-card strong { color: var(--text); font-size: 14px; }
.subscription-status-card span { color: var(--text-secondary); font-size: 12px; }
.topup-choice.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

.free-plan-panel {
  display: none;
  margin-top: var(--sp-sm);
  padding: var(--sp-md);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
}
.free-plan-panel.visible { display: grid; gap: var(--sp-sm); }
.free-plan-panel strong,
.free-plan-panel span { display: block; }
.free-plan-panel strong { color: var(--text); font-size: 14px; }
.free-plan-panel > div > span {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.free-plan-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}
.free-plan-status span {
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-border);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  font-size: 12px;
}
.free-plan-status span.ok {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  box-shadow: none;
}
.free-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}
.free-plan-actions .btn { flex: 1 1 150px; }





.custom-topup-input {
  display: none;
  grid-column: 1 / -1;
  height: 42px;
  padding: 0 var(--sp-sm);
  box-shadow: var(--shadow-border);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
}
.custom-topup-input.visible { display: block; }
.custom-topup-input:focus { box-shadow: 0 0 0 1px var(--accent); }
.custom-topup-input::placeholder { color: var(--text-tertiary); }

.custom-topup-currency-hint {
  display: none;
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.custom-topup-currency-hint.visible { display: block; }

.topup-usage-hint {
  min-height: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.topup-usage-hint:empty { display: none; }

.topup-checkout-entry {
  display: grid;
  gap: var(--sp-xs);
}

.topup-continue {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  text-align: center;
}
.topup-continue strong { color: inherit; font-weight: 600; }
.topup-payment-hint {
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

/* ── Billing History ─────────────────────────────────────────────── */
.billing-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.billing-item:last-child { border-bottom: none; }
.billing-item .bill-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  width: 120px;
}
.billing-item .bill-model {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.billing-item .bill-cost {
  color: var(--text);
  font-weight: 500;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.billing-item .bill-cost.credit { color: var(--success); }

.tx-show-more {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tx-show-more:hover { background: var(--surface-hover); color: var(--text); }

/* ── Period Selector ─────────────────────────────────────────────── */
.period-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  padding: 2px;
}
.period-selector button {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.period-selector button:hover { color: var(--text); }
.period-selector button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-border);
}

/* ── States ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  text-align: center;
  padding: var(--sp-2xl);
  color: var(--text-tertiary);
  font-size: 13px;
}
.empty-state.compact { padding: var(--sp-lg); }
.empty-state svg { width: 20px; height: 20px; color: var(--text-tertiary); margin-bottom: 4px; }
.empty-state strong { color: var(--text-secondary); font-size: 14px; }
.empty-state span { max-width: 360px; color: var(--text-tertiary); }
.action-state strong { color: var(--text); }

/* ── Info Banner ─────────────────────────────────────────────────── */
.info-banner {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--sp-sm) var(--sp-md);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  margin-bottom: var(--sp-md);
  font-size: 13px;
  color: var(--text-secondary);
}
.info-banner strong { color: var(--text); }
.info-banner code { font-family: var(--font-mono); color: var(--accent); }

/* ── Docs ────────────────────────────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-sm);
  margin: var(--sp-md) 0;
}
.doc-snippet {
  display: grid;
  gap: 7px;
  padding: var(--sp-md);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}
.doc-snippet strong { color: var(--text); font-size: 13px; }
.doc-snippet code,
.docs-filter-note code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}
.docs-filter-note {
  margin-top: var(--sp-sm);
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.7;
}
.docs-filter-note code { color: var(--accent); }
.docs-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-md);
}
.docs-hero-panel .panel-header { align-items: flex-start; }
.docs-hero-panel h2 { margin-top: 4px; font-size: 24px; line-height: 32px; letter-spacing: -0.02em; }
.dashboard-docs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted-copy {
  margin: 0 0 var(--sp-md);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
}

/* ── Logs ────────────────────────────────────────────────────────── */
.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  padding: var(--sp-sm) 0;
  border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-row strong { display: block; color: var(--text); font-size: 13px; }
.log-row span { display: block; color: var(--text-tertiary); font-size: 12px; }
.log-meta { color: var(--text-secondary); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.code-block {
  margin: 0;
  overflow-x: auto;
  padding: var(--sp-md);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
}

/* ── Details List ────────────────────────────────────────────────── */
.details-list { display: flex; flex-direction: column; gap: var(--sp-sm); }
.details-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--border);
}
.details-list > div:last-child { border-bottom: none; padding-bottom: 0; }
.details-list span {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.details-list strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.details-list .copy-row { min-width: 0; margin-bottom: 0; }
.details-list code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--text);
}

/* ── Model Catalog ───────────────────────────────────────────────── */
.model-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 280px) auto;
  align-items: end;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}
.model-toolbar .form-group { min-width: 0; margin-bottom: 0; }
.model-search-group input[type="search"] {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  box-shadow: var(--shadow-border);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.model-search-group input[type="search"]:focus { box-shadow: 0 0 0 1px var(--accent); }

.model-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--sp-sm);
}
.model-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  min-height: 136px;
  padding: var(--sp-md);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: box-shadow .15s ease;
}
.model-card:hover { box-shadow: var(--shadow-border-hover); }
.model-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.model-logo.has-image { background: var(--surface); }
.model-logo img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}
.model-logo.local-logo img { width: 26px; height: 26px; }
.model-card-main { flex: 1; min-width: 0; }
.model-card strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-card code {
  display: block;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-card span {
  display: block;
  color: var(--text-tertiary);
  font-size: 13px;
  margin-top: 2px;
}
.model-price-line {
  display: inline-flex;
  margin-top: var(--sp-xs);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
  animation: modalFade 0.15s ease-out;
}
.modal {
  background: var(--surface-raised);
  box-shadow: var(--shadow-modal);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  width: 100%;
  max-width: 480px;
  animation: modalScale 0.15s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalScale { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
.modal h3 {
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: var(--sp-lg);
}
.payment-method-modal {
  max-width: 640px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.payment-method-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-md);
}
.payment-method-header h3 {
  margin: 2px 0 4px;
  font-size: 22px;
  line-height: 30px;
}
.payment-method-header p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}
.payment-method-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.payment-method-close:hover { background: var(--surface-hover); color: var(--text); }
.payment-method-close:focus-visible,
.payment-method-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.payment-method-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  margin: var(--sp-md) 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
}
.payment-method-summary span {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.payment-method-summary strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}
.payment-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-sm);
}
.payment-method-option {
  position: relative;
  min-width: 0;
  min-height: 160px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.payment-method-option:not(:disabled):hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.payment-method-option:disabled {
  cursor: not-allowed;
  opacity: .56;
}
.payment-method-option.loading { opacity: .72; }
.payment-method-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text);
}
.payment-method-icon svg { width: 22px; height: 22px; }
.payment-method-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.payment-method-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.payment-method-title-row strong { color: var(--text); font-size: 16px; font-weight: 600; }
.payment-method-copy > span:not(.payment-method-title-row) { color: var(--text-secondary); font-size: 13px; }
.payment-method-copy .payment-method-amount { color: var(--text); font-weight: 600; }
.payment-method-copy small { color: var(--text-tertiary); font-size: 12px; line-height: 1.45; }
.payment-method-status {
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.payment-method-status.available {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}
.payment-method-arrow {
  align-self: center;
  color: var(--text-tertiary);
  font-size: 18px;
}
.payment-method-option:disabled .payment-method-arrow { visibility: hidden; }
.payment-method-crypto {
  grid-template-columns: 42px minmax(0, 1fr);
  cursor: default;
}
.payment-method-crypto:not(:disabled):hover {
  border-color: var(--border);
  background: var(--surface);
  transform: none;
}
.payment-method-crypto.is-disabled { opacity: .56; }
.crypto-currency-picker {
  min-width: 0;
  display: grid;
  gap: 7px;
  margin: 8px 0 2px;
  padding: 0;
  border: 0;
}
.crypto-currency-picker legend {
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.crypto-currency-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
}
.crypto-currency-option:has(input:checked) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.crypto-currency-option:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--accent); }
.crypto-currency-option.disabled { cursor: not-allowed; opacity: .56; }
.crypto-currency-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.crypto-currency-option > span { display: grid; gap: 1px; }
.crypto-currency-option strong { color: var(--text); font-size: 13px; }
.crypto-currency-option small { color: var(--text-tertiary); font-size: 11px; }
.crypto-checkout-button {
  width: 100%;
  margin-top: 5px;
}
.payment-method-footnote {
  margin-top: var(--sp-md);
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}
.confirm-modal {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--sp-md);
  align-items: start;
  max-width: 520px;
}
.confirm-modal h3 { margin-bottom: 6px; }
.confirm-modal p { color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.confirm-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
  color: var(--text);
}
.confirm-mark svg { width: 20px; height: 20px; }
.confirm-mark.danger {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  box-shadow: none;
}
.confirm-modal .modal-actions { grid-column: 1 / -1; margin-top: var(--sp-sm); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-md); }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-group input,
.form-group select {
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-sm);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-border);
  border: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: box-shadow .15s ease;
}
.form-group select option { background: var(--surface); color: var(--text); }
.form-group input:focus,
.form-group select:focus { box-shadow: 0 0 0 1px var(--accent); }
.form-group input::placeholder { color: var(--text-tertiary); }
.model-multi-select { min-height: 168px; height: auto; padding: var(--sp-xs); }
.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.45;
}
.key-limit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-md);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-xs);
  margin-top: var(--sp-lg);
}

/* ── Toast — top center ──────────────────────────────────────────── */
#toastRoot {
  position: fixed;
  top: var(--sp-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-modal);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
}
.toast.leaving { animation: toastOut 0.15s ease forwards; }
.toast .toast-icon {
  flex-shrink: 0;
  display: inline-flex;
  margin-top: 1px;
}
.toast .toast-icon svg { width: 16px; height: 16px; }
.toast .toast-message { flex: 1; min-width: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Grid Layouts ────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
}

/* ── Referrals ───────────────────────────────────────────────────── */
.referral-hero { padding: var(--sp-xl); }
.referral-intro {
  max-width: 720px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 24px;
  margin-bottom: var(--sp-lg);
}
.referral-share-row {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  background: var(--bg);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-md);
}
.referral-share-row code {
  flex: 1;
  min-width: 0;
  padding: 0 var(--sp-xs);
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.referral-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-md);
}
.referral-stat { display: flex; flex-direction: column; gap: var(--sp-xs); }
.referral-stat span { color: var(--text-tertiary); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.referral-stat strong { color: var(--text); font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.referral-steps { display: flex; flex-direction: column; gap: var(--sp-md); list-style: none; }
.referral-steps li { display: flex; align-items: flex-start; gap: var(--sp-sm); }
.referral-steps li > span {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.referral-steps strong { display: block; color: var(--text); font-weight: 600; }
.referral-steps p, .referral-own-status p, .referral-fine-print { color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.referral-fine-print { margin-top: var(--sp-md); }
.referral-status {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
  font-size: 12px;
  font-weight: 500;
}
.referral-status.rewarded,
.referral-status.active { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
.referral-status.cancelled { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.referral-own-status .referral-status { margin-bottom: var(--sp-xs); }
.referral-history-list { display: flex; flex-direction: column; }
.referral-history-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md); min-height: 56px; border-bottom: 1px solid var(--border); }
.referral-history-row:last-child { border-bottom: 0; }
.referral-history-row > div { display: flex; flex-direction: column; }
.referral-history-row strong { color: var(--text); font-weight: 500; }
.referral-history-row span:not(.referral-status) { color: var(--text-tertiary); font-size: 12px; }

/* ── Daily GLM Allowance ─────────────────────────────────────────── */
.allowance-panel { position: relative; }
.allowance-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(260px, 0.55fr);
  align-items: end;
  gap: var(--sp-lg);
}
.allowance-value {
  color: var(--text);
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.allowance-copy {
  max-width: 680px;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.allowance-cta { margin-top: 14px; }
.allowance-meter-wrap { display: grid; gap: var(--sp-xs); }
.allowance-meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-border);
  background: var(--bg-subtle);
}
.allowance-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.18s ease;
}
.allowance-meter-label {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .referral-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1023px) {
  .portal-shell {
    grid-template-columns: 1fr;
    padding-top: 58px;
  }

  .mobile-console-bar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 60;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
  }
  .mobile-console-bar .brand { min-width: 0; gap: 8px; }
  .mobile-console-bar .logo-mark { width: 130px; height: 34px; }

  .mobile-menu-btn {
    width: 40px;
    height: 38px;
    display: inline-grid;
    place-content: center;
    gap: 5px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-border);
    border: none;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
  }
  .mobile-menu-btn span {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.16s ease, opacity 0.16s ease;
  }
  body.sidebar-open .mobile-menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.sidebar-open .mobile-menu-btn span:nth-child(2) { opacity: 0; }
  body.sidebar-open .mobile-menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.16s ease;
  }
  body.sidebar-open .sidebar-backdrop { pointer-events: auto; opacity: 1; }

  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    width: min(300px, calc(100vw - 48px));
    height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: stretch;
    gap: var(--sp-md);
    padding: var(--sp-md) var(--sp-sm);
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  body.sidebar-open .portal-sidebar { transform: translateX(0); }
  .portal-sidebar .tab-nav {
    min-height: 0;
    overflow-y: auto;
  }

  .main-content { max-width: 100%; min-width: 0; }
  .hero-card { grid-template-columns: 1fr; }

  .usage-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Single-column; prevent long model IDs/prices forcing overflow */
  .model-catalog {
    grid-template-columns: 1fr;
  }
  .model-card {
    min-width: 0;
    max-width: 100%;
  }
  .model-card-main {
    min-width: 0;
  }
  .model-card code {
    max-width: 100%;
  }
  .model-price-line {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 768px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .settings-grid,
  .model-catalog,
  .docs-grid,
  .dashboard-docs-grid { grid-template-columns: 1fr; }
  .model-toolbar { grid-template-columns: 1fr; align-items: stretch; }
  .hero-card h1 { font-size: 28px; line-height: 34px; }
  .allowance-grid { grid-template-columns: 1fr; gap: var(--sp-md); }
}

@media (max-width: 640px) {
  .referral-share-row { align-items: stretch; flex-direction: column; }
  .referral-share-row code { padding: var(--sp-xs); }
  .referral-stat-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .topup-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topup-panel-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .subscription-status-card { align-items: flex-start; flex-direction: column; }
  .free-plan-actions { flex-direction: column; }
  .free-plan-actions .btn { width: 100%; flex-basis: auto; }
  .payment-method-summary { align-items: flex-start; flex-direction: column; gap: 4px; }
  .payment-method-summary strong { text-align: left; }
  .payment-method-grid { grid-template-columns: 1fr; }
  .payment-method-option { min-height: 132px; }
  .key-row { flex-direction: column; align-items: flex-start; }
  .key-actions { width: 100%; justify-content: flex-end; }
  .panel-header { flex-direction: column; align-items: flex-start; gap: var(--sp-xs); }
  .billing-item {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
  }
  .billing-item .bill-time { grid-column: 1 / -1; width: auto; }
  .billing-item .bill-model { white-space: normal; }
  .hero-card,
  .panel,
  .balance-card { padding: var(--sp-md); }
  .modal { padding: var(--sp-md); }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
