@import url('https://fonts.googleapis.com/css2?family=Anuphan:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Theme: "night shift" — ink-blue control room lit by sodium street lamps.
   Status colours (green / red) carry meaning only; the amber lamp is the brand. */
:root, [data-theme="dark"] {
  --bg: #0d1724;
  --panel: #121f2e;
  --panel-2: #182839;
  --raise: #1e3146;
  --line: #243649;
  --line-2: #2f4660;
  --text: #e7eef5;
  --muted: #8397ab;
  --accent: #f4a340;
  --accent-strong: #f6b35e;
  --accent-ink: #1f1406;
  --accent-wash: rgba(244, 163, 64, .12);
  --ok: #3dd68c;
  --ok-wash: rgba(61, 214, 140, .13);
  --bad: #ff5d5d;
  --bad-text: #ff8f8f;
  --bad-wash: rgba(255, 93, 93, .13);
  --unknown: #7d8fa3;
  --map-bg: #13202e;
  --field: #0a131e;
  --shadow: 0 18px 50px rgba(2, 8, 16, .55);
  --pin-ink: #0d1724;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-2: #f4f7f9;
  --raise: #e9eff4;
  --line: #d9e1e8;
  --line-2: #c4d0db;
  --text: #13212f;
  --muted: #5e7183;
  --accent: #f2a23e;
  --accent-strong: #a85c08;
  --accent-ink: #2a1803;
  --accent-wash: rgba(242, 162, 62, .16);
  --ok: #12a866;
  --ok-wash: rgba(18, 168, 102, .12);
  --bad: #e23d3d;
  --bad-text: #c42b2b;
  --bad-wash: rgba(226, 61, 61, .1);
  --unknown: #8a9aab;
  --map-bg: #e5e9ec;
  --field: #ffffff;
  --shadow: 0 16px 40px rgba(19, 33, 47, .16);
  --pin-ink: #ffffff;
  color-scheme: light;
}
:root {
  --radius: 10px;
  --font: 'Anuphan', 'Noto Sans Thai', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .clock, .stat .v { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer;
  text-decoration: none; white-space: nowrap; font-weight: 500; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--raise); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad-text); }
.btn.danger:hover { background: var(--bad-wash); border-color: var(--bad); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13.5px; }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .55; cursor: progress; }
.ghost-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0;
  background: none; color: var(--muted); cursor: pointer; }
.ghost-btn:hover { background: var(--panel-2); color: var(--text); }
.ghost-btn svg { width: 19px; height: 19px; }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--field); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 9px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
input[readonly] { color: var(--muted); }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.mono, input.mono { font-family: var(--mono); font-size: 13.5px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line);
  padding: 0 5px; border-radius: 4px; }

/* ---- brand mark: a viewfinder ---- */
.mark { width: 26px; height: 26px; flex: none; color: var(--accent); }

/* ---- top bar ---- */
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 14px 0 18px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; min-width: 0; }
.brand > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .crumb { color: var(--muted); font-weight: 500; }
.rec-dot { display: none; }
.topbar .spacer { flex: 1; }
.clock { color: var(--muted); font-size: 14px; }
.who { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }

/* ---- viewer layout ---- */
.viewer { position: fixed; inset: 58px 0 0 0; display: flex; }
.side { width: 318px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 10; }
.side .search { padding: 16px 16px 14px; border-bottom: 1px solid var(--line); }

.summary { margin-bottom: 14px; }
.sum-text { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.sum-text b { color: var(--text); font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-right: 2px; font-variant-numeric: tabular-nums; }
.sum-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); gap: 2px; }
.sum-bar i { display: block; height: 100%; transition: flex-grow .4s; }
.sum-bar .g { background: var(--ok); } .sum-bar .r { background: var(--bad); } .sum-bar .u { background: var(--unknown); }

.filters { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; margin-top: 12px;
  background: var(--field); border: 1px solid var(--line); border-radius: 9px; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border-radius: 7px;
  border: 0; background: transparent; color: var(--muted); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); font-weight: 600; }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.g { background: var(--ok); } .dot.r { background: var(--bad); }

