:root { color-scheme: dark; --bg: #101113; --panel: #17181b; --panel-2: #1d1f22; --border: #2b2d30; --text: #eeefeb; --muted: #92968e;
  --accent: #c9ef98; --accent-ink: #18210f; --amber: #e0bd7b; --red: #e48c88; --radius: 10px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.brand .mark { font-size: 26px; font-weight: 900; font-style: italic; letter-spacing: -2px; color: var(--accent); }
.brand .sub { font-size: 10px; letter-spacing: 3px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: 1.6px; color: var(--muted); font-weight: 600; }
h1 { margin: 2px 0 6px; font-size: 26px; letter-spacing: -0.5px; } h2 { font-size: 17px; margin: 0 0 12px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; text-decoration: none; font-weight: 600; }
button:disabled { opacity: .6; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ghost { background: transparent; } .ghost.active { background: #252c20; color: var(--accent); border-color: #3d4933; }
.danger { background: transparent; color: var(--red); border-color: #5a3331; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
input, select { min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); font-size: 14px; color: var(--text); width: 100%; }
input:focus, select:focus { border-color: var(--accent); outline: none; }
.form-error { color: var(--red); min-height: 1.2em; margin: 0; font-size: 13px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: rgba(16,17,19,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 8px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 600; }
.topbar nav a.active, .topbar nav a:hover { background: #1e211c; color: var(--accent); }
.me { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
main { padding: 24px; max-width: 1600px; margin: 0 auto; outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.form { display: grid; gap: 14px; max-width: 640px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px; } legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 13px; }
label.check input { width: 16px; min-height: 16px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  background: #24262a; color: var(--muted); white-space: nowrap; }
.badge.live { background: #24321d; color: var(--accent); } .badge.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.badge.partial { background: #33301f; color: var(--amber); } .badge.warn { background: #2f2a1e; color: var(--amber); } .badge.error { background: #3a2321; color: var(--red); }

.gyms { display: grid; gap: 28px; }
.gym h2 { display: flex; align-items: baseline; gap: 12px; } .gym .count { font-size: 12px; color: var(--muted); font-weight: 500; }
.nvr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.nvr-card { display: block; padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); text-decoration: none; transition: border-color .15s; }
.nvr-card:hover { border-color: #3d4933; }
.nvr-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; }
.nvr-card dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nvr-card dt { font-size: 10px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; } .nvr-card dd { margin: 0; font-size: 13px; }
.empty { text-align: center; padding: 60px 16px; border: 1px dashed var(--border); border-radius: 14px; } .empty p { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.layout-switch { display: flex; gap: 4px; } .layout-switch button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tiles[data-cols="2"] { grid-template-columns: repeat(2, 1fr); } .tiles[data-cols="3"] { grid-template-columns: repeat(3, 1fr); } .tiles[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
.tile { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--border); cursor: zoom-in; }
.tile video, .tile-canvas { width: 100%; height: 100%; object-fit: contain; display: block; background: #0b0c0d; }
.tile:fullscreen { aspect-ratio: auto; cursor: zoom-out; }
.tile-bar { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); font-size: 12px; }
.user-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }

.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--border); z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.success { border-color: #3d4933; color: var(--accent); } .toast.error { border-color: #5a3331; color: var(--red); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; } .topbar nav { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .me { margin-left: auto; } #me-email { display: none; }
  main { padding: 16px; } .row { grid-template-columns: 1fr; }
  .tiles, .tiles[data-cols] { grid-template-columns: 1fr; } .layout-switch { display: none; }
}
