:root { --bg:#0b1220; --panel:#111c30; --panel2:#0e1728; --line:#22314d;
  --txt:#e2e8f0; --mut:#8fa0b8; --acc:#38bdf8; --ok:#34d399; --warn:#fbbf24; --bad:#f87171; }
* { margin:0; padding:0; box-sizing:border-box; }
body { background:var(--bg); color:var(--txt); font-family:"Segoe UI",Arial,sans-serif; font-size:14px; }
.hidden { display:none !important; }
.center-view { min-height:100vh; display:flex; align-items:center; justify-content:center; }
.login-card { background:var(--panel); border:1px solid var(--line); border-radius:14px;
  padding:40px 48px; width:360px; text-align:center; }
.brand { font-size:26px; font-weight:800; letter-spacing:4px; }
.brand span { color:var(--acc); }
.brand.small { font-size:17px; }
.login-sub { color:var(--mut); margin:8px 0 22px; font-size:13px; }
input, select { background:var(--panel2); border:1px solid var(--line); color:var(--txt);
  border-radius:8px; padding:9px 12px; font-size:14px; }
input:focus, select:focus { outline:none; border-color:var(--acc); }
#pw { width:100%; margin-bottom:14px; }
.btn { background:var(--panel2); border:1px solid var(--line); color:var(--txt);
  border-radius:8px; padding:9px 16px; cursor:pointer; font-size:14px; }
.btn:hover { border-color:var(--acc); }
.btn.primary { background:#0369a1; border-color:#0369a1; color:#fff; }
.btn.primary:hover { background:#0284c7; }
.btn.danger { border-color:var(--bad); color:var(--bad); }
.btn.ghost { background:transparent; }
.btn.sm { padding:5px 10px; font-size:12px; }
.err { color:var(--bad); margin-top:10px; min-height:18px; font-size:13px; }

.topbar { display:flex; align-items:center; gap:24px; padding:12px 20px;
  background:var(--panel); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10; }
.tabs { display:flex; gap:4px; }
.tab { background:transparent; border:0; color:var(--mut); padding:10px 16px; cursor:pointer;
  font-size:14px; border-bottom:2px solid transparent; }
.tab.active { color:var(--txt); border-bottom-color:var(--acc); }
.top-actions { margin-left:auto; display:flex; align-items:center; gap:12px; }
.clock { color:var(--mut); font-size:12px; font-variant-numeric:tabular-nums; }

main { max-width:1200px; margin:0 auto; padding:24px 20px 60px; }
.pane-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; flex-wrap:wrap; gap:10px; }
.pane-head h2 { font-size:20px; }
.hint { color:var(--mut); font-size:12.5px; }
.hint code { background:var(--panel2); padding:2px 6px; border-radius:4px; color:var(--acc); }
.row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin:10px 0; }
.row.end { justify-content:flex-end; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:18px; margin-bottom:16px; }
.card h3 { margin-bottom:10px; font-size:15px; }

.tbl { width:100%; border-collapse:collapse; background:var(--panel); border-radius:12px; overflow:hidden; }
.tbl th, .tbl td { text-align:left; padding:11px 14px; border-bottom:1px solid var(--line); font-size:13.5px; }
.tbl th { color:var(--mut); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.5px; }
.tbl tr:last-child td { border-bottom:0; }

.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:7px; }
.dot.on { background:var(--ok); box-shadow:0 0 8px var(--ok); }
.dot.off { background:var(--bad); }
.dot.pend { background:var(--warn); }
.st { font-size:12.5px; }