.side .count { font-size: 13px; color: var(--muted); margin-top: 12px; display: flex; justify-content: space-between; }
.side .count a { text-decoration: none; font-weight: 500; }
.cam-list { flex: 1; overflow: auto; padding: 6px 8px 16px; }
.cam-group { font-size: 13px; font-weight: 600; color: var(--muted); padding: 14px 10px 6px; }
.cam-item { display: flex; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 9px; cursor: pointer; position: relative; }
.cam-item:hover { background: var(--panel-2); }
.cam-item.active { background: var(--accent-wash); }
.cam-item.active::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--accent); }
.cam-item .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); border: 1px solid var(--line); }
.cam-item .ic svg { width: 18px; height: 18px; }
.cam-item .nm { font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-item .sub { font-size: 13px; color: var(--muted); }
.st.on { color: var(--ok); } .st.off { color: var(--bad-text); }
.map { flex: 1; position: relative; background: var(--map-bg); }
#map { position: absolute; inset: 0; }
.side-toggle { display: none; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* ---- video dock: each tile is a camera viewfinder with an OSD ---- */
.dock { position: absolute; right: 16px; bottom: 16px; display: grid; gap: 12px; z-index: 15;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); width: min(calc(var(--cols, 1) * 440px), calc(100% - 32px)); }
.tile { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.06); }
.tile.active { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.tile.offline .screen { filter: grayscale(1) brightness(.55); }
.screen { position: absolute; inset: 0; background: #000; }
.screen video, .screen img, .screen iframe, .preview video, .preview img, .preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; background: #000; }
.vf { position: absolute; inset: 10px; pointer-events: none; --c: rgba(255,255,255,.75); --l: 16px; --w: 2px;
  background:
    linear-gradient(var(--c),var(--c)) top left / var(--l) var(--w), linear-gradient(var(--c),var(--c)) top left / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) top right / var(--l) var(--w), linear-gradient(var(--c),var(--c)) top right / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) bottom left / var(--l) var(--w), linear-gradient(var(--c),var(--c)) bottom left / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) bottom right / var(--l) var(--w), linear-gradient(var(--c),var(--c)) bottom right / var(--w) var(--l);
  background-repeat: no-repeat; }
.osd { position: absolute; color: #fff; font-size: 13.5px; font-weight: 600; line-height: 1.2; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; max-width: 60%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.osd-tl { top: 20px; left: 22px; font-size: 15px; }
.osd-tr { top: 20px; right: 22px; font-weight: 500; opacity: .9; }
.osd-bl { bottom: 20px; left: 22px; display: inline-flex; align-items: center; gap: 7px; }
.osd-bl .rec { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(255,93,93,.25); animation: rec 1.6s steps(1) infinite; }
.osd-bl.off .rec { background: #9aa7b5; box-shadow: none; animation: none; }
@keyframes rec { 50% { opacity: .2; } }
.tools { position: absolute; right: 14px; bottom: 12px; display: flex; gap: 4px; padding: 4px; border-radius: 10px;
  background: rgba(8, 14, 22, .72); backdrop-filter: blur(6px); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; }
.tile:hover .tools, .tile:focus-within .tools { opacity: 1; transform: none; }
@media (hover: none) { .tools { opacity: 1; transform: none; } }
.tools button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: #dfe7ef; cursor: pointer; }
.tools button:hover { background: rgba(255,255,255,.14); color: #fff; }
.tools svg { width: 17px; height: 17px; pointer-events: none; }
.player-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background: rgba(8,14,22,.78);
  padding: 7px 14px; border-radius: 8px; font-size: 14px; color: #c9d5e1; pointer-events: none; text-align: center; max-width: 80%; }
.player-status.err { color: #ffb0b0; }
.tile:fullscreen { border-radius: 0; }

/* ---- leaflet ---- */
.cam-pin { background: none; border: 0; }
.leaflet-container { background: var(--map-bg); font-family: var(--font); }
.leaflet-control-layers, .leaflet-bar a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 80%, transparent) !important; color: var(--muted) !important; }

/* ---- login ---- */
.center-page { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px 32px 30px; width: min(400px, 100%); box-shadow: var(--shadow); }
.card::before { content: ''; position: absolute; inset: -12px; pointer-events: none; --c: var(--accent); --l: 22px; --w: 2px;
  background:
    linear-gradient(var(--c),var(--c)) top left / var(--l) var(--w), linear-gradient(var(--c),var(--c)) top left / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) top right / var(--l) var(--w), linear-gradient(var(--c),var(--c)) top right / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) bottom left / var(--l) var(--w), linear-gradient(var(--c),var(--c)) bottom left / var(--w) var(--l),
    linear-gradient(var(--c),var(--c)) bottom right / var(--l) var(--w), linear-gradient(var(--c),var(--c)) bottom right / var(--w) var(--l);
  background-repeat: no-repeat; }
