/* =====================================================================
   API Merge — Design System v3
   Light, modern, digital sci-fi aesthetic.
   Particle canvas, glassmorphism, neon glows, smooth animations.
   All --am-* variables preserved for inline chart references in app.js.
   ===================================================================== */

:root {
  /* radius */
  --am-radius: 12px;
  --am-radius-sm: 9px;
  --am-radius-xs: 7px;

  /* base palette — light */
  --am-bg:          #f0f4f8;
  --am-bg-2:        #e2e8f0;
  --am-fg:          #0f172a;
  --am-fg-secondary:#475569;
  --am-fg-tertiary: #94a3b8;

  /* accents */
  --am-accent-cyan:   #06b6d4;
  --am-accent-blue:   #3b82f6;
  --am-accent-purple: #8b5cf6;
  --am-accent-dark:   #2563eb;
  --am-success:  #10b981;
  --am-warning:  #f59e0b;
  --am-danger:   #ef4444;
  --am-info:     #0ea5e9;

  /* surfaces — glass-ready */
  --am-panel:        rgba(255,255,255,0.88);
  --am-panel-solid:  #ffffff;
  --am-panel-2:      rgba(241,245,249,0.86);
  --am-border:       rgba(203,213,225,0.7);
  --am-border-strong:#cbd5e1;

  /* sidebar */
  --am-sidebar-w: 220px;

  /* skeleton */
  --am-skel-base:  #e2e8f0;

  /* glow & shadow */
  --am-glow-cyan:   0 0 24px rgba(6,182,212,0.28);
  --am-glow-blue:   0 0 24px rgba(59,130,246,0.28);
  --am-glow-purple: 0 0 24px rgba(139,92,246,0.28);
  --am-shadow:      0 4px 14px rgba(15,23,42,0.06);
  --am-shadow-lg:   0 18px 40px rgba(15,23,42,0.12);
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --am-bg:          #0b1220;
  --am-bg-2:        #111b2e;
  --am-fg:          #e8edf5;
  --am-fg-secondary:#8b9cb5;
  --am-fg-tertiary: #5c6e88;

  --am-accent-cyan:   #22d3ee;
  --am-accent-blue:   #60a5fa;
  --am-accent-purple: #a78bfa;
  --am-accent-dark:   #93c5fd;
  --am-success:  #34d399;
  --am-warning:  #fbbf24;
  --am-danger:   #f87171;
  --am-info:     #38bdf8;

  --am-panel:        rgba(17,27,46,0.88);
  --am-panel-solid:  #111b2e;
  --am-panel-2:      rgba(22,32,52,0.86);
  --am-border:       rgba(255,255,255,0.08);
  --am-border-strong: rgba(255,255,255,0.14);

  --am-skel-base:  #162034;
  --am-shadow:      0 4px 14px rgba(0,0,0,0.25);
  --am-shadow-lg:   0 18px 40px rgba(0,0,0,0.35);
}

/* ---- Auto (system preference) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --am-bg:          #0b1220;
    --am-bg-2:        #111b2e;
    --am-fg:          #e8edf5;
    --am-fg-secondary:#8b9cb5;
    --am-fg-tertiary: #5c6e88;

    --am-accent-cyan:   #22d3ee;
    --am-accent-blue:   #60a5fa;
    --am-accent-purple: #a78bfa;
    --am-accent-dark:   #93c5fd;
    --am-success:  #34d399;
    --am-warning:  #fbbf24;
    --am-danger:   #f87171;
    --am-info:     #38bdf8;

    --am-panel:        rgba(17,27,46,0.88);
    --am-panel-solid:  #111b2e;
    --am-panel-2:      rgba(22,32,52,0.86);
    --am-border:       rgba(255,255,255,0.08);
    --am-border-strong: rgba(255,255,255,0.14);

    --am-skel-base:  #162034;
    --am-shadow:      0 4px 14px rgba(0,0,0,0.25);
    --am-shadow-lg:   0 18px 40px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }

/* ---------- global ---------- */
html, body { margin: 0; min-height: 100%; }

body.page {
  background-color: var(--am-bg);
  color: var(--am-fg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: ui-monospace, Menlo, Consolas, "SF Mono", "JetBrains Mono", monospace; }

.hidden { display: none !important; }
.muted { color: var(--am-fg-secondary); }

/* ---------- particle canvas ---------- */
#particles {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}

/* ---------- focus ring ---------- */
:focus-visible {
  outline: 2px solid var(--am-accent-cyan);
  outline-offset: 2px;
}

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--am-border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--am-fg-tertiary); }
* { scrollbar-width: thin; scrollbar-color: var(--am-border-strong) transparent; }

/* ---------- animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(18px) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #particles { display: none !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- layout ---------- */
.app-layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--am-sidebar-w);
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--am-panel);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-right: 1px solid var(--am-border);
  box-shadow: var(--am-shadow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--am-border);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-status {
  margin: 0 10px 10px;
  padding: 12px 14px;
  background: var(--am-panel-2);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11.5px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sidebar-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--am-fg-secondary);
}

