/* ============================================================
   apiai.me — main.css
   ============================================================ */

/* ── Brand design tokens ── */
:root {
  /* Backgrounds */
  --bg:           #0B1120;
  --card:         #0F172A;
  --card-alt:     #1E293B;
  --code-bg:      #121D33;
  --muted-bg:     #192237;

  /* Foreground / text */
  --fg:           #E2E8F0;
  --fg-white:     #fff;
  --muted:        #7B8BA3;
  --muted-dim:    #5a6a82;
  --dim:          #4a5568;

  /* Accent / primary */
  --accent:       #3B82F6;
  --accent-hover: #2563EB;
  --accent-light: #60a5fa;
  --accent-pale:  #93c5fd;
  --gradient-end: #7C3AED;
  --gradient:     linear-gradient(135deg, #3B82F6, #7C3AED);

  /* Borders & inputs */
  --border:       #243044;
  --input-bg:     #121D33;

  /* Semantic */
  --success:      #1BCA5B;
  --warning:      #F59E0B;
  --destructive:  #DC2626;
  --danger:       #DC2626;
  --danger-hover: #b91c1c;

  /* Grid overlay */
  --grid-color:   rgba(59,130,246,.045);
  --grid-size:    60px;

  /* Fonts */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Fira Code', Monaco, monospace;
}

/* ── Shared / utility ─────────────────────────────────────── */
.hidden { display: none; }

/* ============================================================
   INDEX PAGE
   ============================================================ */

/* ── Reset & base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}

/* ── Navbar ── */
.navbar {
  background: rgba(11,17,32,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
}
.navbar-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}
.navbar h1 { font-size: 1.3rem; color: var(--fg-white); margin: 0; }
.nav-subtitle { font-weight: 400; color: var(--accent); font-size: 0.85rem; margin-left: 0.35rem; }
.navbar .nav-links { display: flex; gap: 1rem; align-items: center; }
.navbar a, .navbar button {
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.navbar a:hover, .navbar button:hover { color: var(--fg-white); }

/* ── Layout ── */
.container {
  max-width: 80em;
  margin: 3rem auto;
  padding: 0 1rem;
}
#auth-section {
    display: grid;
    place-content: center;
    height: 90vh;
}
#auth-section.hidden {
    display: none;
}