.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(270px,1fr)); gap:14px; }
.mcard { background:var(--panel); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.mcard .thumb { height:120px; background:#000 center/contain no-repeat; display:flex; align-items:center; justify-content:center; color:var(--mut); font-size:12px; }
.mcard video.thumbv { height:120px; width:100%; object-fit:cover; background:#000; display:block; }
.mcard .meta { padding:10px 12px; }
.mcard .meta .nm { font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mcard .meta .sub { color:var(--mut); font-size:11.5px; margin:4px 0 8px; }
.mcard .acts { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.mcard .acts input { width:64px; padding:4px 6px; font-size:12px; }

.split { display:grid; grid-template-columns:1fr 1.6fr; gap:16px; }
.pl-item { display:flex; align-items:center; gap:8px; padding:9px 6px; border-bottom:1px solid var(--line); font-size:13.5px; }
.pl-item:last-child { border-bottom:0; }
.pl-item .pos { color:var(--mut); width:26px; }
.pl-item .grow { flex:1; }
.pl-item .k { font-size:11px; color:var(--acc); text-transform:uppercase; letter-spacing:.5px; }
#pl-list .pli { padding:10px 12px; border-radius:8px; cursor:pointer; display:flex; justify-content:space-between; align-items:center; }
#pl-list .pli:hover { background:var(--panel2); }
#pl-list .pli.sel { background:var(--panel2); border:1px solid var(--acc); }

.form-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:10px; margin:10px 0; }
.fld { display:flex; flex-direction:column; gap:4px; min-width:0; }
.fld > span { font-size:12px; color:#94a3b8; letter-spacing:.3px; }
.fld input, .fld select { width:100%; }
#sc-days label { display:flex; gap:5px; align-items:center; font-size:13px; color:var(--mut); }
.pill { display:inline-block; background:var(--panel2); border:1px solid var(--line);
  border-radius:20px; padding:3px 10px; font-size:12px; margin:1px 2px; }
.pill.warn { background:#4a2b00; border-color:#a86a00; color:#ffd9a0; }
.pill.danger { background:#4a1010; border-color:#a83a3a; color:#ffb0b0; }
.badge { display:inline-block; background:#12325e; border:1px solid #2c5cb8; color:#cfe3ff;
  border-radius:6px; padding:3px 10px; font-size:12px; font-weight:600; white-space:nowrap; }
.badge.warn { background:#4a2b00; border-color:#a86a00; color:#ffd9a0; }
/* playlist cards (collapsible, Navori-style) */
.pl-card { margin-bottom:10px; }
.pl-head { display:flex; align-items:center; gap:10px; cursor:pointer; padding:2px 0; }
.pl-head:hover .pl-name { color:var(--acc); }
.pl-chev { color:var(--mut); width:18px; flex:none; }
.pl-name { font-weight:600; font-size:15px; }
.pl-head .grow { flex:1; }
.pl-body { margin-top:10px; border-top:1px solid var(--line); padding-top:10px; }
.pl-items { margin:6px 0; }
.pl-item.dim { opacity:.45; }
.pthumb { width:72px; height:40px; object-fit:cover; border-radius:4px; background:#000; flex:none; }
.pthumb-web { display:flex; align-items:center; justify-content:center; font-size:10px; color:var(--mut);
  background:var(--panel2); border:1px solid var(--line); }
tr.muted td { opacity:.55; }
.mcard.dim { opacity:.45; }
.errline { color:#f87171; font-size:11.5px; margin-top:3px; max-width:260px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.days { display:flex; gap:10px; flex-wrap:wrap; margin:8px 0; }
.days .chk { display:flex; gap:4px; align-items:center; font-size:13px; }
#toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%) translateY(20px);
  background:#1f2937; color:#fff; padding:10px 18px; border-radius:10px; opacity:0;
  transition:all .25s; z-index:99; pointer-events:none; font-size:14px; }
#toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
#toast.err { background:#7f1d1d; }
.modal-body h4 { margin:14px 0 6px; }

#modal { position:fixed; inset:0; background:rgba(0,0,0,.6); display:flex; align-items:center; justify-content:center; z-index:50; }
.modal-card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:24px; width:440px; max-width:92vw; }
.modal-card h3 { margin-bottom:14px; }
.modal-card input, .modal-card select, .modal-card textarea { width:100%; margin:6px 0; }
.modal-card textarea { background:var(--panel2); border:1px solid var(--line); color:var(--txt); border-radius:8px; padding:9px 12px; min-height:70px; font-family:inherit; }
.modal-card label.fl { display:block; font-size:12.5px; color:var(--mut); margin-top:8px; }

/* ---------- monitoring wall ---------- */
.wall-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:12px; }
.wtile { background:var(--panel); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.wtile.off { border-color:var(--bad); box-shadow:0 0 0 1px var(--bad) inset; }
.wtile .wthumb { height:120px; background:#000 center/contain no-repeat; display:flex; align-items:center; justify-content:center; color:var(--mut); font-size:34px; }
.wtile .wthumb.woff { flex-direction:column; gap:6px; background:#141a24; }
.wtile .wthumb.woff span { font-size:13px; letter-spacing:3px; color:var(--bad); font-weight:700; }
.wtile .wbody { padding:8px 10px 10px; }
.wtile .wname { font-weight:700; font-size:13.5px; display:flex; align-items:center; gap:6px; }
.wtile .wnow { color:var(--mut); font-size:12px; margin:3px 0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wtile .wmeta { color:var(--mut); font-size:11.5px; display:flex; justify-content:space-between; align-items:center; }
.wtile .wacts { margin-top:7px; display:flex; gap:6px; }

/* ---------- responsive level 1: phones & small tablets ---------- */
@media (max-width: 760px) {  body { font-size:15px; }
  /* 16px inputs stop iOS auto-zooming on focus */
  input, select, textarea { font-size:16px; }
  /* nav: tabs become a horizontally scrollable strip */
  .topbar { flex-wrap:wrap; gap:8px; padding:10px 12px; }
  .brand.small { font-size:15px; }
  .tabs { order:3; width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .tabs::-webkit-scrollbar { display:none; }
  .tab { padding:12px 14px; white-space:nowrap; flex-shrink:0; }
  .clock { display:none; }
  main { padding:16px 12px 60px; }
  .pane-head h2 { font-size:17px; }
  .card { padding:14px; }
  /* touch-friendly buttons */
  .btn { padding:12px 18px; min-height:44px; font-size:15px; }
  .btn.sm { padding:9px 14px; font-size:13.5px; min-height:40px; }
  .login-card { width:92vw; max-width:360px; padding:32px 24px; }
  .form-grid { grid-template-columns:1fr; }
  /* tables -> cards */
  .tbl.resp, .tbl.resp tbody { display:block; }
  .tbl.resp thead { display:none; }
  .tbl.resp tr { display:block; background:var(--panel); border:1px solid var(--line);
    border-radius:12px; margin-bottom:12px; overflow:hidden; }
  .tbl.resp tr.muted td { opacity:1; }
  .tbl.resp td { display:flex; justify-content:space-between; align-items:center; gap:14px;
    padding:10px 14px; border-bottom:1px solid var(--line); font-size:14px; text-align:right; }
  .tbl.resp td:last-child { border-bottom:0; }
  .tbl.resp td::before { content:attr(data-th); color:var(--mut); font-size:11.5px;
    text-transform:uppercase; letter-spacing:.5px; text-align:left; flex-shrink:0; }
  .tbl.resp td[data-th=""]::before { content:none; }
  .tbl.resp td[data-th=""] { justify-content:flex-end; flex-wrap:wrap; }
  .tbl.resp td:empty { display:none; }
  .tbl.resp .errline { max-width:55vw; }
  /* grids */
  .split { grid-template-columns:1fr; }
  .grid { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; }
  .wall-grid { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; }
  .wtile .wthumb { height:96px; }
  .modal-card { padding:18px; }
  .mcard .acts .btn { flex:1 1 45%; }
}

/* ---------- level-1 mobile additions ---------- */
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width: 760px) {
  .grid2 { grid-template-columns:1fr; }
  /* monitoring wall: 2 compact columns on phones for at-a-glance checks */
  .wall-grid { grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; }
  .wtile .wthumb { height:90px; font-size:26px; }
  .wtile .wname { font-size:12.5px; }
  .wtile .wacts .btn { flex:1; justify-content:center; }
  /* settings email rows stack full width */
  #tab-settings .row > label { width:100%; }
  #tab-settings .row input, #tab-settings .row select { width:100%; }
}

/* ---------- screens tree view ---------- */
.seg { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.seg .btn { border:0; border-radius:0; }
.seg .btn.active { background:var(--acc); color:#fff; }
#screens-tree { border:1px solid var(--line); border-radius:10px; background:var(--panel); padding:6px 0; }
.tnode { display:flex; align-items:center; gap:8px; padding:7px 12px; padding-left:calc(12px + var(--d,0)*26px); }
.tnode:hover { background:var(--panel2); }
.tnode .ttoggle { background:none; border:0; color:var(--mut); font-size:13px; width:22px; cursor:pointer; padding:2px; }
.tnode .ttoggle:hover { color:var(--txt); }
.tnode .gname { font-weight:700; }
.tnode .grow { flex:1; }
.tnode select { font-size:12.5px; padding:3px 6px; }
.tkids.hidden { display:none; }
.tscreen { display:flex; align-items:center; gap:8px; padding:6px 12px; padding-left:calc(12px + var(--d,0)*26px + 22px); font-size:14px; }
.tscreen:hover { background:var(--panel2); }
.tscreen .nm { font-weight:600; }
.tscreen .grow { flex:1; }
.tungrouped { padding:8px 12px 4px; color:var(--mut); font-size:12.5px; text-transform:uppercase; letter-spacing:.5px; }
#tree-search { background:var(--panel2); border:1px solid var(--line); color:var(--txt); border-radius:8px; padding:7px 10px; font-size:14px; }
