:root {
  --blue: #2f65ba; --blue-2: #2196f3; --bg: #f3f6fb; --card: #ffffff; --text: #1b2a41; --muted: #62708a;
  --line: #dde4f0; --ok: #1a9b5b; --warn: #c98200; --bad: #d23a3a; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1622; --card: #172233; --text: #e6edf8; --muted: #93a2bd; --line: #26364d; }
  .logo { filter: brightness(1.5) saturate(1.1); }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 20px; } h3 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* login / setup */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 16px; padding: 28px; box-shadow: 0 10px 40px rgba(20, 40, 90, .12); }
.auth-card .logo { display: block; width: 260px; max-width: 100%; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; font-size: 18px; color: var(--muted); font-weight: 500; margin-bottom: 20px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-2); border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: linear-gradient(90deg, var(--blue), var(--blue-2)); color: #fff; font-weight: 600; }
.btn:hover { filter: brightness(1.08); } .btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; margin-top: 18px; }
.btn.ghost { background: transparent; color: var(--blue-2); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }
.hint { color: var(--muted); font-size: 13px; }
.secret { font: 600 16px/1.4 Consolas, monospace; letter-spacing: 2px; background: var(--bg); padding: 10px; border-radius: 8px; word-break: break-all; text-align: center; margin: 8px 0; user-select: all; }

/* app shell */
header.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top .logo { height: 34px; }
header.top .grow { flex: 1; }
header.top .who { font-size: 13px; color: var(--muted); text-align: right; }
nav.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.tabs button { background: none; border: 0; padding: 12px 14px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs button.active { color: var(--blue-2); border-color: var(--blue-2); font-weight: 600; }
main { max-width: 1180px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 30px; font-weight: 700; color: var(--blue); } .stat .l { color: var(--muted); font-size: 13px; }
.connect { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.connect .field { flex: 1; min-width: 220px; } .connect label { margin-top: 0; }
.connect input { font-size: 20px; letter-spacing: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); }
.pill.ok { background: #d9f3e5; color: #0f6c3d; } .pill.warn { background: #fdecc8; color: #8a5a00; }
.pill.bad { background: #fadcdc; color: #9b2222; } .pill.blue { background: #d9e9fb; color: #1d4f9a; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #aab4c6; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #1a9b5b33; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.timer { font: 600 16px Consolas, monospace; }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.banner { padding: 12px 14px; border-radius: 8px; background: #fdecc8; color: #6d4700; margin-bottom: 14px; font-size: 14px; }
.once { background: #d9e9fb; color: #17407f; padding: 12px; border-radius: 8px; margin: 12px 0; word-break: break-all; font-family: Consolas, monospace; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2a41; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
@media (max-width: 640px) { header.top .who { display: none; } main { padding: 12px; } }
