/* WireWave Camera Gateway - viewer styles (dark control-room theme) */
:root {
  --bg: #0b0f17; --panel: #121826; --panel-2: #182033; --line: #253049; --text: #e6ebf5;
  --muted: #8d99b3; --accent: #38bdf8; --accent-2: #0ea5e9; --ok: #22c55e; --warn: #f59e0b;
  --bad: #ef4444; --rec: #ef4444; --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; vertical-align: -3px; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.brand .icon { width: 22px; height: 22px; color: var(--accent); }
.brand b { color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 200px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-2); border-color: var(--accent-2); color: #04121d; font-weight: 600; }
.btn-danger { background: #3a1216; border-color: #7f1d1d; color: #fecaca; }
.btn-danger.recording { background: var(--rec); color: #fff; animation: pulse 1.2s infinite; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.select { padding: 6px 8px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }

/* grid */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 5px 10px; background: var(--panel); border: 0; border-right: 1px solid var(--line); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent-2); color: #04121d; font-weight: 600; }
.grid { display: grid; gap: 8px; padding: 0 16px 16px; }
.grid.g1 { grid-template-columns: 1fr; } .grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); } .grid.g4 { grid-template-columns: repeat(4, 1fr); }
.grid.gauto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px; }
.tile { position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16 / 9; cursor: pointer; }
.tile:hover { border-color: var(--accent); }
.tile.motion { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.tile ww-video, .tile .ph { position: absolute; inset: 0; display: block; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.ph { display: flex !important; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 10px; }
.tile-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; gap: 6px;
  padding: 6px 8px; background: linear-gradient(#000c, #0000); font-size: 12px; z-index: 2; pointer-events: none; }
.tile-top .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 4px; align-items: center; }
.badge { padding: 1px 6px; border-radius: 4px; background: #0009; border: 1px solid #fff3; font-size: 10px; text-transform: uppercase; }
.badge.rec { background: var(--rec); border-color: var(--rec); }
.badge.mot { background: var(--warn); border-color: var(--warn); color: #000; }
.badge.off { background: #444; }
.tile-tools { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; z-index: 3; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-tools { opacity: 1; }
.tile-tools button { background: #000a; border: 1px solid #fff3; border-radius: 6px; padding: 4px 6px; cursor: pointer; }
.gauto .tile-top { padding: 3px 6px; font-size: 11px; }
.empty { margin: 60px auto; max-width: 520px; text-align: center; padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* modal */
.modal { position: fixed; inset: 0; background: #000b; display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 4vh 12px; overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 640px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.modal-box.wide { max-width: 980px; } .modal-box.full { max-width: 1500px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.x:hover { color: var(--text); }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label, .lbl { font-size: 12px; color: var(--muted); }
.input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0b1220; }
.input:focus, .select:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; } .row > .field { flex: 1; min-width: 140px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; background: var(--panel-2); font-size: 13px; }
.pill input { margin: 0; accent-color: var(--accent-2); }
.pill.active, .pill:has(input:checked) { border-color: var(--accent); background: #0c2a3a; }
.hint { display: flex; gap: 8px; padding: 10px 12px; background: #0c2233; border: 1px solid #164e63; border-radius: 8px; font-size: 13px; }
.box { padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); margin-top: 12px; }
.box.ok { border-color: #166534; background: #0b2416; } .box.bad { border-color: #7f1d1d; background: #2a0f12; }
.box.warn { border-color: #92400e; background: #2a1a08; }
input[type=range] { width: 100%; accent-color: var(--accent-2); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }

/* zoom */
.zoom-stage { position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 78vh; width: 100%; }
.zoom-stage ww-video { position: absolute; inset: 0; display: block; }
.zoom-stage video { width: 100%; height: 100%; object-fit: contain; }
.rec-ind { display: inline-flex; align-items: center; gap: 6px; color: #fecaca; font-weight: 600; }
.rec-ind .dot { background: var(--rec); animation: pulse 1s infinite; }
.qual { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* cards / tables */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.card h4 { margin: 0 0 8px; font-size: 13px; color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #1d2740; }
.bar { height: 8px; background: #0b1220; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.big { font-size: 22px; font-weight: 700; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
pre.log { background: #05080f; border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 200px; overflow: auto; white-space: pre-wrap; font-size: 12px; }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); max-width: 380px; box-shadow: 0 6px 20px #0008; }
.toast.ok { border-color: var(--ok); } .toast.bad { border-color: var(--bad); }

/* login */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }

@keyframes pulse { 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .grid.g3, .grid.g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; } .topbar { padding: 8px 12px; } }
