/* ============================================================================
 *  ПОРТАЛ ПРОИСШЕСТВИЙ — ПАРКИ САО
 *  assets/css/style.css
 * ==========================================================================
 *  Все цвета, отступы, радиусы и тени вынесены в CSS-переменные (:root).
 *  Часть переменных (--brand, --accent) перезаписывается из index.php
 *  настройками из админки (settings/app) — смена темы без правки CSS.
 *
 *  СОДЕРЖАНИЕ
 *   1.  Переменные темы            7.  Экран охранника / SOS
 *   2.  База, типографика          8.  Мастер рапорта (3 шага)
 *   3.  Каркас приложения          9.  Список рапортов / карточка
 *   4.  Компоненты (btn, input…)  10.  Админка: сводка, таблицы, формы
 *   5.  Экран входа               11.  Утилиты, тосты, модалки, lightbox
 *   6.  Шапка / нижняя навигация  12.  Адаптив и тёмная/светлая темы
 * ========================================================================== */

/* ==========================================================================
 * 1. ПЕРЕМЕННЫЕ ТЕМЫ
 * ======================================================================= */
:root {
  /* v9.2 алиасы */
  --border: var(--line);
  --r-sm: var(--radius-sm);
  --r-md: var(--radius);
  /* Брендовые (перезаписываются настройками портала) */
  --brand:            #1f7a3d;
  --brand-2:          #2fa46a;
  --accent:           #e5484d;

  /* Палитра */
  --bg:               #f2f5f3;
  --bg-soft:          #e8eee9;
  --surface:          #ffffff;
  --surface-2:        #f7faf8;
  --surface-3:        #eef3ef;
  --line:             #dde5df;
  --line-soft:        #eaeff0;
  --text:             #16211c;
  --text-soft:        #4a5c53;
  --muted:            #7c8d84;
  --white:            #ffffff;

  /* Статусы */
  --ok:               #30a46c;
  --ok-bg:            #e7f6ee;
  --warn:             #f5a524;
  --warn-bg:          #fff4e0;
  --danger:           #e5484d;
  --danger-bg:        #fdecec;
  --info:             #3b82f6;
  --info-bg:          #e9f1fe;
  --neutral:          #8b8d98;
  --neutral-bg:       #eef0f2;

  /* Severity */
  --sev-1:            #3b82f6;
  --sev-2:            #f5a524;
  --sev-3:            #e5484d;

  /* Геометрия */
  --radius-xs:        6px;
  --radius-sm:        10px;
  --radius:           14px;
  --radius-lg:        20px;
  --radius-xl:        28px;
  --gap:              14px;
  --gap-sm:           8px;
  --gap-lg:           22px;

  /* Высота элементов */
  --header-h:         58px;
  --nav-h:            64px;
  --tap:              48px;

  /* Тени */
  --shadow-1:         0 1px 2px rgba(16,32,24,.06), 0 2px 8px rgba(16,32,24,.05);
  --shadow-2:         0 4px 14px rgba(16,32,24,.10);
  --shadow-3:         0 18px 44px rgba(16,32,24,.18);
  --shadow-sos:       0 16px 44px rgba(229,72,77,.42);

  /* Типографика */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "Noto Sans", Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs:            11.5px;
  --fs-sm:            13px;
  --fs-md:            15px;
  --fs-lg:            18px;
  --fs-xl:            22px;
  --fs-2xl:           30px;

  /* Анимации */
  --ease:             cubic-bezier(.22,.72,.28,1);
  --t-fast:           .14s var(--ease);
  --t:                .24s var(--ease);

  /* Безопасные зоны (iPhone notch) */
  --sat:              env(safe-area-inset-top, 0px);
  --sab:              env(safe-area-inset-bottom, 0px);
}

/* Тёмная тема (системная или принудительная через data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0c1310;
    --bg-soft:     #101a15;
    --surface:     #141f1a;
    --surface-2:   #182520;
    --surface-3:   #1e2d26;
    --line:        #26382f;
    --line-soft:   #1f2f28;
    --text:        #e8f2ec;
    --text-soft:   #b6c9bf;
    --muted:       #8ba79a;
    --ok-bg:       rgba(48,164,108,.16);
    --warn-bg:     rgba(245,165,36,.16);
    --danger-bg:   rgba(229,72,77,.16);
    --info-bg:     rgba(59,130,246,.16);
    --neutral-bg:  rgba(139,141,152,.18);
    --shadow-1:    0 1px 2px rgba(0,0,0,.4);
    --shadow-2:    0 6px 18px rgba(0,0,0,.45);
    --shadow-3:    0 20px 48px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] {
  --bg:          #0c1310;
  --bg-soft:     #101a15;
  --surface:     #141f1a;
  --surface-2:   #182520;
  --surface-3:   #1e2d26;
  --line:        #26382f;
  --line-soft:   #1f2f28;
  --text:        #e8f2ec;
  --text-soft:   #b6c9bf;
  --muted:       #8ba79a;
  --ok-bg:       rgba(48,164,108,.16);
  --warn-bg:     rgba(245,165,36,.16);
  --danger-bg:   rgba(229,72,77,.16);
  --info-bg:     rgba(59,130,246,.16);
  --neutral-bg:  rgba(139,141,152,.18);
}

/* ==========================================================================
 * 2. БАЗА
 * ======================================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p  { margin: 0 0 .8em; }
a  { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.muted   { color: var(--muted); }
.soft    { color: var(--text-soft); }
.mono    { font-family: var(--font-mono); font-size: .92em; }
.tiny    { font-size: var(--fs-xs); }
.small   { font-size: var(--fs-sm); }
.bold    { font-weight: 700; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.truncate{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: 4px; }

::selection { background: rgba(47,164,106,.28); }

/* Скроллбары */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ==========================================================================
 * 3. ЭКРАН ЗАГРУЗКИ (в index.php)
 * ======================================================================= */
