:root {
  --bg: #080b12;
  --surface: #0f1420;
  --surface-2: #151c2c;
  --line: #1f2940;
  --text: #e8edf7;
  --muted: #8a95ad;
  --accent: #2f7bff;
  --accent-2: #5aa0ff;
  --accent-soft: rgba(47, 123, 255, .14);
  --ok: #2fd48a;
  --warn: #ffb547;
  --bad: #ff5468;
  --radius: 14px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(47,123,255,.12), transparent 60%),
    var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .3px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; font-weight: 900; color: #fff; box-shadow: 0 6px 20px rgba(47,123,255,.35); }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.login-card h1 { font-size: 20px; margin: 22px 0 16px; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: rgba(8,11,18,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); white-space: nowrap; }
.pill b { color: var(--text); }
.pill.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-2); }
main { max-width: 980px; margin: 0 auto; padding: 18px 16px 110px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: center; gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: rgba(15,20,32,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabs a { flex: 1; max-width: 160px; text-align: center; padding: 8px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600; }
.tabs a .ico { display: block; font-size: 18px; line-height: 1.2; }
.tabs a.on { color: var(--text); background: var(--accent-soft); }
.tabs a.on .ico { color: var(--accent-2); }
@media (min-width: 820px) {
  .tabs { position: static; justify-content: flex-start; background: transparent; border: 0; padding: 0; max-width: 980px; margin: 14px auto 0; padding: 0 16px; }
  .tabs a { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 8px 14px; font-size: 14px; }
  .tabs a .ico { display: inline; font-size: 15px; }
  main { padding-bottom: 40px; }
}

h2 { font-size: 20px; margin: 4px 0 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.input, select.input, textarea.input { width: 100%; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 70px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #2c3a58; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2569e0; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 21px; }

/* ---------- liste ---------- */
.list { display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.click { cursor: pointer; transition: border-color .15s, transform .1s; }
.card.click:hover { border-color: #2c3a58; }
.card.click:active { transform: scale(.995); }
.code-big { font-family: var(--mono); font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.badge.ok { background: rgba(47,212,138,.12); color: var(--ok); }
.badge.off { background: rgba(255,84,104,.12); color: var(--bad); }
.badge.blue { background: var(--accent-soft); color: var(--accent-2); }
.badge.grey { background: var(--surface-2); color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.delta-plus { color: var(--ok); font-weight: 700; }
.delta-minus { color: var(--bad); font-weight: 700; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(3,5,10,.7); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.pl { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--bg); }
.pl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pl-grid .full { grid-column: 1 / -1; }
.pl-grid label.f { margin: 0; }
.check-res { font-size: 13px; margin-top: 8px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.dev { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.dev:last-child { border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 100; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
.toast.err { border-color: var(--bad); color: #ffd0d6; }
.toast.ok { border-color: var(--ok); }
