/* Sentinel VMS - control-room UI */
:root {
  --bg: #0b0f14;
  --panel: #111823;
  --panel-2: #172232;
  --panel-3: #1e2b3d;
  --line: #24344a;
  --line-soft: #1a2534;
  --text: #e6edf5;
  --muted: #8ea1b8;
  --faint: #5d7086;
  --accent: #2dd4bf;
  --accent-dim: #16a394;
  --info: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #223047; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e405c; }

/* ---------------------------------------------------------------- boot */
.boot { height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- login */
.login-wrap { height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #12202e 0%, var(--bg) 60%); }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px 28px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.login-brand svg { flex: none; }
.login-brand h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* --------------------------------------------------------------- shell */
.shell { height: 100vh; display: grid; grid-template-rows: 52px 1fr; }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600;
  letter-spacing: .2px; white-space: nowrap; }
.brand span { font-size: 15px; }
.nav { display: flex; gap: 2px; height: 100%; }
.nav button {
  background: none; border: 0; padding: 0 15px; height: 100%; cursor: pointer;
  color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
}
.nav button:hover { color: var(--text); }
.nav button.active { color: var(--text); border-bottom-color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 7px rgba(34,197,94,.65); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.dot.live { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-weight: 500; transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #31465f; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #04231f; font-weight: 600; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.danger { color: #ffc9c9; border-color: #5b2626; background: #2a1516; }
.btn.danger:hover { background: #3a1c1d; border-color: #7a3030; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.icon { padding: 6px; width: 30px; height: 30px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- inputs */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted);
  margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.45; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 11px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); outline: none; }
textarea { resize: vertical; min-height: 62px; font-family: var(--mono); font-size: 12.5px; }
select { cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--text); font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--accent-dim); cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- views */
.view { overflow: auto; height: 100%; }
.page { padding: 22px 24px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.page-head .spacer { flex: 1; }
.section { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.section-head { padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px; }
.section-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.section-head .spacer { flex: 1; }
.section-body { padding: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty h4 { margin: 0 0 6px; color: var(--text); font-size: 15px; }

/* -------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--faint); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.022); }
.tbl-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11.5px;
  background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); }
.tag.brand { text-transform: capitalize; }
.tag.ok { background: rgba(34,197,94,.12); color: #7ee2a8; border-color: rgba(34,197,94,.3); }
.tag.err { background: rgba(239,68,68,.1); color: #fca5a5; border-color: rgba(239,68,68,.3); }
.tag.warn { background: rgba(245,158,11,.1); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.tag.info { background: rgba(56,189,248,.1); color: #7dd3fc; border-color: rgba(56,189,248,.3); }

/* ----------------------------------------------------------- live view */
.live { display: grid; grid-template-columns: 252px 1fr; height: 100%; overflow: hidden; }
.live.collapsed { grid-template-columns: 0 1fr; }
.cam-panel { background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden; }
.cam-panel-head { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.cam-search { width: 100%; padding: 6px 10px; font-size: 13px; }
.cam-list { overflow-y: auto; flex: 1; padding: 6px; }
.cam-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--faint); padding: 11px 8px 5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; }
.cam-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; cursor: pointer;
  border-radius: var(--radius-sm); user-select: none; font-size: 13.5px;
}
.cam-item:hover { background: var(--panel-2); }
.cam-item.playing { background: rgba(45,212,191,.1); color: var(--accent); }
.cam-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-item .ptz-badge { margin-left: auto; font-size: 10px; color: var(--faint);
  border: 1px solid var(--line); padding: 0 4px; border-radius: 3px; }
.cam-panel-foot { padding: 9px 12px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--faint); }

.stage { display: flex; flex-direction: column; overflow: hidden; background: #070a0e; }
.stage-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stage-bar .spacer { flex: 1; }
.layout-btns { display: flex; gap: 3px; background: var(--bg); padding: 3px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); }
.layout-btns button { background: none; border: 0; padding: 4px 9px; cursor: pointer;
  color: var(--muted); border-radius: 5px; font-size: 12.5px; font-weight: 600; }
.layout-btns button:hover { color: var(--text); background: var(--panel-2); }
.layout-btns button.active { background: var(--accent-dim); color: #04231f; }
.layout-btns button.custom { font-size: 15px; padding: 4px 8px; letter-spacing: 1px; }

/* Dense walls: the tile chrome shrinks so the picture keeps the space. */
.grid.dense { gap: 2px; padding: 2px; }
.grid.dense .tile { border-radius: 4px; }
.grid.dense .tile-bar { padding: 4px 6px; font-size: 11px; gap: 5px; }
.grid.dense .tile-bar .acts { gap: 3px; }
.grid.dense .tile-bar .acts button { width: 20px; height: 20px; }
.grid.dense .tile-state { display: none; }
.grid.dense .tile-placeholder { font-size: 11px; }
.grid.dense .tile-placeholder svg { display: none; }

.grid { flex: 1; display: grid; gap: 3px; padding: 3px; overflow: hidden; }
.tile {
  position: relative; background: #0d1117; border: 1px solid var(--line-soft);
  border-radius: 6px; overflow: hidden; display: grid; place-items: center;
  min-height: 0; min-width: 0;
}
.tile.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile.empty-tile { cursor: pointer; }
.tile.empty-tile:hover { background: #10161f; border-color: var(--line); }
.tile-placeholder { text-align: center; color: #33455c; font-size: 12.5px;
  pointer-events: none; padding: 8px; }
.tile-placeholder svg { display: block; margin: 0 auto 7px; opacity: .6; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
vms-stream { width: 100%; height: 100%; display: block; position: relative; }
.tile-bar {
  position: absolute; left: 0; right: 0; top: 0; padding: 7px 9px;
  display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  background: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,0));
  opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 3;
}
.tile:hover .tile-bar, .tile.selected .tile-bar { opacity: 1; }
.tile-bar .nm { font-weight: 600; text-shadow: 0 1px 3px #000;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-bar .acts { margin-left: auto; display: flex; gap: 4px; pointer-events: auto; }
.tile-bar .acts button {
  background: rgba(15,23,34,.8); border: 1px solid rgba(255,255,255,.12);
  color: #cfe0f0; width: 25px; height: 25px; border-radius: 5px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.tile-bar .acts button:hover { background: var(--accent-dim); color: #04231f; }
.tile-state { position: absolute; bottom: 7px; left: 9px; font-size: 11px;
  color: var(--faint); font-family: var(--mono); z-index: 3; pointer-events: none;
  text-shadow: 0 1px 2px #000; }
.tile-err { color: #fca5a5; font-size: 12.5px; text-align: center; padding: 14px;
  max-width: 90%; }

/* PTZ pad */
.ptz {
  position: absolute; right: 9px; bottom: 9px; z-index: 4;
  display: grid; grid-template-columns: repeat(3, 26px); grid-auto-rows: 26px; gap: 3px;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .ptz, .tile.selected .ptz { opacity: 1; }
.ptz button {
  background: rgba(15,23,34,.82); border: 1px solid rgba(255,255,255,.12);
  color: #cfe0f0; border-radius: 5px; cursor: pointer; display: grid;
  place-items: center; padding: 0; font-size: 13px; line-height: 1;
}
.ptz button:hover { background: var(--accent-dim); color: #04231f; }
.ptz button:active { background: var(--accent); }
.ptz .zoom { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }

/* ------------------------------------------------------- playback view */
.pb-date, .pb-time { padding: 5px 8px; font-size: 12.5px; width: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); color-scheme: dark; }
.pb-clock { font-family: var(--mono); font-size: 12px; color: var(--muted);
  white-space: nowrap; }

.timeline { border-top: 1px solid var(--line); background: var(--panel);
  padding: 7px 12px 10px; max-height: 34vh; overflow-y: auto; flex: none; }
.tl-head { display: flex; align-items: center; height: 15px; margin-bottom: 3px; }
.tl-ticks { position: relative; flex: 1; height: 15px; }
.tl-ticks span { position: absolute; top: 0; transform: translateX(-50%);
  font-size: 10px; color: var(--faint); font-family: var(--mono); }
.tl-ticks span:first-child { transform: none; }
.tl-ticks span:last-child { transform: translateX(-100%); }
.tl-row { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.tl-label { width: 104px; flex: none; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; flex: 1; height: 20px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px; cursor: crosshair;
  overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: rgba(45,212,191,.55);
  border-left: 1px solid rgba(45,212,191,.9); }
.tl-seg:hover { background: rgba(45,212,191,.8); }
.tl-cursor { position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: #fbbf24; box-shadow: 0 0 5px rgba(251,191,36,.8); pointer-events: none; }
.tl-note { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--faint); pointer-events: none; }
.tl-note.err { color: #fca5a5; }

/* --------------------------------------------------------------- modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(4,7,11,.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  animation: fade .13s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal.wide { max-width: 760px; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 9px; justify-content: flex-end; align-items: center; }
.modal-foot .spacer { flex: 1; }

/* --------------------------------------------------------------- toast */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font-size: 13.5px; animation: slide .18s ease-out; display: flex; gap: 9px;
}
@keyframes slide { from { transform: translateX(18px); opacity: 0; } }
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast .tx { flex: 1; word-break: break-word; }

/* ---------------------------------------------------------- stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 13px; }
.stat { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--faint); font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 650; margin-top: 5px; letter-spacing: -.4px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 5px; background: var(--bg); border-radius: 3px; margin-top: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent-dim); border-radius: 3px; }
.bar i.warn { background: var(--warn); }
.bar i.err { background: var(--err); }

/* ------------------------------------------------------------ site row */
.site-card { border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 13px; overflow: hidden; }
.site-head { padding: 13px 16px; display: flex; align-items: center; gap: 11px;
  flex-wrap: wrap; }
.site-head h4 { margin: 0; font-size: 14.5px; font-weight: 600; }
.site-head .spacer { flex: 1; }
.site-meta { padding: 0 16px 14px; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 11px 18px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--faint); font-weight: 600; }
.kv .v { font-family: var(--mono); font-size: 12.5px; margin-top: 3px; word-break: break-all; }

pre.conf { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  line-height: 1.65; margin: 0; white-space: pre; color: #cbd9e8; }
.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding-left: 30px;
  margin-bottom: 11px; font-size: 13.5px; color: var(--muted); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%; background: var(--panel-3);
  color: var(--accent); font-size: 11.5px; font-weight: 700; display: grid;
  place-items: center; border: 1px solid var(--line);
}
.steps li b { color: var(--text); font-weight: 600; }

.fs-hint { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(15,23,34,.9); border: 1px solid var(--line); padding: 6px 13px;
  border-radius: 999px; font-size: 12.5px; color: var(--muted); z-index: 50; }

@media (max-width: 780px) {
  .live { grid-template-columns: 1fr; }
  .cam-panel { position: absolute; z-index: 20; width: 252px; height: calc(100% - 52px);
    box-shadow: var(--shadow); }
  .live.collapsed .cam-panel { display: none; }
  .nav button { padding: 0 10px; font-size: 13px; }
  .brand span { display: none; }
  .page { padding: 16px 14px 50px; }
}
