/* ==========================================================
   Draco VMS – Demo UI
   ========================================================== */
:root {
  /* Palette inspired by the 21st.dev "Cyber Cyan" theme */
  --bg: #020811;
  --bg-2: #051424;
  --panel: rgba(6, 18, 32, 0.86);
  --panel-solid: #071423;
  --panel-head: rgba(10, 36, 54, 0.55);
  --border: rgba(60, 200, 235, 0.30);
  --border-soft: rgba(60, 200, 235, 0.14);
  --accent: #0b7aa6;          /* fills with white text (AA contrast) */
  --accent-grad: linear-gradient(90deg, #0a6690, #0e93c4);
  --accent-2: #3cedeb;        /* cyan glow, icons, links */
  --accent-glow: rgba(60, 237, 235, 0.35);
  --purple: #a78bfa;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #ef4444;
  --text: #def7fb;
  --text-2: #a9c6d3;
  --muted: #7194a8;
  --radius: 6px;
  --gap: 10px;
  --font: "Heebo", "Assistant", "Segoe UI", Arial, sans-serif;
  --mono: "Roboto Mono", "Consolas", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 75% -10%, rgba(30, 170, 220, 0.16), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(60, 237, 235, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
  font-size: 14px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  padding: 0 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 0 0 30px rgba(30, 170, 220, 0.08);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 44px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1; direction: ltr; }
.brand-text b { font-size: 21px; letter-spacing: 1.5px; font-weight: 800; }
.brand-text small { font-size: 12px; letter-spacing: 3.2px; color: var(--accent-2); font-weight: 700; margin-top: 3px; }
.brand-sep { width: 1px; height: 36px; background: var(--border); }
.brand-title { font-size: 24px; font-weight: 600; direction: ltr; }
.topbar .spacer { flex: 1; }
.top-status { display: flex; align-items: center; gap: 18px; color: var(--text-2); font-size: 13px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border-soft); background: rgba(30, 170, 220, 0.08);
  font-size: 12px; white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex: none; }
.dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.dot.blink { animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.clock { display: flex; flex-direction: column; align-items: flex-start; padding-inline-start: 18px; border-inline-start: 1px solid var(--border); }
.clock .t { font-size: 20px; font-weight: 600; }
.clock .d { font-size: 13px; color: var(--text-2); }
.user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius); }
.user:hover { background: rgba(30, 170, 220, 0.1); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--text-2); display: grid; place-items: center;
}
.user .meta { display: flex; flex-direction: column; line-height: 1.25; }
.user .meta b { font-weight: 600; font-size: 15px; }
.user .meta small { color: var(--text-2); font-size: 13px; }

