:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #1b1d1f;
  --muted: #6b6f74;
  --line: #e2e0d9;
  --accent: #2b6cb0;
  --accent-ink: #ffffff;
  --good: #2f855a;
  --good-bg: #e6f4ec;
  --warn: #b7791f;
  --bad: #c53030;
  --bad-bg: #fdecec;
  --chip: #eef3fa;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416; --panel: #1c1e21; --ink: #e9e8e4; --muted: #9a9ea3; --line: #2d3034;
    --accent: #5a9be0; --accent-ink: #0d0f11; --good: #6fcf97; --good-bg: #17291f;
    --bad: #f08a8a; --bad-bg: #2e1919; --chip: #22303f; --warn: #e0b45a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.acct { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }
.dot.on { background: var(--good); }

nav { display: flex; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
nav button {
  border: 0; background: none; padding: 12px 12px 11px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav button.active { color: var(--ink); border-bottom-color: var(--accent); }
nav .badge { background: var(--chip); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
section { display: none; }
section.active { display: block; }
h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0 0 18px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 180px; }

input[type=text], input[type=password], input[type=tel], input[type=search], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 260px; font-family: var(--mono); font-size: 13.5px; resize: vertical; }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.btn {
  border: 1px solid var(--line); background: var(--panel); padding: 9px 16px; border-radius: 8px; cursor: pointer;
  text-decoration: none; color: var(--ink); display: inline-block;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }

.msg { padding: 10px 12px; border-radius: 8px; margin-top: 12px; display: none; }
.msg.err { display: block; background: var(--bad-bg); color: var(--bad); }
.msg.ok { display: block; background: var(--good-bg); color: var(--good); }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

/* группы */
.glist { display: flex; flex-direction: column; }
.g { display: flex; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.g:last-child { border-bottom: 0; }
.g input { width: 18px; height: 18px; accent-color: var(--accent); }
.g .t { flex: 1; }
.g .m { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* прогресс */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.state { font-weight: 600; }
.state.run { color: var(--accent); }
.log { font-family: var(--mono); font-size: 12.5px; max-height: 320px; overflow: auto; }
.log div { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.log time { color: var(--muted); margin-right: 8px; }

/* лиды */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.who { white-space: nowrap; }
td.who a { font-weight: 600; text-decoration: none; }
td.who small { display: block; color: var(--muted); }
.chip { display: inline-block; background: var(--chip); border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 0 4px 4px 0; }
td.grp { color: var(--muted); font-size: 13px; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
@media (max-width: 720px) {
  thead { display: none; }
  tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { display: block; border: 0; padding: 3px 0; }
}

/* вход */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }

[hidden] { display: none !important; }

.btn.sm { padding: 5px 12px; font-size: 13px; }
.g small.gs { display: block; color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 8px 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--chip); color: var(--ink); font-weight: 600; }

.period { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 2px; }
select { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
