/* ============================================================
   MENDADAKXCRYPTO — API Router Command Center
   Terminal / phosphor aesthetic. Crisp borders, mono data,
   no soft-shadow slop. Distinctive by design.
   ============================================================ */

:root {
  --bg: #0a0d0a;
  --bg-2: #0d110d;
  --panel: #101510;
  --raised: #141a14;
  --border: #1e291e;
  --border-strong: #2b3a2b;
  --text: #e3ede3;
  --muted: #7a8a7a;
  --faint: #4a5a4a;
  --accent: #00e676;
  --accent-bright: #a3f445;
  --accent-dim: #00a95a;
  --danger: #ff5252;
  --warn: #ffc400;
  --info: #40c4ff;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  /* faint grid texture */
  background-image:
    linear-gradient(rgba(0, 230, 118, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 230, 118, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
}

.hidden { display: none !important; }

/* Micro-label convention: uppercase, letterspaced, mono */
.micro {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  color: var(--faint);
}
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

code {
  font-family: var(--mono);
  background: var(--raised);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent-bright);
}

/* ===================== Buttons ===================== */
.btn {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--border-strong);
  background: var(--raised);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-bright); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04120a;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); color: #04120a; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.icon-only { padding: 9px 12px; }
.mini { padding: 5px 11px; font-size: 11px; border-radius: 4px; }

/* ===================== Login ===================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 24px 60px rgba(0,0,0,.6);
  overflow: hidden;
}
.login-head {
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
}
.login-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.login-body { padding: 26px 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  font-family: var(--mono);
  font-weight: 800;
  color: var(--accent);
  font-size: 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 4px 8px;
  box-shadow: 0 0 14px rgba(0,230,118,.25);
}
.brand-name { font-family: var(--mono); font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-name b { color: var(--accent); }
.brand-sub { font-family: var(--mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); }

input, select {
  font-family: var(--mono);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px rgba(0,230,118,.25); }
input::placeholder { color: var(--faint); }
.error { color: var(--danger); font-size: 13px; font-family: var(--mono); }

/* ===================== App shell ===================== */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* Status bar (top) */
.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  position: sticky; top: 0; z-index: 30;
}
.statusbar .live {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--accent); font-weight: 700; letter-spacing: .08em;
}
.statusbar .live .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.statusbar .spacer { flex: 1; }
.statusbar .sep { color: var(--border-strong); }

/* Body: sidebar + content */
.app-body { display: flex; flex: 1; }

.sidebar {
  width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
  position: sticky; top: 36px; height: calc(100vh - 36px);
}
.sidebar .brand { padding: 2px 10px 16px; }
.sidebar .section-label { padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid transparent;
  transition: .12s;
}
.nav-item .idx { color: var(--faint); font-size: 11px; width: 14px; }
.nav-item:hover { color: var(--text); background: var(--raised); }
.nav-item.active {
  color: var(--accent-bright);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Quota card (bottom of sidebar) */
.quota {
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  display: flex; flex-direction: column; gap: 10px;
}
.quota .row { display: flex; justify-content: space-between; align-items: center; }
.quota .val { font-family: var(--mono); color: var(--accent-bright); font-weight: 700; }
.badge-unlimited {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
  padding: 2px 9px; font-weight: 700;
}
.progress { height: 6px; background: var(--raised); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.sidebar-foot { display: flex; gap: 8px; padding-top: 10px; }

/* Content */
.content { flex: 1; padding: 22px 28px; min-width: 0; max-width: 1140px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.topbar h1 { font-family: var(--mono); font-size: 18px; letter-spacing: -.01em; margin: 0; flex: 1; }
.topbar h1::before { content: ">_ "; color: var(--accent); }
#menu-btn { display: none; }

.view-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 6px 0 16px; gap: 12px;
}
.view-head p { margin: 0; font-size: 13px; }

/* ===================== Stat cards ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0 26px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent);
  opacity: .7;
}
.stat-card .num { font-family: var(--mono); font-size: 28px; font-weight: 700; color: var(--accent-bright); }
.stat-card .lbl { margin-top: 5px; }

/* ===================== Tables ===================== */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); font-weight: 600; background: var(--bg-2);
}
tr:hover td { background: var(--raised); }
tr:last-child td { border-bottom: none; }
.empty { padding: 34px; text-align: center; color: var(--faint); font-family: var(--mono); }