/* ── Dashboard layout (sidebar + main) ── */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}
#dashboard-section.hidden {
  display: none;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.logo-svg {
  width: 120px;
  height: 22px;
}
.logo-svg-sm {
  width: 100px;
  height: 18px;
}
.sidebar-nav {
  padding: 0.75rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover {
  background: rgba(59,130,246,0.06);
  color: var(--fg);
}
.sidebar-link.active {
  background: rgba(59,130,246,0.12);
  color: var(--accent-light);
}
.sidebar-link svg {
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.6rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 0.3rem;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  color: var(--fg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.sidebar-user-info {
  min-width: 0;
  overflow: hidden;
}
.sidebar-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-email {
  font-size: 0.72rem;
  color: var(--muted-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Sidebar balance + add-funds */
.sidebar-balance {
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.25rem;
  border-radius: 8px;
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.12);
}
.sidebar-bal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-bal-label {
  font-size: 0.72rem;
  color: var(--muted-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-bal-value {
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--success);
}
.sidebar-bal-value.low { color: var(--danger); }

.sidebar-balance:hover {
  background: rgba(59,130,246,0.12);
  border-color: var(--accent);
}

/* ── Funds page ─────────────────────────────── */
.funds-balance-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  margin-bottom: 2rem;
  background: rgba(59,130,246,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.funds-balance-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.funds-balance-amount {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--success);
}
.funds-balance-amount.low { color: var(--danger); }
.funds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.funds-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.5rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.funds-card:hover {
  border-color: var(--accent);
  background: rgba(59,130,246,0.06);
}
.funds-card:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.funds-card-amount {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--fg);
}
.funds-card-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (max-width: 600px) {
  .funds-grid { grid-template-columns: 1fr; }
  .funds-balance-amount { font-size: 1.8rem; }
}

/* ── Auto-refill per-option ──────────────────── */
.funds-card-wrap {
  display: flex;
  flex-direction: column;
}
.auto-refill-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0;
  margin-top: -1px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.auto-refill-opt .ar-icon {
  display: flex;
  transition: transform 0.3s;
}
.auto-refill-opt:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.auto-refill-opt:hover .ar-icon {
  animation: ar-spin 0.6s ease;
}
.auto-refill-opt.active {
  background: rgba(59,130,246,0.08);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.auto-refill-opt.active .ar-icon {
  animation: ar-spin 1s linear infinite;
}
.auto-refill-opt.active .ar-text::after {
  content: ' ✓';
}
@keyframes ar-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.funds-card-wrap .funds-card {
  border-radius: var(--radius) var(--radius) 0 0;
}
.auto-refill-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.65rem 0.9rem;
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
}
.auto-refill-note span { font-weight: 600; color: var(--success); }

/* ── Confirm modal ───────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.confirm-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.confirm-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 360px;
  max-width: 90vw;
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.2s;
}
.confirm-overlay.open .confirm-box {
  transform: scale(1);
}
.confirm-icon {
  margin-bottom: 1rem;
}
.confirm-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  margin: 0 0 0.5rem;
}
.confirm-msg {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}
.confirm-msg span {
  font-weight: 700;
  font-family: var(--mono);
  color: var(--fg);
}
.confirm-actions {
  display: flex;
  gap: 0.75rem;
}
.confirm-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
}
.confirm-btn.cancel {
  background: transparent;
  color: var(--muted);
}
.confirm-btn.cancel:hover {
  background: rgba(255,255,255,0.04);
  color: var(--fg);
}
.confirm-btn.ok {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.confirm-btn.ok:hover {
  background: #2563EB;
}

.sidebar-signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  color: var(--muted-dim);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-signout:hover {
  color: var(--fg);
}

/* ── Mobile header ── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(11,17,32,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  z-index: 90;
}
.hamburger-btn {
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.mobile-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--font-mono);
}
.sidebar-overlay {
  display: none;
}
.sidebar-overlay.open {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ── Main content area ── */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 2rem 3rem;
  min-height: 100vh;
  max-width: calc(100% - 240px);
  overflow-x: hidden;
}

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }

.page-crumb {
  display: block;
  font-size: 0.78rem;
  color: var(--muted-dim);
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg-white);
  margin: 0 0 0.35rem;
}
.page-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

/* ── Production Key card ── */
.prod-key-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.prod-key-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--code-bg);
  flex-shrink: 0;
}
.prod-key-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-white);
}
.prod-key-meta {
  font-size: 0.78rem;
  color: var(--muted-dim);
}

/* ── Regenerate button (red) ── */
.regen-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.btn-regen-red {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--danger);
  color: var(--fg-white);
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-regen-red:hover {
  background: var(--danger-hover);
}
.regen-hint {
  font-size: 0.78rem;
  color: var(--muted-dim);
}

/* ── Card section title ── */
.card-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-white);
  margin: 0 0 1rem;
}

/* ── Stat cards (analytics) ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}
.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.stat-card-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.stat-card-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg-white);
  line-height: 1.2;
  margin-bottom: 0.3rem;
}
.stat-card-change {
  font-size: 0.75rem;
  font-weight: 500;
}
.stat-card-change.positive { color: var(--success); }
.stat-card-change.negative { color: var(--danger); }
.stat-card-change.neutral  { color: var(--muted-dim); }

/* Balance stat card highlight */
.stat-card-balance {
  border-color: var(--accent);
  border-width: 1.5px;
}

/* Funds card */
#funds-card { margin-bottom: 1.5rem; }
.funds-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.btn-fund {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-fund:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-fund:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Balance inline (API Keys page) */
.balance-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.balance-inline-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.balance-inline-label {
  font-size: 0.8rem;
  color: var(--muted-dim);
  font-weight: 500;
}
.balance-inline-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--success);
}
.balance-inline-value.low {
  color: var(--danger);
}
.balance-inline-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}
.balance-inline-link:hover { text-decoration: underline; }