.sidebar-status-val {
  font-weight: 700;
  color: var(--am-fg);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding: 12px 16px;
  font-size: 10.5px;
  color: var(--am-fg-tertiary);
  border-top: 1px solid var(--am-border);
  text-align: center;
}

.sidebar-footer::before {
  content: "⇄";
  display: block;
  font-size: 16px;
  color: var(--am-border-strong);
  margin-bottom: 4px;
}

.main-wrap {
  flex: 1;
  margin-left: var(--am-sidebar-w);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--am-panel);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--am-border);
  box-shadow: var(--am-shadow);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--am-fg); }

.gw-chip {
  position: relative;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--am-panel-2);
  border: 1px solid var(--am-border);
  color: var(--am-fg-secondary);
  cursor: pointer;
  user-select: all;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.gw-chip:hover {
  background: var(--am-panel);
  border-color: var(--am-accent-cyan);
  color: var(--am-fg);
  box-shadow: var(--am-glow-cyan);
}
.gw-chip .copy-icon {
  opacity: 0;
  font-size: 11px;
  color: var(--am-accent-cyan);
  transition: opacity .2s;
}
.gw-chip:hover .copy-icon { opacity: 1; }
.gw-chip.copied { border-color: var(--am-success); }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.ok      { background: var(--am-success); color: rgba(16,185,129,0.45); animation: pulse 2s infinite; }
.health-dot.warn    { background: var(--am-warning); color: rgba(245,158,11,0.45); animation: pulse 2s infinite; }
.health-dot.err     { background: var(--am-danger);  color: rgba(239,68,68,0.45);  animation: pulse 2s infinite; }

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--am-border);
  background: var(--am-panel-2);
  color: var(--am-fg-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: border-color .2s, background .2s, color .2s, box-shadow .2s;
}
.theme-btn:hover {
  background: var(--am-panel);
  border-color: var(--am-accent-blue);
  color: var(--am-fg);
  box-shadow: var(--am-glow-blue);
}

.content {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 1300px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* ---------- auth ---------- */
.auth-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--am-panel);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  padding: 32px;
  box-shadow: var(--am-shadow-lg), 0 0 40px rgba(6,182,212,0.08);
  animation: fadeUp 0.6s ease-out;
}

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.brand-logo {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: var(--am-radius-sm);
  background: linear-gradient(135deg, var(--am-accent-blue), var(--am-accent-cyan));
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: var(--am-glow-blue);
}
.brand-logo.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; }
.brand-name { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 0; }
.brand-sub { margin: 4px 0 0; color: var(--am-fg-secondary); font-size: 12px; }

/* ---------- navigation ---------- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--am-radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--am-fg-secondary);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}

.nav-item:hover {
  background: var(--am-panel-2);
  color: var(--am-fg);
  transform: translateX(2px);
}

.nav-item.is-active {
  background: linear-gradient(90deg, var(--am-accent-t), transparent);
  color: var(--am-accent-blue);
  font-weight: 600;
  border-left: 3px solid var(--am-accent-cyan);
  border-color: var(--am-border);
  border-left-color: var(--am-accent-cyan);
  padding-left: 10px;
  box-shadow: inset 4px 0 12px rgba(6,182,212,0.12);
}
:root { --am-accent-t: rgba(6,182,212,0.10); }
[data-theme="dark"] { --am-accent-t: rgba(6,182,212,0.14); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --am-accent-t: rgba(6,182,212,0.14); }
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ---------- views ---------- */
.view { display: none; }
.view.active {
  display: block;
  animation: viewIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.view.active .panel,
.view.active .stat,
.view.active .model-card,
.view.active .provider-card {
  animation: fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0; }
.view-sub { margin: 5px 0 0; color: var(--am-fg-secondary); font-size: 12.5px; max-width: 70ch; line-height: 1.5; }

.row { display: flex; align-items: center; }
.gap { gap: 10px; }

.view-head .row.gap {
  display: inline-flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: nowrap;
}

.view-head .row.gap .input,
.view-head .row.gap .btn {
  height: 34px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* ---------- glass panels ---------- */
.panel {
  position: relative;
  background: var(--am-panel);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--am-shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.panel:hover {
  border-color: var(--am-border-strong);
  box-shadow: var(--am-shadow-lg), 0 0 24px rgba(6,182,212,0.08);
}

.panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--am-accent-cyan), transparent);
  opacity: 0.6;
  pointer-events: none;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--am-fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--am-accent-cyan), var(--am-accent-blue));
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent);
  opacity: 0;
  transition: opacity .2s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--am-glow-blue);
}
.btn:hover::before { opacity: 1; }

.btn:active { transform: translateY(0); filter: brightness(0.95); }

.btn--primary {
  background: linear-gradient(135deg, var(--am-accent-blue), var(--am-accent-purple));
}
.btn--primary:hover { box-shadow: var(--am-glow-purple); }

.btn--ghost {
  background: transparent;
  color: var(--am-fg-secondary);
  border: 1px solid var(--am-border-strong);
}
.btn--ghost:hover {
  background: rgba(6,182,212,0.08);
  color: var(--am-fg);
  border-color: rgba(6,182,212,0.35);
  box-shadow: var(--am-glow-cyan);
}