/* ---------- Body: content + nav ---------- */
.body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;   /* RTL: content on the right, nav on the left (as in the mockup) */
  gap: var(--gap);
  min-height: 0;
}
.sidenav {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.sidenav a {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  color: var(--text); font-size: 15px; font-weight: 500;
  border-inline-start: 3px solid transparent;
  text-decoration: none;
  transition: background .15s;
}
.sidenav a svg.ic { width: 20px; height: 20px; }
.sidenav a:hover { background: rgba(30, 170, 220, 0.12); }
.sidenav a.active {
  background: var(--accent-grad);
  border-inline-start-color: var(--accent-2);
  box-shadow: 0 0 18px var(--accent-glow);
}
.sidenav a.small { font-size: 13px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 0 0 24px rgba(30, 170, 220, 0.06), 0 0 0 1px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
  min-height: 0;
  position: relative;
}
.panel::before {
  /* corner accent */
  content: ''; position: absolute; top: -1px; inset-inline-start: -1px;
  width: 18px; height: 18px;
  border-top: 2px solid var(--accent-2); border-inline-start: 2px solid var(--accent-2);
  border-start-start-radius: var(--radius);
  pointer-events: none; opacity: .8;
}
.panel-h {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--panel-head), transparent);
}
.panel-h h2, .panel-h h3 { font-size: 17px; font-weight: 600; white-space: nowrap; }
.panel-h .ic { color: var(--accent-2); width: 22px; height: 22px; }
.panel-h .end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.panel-b { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.panel-b.tight { gap: 4px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.label { color: var(--text-2); font-size: 13px; }
.val { font-weight: 600; }
.val.green { color: var(--green); }
.val.yellow { color: var(--yellow); }
.val.red { color: var(--red); }
.val.blue { color: var(--accent-2); }
.muted { color: var(--muted); }

.check-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.check-list li { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.check {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--green); display: grid; place-items: center; flex: none;
  box-shadow: 0 0 8px rgba(34,197,94,.5);
}
.check svg { width: 12px; height: 12px; stroke: #04210f; stroke-width: 3.2; fill: none; }
.check-o { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--green); display: grid; place-items: center; color: var(--green); flex: none; margin-inline-start: auto; }
.check-o svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 3; fill: none; }

/* Signal bars */
.signal { display: flex; align-items: flex-end; gap: 3px; height: 20px; direction: ltr; }
.signal i { width: 7px; background: var(--accent); border-radius: 1px; opacity: .35; transition: height .5s, opacity .5s; }
.signal i.on { opacity: 1; box-shadow: 0 0 6px var(--accent-glow); }
.spark { width: 100%; height: 34px; display: block; }
.spark path { fill: none; stroke: var(--accent-2); stroke-width: 1.4; }
.spark .area { fill: url(#sparkGrad); stroke: none; }

/* Meter bars */
.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; direction: ltr; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--yellow), var(--accent-2)); transition: width .8s; }
.meter.blue > i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.green > i { background: linear-gradient(90deg, #16a34a, var(--green)); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { font-weight: 500; color: var(--text-2); text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid rgba(60, 200, 235,.1); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.boxed { border: 1px solid var(--border-soft); }
.tbl.boxed th + th, .tbl.boxed td + td { border-inline-start: 1px solid var(--border-soft); }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 5px;
  border: 1px solid var(--border); background: rgba(30, 170, 220,.1);
  font-size: 13px; transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(30, 170, 220,.22); box-shadow: 0 0 10px var(--accent-glow); }
.btn.primary { background: var(--accent-grad); border-color: rgba(60, 237, 235, .55); color: #fff; }
.btn.icon { padding: 6px; }
.btn.active { background: var(--accent); border-color: var(--accent-2); color: #fff; }
.btn svg.ic { width: 16px; height: 16px; }
.input, select.input {
  background: rgba(2, 10, 20, .8); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; padding: 6px 10px; font-family: inherit; font-size: 13px;
  outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(60, 237, 235,.2); }
.search { position: relative; display: flex; align-items: center; }
.search .input { width: 100%; padding-inline-start: 30px; }
.search .ic { position: absolute; inset-inline-start: 8px; width: 15px; height: 15px; color: var(--muted); }

/* ---------- Status footer ---------- */
.statusbar {
  display: flex; align-items: center; gap: 28px;
  padding: 8px 16px; font-size: 13px; color: var(--text-2);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.statusbar .usage { display: flex; align-items: center; gap: 10px; }
.statusbar .usage .meter { width: 180px; }
.statusbar .copy { margin-inline-start: auto; color: var(--muted); font-size: 12px; }

/* ==========================================================
   LIVE DASHBOARD
   ========================================================== */
.dash {
  display: grid;
  grid-template-columns: minmax(300px, 22%) minmax(0, 1fr) minmax(280px, 21%); /* RTL: right | center | left */
  gap: var(--gap);
  min-height: 0;
}
.col { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.center { display: grid; grid-template-rows: 1fr auto; gap: var(--gap); min-height: 0; }
.center-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); }

/* Video wall */
.wall-panel .panel-b { padding: 8px; flex: 1; }
.wall { display: grid; gap: 8px; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: start; width: 100%; margin: 0 auto; }
body.wall-mode .wall { max-width: calc((100vh - 200px) * 16 / 9); }
.wall.l1 { grid-template-columns: minmax(0, 1fr); }
.wall.l1 .tile:not(.solo) { display: none; }
.wall.l9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tile {
  position: relative; overflow: hidden;
  background: #000; border: 1px solid var(--border-soft); border-radius: 4px;
  aspect-ratio: 16 / 9; min-height: 0; cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.tile:hover { border-color: var(--accent-2); }
.tile.alarm { border-color: var(--red); box-shadow: 0 0 0 2px var(--red), 0 0 22px rgba(239,68,68,.6); animation: alarmPulse 1s ease-in-out 4; }
@keyframes alarmPulse { 50% { box-shadow: 0 0 0 2px var(--red), 0 0 4px rgba(239,68,68,.2); } }
.tile .media { position: absolute; inset: 0; }
.tile .media video, .tile .media img, .tile .media iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; background: #000; }
.tile .media iframe { pointer-events: none; }
.tile-top {
  position: absolute; top: 0; inset-inline: 0; display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; background: linear-gradient(180deg, rgba(0,0,0,.55), transparent);
  font-size: 12px; pointer-events: none;
}
.live-badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(239,68,68,.92); color: #fff; font-weight: 700; padding: 2px 7px; border-radius: 3px; font-size: 11px; letter-spacing: .5px; direction: ltr; }
.live-badge .dot { background: #fff; box-shadow: none; width: 6px; height: 6px; }
.net-badge { background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.2); padding: 1px 6px; border-radius: 3px; font-size: 11px; direction: ltr; }
.tile-tools { margin-inline-start: auto; display: flex; gap: 4px; pointer-events: auto; opacity: 0; transition: opacity .2s; }
.tile:hover .tile-tools { opacity: 1; }
.tile-tools button { background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 4px; display: grid; place-items: center; }
.tile-tools button:hover { background: var(--accent); }
.tile-tools svg.ic { width: 15px; height: 15px; }
.tile-info {
  position: absolute; bottom: 0; inset-inline: 0;
  padding: 18px 10px 7px; pointer-events: none;
  background: linear-gradient(0deg, rgba(2, 8, 17,.92) 40%, transparent);
}
.tile-info .name { font-size: 15px; font-weight: 700; text-shadow: 0 1px 3px #000; }
.tile-info .meta { display: flex; align-items: center; gap: 14px; font-size: 12px; margin-top: 3px; color: #dbe7ff; }
.tile-info .meta .grow { flex: 1; }
.batt { display: inline-flex; align-items: center; gap: 4px; direction: ltr; }
.batt b { display: inline-block; width: 20px; height: 10px; border: 1.5px solid #dbe7ff; border-radius: 2px; position: relative; padding: 1px; }
.batt b::after { content: ''; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; background: #dbe7ff; border-radius: 1px; }
.batt b i { display: block; height: 100%; background: #dbe7ff; border-radius: 1px; }
.batt.low b i { background: var(--red); }

/* No-signal placeholder */
.nosig {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-2); text-align: center; padding: 10px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, #08283a 0%, #020811 75%);
}
.nosig::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(60, 237, 235,.10), transparent);
  height: 30%; animation: scan 3.5s linear infinite;
}
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(400%); } }
.nosig svg.ic { width: 34px; height: 34px; color: var(--accent-2); opacity: .8; }
.nosig b { font-size: 14px; color: var(--text); }
.nosig small { font-size: 12px; color: var(--muted); }
.nosig .spinner { width: 26px; height: 26px; border: 2px solid rgba(60, 237, 235,.25); border-top-color: var(--accent-2); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Calendar */
.cal { font-size: 12.5px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-head b { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.cal-grid .dow { color: var(--muted); font-size: 12px; padding: 2px 0; }
.cal-grid button { padding: 3px 0; border-radius: 3px; font-family: var(--mono); font-size: 12px; position: relative; }
.cal-grid button:hover { background: rgba(30, 170, 220,.2); }
.cal-grid button.has::after { content: ''; position: absolute; bottom: 1px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: var(--accent-2); }
.cal-grid button.today { outline: 1px solid var(--accent-2); }
.cal-grid button.sel { background: var(--accent); color: #fff; }
.cal-grid button.future { color: #3b5072; cursor: default; }
.cal-grid button.future:hover { background: none; }

/* 24h timeline */
.tl { position: relative; direction: ltr; }
.tl-bar { position: relative; height: 12px; border-radius: 3px; background: rgba(255,255,255,.06); overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; }
.tl-seg.rec { background: var(--accent); }
.tl-seg.motion { background: var(--yellow); }
.tl-seg.alert { background: var(--red); }
.tl-seg.ai { background: var(--purple); }
.tl-now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; box-shadow: 0 0 6px #fff; }
.tl-ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }

/* Alerts */
.alerts { list-style: none; display: flex; flex-direction: column; overflow: hidden; }
.alerts li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 8px 4px; border-bottom: 1px solid rgba(60, 200, 235,.12); cursor: pointer; font-size: 13.5px;
}
.alerts li:hover { background: rgba(30, 170, 220,.08); }
.alerts li.new { animation: slideIn .5s ease-out, flashNew 2s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-14px); } }
@keyframes flashNew { 0%, 40% { background: rgba(239,68,68,.18); } }
.alerts .time { font-family: var(--mono); color: var(--text-2); font-size: 12.5px; }
.alerts .sev { font-weight: 700; font-size: 12.5px; }
.sev.high { color: var(--red); }
.sev.mid { color: var(--yellow); }
.sev.low { color: var(--accent-2); }
.alerts .aic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.alerts .aic svg.ic { width: 15px; height: 15px; }
.aic.high { background: rgba(239,68,68,.18); color: var(--red); }
.aic.mid { background: rgba(250,204,21,.15); color: var(--yellow); }
.aic.low { background: rgba(60, 237, 235,.15); color: var(--accent-2); }

/* AI brain */
.ai-wrap { display: flex; align-items: center; gap: 14px; }
.brain { width: 92px; height: 92px; flex: none; filter: drop-shadow(0 0 10px rgba(60, 237, 235,.55)); }
.brain path, .brain circle, .brain line { stroke: #3cedeb; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.brain .node { fill: #a5fffd; stroke: none; animation: nodePulse 2.4s ease-in-out infinite; }
@keyframes nodePulse { 50% { opacity: .25; } }
.ai-count { margin-inline-start: auto; font-family: var(--mono); font-size: 12px; color: var(--accent-2); background: rgba(60, 237, 235,.1); padding: 1px 7px; border-radius: 10px; }

/* Stats grid */
.stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.stat { border: 1px solid var(--border-soft); border-radius: 5px; padding: 8px 10px; background: rgba(2, 10, 20,.4); }
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Device list */
.devices { list-style: none; display: flex; flex-direction: column; }
.devices li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(60, 200, 235,.1); font-size: 13px; cursor: pointer; }
.devices li:last-child { border-bottom: 0; }
.devices li:hover { color: var(--accent-2); }
.devices .id { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.devices .sigmini { display: flex; gap: 2px; align-items: flex-end; height: 12px; direction: ltr; }
.devices .sigmini i { width: 3px; background: var(--accent-2); border-radius: 1px; }
.devices .sigmini i.off { opacity: .25; }

.link-end { display: flex; justify-content: flex-end; font-size: 12.5px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(1, 4, 10,.78); backdrop-filter: blur(3px); padding: 24px; }
.modal.open { display: grid; }
.modal-box { width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel-solid); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 30px rgba(30, 170, 220,.2); overflow: hidden; }
.modal-box.sm { width: min(560px, 100%); }
.modal-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; padding: 12px; min-height: 0; }
.modal-body .tile { cursor: default; }
.modal-side { display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-2); }
.kv dd { font-weight: 600; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 70px; left: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 300px; max-width: 380px; display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel-solid); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent-2);
  border-radius: 6px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toastIn .35s ease-out; font-size: 13.5px;
}
.toast.high { border-inline-start-color: var(--red); }
.toast.mid { border-inline-start-color: var(--yellow); }
.toast b { display: block; margin-bottom: 2px; }
.toast.out { animation: toastOut .3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-30px); } }

