/* ДезКонтроль — дизайн-система. Светлая/тёмная тема через data-theme. */

:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --surface: #fffefb;
  --surface-2: #f0efe9;
  --ink: #171512;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e3e1d8;
  --brand: #b45309;          /* янтарь — яичный профиль хозяйства */
  --brand-ink: #fff;
  --brand-soft: #f6e8d4;
  --accent-green: #1d6b43;
  --ok: #0a7d2c;
  --ok-soft: #e0f2e4;
  --bad: #c22f2f;
  --bad-soft: #fbe4e4;
  --warn: #9a6700;
  --warn-soft: #fdf0d3;
  --sidebar-bg: #12291d;
  --sidebar-ink: #d9e5da;
  --sidebar-active: #1e4230;
  --chart-s1: #2a78d6;       /* серия «верные проходы» */
  --chart-s2: #d03b3b;       /* серия «нарушения» */
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --shadow: 0 1px 2px rgba(23,21,18,.06), 0 8px 24px rgba(23,21,18,.07);
}
:root:not([data-theme="light"]) {
  /* тёмная тема по настройке браузера */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1b1b19;
    --surface-2: #242422;
    --ink: #f2f1ec;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --line: #2e2e2b;
    --brand: #e08a2e;
    --brand-ink: #1b1206;
    --brand-soft: #33261440;
    --accent-green: #4eb37c;
    --ok: #35b45e;
    --ok-soft: #12351d;
    --bad: #e66060;
    --bad-soft: #3a1a1a;
    --warn: #d9a514;
    --warn-soft: #33290f;
    --sidebar-bg: #0d1f16;
    --sidebar-ink: #c9d6ca;
    --sidebar-active: #1c3a29;
    --chart-s1: #3987e5;
    --chart-s2: #d03b3b;
    --chart-grid: #2c2c2a;
    --chart-axis: #383835;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1b1b19;
  --surface-2: #242422;
  --ink: #f2f1ec;
  --ink-2: #c3c2b7;
  --muted: #8f8d86;
  --line: #2e2e2b;
  --brand: #e08a2e;
  --brand-ink: #1b1206;
  --brand-soft: #33261440;
  --accent-green: #4eb37c;
  --ok: #35b45e;
  --ok-soft: #12351d;
  --bad: #e66060;
  --bad-soft: #3a1a1a;
  --warn: #d9a514;
  --warn-soft: #33290f;
  --sidebar-bg: #0d1f16;
  --sidebar-ink: #c9d6ca;
  --sidebar-active: #1c3a29;
  --chart-s1: #3987e5;
  --chart-s2: #d03b3b;
  --chart-grid: #2c2c2a;
  --chart-axis: #383835;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
}
.side-logo svg { width: 40px; height: 40px; flex-shrink: 0; }
.side-logo .t1 { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .2px; }
.side-logo .t2 { font-size: 12px; opacity: .75; margin-top: 1px; }
.nav { padding: 8px 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  font-size: 14.5px; opacity: .85; margin-bottom: 2px;
}
.nav a svg { width: 19px; height: 19px; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.07); opacity: 1; }
.nav a.active { background: var(--sidebar-active); opacity: 1; color: #fff; font-weight: 600; }
.side-foot { padding: 14px 18px; font-size: 11.5px; opacity: .55; line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; }
.demo-badge {
  font-size: 12px; font-weight: 600; color: var(--warn);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  padding: 4px 10px; border-radius: 999px;
}
.content { padding: 26px 28px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- контролы ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: var(--brand-ink);
  border: none; border-radius: 9px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: filter .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line);
}
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 9px;
  width: 36px; height: 36px; cursor: pointer; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }
select, input[type=text], input[type=password] {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; font-size: 14px; font-family: inherit;
}
select:focus, input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filters .lbl { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg a { padding: 7px 14px; font-size: 13.5px; color: var(--ink-2); background: var(--surface); }
.seg a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* ---------- карточки ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px;
}
.kpi .lab { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.kpi .val { font-size: 32px; font-weight: 700; letter-spacing: -.5px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.kpi .val.ok { color: var(--ok); }
.kpi .val.bad { color: var(--bad); }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.card h3 .hint { font-weight: 400; font-size: 12.5px; color: var(--muted); margin-left: 8px; }

/* ---------- бейджи и таблицы ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge.ok  { color: var(--ok);  background: var(--ok-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }
.badge.demo { color: var(--muted); background: var(--surface-2); font-weight: 500; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); font-weight: 600; padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { font-variant-numeric: tabular-nums; }

/* ---------- камеры ---------- */
.cam-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cam-card { overflow: hidden; padding: 0; }
.cam-shot { position: relative; aspect-ratio: 16/9; background: var(--surface-2); }
.cam-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-shot .ph {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px;
}
.cam-shot .ph svg { width: 34px; height: 34px; opacity: .6; }
.cam-live {
  position: absolute; top: 10px; left: 10px;
}
.cam-body { padding: 14px 16px; }
.cam-body .nm { font-weight: 700; }
.cam-body .loc { font-size: 13px; color: var(--ink-2); margin: 2px 0 10px; }
.cam-meta { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.cam-meta b { color: var(--ink); font-weight: 600; }

/* ---------- клипы ---------- */
.clip-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.clip-card { overflow: hidden; padding: 0; cursor: pointer; transition: transform .12s; }
.clip-card:hover { transform: translateY(-2px); }
.clip-thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.clip-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.clip-thumb .play span {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center;
}
.clip-body { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; }
.clip-body .t { font-size: 13.5px; }
.clip-body .t b { display: block; }
.clip-body .t span { color: var(--muted); font-size: 12.5px; }

/* ---------- модал плеера ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(10,10,8,.72);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: 16px; overflow: hidden;
  max-width: 960px; width: 100%; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; padding: 14px 18px; }
.modal-head .t { font-weight: 700; flex: 1; }
.modal-box video { width: 100%; display: block; background: #000; }

/* ---------- графики ---------- */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 30;
  background: var(--ink); color: var(--bg);
  font-size: 12.5px; padding: 7px 10px; border-radius: 8px;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap; display: none; box-shadow: var(--shadow);
}
.chart-tip b { font-weight: 700; }
.legend { display: flex; gap: 18px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend .it { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

details.tblview { margin-top: 12px; }
details.tblview summary { font-size: 12.5px; color: var(--muted); cursor: pointer; }

/* ---------- логин ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 500px at 80% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
    radial-gradient(800px 500px at -10% 110%, color-mix(in srgb, var(--accent-green) 12%, transparent), transparent),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 34px 34px 28px;
}
.login-card .logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.login-card .logo-row svg { width: 52px; height: 52px; }
.login-card h1 { font-size: 21px; }
.login-card .sub { color: var(--ink-2); font-size: 13.5px; margin: 2px 0 22px; }
.login-card label { display: block; font-size: 13px; color: var(--ink-2); margin: 14px 0 6px; }
.login-card input { width: 100%; padding: 11px 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 12px; }
.login-err {
  background: var(--bad-soft); color: var(--bad);
  font-size: 13.5px; padding: 10px 12px; border-radius: 9px; margin-top: 16px;
}
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 20px; line-height: 1.5; }

/* ---------- анализ ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.job-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.job-row:last-child { border-bottom: none; }
.job-main { flex: 1; min-width: 0; }
.job-main .nm { font-weight: 600; font-size: 14px; }
.job-main .st { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.empty {
  text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px;
}
.mt { margin-top: 18px; }
.pager { display: flex; gap: 8px; margin-top: 16px; align-items: center; font-size: 13.5px; color: var(--muted); }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.pager a.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 18px 14px; }
}