.btn--danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}
.btn--danger:hover { box-shadow: 0 0 20px rgba(239,68,68,0.35); }

.btn--sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---------- stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: var(--am-panel);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  padding: 16px 18px 14px 20px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--am-shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--am-accent-blue);
  box-shadow: 0 0 12px rgba(59,130,246,0.45);
}

.stat::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--am-accent-cyan), transparent);
  opacity: 0.5;
  pointer-events: none;
}

.stat:hover {
  transform: translateY(-3px);
  border-color: var(--am-border-strong);
  box-shadow: var(--am-shadow-lg), var(--am-glow-cyan);
}

.stat .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--am-accent-blue);
  transition: box-shadow .2s;
}
.stat:hover .icon { box-shadow: var(--am-glow-blue); }

.stat .v {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  margin-top: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.stat .l { font-size: 11.5px; color: var(--am-fg-secondary); margin-top: 6px; font-weight: 500; }

.stat .delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat .delta.up   { background: rgba(16, 185, 129, 0.12); color: var(--am-success); }
.stat .delta.down { background: rgba(239, 68, 68, 0.12);  color: var(--am-danger); }
.stat .delta.flat { background: var(--am-panel-2);         color: var(--am-fg-tertiary); }

.stat .sparkline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
  opacity: 0.55;
}

.stat.accent-blue::before  { background: var(--am-accent-blue);  box-shadow: 0 0 12px rgba(59,130,246,0.45); }
.stat.accent-blue .icon    { background: rgba(59, 130, 246, 0.12);  color: var(--am-accent-blue); }
.stat.accent-cyan::before  { background: var(--am-accent-cyan);  box-shadow: 0 0 12px rgba(6,182,212,0.45); }
.stat.accent-cyan .icon    { background: rgba(6, 182, 212, 0.12);   color: var(--am-accent-cyan); }
.stat.accent-emerald::before { background: var(--am-success);     box-shadow: 0 0 12px rgba(16,185,129,0.45); }
.stat.accent-emerald .icon { background: rgba(16, 185, 129, 0.12);  color: var(--am-success); }
.stat.accent-amber::before { background: var(--am-warning);      box-shadow: 0 0 12px rgba(245,158,11,0.45); }
.stat.accent-amber .icon   { background: rgba(245, 158, 11, 0.12);  color: var(--am-warning); }
.stat.accent-red::before   { background: var(--am-danger);         box-shadow: 0 0 12px rgba(239,68,68,0.45); }
.stat.accent-red .icon     { background: rgba(239, 68, 68, 0.12);   color: var(--am-danger); }
.stat.accent-purple::before { background: var(--am-accent-purple); box-shadow: 0 0 12px rgba(139,92,246,0.45); }
.stat.accent-purple .icon  { background: rgba(139, 92, 246, 0.12);  color: var(--am-accent-purple); }
.stat.accent-slate::before { background: var(--am-fg-tertiary);   box-shadow: 0 0 12px rgba(148,163,184,0.35); }
.stat.accent-slate .icon   { background: rgba(148, 163, 184, 0.12); color: var(--am-fg-tertiary); }

/* stats view KPI: 4 columns so wide screens fill two balanced rows of 4 */
.stat-grid--stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-grid--stats .stat { padding: 13px 14px 12px 17px; min-height: 92px; }
.stat-grid--stats .stat .icon { width: 26px; height: 26px; border-radius: 7px; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.stat-grid--stats .stat .v { font-size: 22px; }
.stat-grid--stats .stat .l { font-size: 11px; margin-top: 3px; }

/* stats toolbar: labelled filter controls, spread out, not cramped */
.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  background: var(--am-panel);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.stats-toolbar-group {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.stats-toolbar-group + .stats-toolbar-group { border-left: 1px solid var(--am-border); padding-left: 18px; }
.stats-toolbar-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--am-fg-tertiary);
  white-space: nowrap;
}
.stats-toolbar .input--grow { flex: 1; min-width: 160px; max-width: 340px; }

/* multi-select filter controls in the stats toolbar */
.msel { position: relative; display: inline-flex; align-items: center; gap: 7px; }
.msel-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--am-panel-2, var(--am-bg));
  border: 1px solid var(--am-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--am-fg);
  cursor: pointer;
  max-width: 190px;
}
.msel-trigger:hover { border-color: var(--am-accent-blue); }
.msel.open .msel-trigger { border-color: var(--am-accent-blue); }
.msel-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-value--active { color: var(--am-accent-blue); font-weight: 700; }
.msel-caret { font-size: 10px; opacity: .7; }
.msel-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 230px;
  max-width: 300px;
  background: var(--am-panel);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow);
  padding: 8px;
}
.msel-search { width: 100%; margin-bottom: 6px; }
.msel-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.msel-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  min-width: 0;
}
.msel-opt:hover { background: var(--am-panel-2, rgba(127,127,127,.12)); }
.msel-opt input[type="checkbox"] { width: 14px; height: 14px; margin: 0; flex-shrink: 0; accent-color: var(--am-accent-blue); cursor: pointer; }
.msel-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-empty { padding: 8px 7px; font-size: 12px; }
.stats-toolbar-actions { margin-left: auto; }
.stats-toolbar-group + .stats-toolbar-actions { border-left: none; padding-left: 0; }
#stats-clear-filters:disabled { opacity: .45; cursor: default; }