/* Admin balance column */
.bal-low { color: var(--danger); font-weight: 600; }
.bal-display { font-family: var(--mono); font-size: 0.85rem; }
.bal-edit-btn {
  padding: 2px 6px !important;
  font-size: 0.75rem !important;
  margin-left: 0.4rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-dim);
  border-radius: 4px;
}
.bal-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Flow cards (replaces wf-pill) ── */
.flow-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.15s;
}
.flow-card:hover {
  border-color: rgba(59,130,246,0.3);
}
.flow-card.open .flow-card-body { max-height: 2000px; }
.flow-card-body { max-height: 0; overflow: hidden; transition: max-height .3s ease; }

.flow-card-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
}
.flow-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(59,130,246,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.flow-card-info {
  flex: 1;
  min-width: 0;
}
.flow-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.15rem;
}
.flow-card-name {
  font-size: 0.95rem;
  color: var(--fg-white);
}
.flow-card-endpoint {
  font-size: 0.78rem;
  color: var(--muted-dim);
  font-family: var(--font-mono);
}
.flow-card-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
  color: var(--muted-dim);
  font-size: 0.78rem;
}
.flow-card-method {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.flow-card-content {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Flow badge ── */
.flow-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.flow-badge-active {
  background: rgba(27,202,91,0.12);
  color: var(--success);
}
.flow-badge-free {
  background: rgba(16,185,129,0.15);
  color: #34d399;
}
.flow-badge-inactive {
  background: rgba(255,255,255,0.08);
  color: var(--muted);
}

/* ── Flows section divider ── */
.flows-divider {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Analytics card spacing ── */
.analytics-card {
  margin-top: 1.5rem;
}

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

/* ── Responsive: mobile ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-header {
    display: flex;
  }
  .main-content {
    margin-left: 0;
    padding: 1.25rem;
    padding-top: 68px;
    max-width: 100%;
  }
  .stat-cards {
    grid-template-columns: 1fr;
  }
  .flow-card-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .flow-card-meta {
    width: 100%;
    padding-left: 52px;
  }
  .page-title {
    font-size: 1.3rem;
  }
  .regen-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Terminal window (auth) ── */
.term-window {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  width: 100%;
  max-width: 460px;
  min-width: 350px;
  box-shadow: 0px 0px 30px var(--code-bg);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.term-dot-r { background: #ff5f57; }
.term-dot-y { background: #febc2e; }
.term-dot-g { background: #28c840; }
.term-title {
  margin-left: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.term-body {
  padding: 1.5rem 2rem 2rem;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  min-width: 0;
}
.card h2 {
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
  color: var(--fg-white);
}
.card h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: var(--fg);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
}
.tab {
  flex: 1;
  padding: 0.75rem;
  background: var(--card-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--fg-white);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Buttons ── */
.btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: var(--fg-white);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.2s;
}
.btn:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--fg-white);
}

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: rgba(27,202,91,.1); border: 1px solid rgba(27,202,91,.25); color: var(--success); }
.alert-error { background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.25); color: #fca5a5; }

/* ── API key box ── */
.api-key-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.api-key-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.api-key-hint {
  font-size: 0.7rem;
  color: var(--dim);
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  font-family: var(--font-mono);
}
.api-key-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.api-key-box code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-light);
  word-break: break-all;
  letter-spacing: 0.5px;
}
.api-key-box code.api-key-masked {
  color: var(--dim);
  letter-spacing: 2px;
}
.api-key-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.api-key-icon-btn {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.api-key-icon-btn:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.06);
}
.api-key-regen {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.4rem 0;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}
.api-key-regen:hover {
  color: var(--danger);
}

/* ── Account card ── */
.account-card {
  padding: 1.5rem 2rem;
}
.account-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gradient);
  color: var(--fg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.account-meta {
  flex: 1;
  min-width: 0;
}
.account-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg-white);
  margin: 0;
  line-height: 1.3;
}
.account-company {
  font-size: 0.8rem;
  color: var(--muted);
}
.account-email {
  font-size: 0.8rem;
  color: var(--muted-dim);
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Section label with icon ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
}
.section-label h3 {
  margin: 0;
  color: var(--fg);
}

