:root {
  --bg: #0f1216;
  --card: #171b21;
  --line: #232a33;
  --text: #e9eef5;
  --muted: #8e9aab;
  --accent: #3d8bfd;
  --ok: #38c172;
  --bad: #e0575b;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8;
    --card: #ffffff;
    --line: #e2e7ee;
    --text: #10151b;
    --muted: #6b7787;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: var(--bad); min-height: 18px; margin-top: 8px; font-size: 13px; }

header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px 6px;
}
.brand { font-weight: 700; letter-spacing: 2px; }
#updated { font-size: 12px; }

.tabs {
  display: flex; gap: 6px; padding: 6px 12px 10px; position: sticky; top: 0;
  background: var(--bg); z-index: 5; overflow-x: auto;
}
.tabs button {
  flex: 1 1 auto; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 12px; border-radius: 10px; font-size: 14px; white-space: nowrap;
}
.tabs button.active { border-color: var(--accent); color: var(--accent); }

main { padding: 0 12px 24px; }
.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
}

#login { display: flex; align-items: center; justify-content: center; padding: 24px; }
#login .card { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 26px; font-weight: 700; letter-spacing: 4px; margin-bottom: 4px; }

input {
  width: 100%; padding: 12px 14px; margin: 14px 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px;
}

button { cursor: pointer; font-family: inherit; }
.primary {
  background: var(--accent); color: #fff; border: 0; padding: 12px 16px;
  border-radius: 10px; font-size: 15px; font-weight: 600;
}
.primary:active { opacity: .85; }
.wide { width: 100%; margin-top: 14px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cam { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cam img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #000; }
.cam .name { padding: 8px 10px; font-size: 13px; display: flex; justify-content: space-between; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.row .left { min-width: 0; }
.row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 12px; }

.big { font-size: 44px; line-height: 1; }
.big-text { font-size: 20px; font-weight: 600; margin: 10px 0 4px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