/* stats panel head: title + inline control */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.panel-head .panel-title { margin-bottom: 0; }
.donut-slot { display: flex; justify-content: center; padding: 8px 0 2px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; color: var(--am-fg-secondary); font-weight: 600; }
.field-end { display: flex; align-items: flex-end; }
.field .check, .field .toggle,
.field label.check, .field label.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--am-fg);
  font-weight: 500;
}
.field .check input, .field .toggle input,
.field label.check input, .field label.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid var(--am-border-strong);
  background: var(--am-panel-solid);
  color: var(--am-fg);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.input:focus {
  border-color: var(--am-accent-cyan);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15), var(--am-glow-cyan);
}

.input--sm { padding: 5px 10px; font-size: 12px; }

select.input {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 10px) center;
  background-size: 10px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* check & toggle */
.check, .toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--am-fg);
}

.check input, .toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.check .box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--am-border-strong);
  background: var(--am-panel-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.check input:checked + .box {
  background: var(--am-accent-blue);
  border-color: var(--am-accent-blue);
  box-shadow: var(--am-glow-blue);
}

.check input:checked + .box::after {
  content: "✓";
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.toggle .track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--am-border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background .2s, box-shadow .2s;
}

.toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .track { background: var(--am-accent-blue); box-shadow: var(--am-glow-blue); }
.toggle input:checked + .track .knob { left: 18px; }

/* ---------- tags & badges ---------- */
.tag, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  background: var(--am-panel-2);
  border: 1px solid var(--am-border);
  color: var(--am-fg-secondary);
  white-space: nowrap;
}

.badge--green  { background: rgba(16, 185, 129, 0.1);  border-color: rgba(16, 185, 129, 0.2);  color: var(--am-success); }
.badge--amber  { background: rgba(245, 158, 11, 0.1);  border-color: rgba(245, 158, 11, 0.2);  color: var(--am-warning); }
.badge--red    { background: rgba(239, 68, 68, 0.1);   border-color: rgba(239, 68, 68, 0.2);   color: var(--am-danger); }
.badge--accent { background: rgba(59, 130, 246, 0.1);  border-color: rgba(59, 130, 246, 0.2);  color: var(--am-accent-blue); }
.tag--accent   { background: rgba(6, 182, 212, 0.1);   border-color: rgba(6, 182, 212, 0.2);   color: var(--am-accent-cyan); }

