:root {
  --bg: #0e1116; --panel: #171b22; --line: #262c36; --text: #e6e9ef; --muted: #8b93a1;
  --accent: #d32f2f; --accent2: #ff5252; --ok: #43a047; --warn: #f9a825;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, .btn, select, input {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px;
}
button, .btn { background: var(--accent); border-color: var(--accent); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: var(--accent2); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; border-color: var(--line); }
button.ghost:hover { background: var(--line); }
[hidden] { display: none !important; }

.brand { font-weight: 700; font-size: 18px; letter-spacing: .3px; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.logo { background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 4px; margin-right: 4px; }
.brand.big { font-size: 26px; text-align: center; }

.top {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.top nav { display: flex; gap: 6px; flex: 1; }
.tab { background: transparent; border-color: transparent; }
.tab.active { background: var(--line); border-color: var(--line); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }

main { padding: 12px 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; color: var(--muted); }
.toolbar label { display: flex; align-items: center; gap: 6px; }
.hint { margin-left: auto; font-size: 13px; }

.grid { display: grid; gap: 6px; height: calc(100vh - 130px); min-height: 300px; }
.g1 { grid-template-columns: 1fr; }
.g4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.g9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.g16 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.tile { position: relative; background: #000; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); cursor: zoom-in; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 13px;
  background: linear-gradient(transparent, rgba(0,0,0,.8)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .state, .full .state { color: var(--muted); font-size: 13px; }
.tile .state { position: absolute; top: 50%; left: 0; right: 0; text-align: center; transform: translateY(-50%); }
.empty { color: var(--muted); text-align: center; margin-top: 60px; }

.full { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; z-index: 10; }
.fullbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); }
.fullbar #fulltitle { font-weight: 600; }
.fullbar button { margin-left: auto; }
.full video { flex: 1; width: 100%; min-height: 0; object-fit: contain; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 13px; }
.err { color: var(--accent2); min-height: 1em; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.bar { display: inline-block; width: 120px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar .fill { height: 100%; background: var(--accent); transition: width .5s; }
.ok { color: var(--ok); } .bad { color: var(--accent2); } .warn { color: var(--warn); font-size: 12px; } .muted { color: var(--muted); }

.login-page { display: flex; align-items: center; justify-content: center; }
.login-card {
  width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card .sub { text-align: center; color: var(--muted); margin: -8px 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.login-card button { padding: 10px; }

@media (max-width: 700px) {
  .g9, .g16 { grid-template-columns: repeat(2, 1fr); grid-template-rows: none; grid-auto-rows: 28vh; height: auto; }
  .g4 { grid-template-rows: none; grid-auto-rows: 28vh; height: auto; }
  .hint { display: none; }
  .brand small { display: none; }
}

/* ---- Configuración ---- */
.subform { margin-top: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 12px; }
.subform h3, .probe h3 { margin: 0; font-size: 15px; }
.subform .row label input, .subform .row label select { min-width: 150px; }
label.wide { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
textarea { font: 14px/1.4 ui-monospace, Consolas, monospace; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; width: 100%; max-width: 520px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
label.chk { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.probe { margin: 12px 0; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.stat { margin: 4px 0; font-size: 14px; }
#devnew, #usrnew { margin-top: 10px; }
.card table + button { margin-top: 10px; }
.warn { color: var(--warn); }