/* Wall-only mode ("תצוגה חיה") */
body.wall-mode .dash { grid-template-columns: minmax(0, 1fr); }
body.wall-mode .dash > .col { display: none; }
body.wall-mode .center-bottom { display: none; }

/* ==========================================================
   RECORDINGS SCREEN
   ========================================================== */
.rec {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;   /* RTL: filters | player | details */
  gap: var(--gap);
  min-height: 0;
}
.player-panel .panel-b { gap: 10px; }
.player-stage { position: relative; aspect-ratio: 16/9; background: #000; border: 1px solid var(--border-soft); border-radius: 4px; overflow: hidden; }
.player-stage .media { position: absolute; inset: 0; }
.player-stage .media video, .player-stage .media img, .player-stage .media iframe { width: 100%; height: 100%; object-fit: contain; border: 0; background: #000; display: block; }
.osd { position: absolute; top: 10px; inset-inline: 10px; display: flex; justify-content: space-between; pointer-events: none; font-size: 13px; }
.osd .box { background: rgba(0,0,0,.6); padding: 4px 9px; border-radius: 4px; border: 1px solid rgba(255,255,255,.15); }
.rec-badge { display: inline-flex; align-items: center; gap: 6px; direction: ltr; }
.osd-bottom { position: absolute; bottom: 10px; inset-inline-start: 10px; pointer-events: none; font-size: 12px; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls .group { display: flex; gap: 4px; align-items: center; }
.controls .grow { flex: 1; }
.big-time { font-family: var(--mono); font-size: 22px; font-weight: 600; direction: ltr; }

.tl-big { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; direction: ltr; user-select: none; padding-top: 6px; }
.tl-area { position: relative; }
.tl-rows { display: flex; flex-direction: column; gap: 5px; }
.tl-rows .tl-bar { height: 18px; cursor: crosshair; }
.tl-rows .tl-bar.sel { outline: 1px solid var(--accent-2); }
.tl-rows .tl-seg.rec { background: rgba(30, 170, 220, 0.55); }
.tl-rows .tl-seg:not(.rec) { min-width: 3px; }
.tl-names { display: flex; flex-direction: column; gap: 5px; direction: rtl; }
.tl-names div { height: 18px; line-height: 18px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tl-names div.sel { color: var(--accent-2); font-weight: 600; }
.tl-cursor { position: absolute; top: -6px; bottom: 18px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 8px #fff; pointer-events: none; }
.tl-cursor::before { content: ''; position: absolute; top: -4px; left: -5px; border: 6px solid transparent; border-top-color: #fff; }
.tl-hover { position: absolute; top: -24px; transform: translateX(-50%); background: var(--panel-solid); border: 1px solid var(--border); font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 3px; pointer-events: none; display: none; white-space: nowrap; z-index: 3; }

.clips { overflow: auto; max-height: 300px; }
.clips tr { cursor: pointer; }
.clips tr:hover td { background: rgba(30, 170, 220,.08); }
.clips tr.playing td { background: rgba(30, 170, 220,.18); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid; white-space: nowrap; }
.tag.rec { color: var(--accent-2); border-color: rgba(60, 237, 235,.4); }
.tag.motion { color: var(--yellow); border-color: rgba(250,204,21,.4); }
.tag.alert { color: var(--red); border-color: rgba(239,68,68,.45); }
.tag.ai { color: var(--purple); border-color: rgba(167,139,250,.45); }
.row-actions { display: flex; gap: 4px; }
.row-actions button { padding: 3px; border-radius: 4px; color: var(--text-2); }
.row-actions button:hover { color: #fff; background: rgba(30, 170, 220,.25); }
.row-actions svg.ic { width: 15px; height: 15px; }

.cam-checks { display: flex; flex-direction: column; gap: 6px; }
.cam-checks label, .type-checks label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.cam-checks input, .type-checks input { accent-color: var(--accent); width: 15px; height: 15px; }
.type-checks { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12.5px; color: var(--text-2); }
.thumb { width: 64px; aspect-ratio: 16/9; border-radius: 3px; background: linear-gradient(135deg, #0b3247, #051424); border: 1px solid var(--border-soft); display: grid; place-items: center; color: var(--muted); }
.thumb svg.ic { width: 16px; height: 16px; }
.hash { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-2); direction: ltr; text-align: left; background: rgba(2, 10, 20,.6); border: 1px solid var(--border-soft); padding: 6px; border-radius: 4px; }

/* Recordings screen fits the viewport on large desktops; the events table and side columns scroll inside */
@media (min-width: 1201px) and (min-height: 900px) {
  body[data-page="recordings"] .app { height: 100vh; height: 100dvh; }
  body[data-page="recordings"] .body, .rec { min-height: 0; overflow: hidden; }
  .rec > .col { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
  .rec > .player-col { overflow: hidden; }
  .player-stage { aspect-ratio: auto; height: clamp(240px, 43vh, 640px); }
  .clips-panel { flex: 1; min-height: 150px; }
  .clips-panel .clips { flex: 1; max-height: none; min-height: 0; }
}
.col > .panel:not(.clips-panel) { flex-shrink: 0; }
.clips thead th { position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
.rec-quick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

/* ==========================================================
   Accessibility & interaction quality
   ========================================================== */
.skip-link {
  position: absolute; top: -48px; inset-inline-start: 12px; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 6px; font-weight: 600;
  transition: top .15s ease-out;
}
.skip-link:focus { top: 12px; text-decoration: none; }
.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; }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }
.tile:focus-visible { outline: 3px solid var(--accent-2); outline-offset: -3px; }
.sidenav a:focus-visible { outline-offset: -3px; }
.input:focus-visible { outline: none; }
[role="button"] { cursor: pointer; }
.btn:active, .tile-tools button:active, .row-actions button:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn { min-height: 32px; transition: background .18s ease-out, box-shadow .18s ease-out, transform .1s ease-out; }
.btn.icon { min-width: 32px; justify-content: center; }

/* Tile tools: visible on keyboard focus and always on touch devices (no hover there) */
.tile:focus-within .tile-tools { opacity: 1; }
@media (hover: none) { .tile-tools { opacity: 1; } }

/* Touch devices: comfortable hit areas */
@media (pointer: coarse) {
  .btn { min-height: 44px; padding-inline: 14px; }
  .btn.icon { min-width: 44px; }
  .tile-tools button { padding: 9px; }
  .cal-grid button { padding: 8px 0; }
  .row-actions button { padding: 9px; }
  .sidenav a { min-height: 48px; }
  .alerts li, .devices li { min-height: 48px; }
}

/* Softer "live" pulse instead of a hard blink */
.dot.blink { animation: livePulse 1.6s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .3; } }
.toast.out { animation-duration: .22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .nosig::after { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1500px) {
  .dash { grid-template-columns: 280px minmax(0, 1fr) 270px; }
  .rec { grid-template-columns: 260px minmax(0, 1fr) 270px; }
  .brain { width: 72px; height: 72px; }
}
@media (max-width: 1440px) {
  .body { grid-template-columns: minmax(0, 1fr) 112px; }
  .sidenav a { padding: 12px 10px; font-size: 14px; gap: 8px; }
  .dash { grid-template-columns: 250px minmax(0, 1fr) 250px; }
  .rec { grid-template-columns: 240px minmax(0, 1fr) 250px; }
  .rec-quick { grid-template-columns: minmax(0, 1fr); }
  .brain { display: none; }
  .panel-h h2, .panel-h h3 { font-size: 15.5px; white-space: normal; }
  .top-status .pill:nth-child(3) { display: none; }
}
@media (max-width: 1200px) {
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash > .center { grid-column: 1 / -1; order: -1; }
  .rec { grid-template-columns: minmax(0, 1fr); }
  .rec > .player-col { order: -1; }
  .center-bottom { grid-template-columns: minmax(0, 1fr); }
  .rec-quick { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .top-status { display: none; }
}
@media (max-width: 760px) {
  .app { padding: 8px; gap: 8px; }
  .topbar { gap: 10px; padding: 0 10px; height: 56px; }
  .brand { gap: 8px; }
  .brand-logo { height: 34px; }
  .clock { padding-inline-start: 10px; }
  .clock .t { font-size: 16px; }
  .clock .d { font-size: 12px; }
  .user > svg.ic { display: none; }
  .body { grid-template-columns: minmax(0, 1fr); }
  .sidenav { order: -1; flex-direction: row; overflow-x: auto; padding: 0; scrollbar-width: none; }
  .sidenav a { padding: 10px 12px; white-space: nowrap; border-inline-start: 0; border-bottom: 3px solid transparent; }
  .dash { grid-template-columns: minmax(0, 1fr); }
  .wall, .wall.l9 { grid-template-columns: minmax(0, 1fr); }
  .brand-text, .brand-sep { display: none; }
  .brand-title { font-size: 17px; }
  .user .meta { display: none; }
  .statusbar { flex-wrap: wrap; gap: 8px 20px; }
  .statusbar .usage .meter { width: 90px; }
  .modal { padding: 8px; }
  .modal-body { grid-template-columns: minmax(0, 1fr); }
  .rec-quick { grid-template-columns: minmax(0, 1fr); }
  .controls .big-time { order: -1; width: 100%; text-align: center; }
  .controls .grow { display: none; }
  .tl-big { grid-template-columns: minmax(0, 1fr) 84px; }
  .clips { overflow-x: auto; }
  .clips table { min-width: 620px; }
}

/* ==========================================================
   HUD layer – tactical control-room styling
   (inspired by 21st.dev: Focus Frame Border, HUD Targeting UI,
    Energy Meter and Data Stream; rebuilt in plain CSS/SVG)
   ========================================================== */
body {
  background:
    linear-gradient(rgba(60, 237, 235, .025) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(60, 237, 235, .025) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(1200px 600px at 75% -10%, rgba(30, 170, 220, .16), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(60, 237, 235, .08), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
}

/* Panels: bracket on two opposite corners + glowing header rule */
.panel::after {
  content: ''; position: absolute; bottom: -1px; inset-inline-end: -1px;
  width: 18px; height: 18px; pointer-events: none; opacity: .8;
  border-bottom: 2px solid var(--accent-2); border-inline-end: 2px solid var(--accent-2);
  border-end-end-radius: var(--radius);
}
.panel-h { border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, transparent, rgba(60, 237, 235, .45), transparent) 1; }
.panel-h .ic { filter: drop-shadow(0 0 4px var(--accent-glow)); }
.topbar { border-bottom-color: rgba(60, 237, 235, .45); box-shadow: inset 0 0 30px rgba(30, 170, 220, .08), 0 1px 18px rgba(60, 237, 235, .08); }
.chip { font-family: var(--mono); font-size: 11.5px; color: var(--accent-2); border: 1px solid rgba(60, 237, 235, .35); border-radius: 3px; padding: 1px 6px; direction: ltr; white-space: nowrap; }

/* Stat tiles */
.stat { position: relative; }
.stat::before { content: ''; position: absolute; top: 6px; inset-inline-start: 6px; width: 6px; height: 6px; border-top: 1px solid var(--accent-2); border-inline-start: 1px solid var(--accent-2); }
.stat .v { color: #eafeff; text-shadow: 0 0 12px rgba(60, 237, 235, .35); }

/* Focus-lock frame on video (camera viewfinder corners) */
.hud-frame { position: absolute; inset: 6px; pointer-events: none; z-index: 2; }
.hud-frame i { position: absolute; width: 18px; height: 18px; border: 0 solid rgba(60, 237, 235, .7); transition: border-color .2s ease-out; }
.hud-frame i:nth-child(1) { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; --fx: -8px; --fy: -8px; }
.hud-frame i:nth-child(2) { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; --fx: 8px; --fy: -8px; }
.hud-frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; --fx: -8px; --fy: 8px; }
.hud-frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; --fx: 8px; --fy: 8px; }
.tile:hover .hud-frame i, .tile:focus-visible .hud-frame i { animation: focusLock .5s ease-out; border-color: var(--accent-2); }
.tile.alarm .hud-frame i { border-color: var(--red); animation: focusLock .5s ease-out 4; }
@keyframes focusLock { 0% { transform: translate(var(--fx), var(--fy)); opacity: .2; } 100% { transform: none; opacity: 1; } }

/* Scanlines + vignette over live video */
.tile::after, .player-stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .35));
}
.tile-top, .tile-info, .osd, .osd-bottom { z-index: 3; }
.tile-top { padding: 10px 26px 0; }
.tile-info { padding: 18px 26px 10px; }
.player-stage .hud-frame { inset: 8px; }
.player-stage .hud-frame i { width: 26px; height: 26px; }
.osd { top: 14px; inset-inline: 32px; }
.osd-bottom { bottom: 14px; inset-inline-start: 32px; }

/* AI targeting reticle (shown on detections) */
.reticle {
  position: absolute; width: 24%; aspect-ratio: 1; transform: translate(-50%, -50%);
  z-index: 2; pointer-events: none; color: var(--red);
  animation: reticleIn .45s cubic-bezier(.2, .8, .2, 1);
}
.reticle.mid { color: var(--yellow); }
.reticle.ai { color: var(--accent-2); }
.reticle svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 4px currentColor); }
.reticle svg * { fill: none; stroke: currentColor; stroke-width: 1.6; }
.reticle .r1 { stroke-dasharray: 18 10; transform-origin: 60px 60px; animation: spin 7s linear infinite; }
.reticle .r2 { stroke-dasharray: 4 6; opacity: .7; transform-origin: 60px 60px; animation: spin 5s linear infinite reverse; }
.reticle .box { stroke-width: 2; }
.reticle-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: rgba(2, 8, 17, .8); border: 1px solid currentColor; padding: 1px 6px; border-radius: 2px;
}
.reticle.out { animation: reticleOut .3s ease-in forwards; }
@keyframes reticleIn { from { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }
@keyframes reticleOut { to { opacity: 0; transform: translate(-50%, -50%) scale(.8); } }

/* Segmented energy meter */
.seg { display: inline-flex; gap: 2px; height: 10px; direction: ltr; vertical-align: middle; }
.seg i { width: 5px; border-radius: 1px; background: rgba(60, 237, 235, .12); transition: background .3s ease-out, box-shadow .3s ease-out; }
.seg i.on { background: var(--accent-2); box-shadow: 0 0 5px var(--accent-glow); animation: segIn .35s ease-out backwards; animation-delay: calc(var(--n) * 25ms); }
.seg.warn i.on { background: var(--yellow); box-shadow: 0 0 5px rgba(250, 204, 21, .45); }
.seg.crit i.on { background: var(--red); box-shadow: 0 0 5px rgba(239, 68, 68, .5); }
.seg.wide i { width: 7px; }
@keyframes segIn { from { opacity: 0; transform: scaleY(.3); } }
.statusbar .usage .seg { height: 9px; }

/* Live data stream (terminal log) */
.stream-panel { flex: 1 1 160px; }
.col > .panel.stream-panel { flex: 1 1 160px; min-height: 150px; }
.stream { list-style: none; font-family: var(--mono); font-size: 12px; line-height: 1.55; display: flex; flex-direction: column; overflow: hidden; flex: 1; min-height: 0; }
.stream li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 8px; padding: 1px 0; color: var(--text-2); }
.stream li time { color: var(--muted); direction: ltr; }
.stream li b { font-weight: 600; color: var(--accent-2); min-width: 34px; direction: ltr; text-align: left; }
.stream li span { font-family: var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream li.new span { animation: typeIn .6s steps(24, end); }
.stream li.alert b, .stream li.alert span { color: var(--red); }
.stream li.warn b { color: var(--yellow); }
@keyframes typeIn { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }

@media (max-width: 1440px) {
  .panel-h .chip { display: none; }
  .devices .seg { display: none; }
  .tile .nosig small { display: none; }
}