.status-dot-inline {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.mtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mtable th, .mtable td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--am-border); white-space: nowrap; }
.mtable thead th {
  color: var(--am-fg-tertiary);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0;
  border-bottom: 1px solid var(--am-border-strong);
  background: var(--am-panel-2);
}
.mtable tbody tr {
  transition: background .15s ease, box-shadow .15s ease;
}
.mtable tbody tr:hover {
  background: var(--am-panel-2);
  box-shadow: inset 3px 0 0 var(--am-accent-cyan);
}
.mtable td code { background: var(--am-panel-2); padding: 2px 6px; border-radius: 4px; font-size: 11.5px; border: 1px solid var(--am-border); }
.mtable td.num { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.rate-bar { position: relative; display: inline-block; width: 48px; height: 6px; border-radius: 999px; background: var(--am-panel-2); border: 1px solid var(--am-border); vertical-align: middle; overflow: hidden; }
.rate-bar .rate-fill { display: block; height: 100%; border-radius: 999px; }
.rate-bar--ok .rate-fill   { background: linear-gradient(90deg, rgba(16,185,129,0.35), var(--am-success)); }
.rate-bar--warn .rate-fill { background: linear-gradient(90deg, rgba(245,158,11,0.35), var(--am-warning)); }
.rate-bar--bad .rate-fill  { background: linear-gradient(90deg, rgba(239,68,68,0.35), var(--am-danger)); }
.rate-num { margin-left: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--am-fg-secondary); font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--am-border);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover {
  background: var(--am-panel-2);
  transform: translateX(4px);
  box-shadow: inset 3px 0 0 var(--am-accent-cyan);
}
.list-item.clickable { cursor: pointer; }
.list-item .primary { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; }
.list-item .desc { color: var(--am-fg-secondary); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.list-item .meta { color: var(--am-fg-tertiary); font-size: 11.5px; text-align: right; white-space: nowrap; }

.list-empty { color: var(--am-fg-tertiary); padding: 24px 8px; font-size: 13px; text-align: center; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  text-align: center;
}
.empty-state svg { color: var(--am-border-strong); }
.empty-state .empty-title { font-size: 15px; font-weight: 600; color: var(--am-fg); margin: 0; }
.empty-state .empty-sub   { font-size: 13px; color: var(--am-fg-secondary); margin: 0; max-width: 36ch; line-height: 1.5; }

/* ---------- filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--am-panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  box-shadow: var(--am-shadow);
}
.filter-bar .field--inline { margin: 0; flex: 1 1 150px; min-width: 110px; }
.filter-bar .field--inline label { display: block; font-size: 10.5px; font-weight: 600; color: var(--am-fg-tertiary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0; }
.filter-bar .field--inline .input { width: 100%; }
@media (max-width: 760px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .field--inline { min-width: 0; }
}

/* ---------- skeleton loaders ---------- */
.skel {
  background: linear-gradient(90deg, var(--am-skel-base) 25%, var(--am-panel-2) 50%, var(--am-skel-base) 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.6s infinite linear;
}

.skel-stat {
  height: 100px;
  border-radius: var(--am-radius);
}

.skel-card {
  height: 80px;
  border-radius: var(--am-radius);
  margin-bottom: 12px;
}

.skel-row {
  height: 44px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.skel-row + .skel-row { opacity: 0.7; }
.skel-row + .skel-row + .skel-row { opacity: 0.5; }

/* ---------- model / provider cards ---------- */
.model-card, .provider-card {
  position: relative;
  background: var(--am-panel);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--am-shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.model-card:hover, .provider-card:hover {
  transform: translateY(-2px);
  border-color: var(--am-border-strong);
  box-shadow: var(--am-shadow-lg), 0 0 24px rgba(6,182,212,0.08);
}

.model-head, .provider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--am-border);
  gap: 12px;
  flex-wrap: wrap;
  background: var(--am-panel-2);
}

.model-head .name, .provider-head .name { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.model-head .name-row, .provider-head .name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-body { padding: 4px 18px 14px; }

.ep-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--am-border);
  transition: background .15s ease, box-shadow .15s ease;
}
.ep-row:last-child { border-bottom: 0; }
.ep-row:hover { background: var(--am-panel-2); border-radius: var(--am-radius-xs); box-shadow: inset 3px 0 0 var(--am-accent-cyan); }

.ep-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ep-left { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.ep-row .ep-name { font-size: 13.5px; font-weight: 600; }
.ep-provider-tag { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-right.ep-actions { margin-left: 0; }
.ep-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--am-fg-secondary); }
.ep-from { color: var(--am-fg); font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-row .ep-url {
  color: var(--am-fg-tertiary);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.ep-actions { display: inline-flex; gap: 5px; flex-wrap: wrap; }

.provider-body { padding: 12px 18px 14px; }
.provider-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }

/* ---------- charts ---------- */
.chart-box { width: 100%; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.chart-box svg { display: block; }
.chart-box--donut { min-height: 160px; justify-content: flex-start; }
.chart-xlabels { font-size: 10px; margin-top: 6px; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--am-fg-tertiary); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-svg { flex: none; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; min-width: 120px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-legend-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.donut-legend-item .lbl { color: var(--am-fg); font-weight: 600; }
.donut-legend-item .val { color: var(--am-fg-tertiary); margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; }
.donut-svg path { cursor: pointer; }
.donut-svg path:hover { opacity: 0.85; }
.hbar-list { display: flex; flex-direction: column; gap: 9px; padding-top: 2px; }
.hbar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.hbar-label { width: 110px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--am-fg-secondary); }
.hbar-track { flex: 1; height: 8px; background: var(--am-panel-2); border-radius: 999px; overflow: hidden; min-width: 40px; border: 1px solid var(--am-border); }
.hbar-fill { display: block; height: 100%; border-radius: 999px; background: var(--am-accent-blue); transition: width 0.6s ease; }
.hbar-val { width: 52px; flex: none; text-align: right; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--am-fg-tertiary); }

/* ---------- pagination ---------- */
.list-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.list-pager .info { font-size: 11.5px; color: var(--am-fg-tertiary); }
.pager-btns { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager-ellipsis { color: var(--am-fg-tertiary); padding: 0 2px; font-size: 12px; }

/* ---------- request detail ---------- */
.chain { display: flex; flex-direction: column; gap: 0; margin: 4px 0 8px; }
.chain-step { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px 10px 18px; margin-left: 6px; }
.chain-step::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 2px; border-radius: 3px; background: var(--am-border-strong); }
.chain-step.ok::before  { background: var(--am-success); box-shadow: 0 0 8px rgba(16,185,129,0.35); }
.chain-step.err::before { background: var(--am-danger); box-shadow: 0 0 8px rgba(239,68,68,0.35); }
.chain-step .idx  { font-size: 11px; color: var(--am-fg-tertiary); min-width: 18px; padding-top: 2px; }
.chain-step .body { flex: 1; min-width: 0; }
.chain-step .ep   { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.chain-step .err-msg { display: flex; align-items: baseline; gap: 8px; color: var(--am-fg-secondary); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; margin-top: 7px; word-break: break-word; }
.chain-step .err-msg span, .chain-step .err-detail-label { flex: 0 0 auto; color: var(--am-fg-tertiary); font-family: inherit; font-size: 10px; font-weight: 700; }
.chain-step .err-detail-label { margin-top: 7px; }
.chain-step .err-detail { margin: 3px 0 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--am-border); border-radius: var(--am-radius-xs); background: var(--am-panel-2); color: var(--am-fg-secondary); padding: 8px 10px; font: 11.5px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.chain-step .err-detail-empty { margin-top: 6px; color: var(--am-fg-tertiary); font-size: 11px; }
.chain-step .meta { color: var(--am-fg-tertiary); font-size: 11px; margin-top: 5px; }
.error-source--upstream { border-color: rgba(239, 68, 68, 0.28); color: var(--am-danger); }
.error-source--downstream { border-color: rgba(245, 158, 11, 0.3); color: var(--am-warning); }
.error-source--gateway { border-color: rgba(6, 182, 212, 0.3); color: var(--am-accent-cyan); }
.chain-arrow { color: var(--am-fg-tertiary); text-align: center; font-size: 13px; margin: -2px 0 -2px 18px; }
.code { background: var(--am-panel-2); border: 1px solid var(--am-border); border-radius: var(--am-radius-sm); padding: 14px 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; color: var(--am-fg); white-space: pre; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-overlay:not(.hidden) { animation: fadeIn 0.2s ease; }
.modal-overlay:not(.hidden) .dialog { animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.dialog {
  width: 100%;
  max-width: 580px;
  background: var(--am-panel);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--am-border-strong);
  border-radius: var(--am-radius);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--am-shadow-lg), 0 0 40px rgba(6,182,212,0.12);
}
.dialog::before { content: ""; position: sticky; top: 0; display: block; height: 2px; background: linear-gradient(90deg, var(--am-accent-cyan), var(--am-accent-blue)); z-index: 2; }
.dialog::-webkit-scrollbar { width: 8px; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--am-border); font-size: 15px; font-weight: 700; letter-spacing: 0; position: sticky; top: 0; background: var(--am-panel); z-index: 1; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.modal-x { background: transparent; border: 0; color: var(--am-fg-tertiary); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 5px; transition: color .2s, background .2s; }
.modal-x:hover { color: var(--am-fg); background: var(--am-panel-2); }
.dialog-body { padding: 20px; }
.mform { display: grid; gap: 14px; }
.mform .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mform .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.header-rows { display: flex; flex-direction: column; gap: 8px; }
.header-row { display: flex; align-items: center; gap: 8px; }
.header-row .p-header-name { flex: 0 1 38%; min-width: 0; }
.header-row .p-header-value { flex: 1 1 auto; min-width: 0; }
.header-row .p-header-del { flex: 0 0 auto; }

/* ---------- command palette ---------- */
.cmd-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding-top: 18vh; }
.cmd-overlay:not(.hidden) { animation: fadeIn 0.15s ease; }
.cmd-dialog { width: 100%; max-width: 520px; background: var(--am-panel-solid); border: 1px solid var(--am-border-strong); border-radius: var(--am-radius); overflow: hidden; box-shadow: var(--am-shadow-lg), 0 0 40px rgba(6,182,212,0.15); }
.cmd-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--am-border); }
.cmd-icon { font-size: 16px; color: var(--am-fg-tertiary); flex-shrink: 0; }
.cmd-input { flex: 1; background: transparent; border: 0; outline: none; font: inherit; font-size: 14px; color: var(--am-fg); }
.cmd-input::placeholder { color: var(--am-fg-tertiary); }
.cmd-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmd-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--am-fg); transition: background .15s; }
.cmd-item:hover, .cmd-item.is-active { background: var(--am-panel-2); }
.cmd-item .cmd-item-icon { font-size: 16px; width: 24px; text-align: center; color: var(--am-fg-secondary); flex-shrink: 0; }
.cmd-item .cmd-item-label { flex: 1; font-weight: 500; }
.cmd-item .cmd-item-hint { font-size: 11px; color: var(--am-fg-tertiary); background: var(--am-panel-2); border: 1px solid var(--am-border); border-radius: 4px; padding: 2px 6px; }
.cmd-footer { display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--am-border); font-size: 11px; color: var(--am-fg-tertiary); }
.cmd-footer kbd { background: var(--am-panel-2); border: 1px solid var(--am-border-strong); border-radius: 4px; padding: 1px 5px; font-size: 10px; font-family: ui-monospace, monospace; color: var(--am-fg-secondary); }

