:root {
  --bg: #0f1311; --surface: #161c19; --panel: #1d2521; --line: #2a3530;
  --ink: #f4f2eb; --muted: #a9b7ad; --accent: #90f6ca; --accent-ink: #062016;
  --good: #69e3a5; --warn: #f5c76b; --bad: #ff8a80; --info: #8fc7ff;
  --radius: 16px; --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.wrap { word-break: break-all; display: block; margin-top: 6px; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 14px; }
input, select { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); width: 100%; margin-top: 6px; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.danger { background: #3a2424; color: var(--bad); border: 1px solid #5a3030; }
.link { background: none; color: var(--muted); padding: 8px 0; margin-top: 8px; font-weight: 500; }
.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.alert.error { background: #3a2424; color: #ffd2cc; }
.alert.ok { background: #1c3328; color: #c9f5de; }
.secret { font: 700 20px ui-monospace, Menlo, monospace; letter-spacing: .08em; background: var(--panel); border-radius: 12px; padding: 16px; text-align: center; margin-bottom: 8px; word-spacing: .4em; }
.codes { columns: 2; font: 600 16px ui-monospace, Menlo, monospace; background: var(--panel); border-radius: 12px; padding: 16px 16px 16px 40px; margin: 0 0 16px; }
.codes li { padding: 3px 0; }

/* ---------- app shell ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: 4px; }
.side nav a { color: var(--ink); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.side nav a:hover { background: var(--panel); }
.side nav a.active { background: var(--panel); color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 10px; font-size: 13px; }
.content { padding: 24px 32px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0; flex: 1; }
.menu { display: none; }
.status { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--panel); white-space: nowrap; }
.status.on::before, .status.off::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.status.on::before { background: var(--good); box-shadow: 0 0 0 4px #69e3a522; }
.status.off { color: var(--bad); }
.status.off::before { background: var(--bad); }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.banner { padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; }
.banner.bad { background: #3a2424; color: #ffd2cc; }
.banner.warn { background: #3a3220; color: #ffe8b5; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--panel); border-radius: 12px; padding: 4px; }
.seg button { background: none; color: var(--muted); padding: 7px 14px; border-radius: 9px; font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.live { background: #1c3328; color: var(--good); }
.pill.down, .pill.invalid_key { background: #3a2424; color: var(--bad); }
.pill.out_of_credit, .pill.rate_limited { background: #3a3220; color: var(--warn); }
.pill.not_configured, .pill.unknown, .pill.off { background: var(--panel); color: var(--muted); }

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.toggle { position: relative; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; transition: .15s; }
.toggle span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); transition: .15s; }
.toggle input:checked + span { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + span::after { transform: translateX(20px); background: var(--accent-ink); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row label { flex: 1; min-width: 140px; margin: 0; }
.row button { flex: none; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel); border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; max-width: 360px; z-index: 10; }
.toast.bad { border-color: #5a3030; color: #ffd2cc; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 5; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax #0009; }
  .menu { display: inline-flex; padding: 8px 12px; }
  .content { padding: 16px; }
  .two { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.mt { margin-top: 16px; }
.mt-s { margin-top: 12px; }
.banner.good { background: #1c3328; color: #c9f5de; }
.switch.block { display: block; }
input.price { max-width: 120px; margin-left: auto; text-align: right; }
.c0 { background: #90f6ca; } .c1 { background: #8fc7ff; } .c2 { background: #f5c76b; }
.c3 { background: #ff8a80; } .c4 { background: #c7a6ff; } .c5 { background: #69e3a5; }
.c6 { background: #ffb38a; } .c7 { background: #7ee0e6; } .c8 { background: #e6e07e; }