.card h1 { font-size: 23px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.card p.sub { color: var(--muted); margin: 0 0 24px; }
.err-msg { color: var(--bad-text); font-size: 14px; min-height: 22px; margin-bottom: 8px; }
.corner-tools { position: fixed; top: 14px; right: 14px; }

/* ---- admin ---- */
.admin { display: flex; flex-direction: column; height: 100%; }
.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 14px 14px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.pane { flex: 1; min-height: 0; overflow: auto; }
.cam-admin { display: grid; grid-template-columns: minmax(320px, 1fr) 460px; height: 100%; }
.cam-admin .list { border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.list-tools { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.list-tools input { flex: 1; min-width: 160px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel); }
tbody tr.sel { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 13px;
  background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.on { color: var(--ok); background: var(--ok-wash); }
.pill.off { color: var(--bad-text); background: var(--bad-wash); }
.editor { overflow: auto; padding: 20px; background: var(--panel); }
.editor h2 { margin: 0 0 16px; font-size: 18px; }
.mini-map { height: 250px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 10px; overflow: hidden; background: var(--map-bg); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.preview { position: relative; aspect-ratio: 16/9; margin-top: 16px; border-radius: 10px; overflow: hidden; background: #000; }
.section { max-width: 780px; padding: 24px; }
.section h2 { font-size: 18px; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 18px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .k { font-size: 13.5px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.pick-list:not(:empty) { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pick { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pick:last-child { border-bottom: 0; }
.pick .nm { flex: 1; min-width: 0; font-weight: 500; }
.pick .id { font: 12.5px var(--mono); color: var(--muted); word-break: break-all; }
.alert-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; }
.alert-item pre { margin: 8px 0 0; white-space: pre-wrap; font: 14px/1.55 var(--font); color: var(--muted);
  background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }

#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line-2); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; font-weight: 500; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.toast.err::before { background: var(--bad); }
.toast.warn::before { background: var(--accent); }
.toast.out { opacity: 0; transform: translateY(-8px); }

@media (max-width: 960px) {
  .cam-admin { grid-template-columns: 1fr; height: auto; }
  .cam-admin .list { border-right: 0; max-height: 45vh; }
}
@media (max-width: 760px) {
  .side { position: absolute; inset: 0 auto 0 0; width: 88%; max-width: 330px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .side-toggle { display: inline-grid; }
  .dock { left: 8px; right: 8px; bottom: 8px; width: auto; grid-template-columns: repeat(min(var(--cols,1), 2), 1fr); gap: 8px; }
  .clock, .who { display: none; }
  .osd { font-size: 12px; } .osd-tl { font-size: 13px; } .osd-tr { display: none; }
  .row { flex-direction: column; gap: 0; }
}

.site-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.site-checks label { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--line-2);
  border-radius: 99px; cursor: pointer; font-size: 14px; background: var(--field); }
.site-checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.site-checks input { width: 15px; height: 15px; }
.f > .lbl { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.site-names { display: flex; flex-wrap: wrap; gap: 5px; }
tr.editing-row > td { background: var(--panel-2); }
.site-select { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.site-select select { height: 38px; font-weight: 600; }
.site-select svg { width: 18px; height: 18px; color: var(--accent); flex: none; }

/* ---- multi-view wall (grid.html) ---- */
.grid-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.gridbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.gridbar .spacer { flex: 1; }
.gb-site { display: flex; align-items: center; gap: 6px; }
.gb-site svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.gb-site select { height: 34px; width: auto; min-width: 150px; font-weight: 600; }
.gb-small { height: 34px !important; width: auto !important; font-size: 14px; }
.gb-label { color: var(--muted); font-size: 14px; margin-left: -4px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--field); border: 1px solid var(--line); border-radius: 9px; }
.seg button { height: 28px; min-width: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; font-weight: 500; font-variant-numeric: tabular-nums; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pager { display: flex; align-items: center; gap: 2px; font-weight: 600; }
.pager .ghost-btn { width: 32px; height: 32px; }
.pager .ghost-btn:disabled { opacity: .35; cursor: default; }
.loadwarn { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; font-size: 14px;
  background: var(--accent-wash); color: var(--text); border-bottom: 1px solid var(--line); }

.wall { flex: 1; min-height: 0; display: grid; gap: 3px; padding: 3px; background: #05090e;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); }
.cell { position: relative; background: #000; overflow: hidden; cursor: pointer; min-height: 0; border-radius: 3px; }
.cell:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .screen { position: absolute; inset: 0; }
.cell .screen video, .cell .screen img, .cell .screen iframe { object-fit: contain; pointer-events: none; }
.cell .player-status { font-size: 12px; padding: 4px 8px; }
.cell-osd { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  background: linear-gradient(rgba(0,0,0,.65), rgba(0,0,0,0)); color: #fff; font-size: 13px; font-weight: 600; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.8); white-space: nowrap; overflow: hidden; }
.cell-ch { flex: none; min-width: 22px; padding: 0 5px; border-radius: 4px; background: rgba(255,255,255,.16); text-align: center; font-size: 11.5px; }
.cell-name { overflow: hidden; text-overflow: ellipsis; }
.cell-site { flex: none; font-weight: 500; opacity: .75; font-size: 11.5px; }
.cell-state { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #8ea0b3; font-size: 13px; pointer-events: none; text-align: center; }
.cell.offline .cell-state { color: #ff9b9b; }
.cell.offline .cell-ch { background: var(--bad); }
.cell.stale .screen img { filter: grayscale(.6) brightness(.7); }
.empty-cell { cursor: default; background: #0a1019; }
.empty-cell:hover { box-shadow: none; }
.empty-cell .cell-ch { position: absolute; top: 6px; left: 8px; color: #4b5b6c; background: none; }
/* denser layouts: smaller labels */
.wall.n32 .cell-osd, .wall.n64 .cell-osd { font-size: 11.5px; padding: 3px 6px; gap: 4px; }
.wall.n64 .cell-site, .wall.n64 .cell .player-status { display: none; }
.wall.n64 .cell-ch { min-width: 18px; font-size: 10.5px; padding: 0 3px; }
.wall.n64 .cell-state { font-size: 11px; }
body.kiosk .topbar, body.kiosk .gridbar, body.kiosk .loadwarn { display: none; }
body.kiosk .wall { padding: 0; gap: 2px; }

.focus { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(3, 7, 12, .82); }
.focus-box { width: min(1280px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.focus-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.focus-head b { font-size: 16px; }
.focus-head .spacer { flex: 1; }
.focus-screen { position: relative; aspect-ratio: 16 / 9; background: #000; }
.focus-screen video, .focus-screen img, .focus-screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; }
@media (max-width: 760px) {
  .gb-label, #rotate { display: none; }
  .wall.n32, .wall.n64 { --cols: 4 !important; }
}

/* ---- video popups anchored to map pins ---- */
.pop-layer { position: absolute; inset: 0; pointer-events: none; z-index: 14; overflow: hidden; }
.tile.pop { position: absolute; left: 0; top: 0; width: min(400px, calc(100% - 16px)); pointer-events: auto; overflow: visible;
  will-change: transform; }
.tile.pop .screen, .tile.pop .vf { border-radius: 12px; overflow: hidden; }
.tile.pop .screen { border-radius: 12px; }
.pop-arrow { position: absolute; bottom: -8px; width: 16px; height: 16px; margin-left: -8px; background: #000;
  transform: rotate(45deg); border-radius: 0 0 3px 0; pointer-events: none; z-index: -1; }
.tile.pop.below .pop-arrow { bottom: auto; top: -8px; border-radius: 3px 0 0 0; }
.tile.pop.active { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
@media (max-width: 760px) { .tile.pop { width: min(320px, calc(100% - 16px)); } }