/* ---------- alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--am-radius-sm); font-size: 12.5px; font-weight: 500; line-height: 1.5; }
.alert--info    { background: rgba(6,182,212,0.08);  border: 1px solid rgba(6,182,212,0.2);  color: var(--am-accent-cyan); }
.alert--success { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.2); color: var(--am-success); }

/* ---------- cc-switch import ---------- */
.import-output { background: var(--am-panel-2); border: 1px solid var(--am-border); border-radius: var(--am-radius-sm); padding: 12px 14px; margin: 10px 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55; color: var(--am-fg); white-space: pre; overflow-x: auto; user-select: all; }
.import-steps { margin: 4px 0 12px; padding-left: 18px; color: var(--am-fg-secondary); font-size: 12.5px; line-height: 1.7; }
.import-steps li { margin-bottom: 2px; }
.discover-box { max-height: 240px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--am-border); border-radius: var(--am-radius-sm); background: var(--am-panel-2); }
.discover-empty { padding: 16px; text-align: center; color: var(--am-fg-tertiary); font-size: 13px; }
.discover-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--am-border); gap: 12px; flex-wrap: wrap; }
.discover-item:last-child { border-bottom: 0; }
.discover-item .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 24px; left: 24px; right: 24px; width: max-content; max-width: calc(100% - 48px); margin: 0 auto; background: var(--am-panel-solid); border: 1px solid var(--am-border-strong); padding: 10px 18px 10px 22px; border-radius: 8px; z-index: 70; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: var(--am-shadow-lg); animation: toastIn 0.25s ease; }
.toast.ok  { color: var(--am-success); }
.toast.err { color: var(--am-danger); }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 8px 0 0 8px; }
.toast.ok::before  { background: var(--am-success); box-shadow: 0 0 12px rgba(16,185,129,0.45); }
.toast.err::before { background: var(--am-danger); box-shadow: 0 0 12px rgba(239,68,68,0.45); }

