/* ============================================================
   СТРАЖ ПРО - система мониторинга и контроля доступа
   Общая дизайн-система. Палитра снята со скриншотов-концептов:
   near-black фон, ярко-красный акцент, зелёный статус доступа,
   угловатые «тактические» панели.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* поверхности */
  --bg:        #080a0e;
  --bg-2:      #0b0e13;
  --panel:     #11151c;
  --panel-2:   #161b23;
  --panel-3:   #1c222c;
  --header:    #0c0f15;

  /* текст */
  --fg:        #eef2f7;
  --muted:     #8b929e;
  --faint:     #5b626d;

  /* акценты */
  --red:       #e11d2a;
  --red-bright:#ff2b3a;
  --red-deep:  #8c1019;
  --red-grad:  linear-gradient(180deg, #e11d2a 0%, #98121c 100%);
  --teal:      #2dd4bf;
  --green:     #28c46c;
  --green-deep:#0f6f3d;
  --amber:     #f0a82a;

  /* линии */
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.12);
  --border-red:rgba(225,29,42,0.55);

  /* размеры */
  --rad:       10px;
  --rad-sm:    8px;
  --sidebar-w: 250px;
  --topbar-h:  66px;

  --shadow:    0 18px 50px rgba(0,0,0,0.55);
  --font-disp: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* фоновая тактическая текстура */
body.app-bg {
  background:
    linear-gradient(180deg, #080a0e 0%, #07090d 100%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--red); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232a34; border-radius: 2px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e3742; }

/* ---------- общие утилиты ---------- */
.disp { font-family: var(--font-disp); letter-spacing: .02em; }
.mono { font-family: var(--font-mono); }
.up   { text-transform: uppercase; letter-spacing: .14em; }

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
}

.clip { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px)); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  font-family: var(--font-disp); font-weight: 600; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--border-2); border-radius: var(--rad-sm);
  background: var(--panel-2); color: var(--fg);
  transition: .16s ease;
}
.btn:hover { border-color: var(--border-red); background: var(--panel-3); }
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  background: var(--red-grad); border: 1px solid rgba(255,255,255,0.08); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--rad-sm);
  color: var(--muted); transition: .16s;
}
.btn-icon:hover { color: var(--fg); border-color: var(--border-red); }
.btn-icon svg { width: 18px; height: 18px; }