.badge {
  display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-strong);
}
.badge-on { color: var(--accent); border-color: var(--accent); }
.badge-off { color: var(--danger); border-color: var(--danger); }
.badge-default { color: var(--info); border-color: var(--info); }
.status-2xx { color: var(--accent); }
.status-4xx, .status-5xx { color: var(--danger); }

.row-actions { display: flex; gap: 6px; }

/* Toggle */
.toggle {
  position: relative; width: 40px; height: 20px;
  background: var(--raised); border: 1px solid var(--border-strong);
  border-radius: 999px; cursor: pointer; display: inline-block;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--muted); transition: .15s;
}
.toggle.on { background: rgba(0,230,118,.2); border-color: var(--accent); }
.toggle.on::after { left: 22px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ===================== Modals ===================== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: 8px; width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 90vh; overflow-y: auto;
}
.modal-card > h3, .modal-card > p, .modal-card > label, .modal-card > input, .modal-card > select, .modal-card > .modal-actions, .modal-card > .key-result {
  margin-left: 22px; margin-right: 22px;
}
.modal-card > input, .modal-card > select { width: auto; }
.modal-card h3 {
  font-family: var(--mono); font-size: 15px; letter-spacing: -.01em;
  border-bottom: 1px solid var(--border);
  padding: 16px 0 13px;
  margin: 0 22px 0;
}
.modal-card h3::before { content: "// "; color: var(--accent); }
.modal-card label { margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin: 12px 22px 20px; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.checkbox input { width: auto; }

.key-result {
  background: var(--panel); border: 1px dashed var(--accent); border-radius: var(--radius);
  padding: 14px; font-family: var(--mono); font-size: 12.5px; word-break: break-all;
  display: flex; flex-direction: column; gap: 10px;
}
.copy-btn { align-self: flex-start; }

/* ===================== Usage analytics ===================== */
.usage-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
}
.usage-summary b { color: var(--accent-bright); }

.chart { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 20px 16px 14px; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 6px;
}
.chart-bar {
  width: 100%;
  max-width: 46px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  opacity: .85;
  box-shadow: 0 0 10px rgba(0, 230, 118, .22);
  transition: opacity .15s;
}
.chart-bar:hover { opacity: 1; }
.chart-bar-value { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.chart-bar-label { font-family: var(--mono); font-size: 10px; color: var(--faint); }

/* ===================== Sidebar backdrop (mobile) & combo entries ===================== */
.sidebar-backdrop { display: none; }

/* modal direct-child padding + model list */
.modal-pad { margin-left: 22px; margin-right: 22px; }

.model-entry {
  display: flex; gap: 8px; align-items: center; margin: 6px 0;
}
.model-entry input { flex: 1; min-width: 0; }
.model-entry .md-del { flex: 0 0 auto; color: var(--danger); }

/* ===================== Toast ===================== */
.toast {
  position: fixed; top: 56px; right: 20px; z-index: 100;
  background: var(--bg-2); border: 1px solid var(--accent);
  color: var(--text); font-family: var(--mono); font-size: 12.5px;
  padding: 12px 16px; border-radius: var(--radius);
  opacity: 0; transform: translateY(-8px); transition: .2s;
  pointer-events: none; max-width: 340px; line-height: 1.4;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* ===================== Recent requests (log list) ===================== */
.log-list { font-family: var(--mono); font-size: 12.5px; }
.log-row {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--faint); flex: 0 0 auto; min-width: 58px; }
.log-status { flex: 0 0 auto; width: 66px; }
.log-model { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-latency { flex: 0 0 auto; color: var(--muted); text-align: right; }
.log-empty { padding: 34px; text-align: center; color: var(--faint); font-family: var(--mono); }

/* ===================== Responsive ===================== */
@media (max-width: 720px) {
  .sidebar { position: fixed; left: -260px; top: 36px; z-index: 40; transition: .2s; }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    display: block;
    position: fixed; top: 36px; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 39;
  }
  #menu-btn { display: inline-block; }
  .content { padding: 14px; }
  .statusbar { font-size: 10px; gap: 10px; }
}