:root {
  --bg: #0a0d14;
  --bg2: #0f1420;
  --card: #131a29;
  --card2: #182134;
  --line: #222c40;
  --text: #e6eaf2;
  --muted: #8a94a8;
  --accent: #8b5cf6;
  --accent2: #a78bfa;
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --blue: #38bdf8;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif; font-size: 15px; }
a { color: inherit; text-decoration: none; }
.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal;
  font-size: 22px; line-height: 1; display: inline-block; vertical-align: middle;
  font-variation-settings: "FILL" 1, "wght" 500; -webkit-font-smoothing: antialiased; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 8px 24px -8px #8b5cf6aa; }
.brand-logo .ms { font-size: 24px; color: #fff; }
.brand b { display: block; font-size: 17px; letter-spacing: -.2px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  padding: 14px 12px 8px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px;
  color: #c3cad8; font-weight: 500; margin-bottom: 2px; transition: .15s; }
.nav a:hover { background: var(--card); color: #fff; }
.nav a.on { background: linear-gradient(90deg, #8b5cf633, #8b5cf60d); color: #fff;
  box-shadow: inset 3px 0 0 var(--accent); }
.nav a.on .ms { color: var(--accent2); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 13px;
  color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.side-foot form { margin: 0; }
.side-foot button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.side-foot button:hover { color: var(--red); background: #ef444415; }
.main { padding: 28px 34px 50px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: -.5px; }
.top p { margin: 4px 0 0; color: var(--muted); }
.mobile-bar { display: none; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--line); gap: 10px; }
.card-h h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.stat { padding: 18px 20px; display: flex; gap: 16px; align-items: center; }
.stat-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.stat-ic .ms { font-size: 26px; }
.stat b { font-size: 28px; display: block; letter-spacing: -.5px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.ic-violet { background: #8b5cf622; color: var(--accent2); }
.ic-blue { background: #38bdf822; color: var(--blue); }
.ic-amber { background: #f59e0b22; color: var(--amber); }
.ic-green { background: #22c55e22; color: var(--green); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit;
  font-weight: 500; font-size: 14px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: #3a4560; background: #1d283d; }
.btn .ms { font-size: 19px; }
.btn-p { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-p:hover { background: #7c4ef0; border-color: #7c4ef0; }
.btn-d:hover { background: #ef444422; border-color: var(--red); color: #fca5a5; }
.btn.on { background: #8b5cf62a; border-color: var(--accent); color: #fff; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; }
.b-green { background: #22c55e1f; color: #4ade80; }
.b-red { background: #ef44441f; color: #f87171; }
.b-amber { background: #f59e0b1f; color: #fbbf24; }
.b-blue { background: #38bdf81f; color: #7dd3fc; }
.b-violet { background: #8b5cf61f; color: #c4b5fd; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------- video ---------- */
.video { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; }
.video img { width: 100%; height: 100%; object-fit: contain; display: block; }
.video .ov { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; }
.video .ov-r { left: auto; right: 12px; }
.video .live-tag { background: #ef4444; color: #fff; font-weight: 700; font-size: 11px; letter-spacing: 1px;
  padding: 4px 9px; border-radius: 6px; display: flex; align-items: center; gap: 6px; }
.video .name-tag { background: #000a; backdrop-filter: blur(6px); color: #fff; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 6px; }
.video .err { position: absolute; inset: 0; display: none; place-items: center; text-align: center;
  color: var(--muted); background: #05070bdd; padding: 20px; }
.video.failed .err { display: grid; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; }
.cam-tile { transition: .15s; display: block; }
.cam-tile:hover { transform: translateY(-2px); }
.cam-tile:hover .video { box-shadow: 0 0 0 2px var(--accent); }
.cam-tile .meta { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px 0; }

/* ---------- events ---------- */
.ev-list { display: flex; flex-direction: column; }
.ev-row { display: flex; gap: 14px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.ev-row:last-child { border-bottom: 0; }
.ev-row:hover { background: var(--card2); }
.ev-row img { width: 96px; height: 54px; object-fit: cover; border-radius: 8px; flex: none; background: #000; }
.ev-row b { display: block; font-size: 14px; }
.ev-row small { color: var(--muted); }
.ev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.ev-card { overflow: hidden; cursor: zoom-in; transition: .15s; }
.ev-card:hover { border-color: #3a4560; transform: translateY(-2px); }
.ev-card .thumb { aspect-ratio: 16/9; background: #000; position: relative; }
.ev-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-card .thumb .badge { position: absolute; top: 8px; left: 8px; backdrop-filter: blur(6px); background: #000a; }
.ev-card .info { padding: 12px 14px; }
.ev-card .info b { font-size: 14px; }
.ev-card .info .row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.layout-ev { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.days a { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.days a:hover { background: var(--card2); }
.days a.on { background: #8b5cf622; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.days a small { color: var(--muted); }
.days { max-height: 70vh; overflow-y: auto; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar input[type=date] { background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 8px 12px; font: inherit; color-scheme: dark; }
.seg { display: inline-flex; background: var(--card2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg a { padding: 6px 13px; border-radius: 8px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.seg a.on { background: var(--accent); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .ms { font-size: 48px; opacity: .5; display: block; margin-bottom: 10px; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

/* lightbox */
.lb { position: fixed; inset: 0; background: #000e; z-index: 50; display: none; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px; }
.lb.open { display: flex; }
.lb img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 10px; }
.lb .lb-bar { display: flex; gap: 10px; align-items: center; margin-top: 14px; color: #ddd; flex-wrap: wrap; justify-content: center; }
.lb .x { position: absolute; top: 16px; right: 20px; }

/* week chart */
.chart { display: flex; gap: 10px; align-items: flex-end; height: 150px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; min-height: 4px;
  background: linear-gradient(180deg, #a78bfa, #7c3aed); }
.chart .col.today .bar { background: linear-gradient(180deg, #f472b6, #db2777); }
.chart small { color: var(--muted); font-size: 12px; }
.chart b { font-size: 12px; }

.msg { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.msg.success { background: #22c55e1a; color: #86efac; border: 1px solid #22c55e44; }
.msg.error { background: #ef44441a; color: #fca5a5; border: 1px solid #ef444444; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; }
.kv span { color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1000px 500px at 20% 0%, #8b5cf62e, transparent), radial-gradient(800px 500px at 100% 100%, #ec48991f, transparent), var(--bg); }
.login { width: 100%; max-width: 400px; padding: 34px; }
.login h1 { margin: 18px 0 4px; font-size: 24px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; outline: none; }
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #8b5cf633; }
.login .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; width: 260px; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax #0009; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
    background: var(--bg2); position: sticky; top: 0; z-index: 30; }
  .mobile-bar button { background: none; border: 0; color: var(--text); padding: 4px; }
  .main { padding: 20px 16px 40px; }
  .cam-grid { grid-template-columns: 1fr; }
  .layout-ev { grid-template-columns: 1fr; }
  .days { max-height: none; display: flex; overflow-x: auto; }
  .days a { flex-direction: column; border: 0; white-space: nowrap; }
  .ev-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .top h1 { font-size: 22px; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; gap: 12px; } .stat { padding: 14px; gap: 12px; }
  .stat b { font-size: 22px; } .stat-ic { width: 40px; height: 40px; } }
