/* Сайт УРВ в стиле Plais: те же цвета, шрифт и скругления. Боковое меню слева, рабочая область справа. */
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("/fonts/golos-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("/fonts/golos-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
:root {
  --bg: #e7e9f0;
  --panel: #fff;
  --panel-2: #f8f9fc;
  --fg: #1f2024;
  --muted: #6b6f76;
  --line: #1012161a;
  --line-strong: #10121629;
  --accent: #c24e29;
  --accent-hover: #ac451f;
  --accent-on: #fff;
  --accent-soft: #fcebe3;
  --accent-text: #b8461f;
  --hover: #1f20240f;
  --ok: #178657;
  --bad: #b83a3a;
  --warn: #9c6518;
  --chip-on: #1f2024;
  --chip-on-fg: #e7e9f0;
  --shadow: 0 1px 2px #1012160f, 0 1px 3px #1012160a;
  --shadow-up: 0 0 0 1px #1012160f, 0 16px 48px #10121633, 0 4px 12px #1012161f;
  --r-card: 16px;
  --r-ctl: 10px;
  --font: "Golos Text", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161719; --panel: #24262a; --panel-2: #1d1f22; --fg: #ececee; --muted: #9aa0a8;
    --line: #ffffff1a; --line-strong: #ffffff24;
    --accent: #e8754d; --accent-hover: #ef8a63; --accent-on: #1a120e; --accent-soft: #3a2820; --accent-text: #f0a585;
    --hover: #ffffff0f; --ok: #57c79a; --bad: #e07a7a; --warn: #d6a24e;
    --chip-on: #ececee; --chip-on-fg: #161719;
    --shadow: 0 0 0 1px #ffffff0a, 0 1px 2px #0006; --shadow-up: 0 0 0 1px #ffffff14, 0 18px 52px #000000b3, 0 6px 16px #00000080;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); }
[hidden] { display: none !important; }
a { color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* каркас */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100%; }
.rail { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px 12px; background: var(--panel-2); border-right: 1px solid var(--line); min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; padding: 0 4px; line-height: 1.2; }
.brand-mark { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-ctl); background: var(--accent); color: var(--accent-on); }
.rail-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs button { display: flex; align-items: center; gap: 10px; width: 100%; font: 500 14px var(--font); border: 0; background: transparent; color: var(--fg); padding: 8px 10px; border-radius: var(--r-ctl); cursor: pointer; text-align: left; }
.tabs button svg { flex: none; color: var(--muted); }
.tabs button:hover { background: var(--hover); }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
.tabs button[aria-selected="true"] svg { color: var(--accent-text); }
.me { margin-top: auto; padding: 10px 6px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.me b { color: var(--fg); font-weight: 600; }
.me-links { display: flex; gap: 12px; flex-wrap: wrap; }
.ver { font-size: 11px; color: var(--muted); }
.col { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow-y: auto; }
.top { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 12px 20px; background: var(--panel-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h1 { margin: 0; font-size: 18px; font-weight: 600; }
#clock { display: inline-flex; flex-direction: column; line-height: 1.2; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#clock-time { font-size: 14px; font-weight: 600; color: var(--fg); }
.counters { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.counters span { padding: 4px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.counters b { color: var(--fg); font-weight: 600; }
.counters .bad b { color: var(--bad); }
@media (max-width: 900px) {
  .app { display: block; height: auto; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); gap: 10px; padding: 12px; }
  .tabs { flex-direction: row; flex-wrap: wrap; }
  .tabs button { width: auto; }
  .rail-label { display: none; }
  .me { margin-top: 0; }
  .col { overflow: visible; }
  .top { position: static; padding: 10px 16px; }
}

/* карта */
.map-view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px 20px; min-height: 0; }
@media (max-width: 1100px) {
  .map-view { grid-template-columns: 1fr; flex: none; }
  #plan { min-height: 55vh; }
  .side { overflow: visible; }
}
.plan-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#plan { width: 100%; flex: 1; min-height: 300px; display: block; }
.plan-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 8px 4px 0; }
#cursor { font-family: var(--mono); }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lg-gw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.lg-gw.on { background: var(--ok); } .lg-gw.off { background: var(--bad); }
.lg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--fg); margin-left: 8px; }

/* SVG */
.zone { stroke-width: calc(2px * var(--k, 1)); cursor: default; transition: fill-opacity .3s; }
.zone-label { font: 600 calc(15px * var(--k, 1)) var(--font); paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: calc(4px * var(--k, 1)); }
.zone-count { font: 700 calc(22px * var(--k, 1)) var(--font); paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: calc(4px * var(--k, 1)); }
#plan.editing { touch-action: none; }
#plan.editing #people, #plan.editing #gws, #plan.editing #ranges { pointer-events: none; opacity: .35; }
#plan.editing .zone { cursor: pointer; }
.ze-v { fill: #fff; stroke: var(--accent); stroke-width: calc(2px * var(--k, 1)); cursor: grab; }
.ze-v.first { fill: var(--accent); }
.ze-m { fill: var(--accent); opacity: .45; cursor: copy; }
.ze-line { fill: none; stroke: var(--accent); stroke-width: calc(2px * var(--k, 1)); stroke-dasharray: 6 4; }
.ze-panel { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 4px 4px 10px; border-bottom: 1px solid var(--line); }
.ze-panel .st-err { font-weight: 600; }
.ze-bar { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gw-mark { stroke: #fff; stroke-width: calc(2px * var(--k, 1)); }
.gw-mark.on { fill: var(--ok); } .gw-mark.off { fill: var(--bad); }
.gw-label { font: 500 calc(11px * var(--k, 1)) var(--font); fill: #4a4e55; paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: calc(3px * var(--k, 1)); }
.person circle { fill: #fff; stroke-width: calc(2.5px * var(--k, 1)); transition: cx .9s ease, cy .9s ease; }
.person text { font: 700 calc(10px * var(--k, 1)) var(--font); fill: #1f2024; pointer-events: none; }
.person.lowbatt circle { stroke-dasharray: 3 2; }
.person.lost circle { fill: #d7dae0; stroke: #6b6f76; stroke-dasharray: calc(4px * var(--k, 1)) calc(3px * var(--k, 1)); transition: none; }
.person.lost text { fill: #6b6f76; }
.lg-dot.lost { background: #d7dae0; border: 2px dashed #6b6f76; }
.person:hover circle { stroke-width: calc(4px * var(--k, 1)); }
.range { fill: none; stroke: var(--accent); stroke-width: calc(1.5px * var(--k, 1)); stroke-dasharray: calc(6px * var(--k, 1)) calc(4px * var(--k, 1)); opacity: .8; pointer-events: none; }
.range-label { font: 500 calc(11px * var(--k, 1)) var(--font); fill: var(--accent); paint-order: stroke; stroke: rgba(255,255,255,.9); stroke-width: calc(3px * var(--k, 1)); pointer-events: none; }

/* локации */
.loc-overview { flex: 1; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-content: start; padding: 16px 20px; }
.loc-card { display: grid; gap: 4px; text-align: left; font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; }
.loc-card:hover { border-color: var(--line-strong); background: var(--panel-2); }

/* карточки справа */
.side { display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow-y: auto; }
#zones-list { display: grid; gap: 8px; }
.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 12px 16px; }
.block summary { font-weight: 600; cursor: pointer; }
.zcard { background: var(--panel); border: 1px solid var(--line); border-left-width: 5px; border-radius: 14px; padding: 10px 14px; }
.zcard h3 { margin: 0; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.zcard h3 span { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.people { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }
.people li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.people .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.people .unknown { color: var(--warn); }
.empty { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* таблицы */
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.on-t { color: var(--ok); font-weight: 600; } .off-t { color: var(--bad); font-weight: 600; }
.gw { margin-top: 6px; }
.tbl { overflow-x: auto; }
td.n, th.n { text-align: right; }
.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* состояние меток: без прокрутки вбок, на узком экране строка становится карточкой */
#tags-table td { white-space: normal; vertical-align: top; }
#tags-table th { white-space: normal; letter-spacing: .03em; }
#tags-table select { width: 100%; max-width: 150px; padding: 4px 6px; }
@media (max-width: 860px) {
  #tags-table thead { display: none; }
  #tags-table, #tags-table tbody, #tags-table tr, #tags-table td { display: block; width: 100%; }
  #tags-table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  #tags-table tr:last-child { border-bottom: 0; }
  #tags-table td { border: 0; padding: 3px 0; }
  #tags-table td::before { content: attr(data-l); display: block; color: var(--muted); font-size: 12px; }
}

/* страницы */
.log-view { flex: 1; padding: 16px 20px; display: grid; gap: 12px; align-content: start; }
.log-view > * { min-width: 0; }
.log-view h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.block h3 { margin: 14px 0 8px; font-size: 14px; font-weight: 600; }
.block p.muted { margin: 0 0 10px; }
.log-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* поля и кнопки */
input, select { font: inherit; font-size: 14px; color: var(--fg); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 7px 11px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="file"] { padding: 5px 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 14px var(--font); padding: 7px 14px; border-radius: var(--r-ctl); border: 1px solid transparent; background: var(--accent); color: var(--accent-on); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: var(--panel); color: var(--fg); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--hover); }
.btn.file { cursor: pointer; }
.seg { display: inline-flex; gap: 4px; }
.seg button { font: 13px var(--font); border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--fg); padding: 3px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-fg); }
.loc-sel { width: 100%; }

.tip { position: fixed; z-index: 10; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow-up); max-width: 320px; pointer-events: none; }
.tip b { display: block; }
@media (prefers-reduced-motion: reduce) { .person circle, .zone { transition: none; } }

/* вход */
.login-page { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-up); padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 600; }
.login p { margin: 0; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-err { color: var(--bad); font-weight: 600; }

/* управление */
.adm-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.adm-add input, .adm-add select { flex: 1 1 160px; min-width: 0; }
.adm-add .btn { flex: none; }
.adm input { width: 100%; min-width: 120px; padding: 5px 9px; }
.adm input.num { width: 70px; min-width: 0; }
.adm input[type="file"] { width: auto; }
.adm td { vertical-align: middle; }
.adm td select { padding: 5px 9px; }
.adm .f-label-cell { display: flex; gap: 6px; }
.cal-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#cal-msg:empty { display: none; }
.adm .f-label-cell input { min-width: 190px; }
.adm .f-lshifts { min-width: 240px; }
.adm .acts { display: flex; gap: 6px; }
/* широкая таблица прокручивается внутри .tbl и не растягивает страницу: иначе форма уходит за край окна */
.adm, .adm > * , .adm .block { min-width: 0; max-width: 100%; }
.adm-msg { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.adm-msg.err { border-color: var(--bad); color: var(--bad); }
.st-ok { color: var(--ok); font-weight: 600; } .st-err { color: var(--bad); font-weight: 600; } .st-wait { color: var(--warn); font-weight: 600; }
.pw-dialog { border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-up); background: var(--panel); color: var(--fg); padding: 20px; max-width: 360px; width: calc(100% - 32px); }
.pw-dialog::backdrop { background: #10121666; }
.pw-form { display: grid; gap: 10px; }
.pw-form h2 { margin: 0; font-size: 16px; font-weight: 600; }
.pw-form p { margin: 0; }