/* ---------- footer ---------- */
.footer { max-width: 1300px; width: 100%; margin: 0 auto; padding: 16px 24px 28px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--am-fg-tertiary); border-top: 1px solid var(--am-border); }

/* ---------- mobile hamburger ---------- */
.hamburger { display: none; flex-direction: column; gap: 4px; padding: 7px; background: transparent; border: 0; cursor: pointer; border-radius: 6px; }
.hamburger:hover { background: var(--am-panel-2); }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--am-fg-secondary); border-radius: 2px; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 25; }

/* ---------- segmented range control ---------- */
.range-seg { display: inline-flex; background: var(--am-panel-2); border: 1px solid var(--am-border); border-radius: 8px; padding: 3px; gap: 2px; height: 34px; align-items: center; }
.range-seg-btn { padding: 3px 10px; border-radius: 6px; border: 0; background: transparent; color: var(--am-fg-secondary); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1; transition: background .15s, color .15s, box-shadow .15s; }
.range-seg-btn:hover { color: var(--am-fg); background: var(--am-panel); }
.range-seg-btn.is-active { background: var(--am-panel); color: var(--am-accent-blue); font-weight: 700; border: 1px solid var(--am-accent-blue); box-shadow: 0 0 10px rgba(59,130,246,0.12); }
#range-select { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .stat-grid--stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid--stats { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .hamburger { display: flex; }
  .sidebar { left: 0; display: none; }
  .sidebar.is-open { display: flex; }
  .sidebar.is-open + .sidebar-backdrop, .sidebar-backdrop.is-visible { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .topbar-title { display: none; }
  .content { padding: 16px 14px 28px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid, .mform .two { grid-template-columns: 1fr; }
  .header-row { flex-wrap: wrap; }
  .header-row .p-header-name, .header-row .p-header-value { flex: 1 1 140px; }
  .ep-row .ep-url { min-width: 100%; }
  .ep-main .ep-left, .ep-main .ep-right { width: 100%; }
  .ep-main .ep-right { justify-content: flex-start; margin-top: 2px; }
  .ep-meta { gap: 5px; }
  .ep-provider-tag, .ep-from { max-width: 100%; }
  .footer { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-grid--stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 22px; }
  .cmd-dialog { margin: 0 12px; }
  #particles { display: none; }
}

/* xAI OAuth */
.oauth-wait .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tag--warn { background: #fff4ce; color: #835c00; border: 1px solid #f0e0a0; padding: 1px 6px; border-radius: 3px; font-size: 12px; }
[data-theme="dark"] .tag--warn { background: #3a2f12; color: #f0d78c; border-color: #5a4a1a; }

/* ---------- Proxy page ---------- */
.proxy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .proxy-layout { grid-template-columns: 1fr; }
}
.panel-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.proxy-status-panel { margin-bottom: 16px; }
.proxy-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .proxy-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.proxy-kpi {
  position: relative;
  background: var(--am-panel-2);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-xs);
  padding: 12px 14px;
  min-width: 0;
  overflow: hidden;
}
.proxy-kpi::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--am-accent-cyan), transparent);
  opacity: 0.6;
}
.proxy-kpi-label {
  display: block;
  font-size: 11px;
  color: var(--am-fg-tertiary);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.proxy-kpi-val {
  display: block;
  font-size: 14px;
  font-weight: 650;
  color: var(--am-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.proxy-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--am-radius-xs);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: var(--am-danger);
  font-size: 12.5px;
  line-height: 1.45;
}

.proxy-settings-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.proxy-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proxy-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--am-fg-secondary);
}
.proxy-field-hint {
  margin: 0;
  font-size: 12px;
  color: var(--am-fg-tertiary);
  line-height: 1.45;
}
.proxy-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--am-fg);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.proxy-switch--lg {
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--am-radius-xs);
  border: 1px solid var(--am-border);
  background: var(--am-panel-2);
}
.proxy-switch input { accent-color: var(--am-accent-blue); }

.proxy-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.proxy-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--am-border);
  background: var(--am-panel-2);
  font-size: 12.5px;
  color: var(--am-fg);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.proxy-chip:hover { border-color: var(--am-border-strong); }
.proxy-chip:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.1);
  color: var(--am-accent-blue);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(59,130,246,0.12);
}
.proxy-chip input { accent-color: var(--am-accent-blue); margin: 0; }