.boot {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(47,164,106,.20), transparent 60%), var(--bg);
  padding: 24px; text-align: center;
  transition: opacity .3s var(--ease), visibility .3s;
}
.boot.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-logo {
  width: 84px; height: 84px; border-radius: 24px; display: flex; align-items: center; justify-content: center;
  font-size: 42px; background: linear-gradient(150deg, var(--brand-2), var(--brand));
  box-shadow: 0 14px 38px rgba(31,122,61,.36); overflow: hidden; margin-bottom: 6px;
}
.boot-logo img { width: 100%; height: 100%; object-fit: cover; }
.boot-title { font-size: 20px; font-weight: 700; }
.boot-sub { color: var(--muted); font-size: 13px; }
.boot-spinner {
  width: 26px; height: 26px; margin-top: 16px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand-2);
  animation: spin .8s linear infinite;
}
.boot-err { margin-top: 14px; color: var(--danger); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
 * 4. КАРКАС ПРИЛОЖЕНИЯ
 * ======================================================================= */
.app { min-height: 100%; padding-bottom: calc(var(--nav-h) + var(--sab) + 8px); }
.app.no-nav { padding-bottom: 0; }

.app-header {
  position: sticky; top: 0; z-index: 60;
  height: calc(var(--header-h) + var(--sat)); padding-top: var(--sat);
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header .h-logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none; overflow: hidden;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
}
.app-header .h-logo img { width: 100%; height: 100%; object-fit: cover; }
.app-header .h-title { font-size: 15px; font-weight: 700; line-height: 1.15; }
.app-header .h-sub { font-size: 11px; color: var(--muted); line-height: 1.2; }
.app-header .h-spacer { flex: 1; }
.app-header .h-actions { display: flex; align-items: center; gap: 6px; padding-right: 10px; }
.h-pad { padding-left: 14px; display: flex; align-items: center; gap: 10px; min-width: 0; }

.page { padding: var(--gap); max-width: 1180px; margin: 0 auto; }
.page.wide { max-width: 1440px; }
.page-title { display: flex; align-items: flex-end; gap: 10px; margin-bottom: var(--gap); flex-wrap: wrap; }
.page-title h1 { font-size: var(--fs-xl); margin: 0; }
.page-title .spacer { flex: 1; }

/* Нижняя навигация (мобильная) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab);
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 6px 2px; position: relative;
  transition: color var(--t-fast); text-decoration: none;
}
.tabbar a .ico { font-size: 20px; line-height: 1; filter: grayscale(1) opacity(.65); transition: filter var(--t-fast); }
.tabbar a.on { color: var(--brand-2); }
.tabbar a.on .ico { filter: none; }
.tabbar a.on::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand-2);
}
.tabbar a .badge-dot {
  position: absolute; top: 7px; right: calc(50% - 20px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}
.tabbar .fab-sos {
  flex: 0 0 74px; align-items: center; justify-content: center;
}
.tabbar .fab-sos .ico {
  width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(180deg, #ff6166, var(--accent));
  color: #fff; font-size: 13px; font-weight: 900; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center; filter: none;
  box-shadow: var(--shadow-sos); margin-top: -18px; border: 3px solid var(--surface);
}

/* Боковая навигация на десктопе */
@media (min-width: 1024px) {
  .app { display: flex; padding-bottom: 0; }
  .app-header { display: none; }
  .tabbar { display: none; }
  .sidenav {
    display: flex !important; flex-direction: column; gap: 4px;
    width: 244px; flex: none; height: 100vh; position: sticky; top: 0;
    padding: 18px 14px calc(18px + var(--sab)); overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .main-col { flex: 1; min-width: 0; }
}
.sidenav { display: none; }
.sidenav .sn-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.sidenav .sn-logo {
  width: 38px; height: 38px; border-radius: 11px; overflow: hidden; flex: none;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.sidenav .sn-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidenav .sn-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidenav .sn-org { font-size: 11px; color: var(--muted); }
.sidenav .sn-sep { height: 1px; background: var(--line); margin: 12px 4px; }
.sidenav .sn-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px 4px; font-weight: 700; }
.sidenav a.sn-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-size: 14px; font-weight: 600; text-decoration: none; transition: background var(--t-fast), color var(--t-fast);
}
.sidenav a.sn-item:hover { background: var(--surface-3); color: var(--text); }
.sidenav a.sn-item.on { background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 16%, transparent), transparent); color: var(--brand-2); }
.sidenav a.sn-item .ico { font-size: 17px; width: 20px; text-align: center; }
.sidenav a.sn-item .cnt {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.sidenav .sn-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}
.sidenav .sn-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 13px;
}
.sidenav .sn-uname { font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidenav .sn-urole { font-size: 11px; color: var(--muted); }

/* ==========================================================================
 * 5. КОМПОНЕНТЫ
 * ======================================================================= */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-1); margin-bottom: var(--gap);
}
.card.tight { padding: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-h h3 { margin: 0; font-size: 15px; }
.card-h .spacer { flex: 1; }
.card-h .ico { font-size: 18px; }

.grid { display: grid; gap: var(--gap); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 860px) {
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 520px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 10px; }

/* --- Кнопки --- */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-size: 14.5px; font-weight: 650; cursor: pointer; text-decoration: none;
  transition: transform var(--t-fast), filter var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap; user-select: none; -webkit-user-select: none;
}
.btn:hover { filter: brightness(1.04); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { --btn-bg: linear-gradient(180deg, var(--brand-2), var(--brand)); --btn-fg: #fff; --btn-bd: transparent; box-shadow: 0 8px 22px rgba(31,122,61,.26); }
.btn.danger  { --btn-bg: linear-gradient(180deg, #ff6166, var(--danger)); --btn-fg: #fff; --btn-bd: transparent; box-shadow: 0 8px 22px rgba(229,72,77,.26); }
.btn.warn    { --btn-bg: linear-gradient(180deg, #ffbe4d, #e08c0b); --btn-fg: #26190a; --btn-bd: transparent; }
.btn.info    { --btn-bg: linear-gradient(180deg, #63a4ff, var(--info)); --btn-fg: #fff; --btn-bd: transparent; }
.btn.ghost   { --btn-bg: transparent; --btn-bd: var(--line); }
.btn.quiet   { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-soft); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn.lg { min-height: 54px; padding: 14px 26px; font-size: 17px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn.icon { min-width: 44px; padding: 10px; }
.btn.icon.sm { min-width: 34px; padding: 6px; }

.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group .btn { border: 0; border-radius: 0; box-shadow: none; background: var(--surface); }
.btn-group .btn + .btn { border-left: 1px solid var(--line); }
.btn-group .btn.on { background: var(--brand); color: #fff; }

/* --- Поля ввода --- */
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, .textarea,
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date],
input[type=time], input[type=email], input[type=tel], select, textarea {
  width: 100%; min-height: 46px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 15px; outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237c8d84' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent);
}
.input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
.input.err, input.err { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(229,72,77,.14); }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.err-text { font-size: 12px; color: var(--danger); margin-top: 5px; }

.search {
  position: relative; display: flex; align-items: center;
}
.search input { padding-left: 40px; }
.search .s-ico { position: absolute; left: 13px; font-size: 15px; color: var(--muted); pointer-events: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 46px; height: 27px; border-radius: 14px; background: var(--line); position: relative;
  transition: background var(--t); flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1); transition: transform var(--t);
}
.switch input:checked + .track { background: var(--brand-2); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch .txt { font-size: 14px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px;
  background: var(--surface-3); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text-soft);
  white-space: nowrap;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.chip.ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip.warn { background: var(--warn-bg); border-color: transparent; color: #b57608; }
.chip.info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { cursor: pointer; transition: transform var(--t-fast), background var(--t-fast); }
.chip-btn:active { transform: scale(.96); }

/* --- Бейджи статусов --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 750; letter-spacing: .01em; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.st-new    { background: var(--danger-bg);  color: var(--danger); }
.badge.st-ack    { background: var(--warn-bg);    color: #b57608; }
.badge.st-work   { background: var(--info-bg);    color: var(--info); }
.badge.st-ok     { background: var(--ok-bg);      color: var(--ok); }
.badge.st-closed { background: var(--neutral-bg); color: var(--neutral); }
.badge.sos       { background: var(--danger); color: #fff; animation: pulse-badge 1.4s infinite; }
@keyframes pulse-badge { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 13px;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.admin  { background: #6d5bd0; }
.avatar.senior { background: #2f7fb5; }
.avatar.guard  { background: var(--brand); }

.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty .ico { font-size: 44px; margin-bottom: 10px; opacity: .55; }
.empty h3 { color: var(--text-soft); font-size: 16px; margin-bottom: 6px; }
.empty p { font-size: 13.5px; margin: 0 auto; max-width: 340px; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line);
  border-top-color: var(--brand-2); animation: spin .75s linear infinite; display: inline-block;
}
.spinner.lg { width: 34px; height: 34px; border-width: 3px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line-soft) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: skel 1.3s linear infinite; border-radius: var(--radius-xs);
}
@keyframes skel { to { background-position: -200% 0; } }

/* ==========================================================================
 * 6. ЭКРАН ВХОДА
 * ======================================================================= */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(1000px 520px at 12% -12%, rgba(47,164,106,.20), transparent 60%),
    radial-gradient(820px 480px at 105% 5%, rgba(43,108,176,.16), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px 24px; box-shadow: var(--shadow-3);
}
.login-logo {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px; overflow: hidden;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  display: flex; align-items: center; justify-content: center; font-size: 36px;
  box-shadow: 0 12px 32px rgba(31,122,61,.32);
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; }
.login-card h1 { text-align: center; font-size: 21px; margin-bottom: 4px; }
.login-card .login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-alert {
  background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 13.5px; margin-bottom: 14px; font-weight: 600;
}
.login-foot { margin-top: 18px; text-align: center; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.pwa-hint {
  margin-top: 16px; padding: 12px 13px; border-radius: var(--radius-sm);
  background: var(--info-bg); color: var(--text-soft); font-size: 12.5px; line-height: 1.5;
}

/* ==========================================================================
 * 7. ЭКРАН ОХРАННИКА / SOS
 * ======================================================================= */
.guard-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 10px 0 4px;
}
.guard-hello { font-size: 13px; color: var(--muted); }
.guard-park { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

.sos-zone { position: relative; width: 100%; display: flex; justify-content: center; padding: 18px 0 8px; }
.sos-btn {
  position: relative; width: min(74vw, 268px); aspect-ratio: 1 / 1; border-radius: 50%;
  border: 0; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 50% 34%, #ff7a7e 0%, #e5484d 52%, #a51d22 100%);
  box-shadow: var(--shadow-sos), inset 0 -10px 24px rgba(0,0,0,.22), inset 0 8px 18px rgba(255,255,255,.22);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .12s var(--ease), box-shadow .2s var(--ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.sos-btn:active { transform: scale(.965); }
.sos-btn .sos-title { font-size: clamp(34px, 12vw, 54px); font-weight: 900; letter-spacing: .04em; line-height: 1; text-shadow: 0 3px 10px rgba(0,0,0,.3); }
.sos-btn .sos-sub { font-size: 12.5px; font-weight: 700; opacity: .92; letter-spacing: .04em; text-transform: uppercase; }
.sos-btn::before, .sos-btn::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid rgba(229,72,77,.5); animation: sos-ring 2.4s var(--ease) infinite; pointer-events: none;
}
.sos-btn::after { animation-delay: 1.2s; }
@keyframes sos-ring {
  0%   { transform: scale(.92); opacity: .85; }
  70%  { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}
.sos-hint { font-size: 12.5px; color: var(--muted); margin-top: 14px; max-width: 330px; line-height: 1.5; }

.sos-active-banner {
  position: fixed; inset: auto 0 0 0; z-index: 120; padding: 14px 16px calc(14px + var(--sab));
  background: linear-gradient(180deg, #ff5a5f, #c9272c); color: #fff;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 -8px 30px rgba(0,0,0,.3);
  animation: slide-up .3s var(--ease);
}
@keyframes slide-up { from { transform: translateY(100%); } }
.sos-active-banner .b-txt { flex: 1; min-width: 0; }
.sos-active-banner .b-title { font-weight: 800; font-size: 15px; }
.sos-active-banner .b-sub { font-size: 12px; opacity: .9; }
.sos-active-banner .btn { background: #fff; color: #c9272c; border-color: #fff; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .quick-grid { grid-template-columns: 1fr; } }
.quick-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; text-align: left;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  box-shadow: var(--shadow-1); min-height: 66px;
}
.quick-card:hover { border-color: var(--brand-2); box-shadow: var(--shadow-2); }
.quick-card:active { transform: scale(.985); }
.quick-card .q-ico { font-size: 26px; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--surface-3); flex: none; }
.quick-card .q-title { font-size: 14px; font-weight: 700; line-height: 1.2; }
.quick-card .q-sub { font-size: 11.5px; color: var(--muted); }
.quick-card.ok-card .q-ico { background: var(--ok-bg); }
.quick-card.sos-card { grid-column: 1 / -1; }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: var(--gap); }
.stat-strip .st {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  text-align: center; box-shadow: var(--shadow-1);
}
.stat-strip .st .v { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-strip .st .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-strip .st.danger .v { color: var(--danger); }
.stat-strip .st.warn .v { color: var(--warn); }
.stat-strip .st.ok .v { color: var(--ok); }

/* ==========================================================================
 * 8. МАСТЕР РАПОРТА (3 шага)
 * ======================================================================= */
.wizard-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.wizard-steps .ws {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: var(--radius-xs);
  background: var(--surface-3); color: var(--muted); font-size: 11.5px; font-weight: 700; position: relative;
}
.wizard-steps .ws .n { display: block; font-size: 15px; }
.wizard-steps .ws.on { background: var(--brand); color: #fff; }
.wizard-steps .ws.done { background: var(--ok-bg); color: var(--ok); }
.wizard-body { min-height: 260px; }
/* v11.9: панель навигации мастера — липкая, всегда на виду (не нужно листать).
 * v11.10: sticky не работал из-за overflow:hidden у .card — для карточки
 * мастера убираем обрезку и добавляем подложку под панель. */
.card.wizard-card { overflow: visible; }
.wizard-nav {
  display: flex; gap: 10px; margin-top: 14px;
  position: sticky; bottom: calc(var(--nav-h) + var(--sab) + 6px); z-index: 65;
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 10px 12px; margin-left: -14px; margin-right: -14px; margin-bottom: -14px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 -6px 18px rgba(15, 34, 22, .07);
}
.wizard-nav .btn { flex: 1; }
@media (min-width: 1024px) {
  .wizard-nav { bottom: 10px; }
}

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.type-card {
  padding: 13px 12px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface-2);
  cursor: pointer; text-align: left; transition: all var(--t-fast); position: relative; display: flex; flex-direction: column; gap: 6px;
  min-height: 96px;
}
.type-card:hover { border-color: var(--brand-2); background: var(--surface); }
.type-card:active { transform: scale(.98); }
.type-card.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.type-card .t-ico { font-size: 26px; line-height: 1; }
.type-card .t-title { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.type-card .t-sev { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; }
.type-card .t-sev.s1 { background: var(--sev-1); }
.type-card .t-sev.s2 { background: var(--sev-2); }
.type-card .t-sev.s3 { background: var(--sev-3); box-shadow: 0 0 0 3px rgba(229,72,77,.2); }

.map-box {
  height: 240px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface-3); position: relative; z-index: 1;
}
.map-box.tall { height: 320px; }
.map-offline-note { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.map-tiles-offline { background:
  repeating-linear-gradient(0deg, rgba(255,255,255,.04) 0 1px, transparent 1px 32px),
  repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 1px, transparent 1px 32px),
  #16211c !important; }
.map-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.coords-line {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 9px 11px; margin-top: 10px;
}
.coords-line .spacer { flex: 1; }

/* Фото */
.photo-drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 20px; text-align: center;
  color: var(--muted); cursor: pointer; transition: all var(--t-fast); background: var(--surface-2);
}
.photo-drop:hover, .photo-drop.drag { border-color: var(--brand-2); background: color-mix(in srgb, var(--brand) 6%, var(--surface-2)); color: var(--text-soft); }
.photo-drop .ico { font-size: 30px; display: block; margin-bottom: 6px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1/1; background: var(--surface-3); border: 1px solid var(--line); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item .del {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff; border: 0; cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.photo-item .sz { position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px; font-size: 10px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); }

.summary-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.summary-box dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.summary-box dt { color: var(--muted); }
.summary-box dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ==========================================================================
 * 9. СПИСОК РАПОРТОВ
 * ======================================================================= */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }

.incident-list { display: flex; flex-direction: column; gap: 10px; }
.incident {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.incident::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--neutral); }
.incident.sev-3::before { background: var(--sev-3); }
.incident.sev-2::before { background: var(--sev-2); }
.incident.sev-1::before { background: var(--sev-1); }
.incident.is-sos { border-color: rgba(229,72,77,.5); box-shadow: 0 0 0 3px rgba(229,72,77,.10), var(--shadow-1); }
.incident.is-sos::before { background: var(--danger); }
.incident:hover { box-shadow: var(--shadow-2); }
.incident .i-head { display: flex; align-items: flex-start; gap: 10px; }
.incident .i-ico { font-size: 22px; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; flex: none; }
.incident .i-title { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.incident .i-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.incident .i-spacer { flex: 1; min-width: 0; }
.incident .i-body { margin-top: 9px; font-size: 13.5px; color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }
.incident .i-photos { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.incident .i-photos img { width: 62px; height: 62px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.incident .i-foot { display: flex; gap: 8px; align-items: center; margin-top: 11px; flex-wrap: wrap; }
.incident .i-actions { margin-left: auto; display: flex; gap: 6px; }
.incident.pending::after {
  content: '⏳ не отправлено'; position: absolute; top: 9px; right: 10px;
  font-size: 10px; color: var(--warn); background: var(--warn-bg); padding: 2px 7px; border-radius: 10px; font-weight: 700;
}
.incident .i-offline-flag { font-size: 10.5px; color: var(--warn); font-weight: 700; }

/* Таблица (десктоп) */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl th {
  background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 750; position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
table.tbl.compact th, table.tbl.compact td { padding: 8px 10px; }

/* ==========================================================================
 * 10. АДМИНКА
 * ======================================================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: var(--gap); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px;
  box-shadow: var(--shadow-1); position: relative; overflow: hidden;
}
.kpi::after { content: ''; position: absolute; right: -18px; top: -18px; width: 74px; height: 74px; border-radius: 50%; background: var(--surface-3); opacity: .6; }
.kpi .k-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 750; position: relative; z-index: 1; }
.kpi .k-value { font-size: 30px; font-weight: 800; line-height: 1.15; margin-top: 3px; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.kpi .k-ico { position: absolute; right: 12px; top: 12px; font-size: 20px; z-index: 1; opacity: .85; }
.kpi.danger { border-color: rgba(229,72,77,.34); background: linear-gradient(180deg, var(--danger-bg), var(--surface) 62%); }
.kpi.danger .k-value { color: var(--danger); }
.kpi.warn { border-color: rgba(245,165,36,.34); background: linear-gradient(180deg, var(--warn-bg), var(--surface) 62%); }
.kpi.ok { border-color: rgba(48,164,108,.3); background: linear-gradient(180deg, var(--ok-bg), var(--surface) 62%); }
.kpi.info { border-color: rgba(59,130,246,.3); background: linear-gradient(180deg, var(--info-bg), var(--surface) 62%); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 150px) 1fr 42px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .b-name { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 9px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--brand-2); transition: width .5s var(--ease); }
.bar-row .b-val { text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; border-bottom: 2.5px solid transparent; padding: 10px 14px; cursor: pointer;
  font-size: 14px; font-weight: 650; color: var(--muted); white-space: nowrap; transition: color var(--t-fast);
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand-2); border-bottom-color: var(--brand-2); }

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 14px; font-weight: 650; }
.list-row .lr-sub { font-size: 12px; color: var(--muted); }
.list-row .lr-actions { display: flex; gap: 6px; flex: none; }

.park-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.12); display: inline-block; }

/* Детали рапорта */
.detail-hero {
  border-radius: var(--radius); padding: 16px; color: #fff; margin-bottom: var(--gap);
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow-2);
}
.detail-hero.danger { background: linear-gradient(135deg, #c9272c, #ff6166); }
.detail-hero h1 { font-size: 20px; margin: 0 0 4px; }
.detail-hero .dh-meta { font-size: 12.5px; opacity: .92; }
.kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 9px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 14px; font-size: 13.5px; }
.tl-item::before {
  content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand-2); border: 2px solid var(--surface);
}
.tl-item .tl-t { color: var(--muted); font-size: 11.5px; }

/* ==========================================================================
 * 11. ТОСТЫ, МОДАЛКИ, LIGHTBOX
 * ======================================================================= */
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--sab) + 16px); width: min(94vw, 420px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: 22px; left: auto; right: 22px; transform: none; } }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); font-size: 13.5px;
  animation: toast-in .26s var(--ease);
}
.toast.out { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast .t-ico { font-size: 17px; line-height: 1.2; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 700; }
.toast .t-msg { color: var(--text-soft); font-size: 12.5px; margin-top: 1px; }
.toast.ok    { border-left: 3px solid var(--ok); }
.toast.err   { border-left: 3px solid var(--danger); }
.toast.warn  { border-left: 3px solid var(--warn); }
.toast.info  { border-left: 3px solid var(--info); }

.overlay { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(6,14,10,.55); backdrop-filter: blur(3px); animation: fade .18s var(--ease); }
@media (min-width: 640px) { .overlay { align-items: center; padding: 20px; } }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 20px; box-shadow: var(--shadow-3);
  animation: modal-in .26s var(--ease); border: 1px solid var(--line);
}
@media (min-width: 640px) { .modal { border-radius: var(--radius-lg); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-h h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-f { display: flex; gap: 10px; margin-top: 18px; }
.modal-f .btn { flex: 1; }
.modal-grab { width: 42px; height: 4px; border-radius: 3px; background: var(--line); margin: -6px auto 14px; }
@media (min-width: 640px) { .modal-grab { display: none; } }

.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.93); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s var(--ease); }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-3); }
.lightbox .lb-close { position: absolute; top: calc(14px + var(--sat)); right: 16px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; border: 0; font-size: 20px; cursor: pointer; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; border: 0; font-size: 22px; cursor: pointer; }
.lightbox .lb-prev { left: 12px; } .lightbox .lb-next { right: 12px; }
.lightbox .lb-count { position: absolute; bottom: calc(18px + var(--sab)); left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; opacity: .8; }

/* Индикатор офлайн */
.netbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 180; padding: 7px 14px calc(7px);
  padding-top: calc(7px + var(--sat));
  background: linear-gradient(180deg, #b57608, #8a5905); color: #fff; font-size: 12.5px; font-weight: 650;
  display: flex; align-items: center; gap: 8px; justify-content: center; box-shadow: var(--shadow-2);
  animation: slide-down .26s var(--ease);
}
@keyframes slide-down { from { transform: translateY(-100%); } }
.netbar-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; flex: none; }
@keyframes blink { 50% { opacity: .25; } }
body.has-netbar .app-header { padding-top: calc(var(--sat) + 32px); }

/* ==========================================================================
 * 12. УТИЛИТЫ И АДАПТИВ
 * ======================================================================= */
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.scroll-x { overflow-x: auto; }
.sticky-top { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.p0 { padding: 0; } .p12 { padding: 12px; } .p16 { padding: 16px; }
.w100 { width: 100%; } .flex1 { flex: 1; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.print-only { display: none; }
@media print {
  .app-header, .tabbar, .sidenav, .toasts, .netbar, .btn, .filters { display: none !important; }
  .print-only { display: block; }
  body, .app { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; page-break-inside: avoid; }
}

@media (max-width: 560px) {
  :root { --gap: 12px; --fs-xl: 20px; --fs-2xl: 26px; }
  .page { padding: 12px; }
  .card { padding: 14px; border-radius: var(--radius); }
  .btn { min-height: var(--tap); }
  .kpi .k-value { font-size: 26px; }
  .stat-strip .st .v { font-size: 20px; }
  h1 { font-size: 22px; }
}

/* Крупные сенсорные экраны (планшеты охраны) */
@media (min-width: 700px) and (pointer: coarse) {
  .btn { min-height: 52px; font-size: 15.5px; }
  .type-card { min-height: 108px; }
}

/* Уменьшенная анимация по запросу системы */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sos-btn::before, .sos-btn::after { display: none; }
}

/* ==========================================================================
 *  PSIM · ДОПОЛНИТЕЛЬНЫЕ СТИЛИ
 *  Матрица прав, карточки поручений, красные окна оповещений, GPS-обход,
 *  база знаний, паспорт объекта, транспорт.
 *  Все цвета — через переменные :root, поэтому тёмная тема подхватывается
 *  автоматически и отдельно прописывать её не нужно.
 * ========================================================================= */

/* --- утилиты --- */
.gap16 { gap: 16px; }
.mt0 { margin-top: 0; }
.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 2px; cursor: pointer; user-select: none;
}
.check input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--brand); }
.check > span:last-child { flex: 1; min-width: 0; }

/* ========================================================================
 * МАТРИЦА ПРАВ (роли и события MAX)
 * ====================================================================== */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 8px;
}
.perm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 10px);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.perm-item:hover { border-color: var(--brand); background: var(--surface-2); }
.perm-item input[type="checkbox"] { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--brand); margin: 0; }
.perm-item.on {
  border-color: var(--brand);
  background: var(--ok-bg);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.pm-ico { font-size: 19px; line-height: 1; flex: 0 0 auto; }
.pm-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.pm-title { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.pm-id { font-size: 10.5px; color: var(--muted); letter-spacing: .02em; }

/* карточка роли */
.role-card .card-h { gap: 10px; }
.avatar.roles, .avatar.senior, .avatar.admin, .avatar.guard { flex: 0 0 auto; }

/* ========================================================================
 * КРАСНОЕ ОКНО ОПОВЕЩЕНИЯ (прибытие персоны, новый SOS)
 * ====================================================================== */
.alert-banner {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--r-md, 12px);
  border: 1px solid transparent;
}
.alert-banner.danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  animation: alertPulse 1.1s ease-in-out 3;
}
.alert-banner.warn { background: var(--warn-bg); border-color: var(--warn); }
.ab-ico { font-size: 34px; line-height: 1; flex: 0 0 auto; }
.ab-body { min-width: 0; flex: 1; }
.ab-title {
  font-size: 17px; font-weight: 800; line-height: 1.3;
  color: var(--text);
  word-break: break-word;
}
.alert-banner.danger .ab-title { color: var(--danger); }
.ab-text { margin-top: 6px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ab-meta { margin-top: 8px; font-size: 12px; color: var(--muted); }

@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .55); }
  50%      { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .alert-banner.danger { animation: none; }
}

/* ========================================================================
 * ПОРУЧЕНИЯ (ЗАДАЧИ)
 * ====================================================================== */
.task-card { position: relative; }
.task-card.sev-3 { border-left: 4px solid var(--danger); }
.task-card.sev-2 { border-left: 4px solid var(--warn); }
.task-card.sev-1 { border-left: 4px solid var(--info); }
.task-card.overdue { background: linear-gradient(180deg, var(--danger-bg), var(--surface) 55%); }
.task-card.overdue::after {
  content: 'просрочено';
  position: absolute; top: 8px; right: 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--danger);
  padding: 2px 7px; border-radius: 999px;
}
/* бейдж просрочки внутри заголовка не дублируем с ::after на узких экранах */
@media (max-width: 560px) { .task-card.overdue::after { display: none; } }