/* ── Copy button ── */
.copy-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); color: var(--fg-white); }

/* ── Info rows ── */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--muted-bg);
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); font-size: 0.9rem; }
.info-value { color: var(--fg); font-size: 0.9rem; }

/* ── Status ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}
.status-ok { background: var(--success); }
.status-error { background: var(--danger); }

/* ── Workflow pills ── */
.wf-pill { 
  background: var(--code-bg); 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  margin-bottom: 0.5rem; 
  overflow: hidden; 
}
.wf-pill.open .wf-arrow { transform: rotate(90deg); }
.wf-pill.open .wf-body { max-height: 2000px; }
.wf-body { max-height: 0; overflow: hidden; transition: max-height .3s ease; }

.wf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
}
.wf-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.wf-arrow {
  color: var(--dim);
  font-size: 0.7rem;
  transition: transform .2s;
}
.wf-name {
  color: var(--fg-white);
  font-size: 0.9rem;
}
.wf-description {
  font-size: 0.8rem;
  color: var(--muted-dim);
}
.wf-endpoint {
  font-size: 0.7rem;
  color: var(--accent-light);
}
.wf-right-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.wf-content {
  padding: 0 1rem 0.75rem 1rem;
}

/* ── Params documentation (customer) ── */
.params-docs {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 0;
}
.params-docs h4 { margin: 0 0 0.65rem; font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.params-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.params-table th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
.params-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.params-table code { background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 3px; font-size: 12px; }
.badge-required { background: rgba(239,68,68,0.15); color: #f87171; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.text-muted { color: var(--muted); }

/* ── Editable param inputs ── */
.param-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--fg);
  padding: 3px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  width: 100%;
  min-width: 60px;
  max-width: 180px;
  transition: border-color 0.15s;
}
.param-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.09);
}
select.param-input { cursor: pointer; }

/* ── Code blocks ── */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
}
.code-block-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
}
.code-text {
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--accent-pale);
  font-family: var(--font-mono);
}
.copy-btn-block {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  margin: 0;
}

/* ── Try-it panel ── */
.try-panel {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 0;
}
.try-panel h5 {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.65rem;
}
.try-dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 1.1rem 1rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.try-prompt-wrap {
  margin-bottom: 0.65rem;
}
.try-prompt-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.55rem 0.7rem;
  resize: vertical;
  min-height: 2.2rem;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.try-prompt-input:focus {
  outline: none;
  border-color: var(--accent);
}
.try-prompt-input::placeholder {
  color: var(--dim);
}
.try-dropzone:hover,
.try-dropzone.drag-hover {
  border-color: var(--accent);
  background: rgba(59,130,246,0.04);
  color: var(--accent-pale);
}
.try-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.try-preview-row {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(255,255,255,0.015);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
}
.try-img-box {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.try-img-box img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}
.try-img-label {
  font-size: 0.68rem;
  color: var(--muted-dim);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}