/* ---------- панели ---------- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--rad);
}
.panel::before {
  display: none;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
}
.panel-head h3 {
  font-family: var(--font-disp); font-weight: 700; font-size: 14px;
  letter-spacing: .075em; text-transform: uppercase;
}
.panel-head .dot { width: 8px; height: 8px; border-radius: 1px; background: var(--red); box-shadow: none; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 12px; }

/* ---------- статус-бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 7px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
}
.badge .pip { width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.badge-ok   { color: #5fe39a; background: rgba(40,196,108,0.12); border: 1px solid rgba(40,196,108,0.3); }
.badge-deny { color: #ff6b76; background: rgba(225,29,42,0.12); border: 1px solid rgba(225,29,42,0.35); }
.badge-warn { color: #ffce6b; background: rgba(240,168,42,0.12); border: 1px solid rgba(240,168,42,0.3); }
.badge-idle { color: var(--muted);  background: rgba(255,255,255,0.05); border: 1px solid var(--border); }

/* ============================================================
   APP SHELL - сайдбар + топбар
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, #0c0f15 0%, #080a0e 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 20;
}
.sb-brand { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.sb-brand .logo-mark { width: 40px; height: 40px; flex: none; }
.logo-img { display: block; object-fit: contain; }
.sb-brand .logo-txt { font-family: var(--font-disp); font-weight: 700; font-size: 19px; letter-spacing: .01em; }
.sb-brand .logo-txt b { color: var(--red); }
.sb-brand .logo-sub { font-size: 9px; letter-spacing: .18em; color: var(--faint); text-transform: uppercase; }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px 12px; }
.sb-group { font-family: var(--font-mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 8px; }
.sb-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 39px; padding: 9px 12px; border-radius: var(--rad-sm); color: var(--muted);
  font-weight: 500; font-size: 13px; position: relative; transition: .14s;
}
.sb-link svg { width: 19px; height: 19px; flex: none; }
.sb-link:hover { background: rgba(255,255,255,0.04); color: var(--fg); }
.sb-link.active { background: linear-gradient(90deg, rgba(225,29,42,0.25), rgba(225,29,42,0.04)); color: #ff4b57; box-shadow: inset 0 0 0 1px rgba(225,29,42,.22), 0 0 18px rgba(225,29,42,.12); }
.sb-link.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--red); border-radius: 0 3px 3px 0; box-shadow: 0 0 10px var(--red); }
.sb-link .tag { margin-left: auto; font-family: var(--font-mono); font-size: 10px; padding: 1px 7px; border-radius: 2px; background: var(--red); color: #fff; }
.sb-foot { padding: 14px; border-top: 1px solid var(--border); }
.sb-emblem {
  position: relative;
  height: 126px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(225,29,42,.16);
  border-radius: var(--rad);
  background:
    linear-gradient(90deg, transparent 0 28%, rgba(225,29,42,.10) 28% 29%, transparent 29%),
    linear-gradient(180deg, transparent 0 58%, rgba(225,29,42,.12) 58% 59%, transparent 59%),
    #090b10;
}
.sb-emblem .logo-mark {
  width: 78px;
  height: 78px;
  opacity: .18;
}
.sb-emblem span,
.sb-emblem i,
.sb-emblem b {
  position: absolute;
  display: block;
  background: rgba(225,29,42,.36);
}
.sb-emblem span { left: 16px; right: 22px; bottom: 24px; height: 1px; }
.sb-emblem i { left: 32px; top: 36px; width: 1px; bottom: 24px; }
.sb-emblem b { right: 36px; top: 28px; width: 1px; height: 54px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--rad-sm); }
.sb-user .av { width: 36px; height: 36px; border-radius: var(--rad-sm); background: var(--panel-2); display: grid; place-items: center; font-family: var(--font-disp); font-weight: 700; color: var(--red); border: 1px solid var(--border); }
.sb-user .nm { font-weight: 600; font-size: 13px; }
.sb-user .rl { font-size: 11px; color: var(--faint); }

/* main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; height: var(--topbar-h); z-index: 15;
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
}
.tb-heading h1 {
  font-family: var(--font-disp);
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.01em;
}
.tb-heading p { margin-top: 5px; font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.tb-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; width: 260px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--rad-sm); color: var(--muted); }
.tb-search input { flex: 1; background: none; border: none; color: var(--fg); outline: none; font-size: 13px; }
.tb-search svg { width: 16px; height: 16px; }
.tb-clock { text-align: right; font-family: var(--font-mono); }
.tb-clock .t { font-size: 18px; font-weight: 700; color: var(--fg); letter-spacing: .04em; }
.tb-clock .d { font-size: 11px; color: var(--faint); }
.tb-stat { display: flex; align-items: center; gap: 8px; padding: 0 14px; border-left: 1px solid var(--border); height: 38px; }
.tb-stat .dot { width: 8px; height: 8px; border-radius: 1px; background: var(--green); box-shadow: none; animation: pulse 2s infinite; }
.tb-stat span { font-size: 12px; color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.tb-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
}
.tb-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
}
.tb-item svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.tb-sep {
  width: 1px;
  height: 34px;
  background: var(--border);
}
.tb-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tb-profile strong {
  display: block;
  font-size: 12px;
  color: var(--fg);
  font-weight: 600;
}
.tb-profile span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.content { flex: 1; padding: 14px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-disp); font-weight: 700; font-size: 26px; letter-spacing: .03em; text-transform: uppercase; }
.page-head .spacer { flex: 1; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--rad); padding: 10px 12px 11px;
  min-height: 74px;
}
.kpi::after { display: none; }
.kpi .ic { width: 28px; height: 28px; border-radius: var(--rad-sm); display: grid; place-items: center; background: rgba(225,29,42,0.10); color: var(--red); margin-bottom: 8px; border: 1px solid rgba(225,29,42,0.24); }
.kpi .ic svg { width: 16px; height: 16px; }
.kpi .val { font-family: var(--font-disp); font-weight: 700; font-size: 26px; line-height: 1; letter-spacing: .01em; }
.kpi .lbl { font-size: 10px; color: var(--muted); margin-top: 5px; text-transform: uppercase; letter-spacing: .07em; }
.kpi .trend { position: absolute; top: 10px; right: 12px; font-family: var(--font-mono); font-size: 10px; }
.kpi .trend.up { color: var(--green); }
.kpi .trend.down { color: #ff6b76; }
.kpi.green .ic { background: rgba(40,196,108,0.12); color: var(--green); border-color: rgba(40,196,108,0.25); }
.kpi.green::after { display: none; }
.kpi.amber .ic { background: rgba(240,168,42,0.12); color: var(--amber); border-color: rgba(240,168,42,0.25); }

/* ---------- таблицы ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--fg); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.025); }
.tbl .who { display: flex; align-items: center; gap: 10px; }
.tbl .who .av { width: 32px; height: 32px; border-radius: 2px; object-fit: cover; border: 1px solid var(--border); flex:none; }
.tbl .who .nm { font-weight: 600; }
.tbl .who .id { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.tbl .t-time { font-family: var(--font-mono); color: var(--muted); }

/* ---------- сетки ---------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- камеры ---------- */
.cam {
  position: relative; aspect-ratio: 16/10; border-radius: var(--rad-sm); overflow: hidden;
  background: #05070a; border: 1px solid var(--border);
  display: block; padding: 0; color: inherit; text-align: left; appearance: none;
}
.cam.is-clickable { cursor: zoom-in; }
.cam.is-clickable:hover { border-color: var(--border-red); }
.cam img { width: 100%; height: 100%; object-fit: cover; filter: contrast(1.05) saturate(.85); }
.cam .ph { width:100%; height:100%; background: repeating-linear-gradient(0deg,#0a0d12,#0a0d12 2px,#0c1016 2px,#0c1016 4px); display:grid; place-items:center; color:var(--faint); }
.cam .cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; padding: 7px 9px; font-family: var(--font-mono); font-size: 10px; background: linear-gradient(180deg, rgba(0,0,0,.72), transparent); }
.cam .live {
  display: flex; align-items: center; gap: 5px;
  color: #ff6b76; letter-spacing: .1em;
  background: rgba(225,29,42,.22);
  border: 1px solid rgba(225,29,42,.45);
  border-radius: 5px;
  padding: 2px 5px;
}
.cam .live .pip { width: 6px; height: 6px; border-radius: 1px; background: var(--red); animation: pulse 1.4s infinite; }
.cam .cam-bot { position: absolute; bottom: 0; left: 0; right: 0; padding: 7px 9px; font-family: var(--font-mono); font-size: 10px; color: #cfd4db; background: linear-gradient(0deg, rgba(0,0,0,.78), transparent); display:flex; align-items:center; gap:6px; }
.cam .scan { display: none; }
@keyframes scan { 0% { top: 0; } 100% { top: 100%; } }

/* enlarged CCTV preview */
.camera-modal {
  position: fixed; inset: 0; z-index: 260; display: none; place-items: center;
  background: rgba(0,0,0,.76); backdrop-filter: blur(8px);
}
.camera-modal.open { display: grid; }
.camera-dialog {
  width: min(1160px, calc(100vw - 48px));
  background: #070a0f;
  border: 1px solid var(--border-2);
  border-radius: var(--rad);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.camera-dialog-head {
  height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--border); background: var(--header);
}
.camera-dialog-head .title { font-family: var(--font-disp); font-size: 17px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.camera-dialog-head .meta { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.camera-dialog-head .spacer { flex: 1; }
.camera-large {
  position: relative; aspect-ratio: 16/9; background: #05070a; overflow: hidden;
}
.camera-large img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: contrast(1.08) saturate(.78); }
.camera-large::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 42px 42px;
}
.camera-large-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; justify-content: space-between; gap: 12px; padding: 14px 18px;
  background: linear-gradient(0deg, rgba(0,0,0,.82), transparent);
  font-family: var(--font-mono); font-size: 12px; color: #cfd4db;
}

/* ---------- формы ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .08em; }
.input {
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 12px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--rad-sm); transition: .14s;
}
.input:focus-within { border-color: var(--border-red); box-shadow: 0 0 0 3px rgba(225,29,42,0.12); }
.input svg { width: 18px; height: 18px; color: var(--faint); }
.input input { flex: 1; background: none; border: none; outline: none; color: var(--fg); font-size: 14px; }
.input input::placeholder { color: var(--faint); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted); }
.toggle input { display: none; }
.toggle .box { width: 18px; height: 18px; border: 1px solid var(--border-2); border-radius: 1px; display: grid; place-items: center; transition: .14s; }
.toggle input:checked + .box { background: var(--red); border-color: var(--red); }
.toggle input:checked + .box::after { content: "✓"; color: #fff; font-size: 12px; }

.switch { position: relative; width: 42px; height: 24px; background: var(--panel-3); border-radius: 2px; cursor: pointer; transition: .16s; border: 1px solid var(--border); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 1px; background: var(--muted); transition: .16s; }
.switch.on { background: var(--red); border-color: var(--red); }
.switch.on::after { left: 20px; background: #fff; }

/* ---------- segmented / tabs ---------- */
.seg { display: inline-flex; padding: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--rad-sm); }
.seg button { height: 28px; padding: 0 12px; border: none; background: none; color: var(--muted); font-size: 12px; font-weight: 600; border-radius: 1px; transition: .14s; }
.seg button.active { background: var(--panel-3); color: var(--fg); }

/* select */
.sel { height: 38px; padding: 0 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--rad-sm); color: var(--fg); font-size: 13px; outline: none; }
.sel:focus { border-color: var(--border-red); }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--panel-2); border: 1px solid var(--border-red); border-radius: var(--rad-sm); padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow); transition: .22s; z-index: 200; display:flex; align-items:center; gap:10px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 18px; height: 18px; color: var(--green); }

/* responsive */
@media (max-width: 1180px) {
  :root { --sidebar-w: 76px; }
  .sb-brand .logo-txt, .sb-brand .logo-sub, .sb-link span, .sb-group, .sb-user .nm, .sb-user .rl, .sb-link .tag, .sb-emblem { display: none; }
  .sb-brand { justify-content: center; }
  .sb-link { justify-content: center; }
  .kpi-row { grid-template-columns: repeat(2,1fr); }
  .tb-search { display: none; }
}
@media (max-width: 760px) {
  .content { padding: 16px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
}
