:root {
  --bg: #0f1115;
  --panel: #161a21;
  --panel2: #1c222b;
  --line: #2a3240;
  --text: #d7dde7;
  --muted: #8b97a8;
  --accent: #5aa9ff;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --warn: #ffc857;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

/* Фон панели — только на страницах после входа (login его не получает).
   Картинка прибита к окну, сверху затемнение, чтобы текст оставался
   читаемым, а панели не сливались с кадром. */
body.has-bg {
  background: #0a0c10 url("bg.webp") center top / cover no-repeat fixed;
}
body.has-bg::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(9, 11, 15, .68),
              rgba(9, 11, 15, .88) 55%, rgba(9, 11, 15, .95));
}
body.has-bg .card,
body.has-bg table.records,
body.has-bg .stat {
  background: rgba(20, 24, 31, .88);
  backdrop-filter: blur(3px);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 18px 60px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: rgba(15, 17, 21, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.top .spacer { flex: 1; }
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { border-radius: 5px; display: block; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav a {
  color: #c4cedd; background: #1a212b; border: 1px solid #303a4a;
  padding: 6px 12px; border-radius: 8px; font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { color: #fff; background: #243041; text-decoration: none; }
.nav a.active { color: #0e1622; background: var(--accent); border-color: var(--accent); font-weight: 600; }

h1 { font-size: 20px; margin: 16px 0 10px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.crumbs { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.foot { padding: 18px; text-align: center; border-top: 1px solid var(--line); margin-top: 40px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat b { font-size: 20px; }
.stat b.small { font-size: 13px; font-weight: 600; }

.filters .grid, .grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }

input, select, button, .button {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  min-height: 34px;
}
input:focus, select:focus, button:focus-visible, .button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button, .button { cursor: pointer; display: inline-block; text-align: center; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.ghost, .button.ghost { background: transparent; color: var(--muted); }
button.danger, .button.danger { color: var(--danger); border-color: #5a2a2e; background: #241417; }
button.tiny, .button.tiny { min-height: 26px; padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.button.off { pointer-events: none; opacity: .35; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }

/* Дашборд: плитки модулей. */
.modules {
  display: grid; gap: 12px; margin: 14px 0;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.module {
  background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.module h2 { margin: 0; font-size: 15px; }
.module .big { margin: 2px 0; font-size: 26px; font-weight: 700; }
.module .button { margin-top: auto; }
.m-steal { border-top-color: #ffd28a; }
.m-clip { border-top-color: #9ecbff; }
.m-keys { border-top-color: #d7b7ff; }
.m-conn { border-top-color: var(--ok); }
.m-workers { border-top-color: var(--accent); }
.inline { display: inline; }
.check { flex-direction: row; align-items: center; gap: 6px; color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; }
table.records { width: 100%; border-collapse: collapse; background: var(--panel); }
table.records th, table.records td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.records th { background: var(--panel2); font-size: 12px; color: var(--muted); position: sticky; top: 0; }
table.records th a { color: var(--muted); }
table.records tbody tr:hover td { background: #1a2029; }
table.records .empty { text-align: center; color: var(--muted); padding: 30px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.arrow { font-size: 9px; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  font-size: 11px; border: 1px solid var(--line); color: var(--muted);
}
.badge.warn { color: var(--warn); border-color: #5a4a1f; }
.badge.ok { color: var(--ok); border-color: #1f5a3d; }
.badge.user { color: var(--ok); border-color: #1f5a3d; }
.badge.t-clip { color: #9ecbff; border-color: #24486e; }
.badge.t-keys { color: #d7b7ff; border-color: #4a2f6e; }
.badge.t-steal { color: #ffd28a; border-color: #6e5324; }
.badge.t-tg { color: #8ae7d4; border-color: #1e5a50; }
.badge.st-alive { color: var(--ok); border-color: #1f5a3d; }
.badge.st-idle { color: var(--warn); border-color: #5a4a1f; }
.badge.st-stale { color: #ffb3b3; border-color: #5a2a2e; }
.badge.st-none { color: var(--muted); border-color: var(--line); }
.badge.r-owner { color: #ffd28a; border-color: #6e5324; }
.badge.r-worker { color: #9ecbff; border-color: #24486e; }
.badge.cat-exchange { color: #ffd28a; border-color: #7a5720; font-weight: 600; }
.badge.cat-wallet { color: #8affc1; border-color: #1f5a3d; }
.badge.cat-mail { color: #9ecbff; border-color: #24486e; }
.badge.cat-cloud { color: #cbb7ff; border-color: #412f6e; }
.badge.cat-social { color: #8ae7d4; border-color: #1e5a50; }
.badge.cat-other { color: var(--muted); border-color: var(--line); }
.ghost.mini { padding: 1px 6px; font-size: 11px; }
.tiny-input { width: auto; min-width: 8em; padding: 2px 4px; font-size: 12px; }
.seed-words { font-family: var(--mono, monospace); font-size: 13px; line-height: 1.6;
  word-spacing: 4px; background: #12161c; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; }
.mods { display: flex; gap: 6px; flex-wrap: wrap; }

.alert { background: #2a1a1c; border: 1px solid #5a2a2e; color: #ffb3b3; padding: 8px 10px; border-radius: 8px; }
.alert.soft { background: #1d222b; border-color: var(--line); color: var(--muted); }

pre.code {
  background: #0b0d11; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px; overflow: auto; max-height: 460px;
  font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap;
  word-break: break-word;
}

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; color: var(--muted); }

.login-wrap { display: flex; justify-content: center; padding: 10vh 0; }
.login { width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; }

.addr { width: 100%; border-collapse: collapse; }
.addr th, .addr td { padding: 7px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.addr th { color: var(--muted); font-size: 12px; }
.addr input { width: 100%; }

/* Меню разделов внутри карточки: липкое, с якорями. */
.sections {
  position: sticky; top: 54px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px; margin: 10px 0 4px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px;
}
.sections a {
  color: var(--muted); background: #10151c; border: 1px solid #263040;
  padding: 4px 9px; border-radius: 7px; font-size: 12px;
}
.sections a:hover { color: var(--text); border-color: #3a4a60; text-decoration: none; }
.sections .count { color: var(--accent); margin-left: 3px; }
h2[id], section[id] { scroll-margin-top: 100px; }

/* Графики дашборда: полосы и столбцы на CSS, без внешних библиотек. */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.stat { flex: 1 1 150px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 22px; font-weight: 700; }
.chart { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.chart-row { display: flex; align-items: center; gap: 10px; }
.chart-label { flex: 0 0 190px; color: var(--muted); font-size: 12.5px; }
.chart-track { flex: 1; height: 16px; background: #10151c; border: 1px solid var(--line);
  border-radius: 7px; overflow: hidden; }
.chart-fill { display: block; height: 100%; min-width: 2px; border-radius: 6px; }
.chart-val { flex: 0 0 48px; text-align: right; font-variant-numeric: tabular-nums; }
.f-auto { background: linear-gradient(90deg, #2f8f66, var(--ok)); }
.f-manual { background: linear-gradient(90deg, #3a6ea8, var(--accent)); }
.f-todo { background: linear-gradient(90deg, #9a7330, var(--warn)); }
.chart-days { flex-direction: row; align-items: flex-end; gap: 12px; height: 170px; padding-top: 6px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; height: 100%; gap: 4px; }
.chart-colbar { flex: 1; width: 100%; max-width: 54px; display: flex; align-items: flex-end;
  background: #10151c; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.chart-colbar .chart-fill { width: 100%; min-height: 2px; }
.chart-collabel { color: var(--muted); font-size: 11.5px; }
.chart-colval { font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .chart-label { flex-basis: 110px; } }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; width: 100%; }
  .sections { top: 96px; }
  .wrap { padding: 12px; }
}

/* --- иконки и план отработки --- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px; margin-right: 6px; color: var(--muted); }
h2 .ico { width: 20px; height: 20px; color: var(--accent); }
.steps { counter-reset: st; display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); }
.step .n { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid;
  place-items: center; font-size: 12px; background: #10151c; color: var(--muted);
  border: 1px solid var(--line); }
.step.done { border-color: #2f6b4c; }
.step.done .n { background: #143524; color: var(--ok); border-color: #2f6b4c; }
.step.cur { border-color: #6b5a2f; }
.step.cur .n { background: #352f14; color: var(--warn); border-color: #6b5a2f; }
.step b { font-weight: 600; }
.step .hint { color: var(--muted); font-size: 12px; }
.step a { margin-left: auto; font-size: 12px; }