.try-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-self: center;
}
.try-run-btn {
  padding: 0.5rem 1.6rem;
  background: var(--accent);
  color: var(--fg-white);
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.try-run-btn:hover { background: var(--accent-hover); }
.try-run-btn:disabled {
  background: var(--border);
  color: var(--muted-dim);
  cursor: not-allowed;
}
.try-clear-btn {
  padding: 0.35rem 1rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.try-clear-btn:hover { border-color: var(--danger); color: var(--danger); }
.try-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: trySpin 0.6s linear infinite;
  margin-right: 0.4rem;
  vertical-align: middle;
}
@keyframes trySpin { to { transform: rotate(360deg); } }
.try-error {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #ef4444;
  background: rgba(239,68,68,0.08);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}
.try-arrow {
  align-self: center;
  color: var(--muted-dim);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.try-download-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0.25rem 0.5rem;
  background: rgba(11,17,32,0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--fg-white);
  border-radius: 5px;
  font-size: 0.65rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.15s;
  z-index: 2;
}
.try-download-btn:hover { background: rgba(59,130,246,0.8); border-color: var(--accent); color: #fff; }

/* ── Chips / drag-and-drop ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: var(--fg-white);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: grab;
  user-select: none;
}
.chip:active { cursor: grabbing; opacity: 0.8; }
.chip .chip-remove { cursor: pointer; opacity: 0.6; font-size: 1rem; line-height: 1; }
.chip .chip-remove:hover { opacity: 1; }
.chip-plus {
  opacity: 0.5;
  font-size: 0.7rem;
}

/* ── Step items ── */
.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: grab;
  user-select: none;
}
.step-item:active { cursor: grabbing; }
.step-item .step-num { color: var(--accent); font-weight: 600; font-size: 0.85rem; min-width: 1.5rem; }
.step-item .step-name { flex: 1; font-size: 0.85rem; }
.step-item .step-remove { color: var(--muted-dim); cursor: pointer; font-size: 0.9rem; }
.step-item .step-remove:hover { color: var(--danger); }
.step-item.drag-over { border-color: var(--accent); background: rgba(59,130,246,0.08); }
.step-arrow {
  color: var(--dim);
  font-size: 0.7rem;
}
#flow-target.drag-over-empty { border-color: var(--accent); background: rgba(59,130,246,0.05); }

/* ── Index utility classes ── */
.hint-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.hint-text-mb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.loading-text {
  color: var(--muted-dim);
  font-size: 0.85rem;
}
.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card-header-flex h3 {
  margin: 0;
}
.btn-inline {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}
.btn-regen {
  display: none; /* deprecated — now using .api-key-regen */
}
.flow-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
#flow-source {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
#flow-target {
  min-height: 60px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.flow-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}
.flow-available {
  margin-bottom: 1rem;
}
.flow-step-count {
  font-size: 0.75rem;
  color: var(--muted-dim);
}
.flow-delete-icon {
  color: var(--muted-dim);
  font-size: 0.8rem;
  cursor: pointer;
}
.pipeline-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.drop-hint {
  color: var(--dim);
  font-size: 0.8rem;
  text-align: center;
  margin: 0.5rem 0;
}
.step-highlight {
  color: var(--accent-light);
}

/* ============================================================
   ADMIN PAGE
   ============================================================ */

/* Admin page inherits all :root tokens defined above.
   Legacy --text alias for backwards compat in admin markup. */
.admin-body { --text: var(--fg); }

/* ── Admin body (accounts for fixed navbar) ── */
.admin-body {
  padding-top: 60px;
}
.admin-body .admin-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Admin tabs ── */
.admin-tabs { display: flex; gap: 4px;
}
.admin-tab {
  padding: 10px 20px;
  background: var(--card);
  border: 1px 1px 1px 0 solid var(--border);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: all .2s;
}
.admin-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Admin cards ── */
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 10px 10px 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.admin-card h2 { font-size: 16px; margin-bottom: 16px; }

/* ── Admin tables ── */
.admin-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-body th,
.admin-body td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-body th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.admin-body tr:hover td { background: rgba(59,130,246,.04); }

/* ── Admin forms ── */
.admin-body label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.admin-body input,
.admin-body textarea,
.admin-body select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  font-family: inherit;
}
.admin-body textarea {
  min-height: 200px;
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
}
.admin-body input:focus,
.admin-body textarea:focus,
.admin-body select:focus { outline: none; border-color: var(--accent); }

