:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #131a2b;
  --text-2: #3c455e;
  --muted: #5d6a85;
  --border: #e2e6f0;
  --baseline: #c3c2b7;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --accent-soft: #eaf0ff;
  --series-1: #2f6fed;
  --series-2: #eb6834;
  --series-neg: #e34948;
  /* Fleet charts (admin_monitoring.html, one line per node): deliberately
     distinct from --series-, --ok, --warn, --err so a node's line is never
     mistaken for a status color. Colorblind-safe (Okabe-Ito-derived);
     see monitoring.py's FLEET_DASH_PATTERNS -- line style (solid/dash/
     dot/dash-dot), not just hue, is what actually disambiguates once a
     fleet has more than 4 nodes. */
  --fleet-1: #0072b2;
  --fleet-2: #d55e00;
  --fleet-3: #009e73;
  --fleet-4: #cc79a7;
  --ok: #1f8a5a;
  --ok-bg: #e3f5ec;
  --warn: #8a5a12;
  --warn-bg: #faf0e0;
  --err: #c43f37;
  --err-bg: #fbe9e7;
  --tooltip-bg: #131a2b;
  --tooltip-text: #ffffff;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(28, 47, 106, 0.08);
}

/* Дизайн-система вариант 6 (утверждено владельцем 2026-09-20, стилизация
   только) — тёмная тема системная по умолчанию, ручной выбор запоминается
   в localStorage (см. static/theme.js), источник истины — data-theme на
   <html>, проставляется блокирующим inline-скриптом в base.html до
   первой отрисовки. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #16213688;
    --text: #eef2fb;
    --text-2: #b7c0da;
    --muted: #8b96b3;
    --border: #232f47;
    --baseline: #383835;
    --accent: #6d9bff;
    --accent-contrast: #0b1a3a;
    --accent-soft: #16233f;
    --series-1: #6d9bff;
    --series-2: #d95926;
    --series-neg: #e28579;
    --fleet-1: #5bb3f0;
    --fleet-2: #ff9a52;
    --fleet-3: #4fd9a8;
    --fleet-4: #e8a0c8;
    --ok: #5fd39c;
    --ok-bg: #12281f;
    --warn: #e0ac52;
    --warn-bg: #2a2010;
    --err: #e28579;
    --err-bg: #2c1614;
    --tooltip-bg: #eef2fb;
    --tooltip-text: #0b1220;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #16213688;
  --text: #eef2fb;
  --text-2: #b7c0da;
  --muted: #8b96b3;
  --border: #232f47;
  --baseline: #383835;
  --accent: #6d9bff;
  --accent-contrast: #0b1a3a;
  --accent-soft: #16233f;
  --series-1: #6d9bff;
  --series-2: #d95926;
  --series-neg: #e28579;
  --fleet-1: #5bb3f0;
  --fleet-2: #ff9a52;
  --fleet-3: #4fd9a8;
  --fleet-4: #e8a0c8;
  --ok: #5fd39c;
  --ok-bg: #12281f;
  --warn: #e0ac52;
  --warn-bg: #2a2010;
  --err: #e28579;
  --err-bg: #2c1614;
  --tooltip-bg: #eef2fb;
  --tooltip-text: #0b1220;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}
.theme-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.theme-toggle-icon {
  font-size: 14px;
}
.theme-toggle-label {
  white-space: nowrap;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 48px;
}

.page-narrow {
  max-width: 420px;
}

.page-wide {
  max-width: 1200px;
}

/* Login screen only (no app shell/nav yet — not an authenticated session) */
.page-narrow {
  padding: 20px 16px 48px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

header.top h1 {
  font-size: 20px;
  margin: 0;
}

/* ---- app shell: top strip (desktop tabs) + bottom nav (mobile) ---- */

.topstrip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  flex: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--ok));
  flex: none;
}

.app-topnav {
  display: none;
  gap: 4px;
  margin-left: 12px;
  flex-wrap: wrap;
}

.app-topnav a {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
}

.app-topnav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  font-size: 15px;
}

.avatar-round {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  flex: none;
  text-decoration: none;
}

/* Notification bell (app shell, base.html): a native <details>/<summary>
   so open/close + keyboard activation need no hand-rolled JS (see
   static/notifications.js for the two things <details> doesn't do on its
   own: close on outside click, close on Escape). Quiet icon with no count
   when there is nothing to report; a small badge only appears once
   `notifications.count` is actually > 0 -- never a badge showing "0". */
.notif-menu {
  position: relative;
}
.notif-menu > summary {
  list-style: none;
  cursor: pointer;
}
.notif-menu > summary::-webkit-details-marker,
.notif-menu > summary::marker {
  display: none;
  content: "";
}
.notif-bell {
  position: relative;
  font-size: 16px;
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--err);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 30;
}
.notif-panel-title {
  margin: 0 0 10px;
  font-size: 13.5px;
  font-weight: 700;
}
.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.notif-item {
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 2px;
  color: var(--text);
  text-decoration: none;
}
.notif-item a:hover,
.notif-item a:focus-visible {
  color: var(--accent);
}
.notif-item .status-dot {
  margin-top: 4px;
}
.notif-text {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}
.notif-age {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.notif-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

main#main {
  padding: 20px clamp(16px, 3vw, 32px) 96px;
  max-width: 1200px;
  margin: 0 auto;
}

.app-bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

.app-bottomnav a {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  text-decoration: none;
}

.app-bottomnav a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.app-bottomnav a[aria-current="page"] {
  color: var(--accent);
}

@media (min-width: 760px) {
  .app-bottomnav {
    display: none;
  }
  .app-topnav {
    display: flex;
  }
  main#main {
    padding: 28px clamp(16px, 3vw, 36px) 60px;
  }
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 13px;
  color: var(--muted);
}

.form-row input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#create-plan-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#create-plan-form input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  flex: 1 1 100px;
  min-width: 0;
}

.subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.subtabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.subtabs a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.subtabs a .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.badge.err {
  color: var(--err);
  background: var(--err-bg);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

.url-row input {
  flex: 1 1 240px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

button, .btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--accent);
}

button:active, .btn:active {
  transform: translateY(1px);
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.qr-wrap img {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

ul.config-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.config-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

ul.config-list li:last-child {
  border-bottom: none;
}

.protocol-tag {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

details.platform summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
}

details.platform p {
  margin: 4px 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.alert {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert.err {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid #f3c8c4;
}

.alert.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #f0dca4;
}

footer.page-footer {
  margin-top: 24px;
  text-align: center;
}

#copy-feedback {
  font-size: 13px;
  color: var(--ok);
  min-height: 18px;
  margin-top: 6px;
}

@media (max-width: 420px) {
  .url-row {
    flex-direction: column;
  }
  .url-row button {
    width: 100%;
  }
}
