:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-2: #1d4ed8; --ok: #16a34a; --bad: #dc2626; --warn: #d97706; --idle: #94a3b8;
  --chip: #eef2ff; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #1f2a40;
    --accent: #3b82f6; --accent-2: #60a5fa; --chip: #1c2742; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.msg { min-height: 1.2em; margin: 6px 0 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); text-align: center; padding: 28px 22px; }
.login-card .logo { width: 64px; height: 64px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; }
.login-card input { margin-top: 18px; text-align: center; font-size: 20px; letter-spacing: 4px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; }
.summary { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); }
.icon-btn { border: 1px solid var(--line); background: var(--card); color: var(--text); width: 36px; height: 36px;
  border-radius: 10px; font-size: 18px; cursor: pointer; flex: none; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px calc(90px + env(safe-area-inset-bottom)); }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.banner { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card input + input, .card input + button, .card input + .btn { margin-top: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }

.proj-head { display: flex; align-items: flex-start; gap: 10px; }
.proj-icon { font-size: 26px; line-height: 1; }
.proj-title { font-weight: 700; font-size: 16px; }
.proj-kind { color: var(--muted); font-size: 13px; }
.badge { margin-left: auto; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.b-work { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.b-partial, .b-moving { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.b-paused, .b-local { background: var(--chip); color: var(--muted); }
.b-down { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.about { margin: 10px 0; font-size: 14px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.lnk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 9px; border-radius: 8px;
  background: var(--chip); color: var(--text); border: 1px solid transparent; }
.lnk:hover { border-color: var(--accent); text-decoration: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.ms { color: var(--muted); font-size: 11.5px; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 10px 0 0; font-size: 13px; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.todo { margin-top: 10px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 12%, transparent); }
details.more summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 8px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }

.h2 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.infra { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.infra .card { padding: 12px 14px; font-size: 13.5px; }
.infra b { display: block; margin-bottom: 4px; font-size: 14.5px; }

/* задачи */
.task-new textarea { resize: vertical; }
.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.row select { flex: 1 1 140px; width: auto; }
.row .btn { flex: 0 0 auto; }
#taskFilters { margin: 14px 0 10px; }
.tasks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; gap: 10px; align-items: flex-start; }
.task input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--ok); }
.task .t-body { flex: 1; min-width: 0; }
.task .t-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.task.done .t-text { text-decoration: line-through; color: var(--muted); }
.task .t-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.prio-high { color: var(--bad); font-weight: 600; }
.del { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.del:hover { color: var(--bad); }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 10px; }
.row .btn.primary { width: auto; margin-top: 0; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--bad); border: 1px solid var(--line); width: 100%; margin-top: 12px; }
#tab-settings .card { margin-bottom: 12px; }

/* нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; gap: 4px;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 160px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 10px; cursor: pointer; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--accent); background: var(--chip); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }
.infra .role { margin-top: 4px; }
.dot.off { background: var(--idle); outline: 2px solid var(--warn); }
.sw-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.sw-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sw-host { flex: 1; overflow-wrap: anywhere; }
.sw-btn { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer; background: var(--card); color: var(--text); }
.sw-btn.offb { color: var(--bad); }
.sw-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.sw-btn[data-armed] { background: var(--bad); border-color: var(--bad); color: #fff; }
.visits { font-size: 13px; margin: 6px 0 0; color: var(--muted); } .visits b { color: var(--text); }
.lk-btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 3px 7px; cursor: pointer; font-size: 14px; }
.lk-form { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px 16px; }
.lk-form input { flex: 1 1 160px; width: auto; padding: 6px 10px; font-size: 13px; }