/* ── Admin buttons ── */
.admin-body .btn { display: inline-block; padding: 9px 18px; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .2s; width: auto; margin-top: 0; }
.admin-body .btn-primary { background: var(--accent); color: #fff; }
.admin-body .btn-primary:hover { background: var(--accent-hover); }
.admin-body .btn-danger { background: var(--danger); color: #fff; }
.admin-body .btn-danger:hover { background: var(--danger-hover); }
.admin-body .btn-sm { padding: 5px 12px; font-size: 12px; }
.admin-body .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.admin-body .btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── Admin layout helpers ── */
.actions { display: flex; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-active { background: rgba(46,204,113,.15); color: var(--success); }
.badge-inactive { background: rgba(231,76,60,.15); color: var(--danger); }

/* ── Empty state ── */
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 999; animation: slideIn .3s; }
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 500px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Sections ── */
.section { display: none; }
.section.active { display: block; }

/* ── Admin login screen ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
}
.login-screen.hidden { display: none; }
.login-card { width: 360px; }
.login-title { text-align: center; margin-bottom: 20px; }
.login-error {
  display: none;
  background: rgba(231,76,60,.15);
  color: var(--danger);
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
}
.login-btn-full { width: 100%; margin-top: 4px; }

/* ── Admin section header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ── Admin access control ── */
.access-row { margin-bottom: 16px; }
.grant-group { display: flex; gap: 8px; }
.grant-select { margin-bottom: 0; }
.grant-btn { white-space: nowrap; }

/* ── Admin workflow modal helpers ── */
.upload-row { display: flex; gap: 8px; margin-bottom: 8px; }
.upload-label { cursor: pointer; margin: 0; flex-shrink: 0; }
.upload-input { display: none; }
.upload-filename { font-size: 12px; color: var(--muted); align-self: center; }
.json-hint { font-size: 12px; color: var(--muted); margin-top: -8px; margin-bottom: 12px; }
.checkbox-inline { width: auto; margin-right: 6px; }

/* ── Workflow Parameters Editor ── */
.params-section { margin-top: 8px; margin-bottom: 12px; }
.params-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.params-header label { margin: 0; font-weight: 600; }
.params-count { font-weight: 400; color: var(--muted); font-size: 13px; }
.param-row { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.param-fields .form-row { margin-bottom: 4px; }
.param-options { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.param-options label { margin: 0; font-size: 13px; }

/* ── Usage grid (customer dashboard) ── */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.usage-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
}
.usage-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}
.usage-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Usage stat color variants */
.usage-requests { border-color: rgba(59,130,246,.4); background: rgba(59,130,246,.06); }
.usage-requests .usage-number { color: #3b82f6; }

.usage-success { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.06); }
.usage-success .usage-number { color: #22c55e; }

.usage-failed { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.06); }
.usage-failed .usage-number { color: #ef4444; }

.usage-cost { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.03); }
.usage-cost .usage-number { color: #e2e2e2; }

/* ── Logs panel (customer dashboard) ── */
.logs-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--muted-bg);
  border-radius: 8px;
  padding: 0.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.logs-list::-webkit-scrollbar { width: 6px; }
.logs-list::-webkit-scrollbar-track { background: transparent; }
.logs-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.log-entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  border-bottom: none;
  flex-wrap: wrap;
  line-height: 1.5;
  min-width: 0;
}
.log-entry:hover { background: rgba(255,255,255,.03); }
.log-icon {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}
.log-success .log-icon { background: rgba(34,197,94,.2); color: #22c55e; }
.log-error .log-icon { background: rgba(239,68,68,.2); color: #ef4444; }
.log-slug {
  font-weight: 500;
  color: var(--accent-pale);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.log-type {
  font-size: 0.65rem;
  color: #636674;
  background: none;
  padding: 0;
  border-radius: 0;
  text-transform: none;
  letter-spacing: 0;
}
.log-meta {
  color: #636674;
  font-size: 0.75rem;
  margin-left: auto;
}
.log-detail {
  font-size: 0.72rem;
  color: #ef4444;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-time {
  font-size: 0.7rem;
  color: #4a4d5a;
  white-space: nowrap;
}

/* ── Admin misc ── */
.api-key-preview { font-size: 11px; }

/* ── Code editor (admin scripts) ── */
.code-editor {
  min-height: 400px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.script-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Admin Flow Builder ── */
.flow-steps-section { margin-top: 16px; }
.flow-step-row { position: relative; transition: box-shadow 0.2s; }
.flow-step-row:hover { box-shadow: 0 0 0 1px var(--accent, #4a9eff); }
.flow-step-row .form-row { gap: 8px; }
.flow-mapping-row .form-row { gap: 8px; }
.flow-step-row select { font-size: 13px; }

/* ============================================================
   Docs page
   ============================================================ */

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

/* ── Docs sidebar ── */
.docs-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  overflow-y: auto;
  z-index: 50;
}
.docs-sidebar-brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.docs-sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--fg-white);
  font-weight: 600;
  font-size: 1.05rem;
}
.docs-sidebar-brand .doc-badge {
  font-weight: 400;
  color: var(--accent);
  font-size: 0.8rem;
  margin-left: 0.25rem;
}
.docs-nav-group {
  padding: 0 0.75rem;
  margin-bottom: 1.25rem;
}
.docs-nav-heading {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted-dim);
  padding: 0 0.5rem;
  margin-bottom: 0.4rem;
}
.collapsible .docs-nav-heading {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.collapsible .docs-nav-heading:hover {
  color: var(--muted);
}
.collapse-chevron {
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.collapsible:not(.collapsed) .collapse-chevron {
  transform: rotate(90deg);
}
.collapsible.collapsed .docs-nav-links {
  display: none;
}
.docs-nav-link {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
}
.docs-nav-link:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.04);
}
.docs-nav-link.active {
  color: var(--accent-light);
  background: rgba(59,130,246,0.08);
}

/* ── Docs content ── */
.docs-content {
  margin-left: 240px;
  flex: 1;
  padding: 2.5rem 3rem;
  max-width: 100%
}
.docs-content h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--fg-white);
}
.docs-content .docs-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.5;
}
.docs-section {
  margin-bottom: 2.5rem;
  scroll-margin-top: 1.5rem;
}
.docs-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--fg-white);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.docs-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--fg);
}
.docs-section p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}
.docs-section ul, .docs-section ol {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}
.docs-section li {
  margin-bottom: 0.35rem;
}
.docs-section code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-light);
}

