:root {
  --bg: #0b0d10;
  --panel: #12161c;
  --panel-2: #171c24;
  --line: #232a35;
  --text: #e8edf3;
  --muted: #8b97a8;
  --accent: #4ade80;
  --accent-dim: #14361f;
  --danger: #f87171;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16202b 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }

/* ---------- LOGIN ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.login-card h1 { font-size: 20px; margin: 12px 0 0; letter-spacing: -.01em; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 8px; text-transform: uppercase; letter-spacing: .08em; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
#apikey { font-family: var(--mono); font-size: 13px; }
.remember { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted); }
.remember input { width: 15px; height: 15px; accent-color: var(--accent); }
.primary {
  background: var(--accent);
  color: #05230f;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.primary:disabled { opacity: .55; cursor: default; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ghost:hover { border-color: #35404f; background: var(--panel-2); }
.ghost.danger { color: var(--danger); }
.ghost:disabled { opacity: .4; cursor: default; }
.link-btn {
  background: none; border: 0; color: var(--muted);
  font-size: 12.5px; cursor: pointer; padding: 4px 0; text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; font-size: 15px; }
.brand-sub { color: var(--muted); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }

/* ---------- DASH ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,13,16,.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.key-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 24px 60px; display: flex; flex-direction: column; gap: 16px; }

.keybanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px dashed #2c4a37;
  background: #101a14;
  border-radius: 12px;
  padding: 12px 16px;
}
.keybanner-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-right: 10px; }
.keybanner strong { font-family: var(--mono); font-size: 13.5px; color: var(--accent); font-weight: 600; }
.keybanner p { margin: 0; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.status { font-size: 12.5px; color: var(--muted); }
.status.err { color: var(--danger); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card.accent { border-color: #255c36; background: linear-gradient(180deg, #16331f, #12241a); }
.card-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.card-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card-sub { font-size: 12px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.panel-actions { display: flex; gap: 8px; align-items: center; }
.panel-actions input { min-width: 230px; padding: 7px 11px; font-size: 13px; }

/* bar chart */
.chart { height: 190px; padding-top: 8px; }
.chart > div.bar-stack { display: flex; align-items: flex-end; gap: 3px; width: 100%; height: 100%; }
section[hidden], div[hidden] { display: none !important; }
.bar-col { flex: 1 1 0; min-width: 4px; height: 100%; display: flex; align-items: flex-end; position: relative; }
.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), #1f7a45);
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: filter .12s;
}
.bar-col:hover .bar { filter: brightness(1.25); }
.bar-col .tip {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #05070a;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  z-index: 2;
}
.bar-col:hover .tip { opacity: 1; }
.chart-axis { display: flex; gap: 3px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.chart-axis span { flex: 1 1 0; min-width: 4px; text-align: center; overflow: hidden; white-space: nowrap; }

/* models */
.models { display: flex; flex-direction: column; gap: 14px; }
.model-row { display: flex; flex-direction: column; gap: 6px; }
.model-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.model-name { font-family: var(--mono); font-size: 12.5px; }
.model-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.model-bar { height: 7px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.model-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #2b9c5b); border-radius: 99px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* plans */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.plan {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-model { font-family: var(--mono); font-size: 13px; }
.plan-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); border: 1px solid #255c36; border-radius: 99px; padding: 2px 8px; }
.plan-nums { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-nums b { color: var(--text); font-weight: 600; }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid #1b212a; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #151b23; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
td.mono { font-family: var(--mono); font-size: 12px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--accent); border-color: #255c36; background: var(--accent-dim); }
.pill.fail { color: var(--danger); border-color: #5c2525; background: #331616; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .wrap { padding: 16px 14px 48px; }
  .topbar { padding: 12px 14px; }
  .key-chip { display: none; }
  .card-value { font-size: 21px; }
  .panel-actions input { min-width: 0; width: 100%; }
}
