:root {
  --bg: #1b1d22;
  --panel: #262930;
  --panel-2: #2f333b;
  --header: #14161a;
  --border: #3a3e47;
  --text: #e2e4e8;
  --muted: #9aa0ab;
  --brand: #3a49a4;       /* Al-Nisour University blue (from the logo) */
  --accent: #6b7ce0;      /* lighter brand blue, readable on the dark background */
  --ok: #59db8f;
  --ok-bg: #1f5c3a;
  --down: #e45959;
  --down-bg: #6b2424;
  --yellow: #ffc859;
  /* Zabbix severity colours */
  --sev-1: #7499ff;
  --sev-2: #ffc859;
  --sev-3: #ffa059;
  --sev-4: #e97659;
  --sev-5: #e45959;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Tahoma, Arial, sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: linear-gradient(90deg, var(--brand) 0, #232a55 260px, var(--header) 520px);
  border-bottom: 3px solid var(--brand);
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: #fff; }
.logo img { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.logo .title { font-size: 19px; font-weight: 700; line-height: 1.1; }
.logo .title span { color: #aeb8ff; }
.logo .sub { font-size: 11px; color: #c9cff5; letter-spacing: .4px; }
nav { display: flex; flex-wrap: wrap; }
nav button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  padding: 15px 14px 12px;
  font-size: 14px;
  cursor: pointer;
}
nav button:hover { color: var(--text); }
nav button.active { color: var(--text); border-bottom-color: var(--accent); }
.status-bar { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }
.badge { padding: 3px 9px; border-radius: 3px; font-size: 12px; font-weight: 600; }
.badge.demo { background: #6b4e12; color: var(--yellow); }
.badge.real { background: var(--ok-bg); color: var(--ok); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.hidden { display: none !important; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 14px 16px; margin-bottom: 18px; overflow-x: auto; }
.panel h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
.panel h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid #30343c; white-space: nowrap; }
tr:hover td { background: #2c3038; }
td.wrap { white-space: normal; }
.empty { color: var(--muted); text-align: center; padding: 18px; }

.up { color: var(--ok); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.warn { color: var(--yellow); font-weight: 600; }
.muted { color: var(--muted); }

.st-problem { color: var(--down); font-weight: 700; }
.st-resolved { color: var(--ok); font-weight: 700; }
.sev { color: #1b1d22; font-weight: 600; }
.sev-1 { background: var(--sev-1); }
.sev-2 { background: var(--sev-2); }
.sev-3 { background: var(--sev-3); }
.sev-4 { background: var(--sev-4); }
.sev-5 { background: var(--sev-5); }
.problems td.problem-cell { white-space: normal; }

.filter button { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); padding: 5px 12px; cursor: pointer; }
.filter button:first-child { border-radius: 3px 0 0 3px; }
.filter button:last-child { border-radius: 0 3px 3px 0; }
.filter button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.sum { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; border-top: 4px solid var(--border); }
.sum .n { font-size: 28px; font-weight: 700; }
.sum .l { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { border-radius: 6px; padding: 22px; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid transparent; }
.tile.ok { background: var(--ok-bg); border-color: var(--ok); }
.tile.bad { background: var(--down-bg); border-color: var(--down); }
.tile.warn { background: #5c4614; border-color: var(--yellow); }
.tile.unknown { background: var(--panel); border-color: var(--border); }
.tile .name { font-size: 20px; font-weight: 700; }
.tile .big { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.tile .info { color: #d0d4da; font-size: 13px; }

.alert { background: var(--down-bg); border: 1px solid var(--down); border-left-width: 6px; padding: 12px 16px; border-radius: 4px; margin-bottom: 12px; font-weight: 600; }
.alert.warning { background: #5c4614; border-color: var(--yellow); }

.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.cam-view { background: #000; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; border-radius: 4px; overflow: hidden; color: var(--muted); text-align: center; padding: 10px; }
.cam-view img, .cam-view canvas { width: 100%; height: 100%; object-fit: contain; }
.cam-head { display: flex; justify-content: space-between; margin-bottom: 8px; }

.btn { background: var(--accent); color: #fff; border: none; padding: 9px 22px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
#save-msg { margin-left: 12px; color: var(--ok); }
.row { display: block; margin-bottom: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.grid-form label { color: var(--muted); font-size: 13px; }
input[type=text], input[type=number], input[type=password] { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; padding: 6px 8px; margin-top: 4px; font-size: 14px; }
.settings-table td { padding: 4px 6px; }
/* wide device list: scrolls inside its panel instead of spilling past the edge (seen in Arabic) */
.settings-table { display: block; max-width: 100%; overflow-x: auto; }
.sim-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: 3px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 3px; cursor: pointer; padding: 3px 8px; }
.icon-btn:hover { color: var(--down); border-color: var(--down); }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-row input[type=text] { width: auto; flex: 1 1 160px; margin-top: 0; }
select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 3px; padding: 6px 8px; font-size: 14px; }
.settings-table input { margin-top: 0; }

/* header buttons */
.head-btn { background: rgba(255, 255, 255, .06); border: 1px solid var(--border); color: var(--text); border-radius: 3px; padding: 4px 10px; font-size: 12px; cursor: pointer; text-decoration: none; }
.head-btn:hover { border-color: var(--accent); }
.user { color: var(--text); font-size: 12px; }

/* power */
.power-now { display: flex; gap: 12px; align-items: baseline; margin-bottom: 14px; font-size: 18px; }
.power-now:empty { display: none; }
.src-national { color: var(--ok); }
.src-generator { color: var(--sev-3); }
.src-none { color: var(--down); }

/* sites (Power tab) */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; }
.site { background: var(--panel); border: 1px solid var(--border); border-top: 5px solid var(--border); border-radius: 6px; padding: 14px; }
.site-national { border-top-color: var(--ok); }
.site-generator { border-top-color: var(--sev-3); }
.site-none { border-top-color: var(--down); box-shadow: 0 0 0 1px var(--down) inset; }
.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.site-name { font-size: 18px; font-weight: 700; }
.site-ar { color: var(--muted); font-size: 13px; }
.site-src { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.site-national .site-src b { color: var(--ok); }
.site-generator .site-src b { color: var(--sev-3); }
.site-none .site-src b { color: var(--down); }
.counter { font-family: Consolas, "Courier New", monospace; font-weight: 700; font-size: 15px; letter-spacing: .5px; }
.site-devs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.dev-tile { border-radius: 5px; padding: 10px 11px; border: 1px solid transparent; display: flex; flex-direction: column; gap: 3px; min-height: 116px; }
.dev-tile.ok { background: var(--ok-bg); border-color: var(--ok); }
.dev-tile.bad { background: var(--down-bg); border-color: var(--down); animation: pulse 1.6s ease-in-out infinite; }
.dev-tile.standby { background: #3a3320; border-color: #8a7330; }
.dev-tile.unknown { background: var(--panel-2); border-color: var(--border); }
.dev-name { font-weight: 700; font-size: 14px; word-break: break-word; }
.dev-role { font-size: 11px; color: #d0d4da; }
.dev-state { font-size: 15px; font-weight: 800; margin-top: auto; }
.dev-time { font-size: 11px; color: #d0d4da; display: flex; flex-direction: column; }
.dev-tile.bad .counter { color: #fff; font-size: 17px; }
.dev-tile.ok .counter { font-size: 12px; font-weight: 600; color: #bfe9cf; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(228, 89, 89, .35); } }

/* speed test */
.speed-net { margin-bottom: 14px; padding: 12px 14px; }
.speed-net #speed-net { font-size: 15px; margin-bottom: 4px; }
.speed-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.speed-card { background: var(--panel); border: 1px solid var(--border); border-top: 5px solid; border-radius: 6px; padding: 14px; }
.speed-card.bad { border-color: var(--down); }
.speed-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.speed-big { font-size: 34px; font-weight: 800; line-height: 1.1; }
.speed-big small { font-size: 14px; color: var(--muted); }
.speed-row { display: flex; gap: 16px; margin: 8px 0 4px; font-size: 13px; }
.small-text { font-size: 11px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { border-color: var(--down); color: var(--down); }

/* assistant */
.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.chip:hover { border-color: var(--accent); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 10px; line-height: 1.5; white-space: normal; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 2px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.msg small { display: block; margin-top: 4px; font-size: 10px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row input { flex: 1; margin: 0; }

/* Iraq map */
.iraq-box { max-width: 760px; margin: 0 auto; }
.iraq { width: 100%; height: auto; display: block; }
.iraq-land { fill: var(--panel-2); stroke: var(--accent); stroke-width: 2; }
.city { cursor: pointer; }
.city circle { stroke: #fff; stroke-width: 2; }
.city .city-pulse { stroke: none; opacity: .35; animation: city-pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.city-ok circle { fill: var(--ok); } .city-ok .city-pulse { animation: none; opacity: 0; }
.city-gen circle { fill: var(--sev-3); }
.city-warn circle { fill: var(--yellow); }
.city-dark circle { fill: var(--down); }
.city .city-heat { stroke: none; opacity: .28; filter: blur(6px); }
.city-temp { fill: var(--text); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.city-name { fill: var(--text); font-size: 15px; font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.city-sub { fill: var(--muted); font-size: 11px; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
@keyframes city-pulse { from { transform: scale(.5); opacity: .55; } to { transform: scale(1.4); opacity: 0; } }

/* unknown-person alert */
.face-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-top: 10px; }
.face-events { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; max-height: 360px; overflow-y: auto; }
.face-ev { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 11px; text-decoration: none; }
.face-ev img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; border: 2px solid var(--down); }
.enroll { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; margin-bottom: 12px; }
.enroll.hidden { display: none; }
.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin-bottom: 10px; }
.steps .add-row { margin-top: 6px; }
.enroll-result { display: flex; flex-direction: column; gap: 6px; }
#enroll-msg { font-weight: 600; min-height: 20px; }
#enroll-preview { max-width: 280px; border-radius: 6px; border: 2px solid var(--border); }
.enroll video { max-width: 360px; width: 100%; border-radius: 6px; margin-top: 10px; display: block; }
.enroll video.hidden { display: none; }
@media (max-width: 900px) { .face-grid { grid-template-columns: 1fr; } }

/* device commands */
.cmd-out { background: #0c0d10; color: #b8f5c8; border-radius: 4px; padding: 10px 12px; font-size: 12px; white-space: pre-wrap; margin-top: 10px; max-height: 220px; overflow: auto; }
.creds { margin-top: 12px; } .creds summary { cursor: pointer; color: var(--muted); }

/* light mode (🌓 button) */
:root[data-theme="light"] {
  --bg: #f1f3f8; --panel: #ffffff; --panel-2: #eceff5; --header: #ffffff; --border: #d6dae3;
  --text: #1d2130; --muted: #5f6675; --accent: #3a49a4;
  --ok: #1f9d55; --ok-bg: #e3f6ea; --down: #d23f3f; --down-bg: #fde4e4; --yellow: #b7860b;
}
:root[data-theme="light"] body { background: var(--bg); }
/* the side bar keeps its dark university-blue look in light mode */
:root[data-theme="light"] header { --header: #14161a; --text: #e2e4e8; --muted: #a9afbb; --border: #3a3e47; --panel-2: #2f333b;
  --accent: #6b7ce0; color: var(--text); }
:root[data-theme="light"] td { border-bottom-color: #e6e9f0; }
:root[data-theme="light"] tr:hover td { background: #f5f7fb; }
:root[data-theme="light"] .chart .grid { stroke: #e3e6ee; }
:root[data-theme="light"] .tile .info, :root[data-theme="light"] .dev-role, :root[data-theme="light"] .dev-time,
:root[data-theme="light"] .dev-tile.ok .counter { color: #4b5363; }
:root[data-theme="light"] .tile.warn, :root[data-theme="light"] .dev-tile.standby { background: #fff4d9; }
:root[data-theme="light"] .map { background: radial-gradient(circle at 50% 0, #dfe4f7 0, transparent 70%); }
:root[data-theme="light"] .bell-item.unread { background: rgba(58, 73, 164, .08); }
:root[data-theme="light"] .alarm-text span { color: #6b2a2a; }

/* paused ("Live alerts & activity" OFF): everything stands still */
body.paused *, body.paused *::before, body.paused *::after { animation: none !important; transition: none !important; }
.paused-badge { background: #6b2424; color: #ffd6d6; }
.live-switch { font-size: 15px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); }
.live-switch input { transform: scale(1.3); margin-right: 8px; }

/* excel export */
.panel { position: relative; }
.export-btn { position: absolute; top: 12px; right: 14px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 9px; font-size: 11px; cursor: pointer; z-index: 2; }
.export-btn:hover { color: var(--text); border-color: var(--ok); }
.panel-head { padding-right: 70px; }

/* demo fault tag */
.fault-tag { display: inline-block; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 3px; background: var(--down); color: #fff;
  vertical-align: middle; animation: fault-blink 1s steps(1) infinite; }
@keyframes fault-blink { 50% { opacity: .45; } }

/* device page */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.chart-grid .panel { margin-bottom: 0; }
.chart-box.small { min-height: 200px; margin-top: 4px; }
.chart-grid { margin-bottom: 18px; }
.demo-tag { align-self: center; background: #5c4614; color: var(--yellow); border-radius: 3px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
#devices-body tr, .dev-tile, #site-page tr[data-dev], #temp-grid .tile { cursor: pointer; }
.map .node { cursor: pointer; }

/* NOC mode: full screen, no sidebar, big text */
.noc-bar { display: none; }
body.noc header, body.noc .search, body.noc .bell, body.noc .bell-panel, body.noc footer, body.noc .page-head,
body.noc .site-actions { display: none !important; }
body.noc main { margin-left: 0 !important; padding: 64px 26px 20px !important; max-width: none; }
body.noc .noc-bar { display: flex; align-items: center; gap: 18px; position: fixed; top: 0; left: 0; right: 0; z-index: 80; height: 52px;
  padding: 0 20px; background: linear-gradient(90deg, var(--brand), #20275a 40%, var(--header)); border-bottom: 2px solid var(--brand); font-size: 16px; }
body.noc .noc-bar img { width: 34px; height: 34px; border-radius: 50%; }
body.noc #noc-bar-title { font-size: 20px; font-weight: 700; margin-left: 20px; }
body.noc #noc-clock { margin-left: auto; font-family: Consolas, monospace; font-size: 18px; }
body.noc .sum .n { font-size: 36px; }
body.noc .site-name { font-size: 24px; }

/* site page */
.site-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.port-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.port-chip { display: inline-flex; flex-direction: column; align-items: center; min-width: 58px; padding: 5px 6px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.port-chip b { color: var(--text); font-size: 12px; }
.port-chip.up-chip { border-color: #3f9e6a; }

/* search box (next to the bell) */
.search { position: fixed; top: 14px; right: 80px; z-index: 70; width: 300px; }
.search input { width: 100%; margin: 0; padding: 10px 12px 10px 34px; border-radius: 22px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text); font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.search input:focus { outline: none; border-color: var(--accent); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .7; pointer-events: none; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; max-height: 60vh; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.55); }
.search-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #30343c; }
.search-item:hover { background: var(--panel-2); }
.search-item span:last-child { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (min-width: 900px) { .page-head .right { margin-right: 400px; } .page-head .right > span:first-child { display: none; } }
@media (max-width: 640px) {
  .search { position: relative; top: 0; right: 0; width: auto; margin: 12px 12px 0; z-index: 40; }
  .search-results { top: 44px; }
}

/* notification bell */
.bell { position: fixed; top: 12px; right: 18px; z-index: 70; width: 44px; height: 44px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 20px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.bell:hover { border-color: var(--accent); }
.bell.alarm { background: var(--down); border-color: #fff; animation: bell-ring 1s ease-in-out infinite; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(0); } }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--down); color: #fff; font-size: 11px; font-weight: 800; line-height: 20px; border: 2px solid var(--bg); }
.bell-panel { position: fixed; top: 64px; right: 18px; z-index: 70; width: min(420px, calc(100vw - 32px)); max-height: 72vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.55); }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }
.bell-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #30343c; cursor: pointer; }
.bell-item:hover { background: var(--panel-2); }
.bell-item.unread { background: rgba(107, 124, 224, .10); }
.bell-item.unread .bell-body b::before { content: "● "; color: var(--accent); }
.bell-sev { width: 6px; align-self: stretch; border-radius: 3px; flex: none; }
.bell-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bell-body b { font-size: 13px; font-weight: 600; }
.bell-body span { color: var(--muted); font-size: 12px; }
.bell-hint { padding: 10px 14px; background: #5c4614; font-size: 12px; }
.flash-target { outline: 3px solid var(--accent); outline-offset: 2px; animation: flash-target 1s ease-in-out infinite; }
@keyframes flash-target { 50% { outline-color: transparent; } }
@media (min-width: 900px) { .bell { top: 14px; right: 26px; } .page-head .right { margin-right: 60px; } }
@media (max-width: 640px) { .bell { top: 10px; right: 12px; width: 40px; height: 40px; } .bell-panel { top: 58px; right: 12px; } }

/* battery */
.battery { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -4px 0 12px; }
.battery-body { position: relative; width: 120px; height: 24px; border: 2px solid #c9cdd6; border-radius: 4px; padding: 2px; }
.battery.big .battery-body { width: 180px; height: 34px; }
.battery-fill { height: 100%; border-radius: 2px; transition: width 1s; }
.battery-body span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; text-shadow: 0 1px 2px #000; }
.battery.big .battery-body span { font-size: 17px; }
.battery-cap { width: 5px; height: 10px; background: #c9cdd6; border-radius: 0 2px 2px 0; margin-left: -6px; }
.battery small { color: var(--muted); font-size: 12px; width: 100%; }

/* alarms that must be acknowledged */
.alarm { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--down-bg); border: 2px solid var(--down); border-radius: 6px; padding: 12px 16px; margin-bottom: 12px;
  animation: alarm-flash 1s steps(1) infinite; }
.alarm.acked { animation: none; background: #3a2a2a; border-color: #7a4a4a; border-width: 1px; }
.alarm-text { display: flex; flex-direction: column; gap: 3px; }
.alarm-text b { font-size: 16px; }
.alarm-text span { color: #f0d0d0; font-size: 13px; }
.alarm-ack { color: var(--ok); font-weight: 600; font-size: 13px; }
@keyframes alarm-flash { 50% { background: #a12f2f; box-shadow: 0 0 18px rgba(228, 89, 89, .6); } }
.ack-btn { background: var(--down); color: #fff; border: none; border-radius: 4px; padding: 4px 10px; font-weight: 700; cursor: pointer; font-size: 12px; }
.ack-btn.big { background: #fff; color: #a12f2f; padding: 10px 22px; font-size: 15px; }
.ack-btn:disabled { opacity: .5; }

/* charts */
.chart-box { position: relative; margin-top: 14px; min-height: 320px; }
.chart { display: block; }
.chart .grid { stroke: #343842; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .threshold { stroke-dasharray: 6 4; stroke-width: 1.5; }
.chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: 10px; background: var(--header); border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; font-size: 12px; pointer-events: none; min-width: 180px; }

/* network map */
.map-box { width: 100%; }
.map { width: 100%; height: auto; display: block; background: radial-gradient(circle at 50% 0, #232a4d 0, transparent 70%); border-radius: 4px; }
.map .link { stroke-width: 3; }
.map .link-up { stroke: #3f9e6a; }
.map .link-down { stroke: var(--down); stroke-dasharray: 8 6; }
.map .node { cursor: grab; }
.map .node circle { fill: var(--panel-2); stroke-width: 3; }
.map .node-up circle { stroke: var(--ok); }
.map .node-down circle { stroke: var(--down); fill: var(--down-bg); }
.map .node-unknown circle { stroke: var(--muted); }
.map .node-icon { font-size: 26px; }
.map .node-name { fill: var(--text); font-size: 14px; font-weight: 600; }
.map .node-sub { fill: var(--muted); font-size: 11px; }

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 0, #2d3878 0, var(--bg) 60%); }
.login-card { background: var(--panel); border: 1px solid var(--border); border-top: 4px solid var(--brand); border-radius: 6px; padding: 30px 28px; width: 100%; max-width: 360px; text-align: center; }
.login-card img { width: 96px; height: 96px; border-radius: 50%; border: 3px solid #fff; }
.login-card h1 { font-size: 22px; margin: 12px 0 2px; }
.login-card h1 span { color: var(--accent); }
.login-card label { display: block; text-align: left; color: var(--muted); font-size: 13px; margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; }
#login-error { margin-top: 10px; min-height: 20px; }
.login-card .remember { display: flex; align-items: center; gap: 8px; color: var(--text); margin-top: 14px; }
.login-card .remember input { width: auto; margin: 0; }

/* ---------- opening eagle animation ---------- */
#splash { position: fixed; inset: 0; z-index: 9999; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #2d3878 0, #111427 55%, #07080f 100%); transition: opacity .7s; cursor: pointer; }
#splash.splash-done { opacity: 0; }
.splash-sky { position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(255,255,255,.08) 0 1px, transparent 2px) 0 0 / 90px 90px,
              radial-gradient(circle at 70% 60%, rgba(255,255,255,.06) 0 1px, transparent 2px) 0 0 / 130px 130px;
  animation: sky 3.3s linear; }
.splash-eagle { position: absolute; width: min(80vw, 600px); transform-origin: 58% 78%;   /* zoom into the talons */
  animation: dive 2.9s cubic-bezier(.55, 0, .9, .4) forwards; }
.eagle-photo { width: 100%; height: auto; display: block;
  /* fade the photo's sky into the dark splash background, so only the eagle stands out */
  -webkit-mask-image: radial-gradient(ellipse 48% 50% at 50% 50%, #000 55%, transparent 100%);
          mask-image: radial-gradient(ellipse 48% 50% at 50% 50%, #000 55%, transparent 100%);
  filter: contrast(1.15) saturate(1.1) brightness(1.05); }
.splash-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
#splash.has-video .splash-video { display: block; }
#splash.has-video .splash-eagle, #splash.has-video .splash-flash { display: none; }
#splash.has-video .splash-title { display: none; }   /* the video shows its own logo and title */
.splash-flash { position: absolute; inset: 0; background: #fff; opacity: 0; animation: flash 3.3s ease-out forwards; pointer-events: none; }
@keyframes flash { 0%, 78% { opacity: 0; } 84% { opacity: .55; } 100% { opacity: 0; } }
.splash-title { position: absolute; text-align: center; color: #fff; opacity: 0; animation: title .9s 2.3s ease-out forwards; }
.splash-title img { width: 110px; height: 110px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 40px rgba(107,124,224,.7); }
.splash-title div { font-size: 34px; font-weight: 800; margin-top: 14px; letter-spacing: .5px; }
.splash-title span { color: #aeb8ff; }
.splash-title small { display: block; color: #c9cff5; margin-top: 6px; font-size: 15px; }
@keyframes dive {
  0%   { transform: translate(-20vw, -25vh) scale(.05) rotate(-12deg); opacity: 0; filter: blur(3px); }
  12%  { opacity: 1; filter: blur(0); }
  70%  { transform: translate(0, 0) scale(1.1) rotate(0deg); opacity: 1; }
  88%  { transform: translate(0, 4vh) scale(4) rotate(4deg); opacity: .95; }
  100% { transform: translate(0, 6vh) scale(9) rotate(6deg); opacity: 0; }
}
@keyframes title  { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes sky    { from { transform: scale(1); } to { transform: scale(1.3); } }
@media (prefers-reduced-motion: reduce) { .splash-eagle { animation-duration: .01s !important; } }

footer { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); margin-top: 10px; }
footer img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--brand); }

nav button i { font-style: normal; margin-right: 6px; }

/* page title bar (desktop) */
.page-head { display: none; }

/* ---------- desktop: left sidebar, like a PC application ---------- */
@media (min-width: 900px) {
  header { position: fixed; top: 0; left: 0; bottom: 0; width: 236px; z-index: 50; flex-direction: column; align-items: stretch;
           flex-wrap: nowrap; gap: 0; padding: 18px 0 14px; border-bottom: none; border-right: 1px solid var(--border);
           background: linear-gradient(180deg, var(--brand) 0, #20275a 170px, var(--header) 360px); overflow-y: auto; }
  .logo { flex-direction: column; text-align: center; padding: 0 16px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
  .logo img { width: 72px; height: 72px; }
  nav { flex-direction: column; flex-wrap: nowrap; }
  nav button { display: flex; align-items: center; text-align: left; padding: 11px 22px; border-bottom: none;
               border-left: 3px solid transparent; font-size: 14px; }
  nav button i { width: 26px; font-size: 16px; }
  nav button:hover { background: rgba(255, 255, 255, .04); }
  nav button.active { background: rgba(107, 124, 224, .16); border-left-color: var(--accent); color: #fff; }
  .status-bar { margin: auto 0 0; padding: 14px 18px 0; flex-direction: column; align-items: stretch; gap: 8px; border-top: 1px solid var(--border); }
  .status-bar .badge, .status-bar .head-btn { text-align: center; }
  #last-poll { text-align: center; font-size: 12px; }
  main, footer { margin-left: 236px; }
  main { max-width: none; padding: 0 26px 24px; }
  .page-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40;
               background: var(--bg); padding: 16px 0 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
  .page-head h1 { margin: 0; font-size: 22px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
  .page-head .right { color: var(--muted); font-size: 13px; display: flex; gap: 16px; align-items: center; }
  .page-head kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; font-size: 11px; }
}

@media (max-width: 640px) {
  header { gap: 6px; padding: 0 12px; }
  main { padding: 12px; }
  .status-bar { margin-left: 0; padding-bottom: 8px; flex-wrap: wrap; gap: 6px; }
  .cams { grid-template-columns: 1fr; }
  /* phone: tabs become a bottom bar with icons, like a phone app */
  header { border-bottom-width: 2px; }
  .logo img { width: 38px; height: 38px; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
        background: var(--header); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  nav button { flex: 0 0 auto; min-width: 68px; display: flex; flex-direction: column; align-items: center; gap: 2px;
               padding: 8px 6px 7px; font-size: 10px; border-bottom: none; border-top: 3px solid transparent; }
  nav button i { font-size: 20px; margin: 0; }
  nav button.active { border-top-color: var(--accent); background: rgba(107, 124, 224, .12); }
  body { padding-bottom: 72px; }
  .page-head { display: none; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 120px; }
  .power-now { flex-direction: column; gap: 2px; font-size: 16px; }
}

/* =================== Theme "Studio Triad" (violet · green · orange, design 3a) =================== */
:root {
  --bg: #101020; --panel: #191930; --panel-2: #22223F; --header: #0A0A17; --border: #2C2C4A;
  --text: #ECEBFA; --muted: #9593B3; --brand: #7D5CFF; --accent: #7D5CFF;
  --green: #27B673; --orange: #FF7A4D;
  --ok: #2FD083; --ok-bg: #12352A; --down: #FF4D6A; --down-bg: #3A1626; --yellow: #FFB224;
  --sev-1: #7D9BFF; --sev-2: #FFB224; --sev-3: #FF9A4D; --sev-4: #FF6F5B; --sev-5: #FF4D6A;
  --row-line: #26263F; --radius: 18px;
}
:root[data-theme="light"] {
  --bg: #F4F2EE; --panel: #FFFFFF; --panel-2: #F0EDF8; --header: #1C1A2E; --border: #E4E0D8;
  --text: #1C1A2E; --muted: #77748A; --brand: #6C47FF; --accent: #6C47FF;
  --green: #1E9E62; --orange: #F46A3D;
  --ok: #1E9E62; --ok-bg: #DDF3E7; --down: #D61F45; --down-bg: #FDE3E4; --yellow: #C98A00;
  --sev-1: #6C8CFF; --sev-2: #E9A100; --sev-3: #F48A3D; --sev-4: #F0603A; --sev-5: #D61F45;
  --row-line: #EEEAE3;
}
:root[data-theme="light"] header { --header: #1C1A2E; --text: #EDEBF7; --muted: #A9A6C0; --border: #2E2B47; --panel-2: #2A2742; --accent: #6C47FF; }
body { font-family: "Manrope", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif; }
.mono, code, kbd, #last-poll, td.num { font-family: "JetBrains Mono", Consolas, monospace; }

/* side bar */
header { background: var(--header); border-bottom: 1px solid var(--border); }
.logo img { border: none; box-shadow: none; }
.logo .title span { color: var(--accent); }
.logo .sub { color: var(--muted); }
.nav-grp { display: none; }
nav button { border-radius: 12px; display: flex; align-items: center; gap: 12px; }
nav button i { display: inline-flex; align-items: center; justify-content: center; }
nav button i svg { opacity: .9; }
nav button.active { color: #fff; }
@media (min-width: 900px) {
  header { background: var(--header); border-right: 1px solid var(--border); }
  .logo { border-bottom: 1px solid var(--border); }
  .nav-grp { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); opacity: .75; padding: 14px 26px 6px; }
  nav button { margin: 1px 12px; padding: 10px 14px; border-left: none; font-size: 14.5px; }
  nav button:hover { background: rgba(255, 255, 255, .05); }
  nav button.active { background: var(--accent); box-shadow: 0 10px 24px -10px var(--accent); font-weight: 600; }
  nav button i { width: 22px; margin-right: 0; }
  .status-bar { border-top: 1px solid var(--border); }
}
@media (max-width: 640px) {
  nav button { border-radius: 0; }
  nav button.active { background: rgba(125, 92, 255, .14); color: var(--text); border-top-color: var(--accent); }
  nav button i svg { width: 21px; height: 21px; }
}

/* buttons, inputs */
.head-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 8px 12px;
            font-size: 13px; background: rgba(255, 255, 255, .04); }
.head-btn svg, .user svg { flex: none; }
.user { display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn { border-radius: 12px; font-weight: 600; padding: 10px 22px; }
.btn:hover { filter: brightness(1.08); }
input[type=text], input[type=number], input[type=password], select, textarea { border-radius: 10px; padding: 9px 12px; }
.filter button { padding: 7px 14px; }
.filter button:first-child { border-radius: 10px 0 0 10px; }
.filter button:last-child { border-radius: 0 10px 10px 0; }
.chip { border-radius: 20px; padding: 6px 14px; }
.badge { border-radius: 8px; padding: 4px 10px; }
.badge.demo { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: var(--yellow); }
.badge.real { background: var(--ok-bg); color: var(--ok); }

/* cards and tables */
.panel { border-radius: 20px; padding: 18px 22px; }
.panel h2 { font-size: 16px; font-weight: 700; }
th { font-size: 11.5px; letter-spacing: .04em; }
td { border-bottom-color: var(--row-line); }
tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.sum { border-radius: var(--radius); padding: 16px 18px; border-top-width: 3px; }
.sum .n { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.sum .l { font-size: 11.5px; letter-spacing: .05em; font-weight: 600; }
/* the first cards are filled with the triad colours, like the design */
#summary .sum:nth-child(1), #power-summary .sum:nth-child(1) { background: var(--accent); border-color: var(--accent); color: #fff; }
#summary .sum:nth-child(2), #power-summary .sum:nth-child(3) { background: var(--orange); border-color: var(--orange); color: #fff; }
#power-summary .sum:nth-child(2) { background: var(--green); border-color: var(--green); color: #fff; }
#summary .sum:nth-child(-n+2) .l, #power-summary .sum:nth-child(-n+3) .l { color: rgba(255, 255, 255, .85); }
.page-head h1 svg { color: var(--accent); }
.tile, .dev-tile { border-radius: var(--radius); }
.cam-view { border-radius: 14px; }
.alert { border-radius: 14px; }
.sev { border-radius: 6px; padding: 2px 8px; }

/* bell and search */
.bell { border-radius: 14px; background: var(--panel); border: 1px solid var(--border); color: var(--text); display: grid; place-items: center; }
.bell-count { background: var(--down); color: #fff; box-shadow: 0 0 0 3px var(--bg); }
.bell-panel { border-radius: 18px; overflow: hidden; }
.search input { border-radius: 14px; background: var(--panel); }
.search-icon { display: inline-flex; color: var(--muted); opacity: 1; }
.search-results { border-radius: 14px; }
.page-head h1 { font-weight: 800; letter-spacing: -.02em; }
.page-head { background: var(--bg); }
.login-card { border-radius: 22px; border-top: 1px solid var(--border); padding: 34px 30px; }
.login-card img { border: none; }
.msg.user { background: var(--accent); }
/* top-right group: AR/EN · sun/moon · bell */
.top-tools { position: fixed; top: 12px; right: 70px; z-index: 70; display: flex; gap: 8px; align-items: center; }
.lang-toggle { display: flex; align-items: center; height: 44px; padding: 4px; gap: 2px; border-radius: 14px; cursor: pointer;
               background: var(--panel); border: 1px solid var(--border); font: 700 12px/1 "Manrope", sans-serif; letter-spacing: .06em; }
.lang-toggle span { display: grid; place-items: center; width: 36px; height: 34px; border-radius: 10px; color: var(--muted); transition: background .2s, color .2s; }
.lang-toggle span.on { background: var(--accent); color: #fff; box-shadow: 0 6px 14px -6px var(--accent); }
.lang-toggle:hover span:not(.on) { color: var(--text); }
.theme-toggle { width: 44px; height: 44px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); color: var(--text);
                display: grid; place-items: center; cursor: pointer; overflow: hidden; }
.theme-toggle span { grid-area: 1 / 1; display: grid; transition: transform .35s ease, opacity .35s ease; }
.theme-toggle .t-sun { color: #FFB224; }
.theme-toggle .t-moon { color: var(--accent); opacity: 0; transform: translateY(24px) rotate(-40deg); }
:root[data-theme="light"] .theme-toggle .t-sun { opacity: 0; transform: translateY(-24px) rotate(40deg); }
:root[data-theme="light"] .theme-toggle .t-moon { opacity: 1; transform: none; }
.lang-toggle:hover, .theme-toggle:hover, .bell:hover { border-color: var(--accent); }
/* the bell */
.bell { width: 44px; height: 44px; border-radius: 14px; box-shadow: none; color: var(--text); transition: border-color .2s; }
.bell svg { transform-origin: 50% 12%; }
.bell:has(.bell-count:not(.hidden)) { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.bell:has(.bell-count:not(.hidden)) svg { animation: bell-nudge 4s ease-in-out infinite; }
@keyframes bell-nudge { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(13deg); } 88% { transform: rotate(-11deg); } 92% { transform: rotate(7deg); } 96% { transform: rotate(-4deg); } }
.bell-count { top: -7px; right: -7px; min-width: 22px; height: 22px; line-height: 18px; border-radius: 11px; font-size: 11px;
              background: linear-gradient(135deg, #FF6A86, var(--down)); border: 2px solid var(--bg); box-shadow: 0 4px 10px -3px var(--down); }
.bell-count::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--down); animation: badge-ping 2.2s ease-out infinite; }
@keyframes badge-ping { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(1.7); opacity: 0; } }
.bell.alarm { color: #fff; background: var(--down); border-color: var(--down); }
:root.paused .bell svg, :root.paused .bell-count::after { animation: none; }
/* hide the old copies in the side bar (the new ones are next to the bell) */
#lang-btn, #theme-btn { display: none; }
.search { right: 228px; }
@media (min-width: 900px) { .top-tools { top: 14px; right: 78px; } .search { right: 228px; } }
@media (max-width: 899px) and (min-width: 641px) { .top-tools { right: 70px; } .search { right: 218px; } }
@media (max-width: 640px) { .top-tools { top: 10px; right: 60px; } .top-tools button { height: 40px; } .theme-toggle { width: 40px; }
  .lang-toggle span { width: 32px; height: 30px; } .bell { width: 40px; height: 40px; } .search { right: 0; }
  .logo .title span { display: block; } }   /* "Al-Nisour / Monitor" on two lines so the buttons never cover the name */
/* segmented filters (All / Problems / Resolved, 6 h / 24 h / 7 d): one pill, same in both directions */
.filter { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.filter button, .filter button:first-child, .filter button:last-child { border: none; border-radius: 9px; background: transparent; padding: 6px 14px; font-weight: 600; }
.filter button:hover { color: var(--text); }
.filter button.active { background: var(--accent); color: #fff; box-shadow: 0 6px 14px -8px var(--accent); }

/* bottom of the side bar: status line · icon buttons · user card */
.sb-status { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.sb-status #last-poll { font-size: 11.5px; color: var(--muted); }
.sb-actions { display: flex; gap: 6px; }
.sb-actions .head-btn { flex: 1; height: 40px; padding: 0; position: relative; }
.sb-actions .head-btn > span { display: none; }
.sb-actions .head-btn.hidden { display: none; }
#sound-btn.off { color: var(--muted); }
#sound-btn:not(.off) { color: var(--ok); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--border); }
.sb-user .avatar { width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center; font-weight: 800; color: #fff;
                   background: linear-gradient(135deg, var(--accent), var(--orange)); }
.sb-user .user { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25; }
.sb-user .user b { font-size: 13.5px; color: var(--text); }
.sb-user .user small { font-size: 11px; color: var(--muted); }
.sb-user #logout-btn { width: 36px; height: 36px; padding: 0; flex: none; }
.sb-user #logout-btn > span { display: none; }
.sb-user #logout-btn:hover { color: var(--down); border-color: var(--down); }
@media (min-width: 900px) {
  .status-bar { gap: 10px; padding: 14px 14px 4px; }
  .status-bar .badge { font-size: 11px; padding: 3px 9px; }
}
@media (max-width: 899px) {
  .status-bar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sb-actions .head-btn { width: 40px; flex: none; }
  .sb-user { padding: 4px 6px; }
}
/* ---------- Arabic (right to left) ---------- */
[dir=rtl] body { font-family: "IBM Plex Sans Arabic", "Manrope", "Segoe UI", Tahoma, Arial, sans-serif; }
[dir=rtl] th, [dir=rtl] td { text-align: right; }
[dir=rtl] #last-poll { font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif; }
[dir=rtl] .status-bar { margin-left: 0; margin-right: auto; }
[dir=rtl] .dot { margin-right: 0; margin-left: 6px; }
[dir=rtl] nav button i { margin-right: 0; margin-left: 6px; }
[dir=rtl] .alert { border-left-width: 1px; border-right-width: 6px; }
[dir=rtl] .steps { padding-left: 0; padding-right: 20px; }
[dir=rtl] .live-switch input { margin-right: 0; margin-left: 8px; }
[dir=rtl] .export-btn { right: auto; left: 14px; }
[dir=rtl] .panel-head { padding-right: 0; padding-left: 70px; }
[dir=rtl] .search { right: auto; left: 80px; }
[dir=rtl] .search input { padding: 10px 34px 10px 12px; }
[dir=rtl] .search-icon { left: auto; right: 12px; }
[dir=rtl] .search-item span:last-child { margin-left: 0; margin-right: auto; }
[dir=rtl] .bell { right: auto; left: 18px; }
[dir=rtl] .bell-count { right: auto; left: -4px; }
[dir=rtl] .bell-panel { right: auto; left: 18px; }
[dir=rtl] #save-msg { margin-left: 0; margin-right: 12px; }
[dir=rtl] input[type=number], [dir=rtl] .num, [dir=rtl] .ip { direction: ltr; unicode-bidi: plaintext; }
@media (min-width: 900px) {
  [dir=rtl] header { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border); }
  [dir=rtl] nav button { text-align: right; border-left: none; border-right: none; }
  [dir=rtl] main, [dir=rtl] footer { margin-left: 0; margin-right: 236px; }
  [dir=rtl] .page-head .right { margin-right: 0; margin-left: 400px; }
  [dir=rtl] .bell { right: auto; left: 26px; }
  [dir=rtl] body.noc main { margin-right: 0 !important; }
}
@media (max-width: 640px) {
  [dir=rtl] .bell { right: auto; left: 12px; }
  [dir=rtl] .bell-panel { right: auto; left: 12px; }
  [dir=rtl] .search { left: 0; }
}
[dir=rtl] .top-tools { right: auto; left: 70px; }
[dir=rtl] .bell-count { right: auto; left: -7px; }
[dir=rtl] .search { right: auto; left: 228px; }
@media (min-width: 900px) { [dir=rtl] .top-tools { left: 78px; } [dir=rtl] .search { left: 228px; } }
@media (max-width: 899px) and (min-width: 641px) { [dir=rtl] .search { left: 218px; } }
@media (max-width: 640px) { [dir=rtl] .top-tools { left: 60px; } [dir=rtl] .search { left: 0; } }
@media (min-width: 900px) { .page-head .right { margin-right: 610px; } [dir=rtl] .page-head .right { margin-right: 0; margin-left: 610px; } }

[dir=rtl] .sb-user .user { align-items: flex-start; }
[dir=rtl] #logout-btn svg { transform: scaleX(-1); }

/* scrollbars: one thin themed bar for the page; the side bar scrolls with the wheel but shows no bar */
html { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 45%, var(--border)) transparent; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }

/* inputs inside tables keep a readable width (they were squeezed to a few pixels, so a drop-down looked empty) */
td input[type=text], td input[type=password], td select { min-width: 130px; margin-top: 0; padding: 7px 10px; }
#settings-devices [data-f="name"] { min-width: 180px; }
#settings-devices [data-f="ip"] { min-width: 130px; direction: ltr; }
#settings-devices [data-f="snmp_community"] { min-width: 110px; }
#settings-devices [data-f="uplink"], #settings-devices [data-f="power_source"] { min-width: 170px; }
#settings-devices [data-f="camera_url"] { min-width: 240px; }
#chat-input, #pw-new { min-width: 180px; }/* side bar: logo on top and the footer (buttons + user) always visible; only the menu list scrolls, with a thin bar */
@media (min-width: 900px) {
  header { overflow: hidden; padding-bottom: 10px; }
  header nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px;
               scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }
  header .status-bar { flex: none; margin-top: 0; }
}
@media (min-width: 900px) and (max-height: 820px) {
  .logo { padding-bottom: 10px; margin-bottom: 4px; } .logo img { width: 52px; height: 52px; }
  .nav-grp { padding-top: 8px; padding-bottom: 3px; } nav button { padding-top: 8px; padding-bottom: 8px; }
}
.search-hint { padding: 9px 12px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--border); }
.search-hint b { color: var(--accent); }
.search-item.ask { color: var(--accent); }
.search-item svg { flex: none; color: var(--accent); }

/* add-a-face: the take-photo button sits inside the picture */
.enroll-frame { position: relative; width: min(480px, 100%); aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden;
                background: #0A0A17; border: 1px solid var(--border); display: grid; place-items: center; margin-bottom: 10px; }
.enroll-frame video, .enroll-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.enroll-empty { color: var(--muted); font-size: 13px; padding: 0 20px 60px; text-align: center; }
.snap-btn { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
            padding: 8px 18px 8px 8px; border-radius: 40px; border: none; cursor: pointer; font: 600 14px "Manrope", "IBM Plex Sans Arabic", sans-serif;
            color: #fff; background: rgba(10, 10, 23, .55); backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.snap-ring { width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px var(--accent); transition: transform .15s; }
.snap-btn:hover .snap-ring { transform: scale(1.06); }
.snap-btn:active .snap-ring { transform: scale(.92); }
.snap-btn:disabled { opacity: .6; cursor: wait; }
[dir=rtl] .snap-btn { padding: 8px 8px 8px 18px; }
.face-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; color: var(--text);
             background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); }
.face-note svg { color: var(--accent); flex: none; margin-top: 2px; }.enroll-frame #enroll-preview { max-width: none; border: none; border-radius: 0; }
.enroll .enroll-frame video { max-width: none; margin: 0; }
.enroll { border-radius: 18px; padding: 16px 20px; }


/* ---------- network map builder ---------- */
.nb { overflow: visible; }
.nb-sites { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.nb-chip { display: inline-flex; align-items: center; gap: 6px; }
.nb-chip small { color: var(--muted); font-weight: 700; }
.nb-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 14px -8px var(--accent); }
.nb-chip.active small { color: rgba(255,255,255,.8); }
.nb-add-site { border-style: dashed; color: var(--accent); }
.nb-led { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.nb-led.bad { background: var(--down); box-shadow: 0 0 6px var(--down); animation: fault-blink 1s steps(1) infinite; }
.nb-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.nb-toolbar .filter.dim { opacity: .55; }
.nb-switch { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 12px; background: var(--panel-2);
  border: 1px solid var(--border); font-weight: 600; cursor: pointer; }
.nb-wrap { display: flex; gap: 14px; align-items: flex-start; }
.nb-canvas { flex: 1; min-width: 0; position: relative; }
.nb-palette { width: 190px; flex: none; display: flex; flex-direction: column; gap: 6px; max-height: 640px; overflow-y: auto; padding-inline-end: 4px; }
.nb-pal-title { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 2px 2px; }
.nb-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2);
  border: 1px solid var(--border); cursor: grab; font-size: 13px; font-weight: 600; user-select: none; transition: border-color .15s, transform .15s; }
.nb-item:hover { border-color: var(--accent); transform: translateX(2px); }
[dir=rtl] .nb-item:hover { transform: translateX(-2px); }
.nb-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); }
.nb-item small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.nb-ic { font-size: 20px; width: 26px; text-align: center; flex: none; }
.nb-tpl { border-style: dashed; }
.nb-hint { margin-top: 8px; min-height: 18px; color: var(--muted); font-size: 13px; }
.nb-legend { margin: 12px 0 0; }
.nb-legend .lg { display: inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: middle; margin-inline-end: 6px; background: var(--muted); }
.nb-legend .lg.s-ok { background: var(--ok); } .nb-legend .lg.s-warn { background: var(--yellow); } .nb-legend .lg.s-down { background: var(--down); }
.nb-legend .lg.k-fiber { height: 6px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.nb-legend .lg.k-lan { background: var(--text); opacity: .7; }
.nb-legend .lg.k-power { background: repeating-linear-gradient(90deg, var(--yellow) 0 4px, transparent 4px 8px); }
.nb-legend .lg.p-mains { background: var(--yellow); } .nb-legend .lg.p-gen { background: var(--orange); }
.nb-legend .lg.p-battery { background: var(--accent); } .nb-legend .lg.p-off { background: var(--down); }

.nb-map { border-radius: 16px; border: 1px solid var(--border); touch-action: none; }
.nb-map .nb-dot { fill: var(--border); }
.nb-map .nb-empty { fill: var(--muted); font-size: 18px; }
.nb-map.mode-connect .node, .nb-map.mode-delete .node { cursor: crosshair; }
.nb-map.mode-cut .cable-hit { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><text y='22' font-size='22'>✂️</text></svg>") 4 14, crosshair; }
.nb-map.mode-repair .cable-hit { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><text y='22' font-size='22'>🔧</text></svg>") 4 14, pointer; }
.nb-map.mode-delete .cable-hit, .nb-map.mode-connect .cable-hit { cursor: pointer; }

.cable path { fill: none; stroke-linecap: round; }
.cable .cable-hit { stroke: transparent; stroke-width: 18; pointer-events: stroke; }
.cable .cable-line { stroke-width: 3; transition: stroke .3s; }
.cable.k-fiber .cable-line { stroke-width: 4.5; }
.cable.k-fiber .cable-glow { stroke-width: 11; opacity: .18; }
.cable.k-power .cable-line { stroke-width: 3; stroke-dasharray: 3 7; }
.cable.s-ok .cable-line, .cable.s-ok .cable-glow { stroke: var(--ok); }
.cable.s-warn .cable-line, .cable.s-warn .cable-glow { stroke: var(--yellow); animation: nb-blink .8s steps(1) infinite; }
.cable.s-down .cable-line, .cable.s-cut .cable-line, .cable.s-down .cable-glow, .cable.s-cut .cable-glow { stroke: var(--down); }
.cable.s-cut .cable-line { stroke-dasharray: 10 8; }
.cable.p-mains .cable-line { stroke: var(--yellow); } .cable.p-gen .cable-line { stroke: var(--orange); }
.cable.p-battery .cable-line { stroke: var(--accent); } .cable.p-off .cable-line { stroke: var(--muted); opacity: .6; }
.cable .cable-dot { fill: #fff; filter: drop-shadow(0 0 3px var(--ok)); pointer-events: none; }
.cable.s-warn .cable-dot { filter: drop-shadow(0 0 3px var(--yellow)); }
.cable.k-power .cable-dot { fill: var(--yellow); filter: none; }
.cable.k-power.p-gen .cable-dot { fill: var(--orange); }
.cable:hover .cable-line { stroke-width: 6; }
.cut-mark circle { fill: var(--down); stroke: var(--panel); stroke-width: 3; }
.cut-mark text { fill: #fff; font-size: 15px; font-weight: 800; }
.cut-mark { animation: nb-pulse 1.2s ease-in-out infinite; transform-box: fill-box; }
@keyframes nb-blink { 50% { opacity: .25; } }
@keyframes nb-pulse { 50% { opacity: .55; } }

.nb-map .node-body { fill: var(--panel-2); stroke-width: 3; }
.nb-map .node-halo { fill: transparent; stroke: transparent; stroke-width: 2; }
.nb-map .node-up .node-body { stroke: var(--ok); }
.nb-map .node-down .node-body { stroke: var(--down); fill: var(--down-bg); }
.nb-map .node-down .node-halo { stroke: var(--down); animation: nb-blink 1s steps(1) infinite; }
.nb-map .node-unknown .node-body { stroke: var(--muted); }
.nb-map .node.picked .node-halo { stroke: var(--accent); stroke-width: 4; stroke-dasharray: 6 5; }
.nb-map .node:hover .node-body { filter: brightness(1.15); }
/* power view: devices take the colour of what feeds them, data cables step back */
.nb-map.power-view .cable:not(.k-power) { opacity: .18; }
.nb-map.power-view .cable.k-power .cable-line { stroke-width: 4; }
.nb-map.power-view .pw-mains .node-body { stroke: var(--yellow); }
.nb-map.power-view .pw-gen .node-body { stroke: var(--orange); }
.nb-map.power-view .pw-battery .node-body { stroke: var(--accent); }
.nb-map.power-view .pw-off .node-body { stroke: var(--down); fill: var(--down-bg); }

.nb-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.nb-site-card { padding: 14px 16px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--border); cursor: pointer;
  border-top: 4px solid var(--ok); transition: transform .15s, border-color .15s; }
.nb-site-card.bad { border-top-color: var(--down); }
.nb-site-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.nb-site-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.nb-site-head b { color: var(--text); font-size: 15px; }
.nb-site-devs { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; }
.nb-mini { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; background: var(--panel);
  border: 2px solid var(--muted); }
.nb-mini.up { border-color: var(--ok); } .nb-mini.down { border-color: var(--down); background: var(--down-bg); }
.nb-site-foot { display: flex; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
:root[data-theme="light"] .cable .cable-dot { fill: #fff; stroke: var(--text); stroke-width: .5; }
@media (max-width: 760px) {
  .nb-wrap { flex-direction: column; }
  .nb-palette { width: 100%; flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 4px; }
  .nb-pal-title { display: none; }
  .nb-item { flex: none; }
  .nb-item small { display: none; }
}.cable.s-idle .cable-line { stroke: var(--muted); opacity: .45; stroke-dasharray: 2 6; }
.engine-ic { fill: var(--orange); vertical-align: -0.15em; }

/* smart root-cause alerts */
.rca-banner { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 8px 12px;
  border: 1px solid var(--down); border-inline-start-width: 4px; border-radius: 8px; background: var(--down-bg); margin-bottom: 4px; }
.rca-banner b { color: var(--down); }
.rca-banner span { color: var(--muted, inherit); font-size: .92em; }
.rca-mini { font-size: .85em; color: var(--down); margin: 4px 0; }
.nb-map .node.rca-root .node-halo { stroke: var(--down); stroke-width: 5; stroke-dasharray: 6 4; animation: rca-spin 3s linear infinite; }
.nb-map .node.rca-hit { opacity: .55; }
.cable.rca-root .cable-line { stroke-width: 7; filter: drop-shadow(0 0 6px var(--down)); }
@keyframes rca-spin { to { stroke-dashoffset: -40; } }
.rca-row td { background: var(--down-bg); font-weight: 600; }
.rca-child td { opacity: .75; font-size: .92em; }
.link-btn.rca-toggle { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 4px; font: inherit; font-size: .9em; }
.bell-body .rca-list { display: block; font-size: .85em; opacity: .85; }