/* ── Endpoint card ── */
.endpoint-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.015);
  border-bottom: 1px solid var(--border);
}
.method-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.method-badge.get    { background: rgba(27,202,91,0.12); color: var(--success); }
.method-badge.post   { background: rgba(59,130,246,0.12); color: var(--accent-light); }
.method-badge.put    { background: rgba(245,158,11,0.12); color: var(--warning); }
.method-badge.delete { background: rgba(220,38,38,0.12); color: var(--danger); }
.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--fg);
}
.endpoint-body {
  padding: 0.85rem 1rem;
}
.endpoint-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* ── Code block (docs) ── */
.docs-code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
  overflow-x: auto;
  position: relative;
}
.docs-code pre {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--fg);
  white-space: pre;
  margin: 0;
}
.docs-code-label {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted-dim);
}

/* ── Param table ── */
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0.75rem 0;
}
.param-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted-dim);
  border-bottom: 1px solid var(--border);
}
.param-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--muted);
  vertical-align: top;
}
.param-table td:first-child {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg);
  white-space: nowrap;
}
.param-required {
  font-size: 0.65rem;
  color: var(--danger);
  font-weight: 600;
  margin-left: 0.3rem;
}
.param-optional {
  font-size: 0.65rem;
  color: var(--muted-dim);
  margin-left: 0.3rem;
}

/* ── Response status badges ── */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
}
.status-badge.s200 { background: rgba(27,202,91,0.1); color: var(--success); }
.status-badge.s201 { background: rgba(27,202,91,0.1); color: var(--success); }
.status-badge.s400 { background: rgba(245,158,11,0.1); color: var(--warning); }
.status-badge.s401 { background: rgba(220,38,38,0.1); color: var(--danger); }
.status-badge.s500 { background: rgba(220,38,38,0.1); color: var(--danger); }

/* ── Docs mobile ── */
@media (max-width: 768px) {
  .docs-sidebar { display: none; }
  .docs-content { margin-left: 0; padding: 1.5rem 1rem; }
}
