:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6ea; --text: #1d2228; --muted: #6a737d; --accent: #2f6fdd;
  --ok: #1f8f3a; --err: #cf222e; --warn: #b7791f; --off: #9aa3ad; --manual: #6f7fa3; --chip: #eef1f4;
  --red-bg: #fdecee; --yellow-bg: #fdf5e3; --grey-bg: #eef0f2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --line: #2a3038; --text: #e6e9ed; --muted: #8b949e; --accent: #5b9bff;
    --ok: #3fb950; --err: #f85149; --warn: #d29922; --off: #6e7681; --manual: #8a98bd; --chip: #222831;
    --red-bg: #3a1d20; --yellow-bg: #362a14; --grey-bg: #22272e;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --line: #2a3038; --text: #e6e9ed; --muted: #8b949e; --accent: #5b9bff;
  --ok: #3fb950; --err: #f85149; --warn: #d29922; --off: #6e7681; --manual: #8a98bd; --chip: #222831;
  --red-bg: #3a1d20; --yellow-bg: #362a14; --grey-bg: #22272e;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.err { color: var(--err); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 100%; max-width: 340px; display: grid; gap: 10px; }
.login h1 { margin: 0 0 6px; font-size: 20px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.login button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.sm { padding: 3px 9px; font-size: 12px; }

header { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
nav button { background: none; border: 0; padding: 7px 10px; border-radius: 8px; white-space: nowrap; color: var(--muted); }
nav button.on { background: var(--chip); color: var(--text); font-weight: 600; }
.cnt { font-size: 11px; background: var(--chip); border-radius: 9px; padding: 0 6px; margin-left: 2px; }
.cnt.red:not(:empty) { background: var(--err); color: #fff; }
.age { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stale { background: var(--red-bg); color: var(--err); padding: 6px 16px; font-weight: 600; text-align: center; }
.alerts { display: flex; gap: 6px; flex-wrap: wrap; }
.alerts:not(:empty) { margin-bottom: 12px; }
nav { scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
.alert { border-radius: 8px; padding: 4px 9px; font-size: 12px; cursor: pointer; border: 0; text-align: left; max-width: min(100%, 520px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert.red { background: var(--red-bg); }
.alert.yellow { background: var(--yellow-bg); }
.alert.grey { background: var(--grey-bg); }
.alert b { margin-right: 4px; }

main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 60px; }
.bar { display: grid; gap: 8px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--chip); border: 1px solid transparent; border-radius: 16px; padding: 3px 10px; font-size: 12px; }
.chip.on { border-color: var(--accent); color: var(--accent); }

.group-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.proj { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.proj-h { display: flex; gap: 8px; align-items: center; padding: 10px 12px; flex-wrap: wrap; }
.proj-h h3 { margin: 0; font-size: 15px; flex: 1; min-width: 180px; }
.proj-chats { padding: 0 12px 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat { font-size: 12px; background: var(--chip); border-radius: 6px; padding: 2px 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat.pc-only::after { content: " · на ПК"; color: var(--muted); }
.task { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); align-items: start; }
.task .dot { margin-top: 5px; }
.task .t { font-weight: 500; }
.task .d { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
.task .meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.task .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.badge { font-size: 11px; border-radius: 6px; padding: 0 6px; background: var(--chip); }
.badge.owner { background: var(--yellow-bg); }
.badge.external { background: var(--grey-bg); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.p1 { background: var(--err); } .p2 { background: var(--warn); } .p3 { background: var(--off); }
.doneList summary { padding: 6px 12px; font-size: 12px; color: var(--muted); cursor: pointer; border-top: 1px solid var(--line); }
.unlinked { margin-top: 16px; }
.unlinked summary { cursor: pointer; color: var(--muted); }
.unlinked .row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.procs { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.proc { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); cursor: pointer; align-items: start; }
.proc:first-child { border-top: 0; }
.proc:hover { background: var(--chip); }
.proc .dot { margin-top: 5px; }
.proc .name { font-weight: 500; }
.proc .st { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.proc .st.e { color: var(--err); }
.proc .st.w { color: var(--warn); }
.proc .right { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.proc .mets { font-size: 12px; margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.proc .mets b { font-variant-numeric: tabular-nums; }
.s-ok { background: var(--ok); } .s-error { background: var(--err); } .s-silent { background: var(--warn); }
.s-off, .s-pc_offline, .s-nodata { background: var(--off); } .s-manual { background: var(--manual); }
.s-cloud { background: transparent; border: 2px solid var(--manual); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.meter { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.meter > i { display: block; height: 100%; background: var(--ok); }
.meter > i.w { background: var(--warn); } .meter > i.e { background: var(--err); }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 2px 0; }
.kv span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.hints { margin: 0 0 12px; padding-left: 18px; }
.hints li { margin: 3px 0; }
.issue { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 6px; }
.issue .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 22px; color: var(--muted); }
dialog h2 { margin: 0 24px 4px 0; font-size: 17px; }
pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 11.5px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
svg.spark { width: 100%; height: 36px; display: block; }
svg.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.formrow { display: grid; gap: 6px; margin: 8px 0; }
.formrow.two { grid-template-columns: 1fr 1fr; }

@media (max-width: 640px) {
  .top { gap: 8px; padding: 6px 12px; }
  main { padding: 10px 12px 60px; }
  .task { grid-template-columns: 12px 1fr; }
  .task .acts { grid-column: 2; justify-content: flex-start; }
  .proc { grid-template-columns: 12px minmax(0, 1fr); }
  .proc .right { grid-column: 2; text-align: left; }
}