/* ========================================================================
 * GPS-ОБХОД
 * ====================================================================== */
.track-ico { font-size: 46px; line-height: 1; margin-bottom: 6px; }
.card.track-active {
  border-color: var(--ok);
  background: linear-gradient(180deg, var(--ok-bg), var(--surface) 60%);
}
.card.track-active .track-ico { animation: satSpin 3.2s linear infinite; display: inline-block; }
@keyframes satSpin {
  0%, 70%, 100% { transform: rotate(0deg); }
  80% { transform: rotate(-12deg); }
  90% { transform: rotate(12deg); }
}
@media (prefers-reduced-motion: reduce) { .card.track-active .track-ico { animation: none; } }

.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat-strip .st {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm, 10px); padding: 10px 8px; text-align: center;
}
.stat-strip .st .v { font-size: 20px; font-weight: 800; line-height: 1.1; }
.stat-strip .st .l { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat-strip .st.ok .v { color: var(--ok); }
.stat-strip .st.warn .v { color: var(--warn); }

/* переключатель тихого режима SOS — заметнее обычных */
.sos-silent-switch {
  margin: 14px auto 0; max-width: 420px;
  padding: 10px 12px;
  border: 1px dashed var(--border); border-radius: var(--r-sm, 10px);
  background: var(--surface-2);
}
.sos-silent-switch .txt { font-size: 13px; line-height: 1.4; }

/* ========================================================================
 * БАЗА ЗНАНИЙ
 * ====================================================================== */
.kb-folder { display: flex; flex-direction: column; }
.kb-folder .card-h { gap: 9px; }
.kb-folder .card-h h3 { font-size: 15px; }
.list-row[data-doc]:hover { background: var(--surface-2); }
.list-row .lr-actions { display: flex; gap: 4px; align-items: center; }

/* ========================================================================
 * ТРАНСПОРТ
 * ====================================================================== */
.incident.is-sos { border-left: 4px solid var(--info); }
tr.row-warn, .tbl tr.row-warn td { background: var(--warn-bg); }

/* ========================================================================
 * АДАПТИВ: матрица прав и статистика на телефоне
 * ====================================================================== */
@media (max-width: 620px) {
  .perm-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-strip .st { padding: 8px 4px; }
  .stat-strip .st .v { font-size: 17px; }
  .ab-ico { font-size: 27px; }
  .ab-title { font-size: 15.5px; }
  .track-ico { font-size: 38px; }
}

/* ========================================================================
 * ПЕЧАТЬ: карточки поручений и паспорта объекта — для бумажного журнала
 * ====================================================================== */
@media print {
  .perm-grid, .stat-strip, .photo-drop, .filters, .tabs, .tabbar, .sidenav, .app-header { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #bbb; }
  .alert-banner { border: 1px solid #000; background: #fff !important; }
}

/* ========== v9.2 ========== */
.type-cat-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin: 18px 0 8px; }
.type-cat-title:first-child { margin-top: 4px; }
.sos-fixed { position: fixed; bottom: 85px; right: 20px; width: 72px; height: 72px; border-radius: 50%; z-index: 90; }
.sos-fixed .sos-btn { width: 72px; height: 72px; border-radius: 50%; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.sos-fixed .sos-btn .sos-title { font-size: 19px; }
.sos-fixed .sos-btn .sos-sub { display: none; }
.tabbar .more-tab { background: none; border: 0; font: inherit; color: inherit; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 0 6px; }
.tabbar .more-tab.on { color: var(--brand, #1f7a3d); }
.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .sheet { grid-template-columns: 1fr; } }
.sheet-item { display: flex; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px); background: var(--surface); color: var(--text); font-size: 14px; }
.sheet-item.on { border-color: var(--brand, #1f7a3d); }
.next-point { border-color: rgba(47,164,106,.6); }
.next-point b { display: block; font-size: 22px; line-height: 1.2; margin: 4px 0 2px; }
.chat-row { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; background: var(--surface); cursor: pointer; }
.chat-bubble { max-width: 84%; padding: 9px 12px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-bubble.me { align-self: flex-end; background: rgba(47,164,106,.14); border-color: rgba(47,164,106,.4); }
.chat-msgs { display: flex; flex-direction: column; gap: 8px; min-height: 45vh; }
.chat-input-row { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 8px 0; background: var(--bg); }
.qr-frame { position: relative; width: 100%; max-width: 420px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #000; }
.qr-frame video { width: 100%; display: block; }
.pdf-toolbar { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.pdf-wrap { background: #525659; border-radius: 12px; padding: 10px; overflow: auto; max-height: 70vh; }
.pdf-wrap canvas { display: block; margin: 0 auto; max-width: 100%; }
#print-sheet { display: none; }
@media print {
  .tabbar, .app-header, .side, .btn, .i-actions, .wizard-nav, .sos-fixed, .more-tab { display: none !important; }
  body.print-one #app { display: none !important; }
  body.print-one #print-sheet { display: block !important; }
}

/* ===== v11.1: категорийное дерево типов происшествий (мастер рапорта) ===== */
.cat-node { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 10px; overflow: hidden; }
.cat-node > summary { list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px; user-select: none; }
.cat-node > summary::-webkit-details-marker { display: none; }
.cat-node > summary::before { content: '▸'; color: var(--muted); transition: transform .15s ease; }
.cat-node[open] > summary::before { transform: rotate(90deg); }
.cat-node > summary:hover { background: rgba(255,255,255,.04); }
.cat-sub { padding: 4px 14px 12px; }
.cat-sub-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; margin: 10px 0 6px; }

/* ===== v11.1: тепловая карта и легенда на дашборде ===== */
.heat-legend { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.heat-legend .bar { flex: 0 0 120px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(48,164,108,.55), #f5a524, #e5484d); }
.heat-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ===== v11.1: журнал действий (audit) ===== */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.audit-table td { vertical-align: top; font-size: 13px; }
.audit-action { font-weight: 700; white-space: nowrap; }
.audit-meta { color: var(--muted); font-size: 12px; }
.audit-payload { max-width: 340px; word-break: break-word; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-soft); }

/* ===== v11.5: умные кнопки (детали происшествия) ===== */
.det-group { margin-bottom: 12px; }
.det-group label { font-weight: 700; }
.det-group .req { color: var(--danger); }
.det-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip-btn { cursor: pointer; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-soft); padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  transition: all .12s ease; user-select: none; }
.chip-btn:hover { border-color: var(--brand); color: var(--text); }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.details-summary { display: flex; flex-direction: column; gap: 8px; }
.ds-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ds-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; min-width: 150px; }
.ds-chip { font-size: 12px; }
.i-details { margin-top: 8px; font-size: 12.5px; color: var(--text-soft); }

/* ===== v11.5: геозамок и отдельный учёт рапортов «Всё в норме» ===== */
.geolock-banner { background: rgba(48,164,108,.12); border: 1px solid rgba(48,164,108,.4);
  color: var(--ok, #30a46c); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.incident.ok-report { opacity: .92; border-left: 3px solid var(--ok, #30a46c); }
.badge.st-ok { background: rgba(48,164,108,.15); color: var(--ok, #30a46c); font-size: 11px;
  padding: 2px 8px; border-radius: 999px; font-weight: 800; vertical-align: middle; }
.coords-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
.err-text { color: var(--danger); font-size: 13px; margin: 6px 0; min-height: 0; }

/* ===== v11.6: плавающая кнопка «Собрать рапорт» на экране поста ===== */
.fab-report { position: fixed; right: 16px; bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 60; display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #2f9e5f, #1f7a3d); color: #fff; font-weight: 800; font-size: 14px;
  padding: 13px 18px; border-radius: 999px; box-shadow: 0 6px 18px rgba(20, 80, 40, .35);
  transition: transform .12s ease, box-shadow .12s ease; }
.fab-report:hover { transform: translateY(-2px); box-shadow: 0 9px 22px rgba(20, 80, 40, .45); }
.fab-report:active { transform: scale(.97); }
.fab-report .fr-ico { font-size: 17px; line-height: 1; }
@media (max-width: 480px) { .fab-report .fr-txt { display: none; } .fab-report { padding: 15px 16px; } }

/* ===== v11.6: экран «Мой парк» ===== */
.infra-list { display: flex; flex-direction: column; }
.infra-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer; }
.infra-row:last-child { border-bottom: none; }
.infra-row:hover { background: var(--surface-2); }
.infra-row .ir-ico { font-size: 20px; width: 28px; text-align: center; flex: none; }
.infra-row .ir-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.infra-row .ir-main b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.infra-row .ir-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.warn { background: rgba(240, 165, 60, .15); color: #b5730f; border-color: rgba(240, 165, 60, .4); }
.chip.danger { background: rgba(229, 72, 77, .12); color: var(--danger); border-color: rgba(229, 72, 77, .4); }
.map-box.tall { min-height: 320px; }
.row.gap8 { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; }

/* v11.7: фильтр «Без «всё в норме»» в лентах рапортов */
.filters .ok-filter { flex-shrink: 0; white-space: nowrap; margin-left: auto; padding-right: 4px; }
.filters .ok-filter .txt { font-size: 13px; color: var(--muted); }
.filters .ok-filter input:checked ~ .txt { color: var(--brand-2); font-weight: 600; }

/* v11.8: кнопка «Собрать рапорт» (конструктор текста из умных кнопок) */
.smart-build { text-align: center; }
.smart-build .hint { text-align: center; }
.smart-preview { display: block; margin: 12px 0 0; padding: 12px 14px; text-align: left;
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px;
  font-family: inherit; font-size: 13px; line-height: 1.5; white-space: pre-wrap;
  color: var(--text); max-height: 220px; overflow: auto; }
.center { text-align: center; }

/* ===== v11.10: автозакрытие «всё в норме», быстрое закрытие, липкая панель мастера ===== */
.ok-auto-card { border-color: rgba(48,164,108,.45); background: linear-gradient(180deg, var(--ok-bg), var(--surface) 72%); }
.btn.ok { background: var(--ok); color: #fff; border: 1px solid var(--ok); }
.btn.ok:hover { filter: brightness(1.06); }
.btn.ok:disabled { opacity: .55; cursor: default; }

/* ===== v11.15: планировщик задач и проверки сотрудников ===== */
.pq-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pq-cal { border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; min-height: 62px; text-align: center; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.pq-cal:hover { border-color: var(--brand); }
.pq-cal.today { border-color: var(--brand); font-weight: 700; }
.pq-cal.sel { background: var(--brand-bg, rgba(59,130,246,.12)); border-color: var(--brand); }
.pq-cal.other { opacity: .38; }
.pq-cal-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin: 2px 1px 0; }
.pq-cal-dot.done { background: var(--ok); }
.pq-cal-dot.cancel { background: var(--muted, #8b8d98); }
.pq-plan { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.pq-plan + .pq-plan { margin-top: 8px; }
.pq-plan.done { border-left-color: var(--ok); opacity: .75; }
.pq-plan.cancel { border-left-color: var(--muted, #8b8d98); opacity: .55; }
.pq-chk-item { display: flex; gap: 8px; align-items: flex-start; padding: 7px 4px; border-bottom: 1px dashed var(--line); }
.pq-chk-item:last-child { border-bottom: 0; }
.pq-chk-item.bad { background: rgba(229,72,77,.07); border-radius: 8px; }
