:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #18212f; --muted: #66758a; --line: #dde3ec;
  --accent: #0f7a5c; --accent-soft: #e8f5f0; --danger: #c0392b; --ok: #1fa971; --off: #b3bcc9;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }

button, input, select { font: inherit; }
button { border-radius: 8px; padding: 7px 13px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.primary { background: var(--accent); color: #fff; font-weight: 600; }
.primary.wide { width: 100%; padding: 11px; margin-top: 18px; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: #eef1f6; }
.ghost.danger { color: var(--danger); }
a.connect { display: inline-block; padding: 7px 13px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
a.connect.off { background: none; color: var(--muted); border: 1px solid var(--line); pointer-events: none; font-weight: 400; }
input:not([type=checkbox]), select, textarea { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin: 14px 0 5px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
label.check { display: flex; gap: 6px; align-items: center; margin: 0; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; color: var(--ink); white-space: nowrap; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.hint { color: var(--muted); margin: 4px 0 0; }
.error { color: var(--danger); margin: 10px 0 0; min-height: 20px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; }

/* Acceso */
#gate { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.panel.narrow { width: 100%; max-width: 380px; }
.panel h1 { font-size: 20px; margin: 14px 0 0; }
.panel input { width: 100%; }

/* Consola */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#tabs { display: flex; gap: 4px; flex: 1; margin-left: 12px; }
.tab { background: none; color: var(--muted); font-weight: 600; }
.tab:hover { background: #eef1f6; }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.who { color: var(--muted); }
.view { padding: 20px 24px; }
.bar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.bar .error { margin: 0; }
#search { flex: 1; min-width: 200px; max-width: 420px; }
.count { color: var(--muted); margin-left: auto; }
.tableWrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.id { font-family: Consolas, "Cascadia Mono", monospace; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 6px; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
.state { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.state i { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.state.on i { background: var(--ok); }
.state.busy i { background: #d9a400; }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; width: min(440px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(16, 21, 29, .45); }
dialog h2 { margin: 0; font-size: 17px; }
dialog input, dialog textarea { width: 100%; }
dialog textarea { min-height: 80px; resize: vertical; }
