:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --accent-soft: #dbe5ff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --ok-soft: #dcfce7;
  --bad-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --bar: #e5e7eb;
  --term: #0f1115;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #6d95ff;
    --accent-soft: #1d2a4d;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --ok-soft: #12301f;
    --bad-soft: #3a1717;
    --warn-soft: #3a2c0c;
    --bar: #2a2f38;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.brand img { width: 24px; height: 24px; }

.pill { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--bar); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.section { margin-top: 18px; }
.section > h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 13px; }
.spark { width: 100%; height: 36px; display: block; margin-top: 6px; }
.spark path.l { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark path.a { fill: var(--accent-soft); }

.bar { height: 6px; border-radius: 3px; background: var(--bar); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.metrics .sub { font-variant-numeric: tabular-nums; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 550; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger.fill { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn.bad { color: var(--bad); }
.icon-btn.ok { color: var(--ok); }

.banner { margin: 12px 16px 0; padding: 12px 14px; border-radius: 12px; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .btn { margin-top: 8px; }
.problems { margin: 6px 0 0; padding-left: 18px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  background: none; border: 0; padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 12px;
}
.tabs svg { width: 22px; height: 22px; fill: currentColor; }
.tabs button.on { color: var(--accent); }

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 96px; }
  .tabs { top: 0; right: auto; width: 96px; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding-top: 64px; border-top: 0; border-right: 1px solid var(--line); }
}

.login { max-width: 360px; margin: 12vh auto 0; }
.login input {
  width: 100%; padding: 12px; font: inherit; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); margin: 8px 0 12px;
}
.err { color: var(--bad); min-height: 1.4em; font-size: 14px; }

.term-wrap { background: var(--term); border-radius: 14px; padding: 8px; height: calc(100dvh - 230px); min-height: 280px; }
@media (min-width: 900px) { .term-wrap { height: calc(100dvh - 150px); } }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; }
.keys button { flex: none; min-width: 48px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-family: ui-monospace, monospace; }
.keys button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.link-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.link-card .grow { flex: 1; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bar); color: var(--muted); white-space: nowrap; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); max-width: 360px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: calc(100% - 32px);
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }

/* ключ восстановления */
.rkey { font: 600 17px/1.5 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; padding: 12px; margin: 10px 0; border: 1px dashed var(--line); border-radius: 12px; text-align: center; word-break: break-all; user-select: all; }
dialog input { width: 100%; box-sizing: border-box; margin: 4px 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 15px; }
.login input + input { margin-top: 8px; }

/* поля паролей, которые браузер не сохраняет (текст скрыт точками) */
.secret { -webkit-text-security: disc; }
.login input[type=checkbox] { width: auto; margin: 0; padding: 0; }
