* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #1c2333; background: #f4f5f7; }
a { color: #c8102e; text-decoration: none; }
a:hover { text-decoration: underline; }
.accent { color: #e0243a; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: #c8102e; color: #fff; font-weight: 800; font-size: 19px; }
.brand-name { font-weight: 800; letter-spacing: .06em; font-size: 15px; }
.brand-sub { font-size: 11px; color: #8a93a6; }

/* Auth pages */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #10151f; padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; padding: 34px 34px 26px; width: 100%; max-width: 400px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.auth-card h1 { font-size: 22px; margin: 22px 0 14px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 0; color: #39415a; }
.auth-card input { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid #ccd2e0; border-radius: 8px; font-size: 15px; }
.auth-card input:focus { outline: 2px solid #c8102e33; border-color: #c8102e; }
.auth-alt { font-size: 13px; color: #5b6478; text-align: center; margin: 16px 0 0; }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.notice.error { background: #fdecec; color: #8f1020; border: 1px solid #f3c2c8; }

/* Buttons */
.btn { display: inline-block; border: 1px solid #ccd2e0; background: #fff; color: #1c2333; border-radius: 8px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #9aa4bb; text-decoration: none; }
.btn.primary { width: 100%; margin-top: 20px; background: #c8102e; border-color: #c8102e; color: #fff; padding: 12px; font-size: 15px; }
.btn.primary:hover { background: #a90d27; }
.btn.small { padding: 6px 11px; font-size: 13px; }

/* App layout */
.app-body { display: flex; min-height: 100vh; }
.side { width: 232px; flex: 0 0 232px; background: #10151f; color: #dfe4ef; display: flex; flex-direction: column; padding: 20px 14px; }
.side-brand .brand-name { color: #fff; }
.side nav { margin-top: 28px; display: flex; flex-direction: column; gap: 4px; }
.nav-item { text-align: left; background: none; border: 0; color: #aeb7c9; font-size: 14.5px; font-weight: 600; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.nav-item:hover { background: #1a2130; color: #fff; }
.nav-item.active { background: #c8102e; color: #fff; }
.side-foot { margin-top: auto; border-top: 1px solid #232c40; padding-top: 14px; font-size: 13px; }
.side-site { font-weight: 700; color: #fff; }
.side-user { color: #8a93a6; margin: 2px 0 8px; }
.signout { color: #aeb7c9; font-size: 13px; }
.main { flex: 1; padding: 26px 30px; min-width: 0; }
.tab { display: none; }
.tab.active { display: block; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.pill.ok { background: #e2f4e5; color: #176b26; }
.pill.warn { background: #fdf0d7; color: #7a5410; }

/* Player */
.player-card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(16,21,31,.12); overflow: hidden; }
.player-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #e6e9f0; }
.cam-name { font-weight: 700; font-size: 14.5px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #c3c9d6; display: inline-block; margin-left: 10px; }
.live-dot.on { background: #e0243a; box-shadow: 0 0 0 4px #e0243a22; }
.live-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: #5b6478; }
.spacer { flex: 1; }
.stage { position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 68vh; }
.stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #aeb7c9; font-size: 15px; padding: 20px; }
.stage-msg.static { position: static; min-height: 300px; }
.player-foot { padding: 11px 16px; font-size: 12.5px; color: #5b6478; border-top: 1px solid #e6e9f0; }

/* Cards and recordings */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(16,21,31,.12); padding: 18px; }
.muted { color: #5b6478; font-size: 14px; }
.rec-list { display: flex; flex-direction: column; }
.rec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #edf0f5; }
.rec-row:last-child { border-bottom: 0; }
.rec-when { font-weight: 700; font-size: 14.5px; }
.rec-meta { font-size: 12.5px; color: #5b6478; margin-top: 2px; }
.kv > div { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid #edf0f5; font-size: 14.5px; }
.kv > div:last-child { border-bottom: 0; }
.kv span { color: #5b6478; }

@media (max-width: 760px) {
  .app-body { flex-direction: column; }
  .side { width: 100%; flex: none; }
  .main { padding: 18px; }
}

.atable { width: 100%; border-collapse: collapse; font-size: 14px; }
.atable th, .atable td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; vertical-align: middle; }
.atable th { color: #9aa3ad; font-weight: 600; }
.atable td.actions { white-space: nowrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin-right: 8px; }
.inline-form input[type="text"], .inline-form input[type="password"] { padding: 6px 8px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; margin-bottom: 10px; }
.grid-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.notice.ok { background: rgba(46,160,80,.15); border: 1px solid rgba(46,160,80,.5); color: #b7e4c7; }
a.nav-item { text-decoration: none; display: block; }
span.nav-item { cursor: default; }

.cam-select { background: #22262e; color: #e8ebef; border: 1px solid #333a44; border-radius: 6px; padding: 4px 6px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; }

.demo-stage { position: absolute; inset: 0; background: #000; }
.demo-stage img, .demo-stage video { width: 100%; height: 100%; object-fit: contain; display: none; }
.demo-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px; background: rgba(10,12,16,.72); color: #e8ebef; font-size: 14px; }
.thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; background: #11141a; }

.btn.danger { background: #f6dde1; color: #8f1020; }
.req-text { width: 100%; min-height: 90px; margin-top: 6px; }
.grid-form label.check { flex-direction: row; align-items: center; gap: 8px; }
.preview { max-width: 420px; width: 100%; border-radius: 8px; background: #000; display: block; }

/* Health monitor */
.main .card { margin-bottom: 16px; }
.health-list { display: flex; flex-direction: column; }
.health-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid #edf0f5; font-size: 14.5px; flex-wrap: wrap; }
.health-row:last-child { border-bottom: 0; }
.health-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px; display: inline-block; }
.health-dot.green { background: #2e9e4f; box-shadow: 0 0 0 4px rgba(46,158,79,.18); }
.health-dot.red { background: #d42b2b; box-shadow: 0 0 0 4px rgba(212,43,43,.18); }
.health-dot.gray { background: #9aa3ad; box-shadow: 0 0 0 4px rgba(154,163,173,.18); }
.health-name { font-weight: 700; min-width: 150px; }
.health-detail { color: #5b6478; flex: 1; min-width: 200px; }
.health-state { color: #39415a; font-size: 13px; }