.proxy-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-xs);
  overflow: hidden;
  background: var(--am-panel-2);
}
.proxy-seg-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  user-select: none;
}
.proxy-seg-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.proxy-seg-item span {
  width: 100%;
  text-align: center;
  padding: 10px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--am-fg-secondary);
  border-right: 1px solid var(--am-border);
  transition: background .15s, color .15s, box-shadow .15s;
}
.proxy-seg-item:last-child span { border-right: 0; }
.proxy-seg-item:has(input:checked) span {
  background: rgba(59, 130, 246, 0.14);
  color: var(--am-accent-blue);
  box-shadow: inset 0 0 12px rgba(59,130,246,0.12);
}
.proxy-seg-item:hover span { color: var(--am-fg); }
.proxy-settings-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--am-border);
}

.proxy-sub-form {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.proxy-sub-form .field { margin: 0; }
.proxy-sub-form .field label {
  display: block;
  font-size: 11.5px;
  color: var(--am-fg-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}
@media (max-width: 720px) {
  .proxy-sub-form { grid-template-columns: 1fr; }
  .proxy-seg { grid-template-columns: 1fr; }
  .proxy-seg-item span { border-right: 0; border-bottom: 1px solid var(--am-border); }
  .proxy-seg-item:last-child span { border-bottom: 0; }
}
.proxy-subs {
  max-height: 280px;
  overflow: auto;
  border-top: 1px solid var(--am-border);
  padding-top: 4px;
}
.proxy-subs .list-item { padding: 12px 4px; }
.proxy-subs .list-item .title { font-size: 13px; }
.proxy-subs .list-empty { padding: 20px 8px; }

.proxy-nodes-panel { margin-top: 0; }
.proxy-nodes-table td:last-child,
.proxy-nodes-table th:last-child { text-align: right; }
.proxy-nodes-table code {
  max-width: 320px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.proxy-delay {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.proxy-delay.is-fast { color: var(--am-success); }
.proxy-delay.is-mid { color: var(--am-warning); }
.proxy-delay.is-slow { color: var(--am-danger); }
.proxy-delay.is-pending { color: var(--am-fg-tertiary); font-weight: 500; }
.proxy-node-actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Provider quota ---------- */
.provider-quota { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--am-border); }
.provider-quota-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--am-fg-secondary);
}
.provider-quota-row strong { color: var(--am-fg); font-variant-numeric: tabular-nums; }
.quota-bar {
  margin-top: 8px; height: 6px; border-radius: 99px;
  background: var(--am-panel-2); border: 1px solid var(--am-border); overflow: hidden;
}
.quota-bar-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.quota-bar-fill.is-ok { background: var(--am-success); }
.quota-bar-fill.is-warn { background: var(--am-warning); }
.quota-bar-fill.is-bad { background: var(--am-danger); }

.quota-window { margin-top: 6px; }
.quota-window-head {
  font-size: 12px; color: var(--am-fg-secondary);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.quota-window .quota-bar { margin-top: 4px; }

/* ---------- OAuth login bar ---------- */
.oauth-bar { margin-bottom: 16px; }
.oauth-bar-head { margin-bottom: 12px; }
.oauth-bar-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--am-fg-tertiary);
  line-height: 1.4;
}
.oauth-login-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1100px) {
  .oauth-login-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .oauth-login-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .oauth-login-grid { grid-template-columns: 1fr; }
}
.oauth-login-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: var(--am-radius-xs);
  border: 1px solid var(--am-border);
  background: var(--am-panel-2);
  color: var(--am-fg);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .1s, box-shadow .2s;
}
.oauth-login-btn:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: var(--am-glow-blue);
}
.oauth-login-btn:active { transform: translateY(1px); }
.oauth-login-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.oauth-login-btn.is-loading {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15), 0 0 12px rgba(59,130,246,0.12);
}
.oauth-login-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: 0 0 12px rgba(59,130,246,0.25);
}
.oauth-login-btn[data-oauth-login="xai"] .oauth-login-icon { background: linear-gradient(135deg, #111827, #4b5563); }
.oauth-login-btn[data-oauth-login="claude"] .oauth-login-icon { background: linear-gradient(135deg, #d97706, #b45309); }
.oauth-login-btn[data-oauth-login="codex"] .oauth-login-icon { background: linear-gradient(135deg, #10b981, #059669); }
.oauth-login-btn[data-oauth-login="kimi"] .oauth-login-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.oauth-login-btn[data-oauth-login="antigravity"] .oauth-login-icon { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.oauth-login-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.oauth-login-meta strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.oauth-login-meta span {
  font-size: 11.5px;
  color: var(--am-fg-tertiary);
}

/* ---------- Global loading ---------- */
.global-loading {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(1px);
}
.global-loading.hidden { display: none; }
.global-loading-card {
  min-width: 180px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 18px 22px;
  border-radius: 12px;
  border: 1px solid var(--am-border-strong);
  background: var(--am-panel-solid);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 12px;
}
.global-loading-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--am-border-strong);
  border-top-color: var(--am-accent-blue);
  animation: global-spin .7s linear infinite;
  flex: 0 0 auto;
}
.global-loading-text {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--am-fg);
  line-height: 1.35;
}
@keyframes global-spin {
  to { transform: rotate(360deg); }
}
