:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #141d26;
  --panel-2: #192530;
  --line: #2b3946;
  --text: #f4f7f9;
  --muted: #9dafbd;
  --green: #2dd881;
  --amber: #ffba49;
  --red: #ff4d5e;
  --blue: #58a6ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", Tahoma, sans-serif; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { border-radius: 13px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px clamp(18px, 4vw, 56px); border-bottom: 1px solid var(--line); background: #0e161e; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: .02em; }
.eyebrow { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .16em; margin-bottom: 5px; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.header-tools { display: flex; align-items: center; gap: 10px; }
main { width: min(1440px, 100%); margin: auto; padding: 24px clamp(14px, 3vw, 42px) 48px; }
.status-banner { display: flex; gap: 18px; align-items: center; min-height: 132px; padding: 24px 28px; border: 1px solid var(--line); border-left-width: 7px; border-radius: 14px; background: linear-gradient(120deg, var(--panel), #101820); }
.status-banner.normal { border-left-color: var(--green); }
.status-banner.alarm { border-left-color: var(--red); background: linear-gradient(120deg, #32141a, #171218); }
.status-banner.trouble { border-left-color: var(--amber); }
.status-icon { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 8px #ffffff0b; }
.normal .status-icon { background: var(--green); box-shadow: 0 0 0 8px #2dd8811f; }
.alarm .status-icon { background: var(--red); box-shadow: 0 0 0 8px #ff4d5e22; animation: pulse 1.2s infinite; }
.trouble .status-icon { background: var(--amber); box-shadow: 0 0 0 8px #ffba4922; }
.status-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; }
.status-banner h2 { margin: 3px 0; font-size: clamp(1.5rem, 4vw, 2.5rem); }
#status-detail { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.metric { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 6px 0 2px; font-size: 1.65rem; }
.panel { margin-top: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 18px; }
.legend { color: var(--muted); font-size: .85rem; display: flex; gap: 7px; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-left: 8px; }
.dot.tested { background: var(--green); }
.dot.pending { background: var(--amber); }
.zone-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.zone-card { min-height: 104px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.zone-card.pending { border-color: #735f35; }
.zone-title { display: flex; justify-content: space-between; gap: 8px; }
.zone-number { color: var(--blue); font-weight: 800; }
.zone-card h3 { margin: 7px 0 12px; font-size: 1rem; }
.zone-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #ffffff0d; color: var(--muted); font-size: .72rem; }
.badge.alarm { color: #fff; background: #9b2330; }
.badge.trouble { color: #1b1406; background: var(--amber); }
.badge.system_state { color: #072112; background: var(--green); }
.filters { display: flex; gap: 10px; }
.filters label { color: var(--muted); font-size: .75rem; }
select { display: block; margin-top: 4px; min-width: 130px; padding: 8px 30px 8px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--panel-2); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
td { font-size: .88rem; }
.raw { max-width: 540px; color: #c7d2da; font-family: Consolas, monospace; font-size: .78rem; white-space: normal; }
.origin-live { color: var(--green); }
.origin-test { color: var(--muted); }
.disclaimer { max-width: 900px; margin: 18px auto 0; color: var(--muted); text-align: center; font-size: .78rem; line-height: 1.5; }
.disclaimer.prominent { padding: 14px 18px; border: 1px solid #735f35; border-radius: 10px; background: #ffba490d; }

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #58a6ff66; outline-offset: 2px; }
.primary-button, .secondary-button, .text-button, .small-button, .icon-button, .main-nav button { border: 0; color: var(--text); }
.primary-button, .secondary-button { min-height: 42px; padding: 9px 16px; border-radius: 9px; font-weight: 700; }
.primary-button { background: #1672e8; }
.primary-button:hover { background: #2d84ef; }
.secondary-button { border: 1px solid var(--line); background: var(--panel-2); }
.secondary-button:hover { border-color: var(--blue); }
.text-button { padding: 7px 9px; background: transparent; color: var(--muted); }
.small-button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: #ffffff0a; font-size: .75rem; }
.icon-button { width: 42px; height: 42px; border-radius: 9px; background: var(--panel); font-size: 1.2rem; }
.button-row, .quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.auth-screen { min-height: calc(100vh - 94px); padding: 40px 16px; display: grid; place-items: start center; background: radial-gradient(circle at 50% 10%, #123a5b 0, var(--bg) 42%); }
.auth-card { width: min(440px, 100%); margin-top: 3vh; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: #111b24ee; box-shadow: 0 24px 70px #0008; }
.auth-logo { display: block; width: 86px; height: 86px; margin: 0 0 18px; border-radius: 20px; }
.auth-card h2 { font-size: 1.8rem; }
.form-intro, .auth-help, .helper-text { margin-top: 8px; color: var(--muted); line-height: 1.6; }
.auth-help { font-size: .8rem; text-align: center; }
form { margin-top: 20px; }
form label { display: block; margin-top: 13px; color: var(--muted); font-size: .82rem; }
input, form select { display: block; width: 100%; min-height: 43px; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); }
form .primary-button { width: 100%; margin-top: 18px; }
.form-error { min-height: 1.3em; margin-top: 10px; color: #ff8d98; font-size: .82rem; }
.form-error.success { color: var(--green); }
.password-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: .76rem; }
.password-rules li.valid { color: var(--green); }

.main-nav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px; padding: 8px clamp(14px, 3vw, 42px); border-bottom: 1px solid var(--line); background: #0e161ef2; backdrop-filter: blur(12px); }
.main-nav button { padding: 9px 12px; border-radius: 8px; background: transparent; color: var(--muted); }
.main-nav button:hover, .main-nav button.active { background: var(--panel-2); color: var(--text); }
.nav-spacer { flex: 1; }
.current-user { max-width: 300px; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.quick-panel, .about-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.about-hero p:not(.eyebrow) { max-width: 840px; margin-top: 10px; color: var(--muted); line-height: 1.65; }
.about-hero img { flex: 0 0 auto; border-radius: 28px; }
.about-grid, .admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-grid { grid-template-columns: minmax(280px, .7fr) minmax(560px, 1.3fr); }
.guide-list { padding-left: 22px; color: var(--muted); line-height: 1.75; }
.program-info { margin: 18px 0; }
.program-info div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.program-info dt { color: var(--muted); }
.program-info dd { margin: 0; text-align: right; }
.developer-credit { margin-top: 22px; color: var(--muted); }
.developer-credit a { color: #ffca3a; font-size: 1.15rem; font-weight: 800; text-decoration: none; }
.invite-result { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #ffffff08; }
.invite-result p { color: var(--muted); }
.users-table td:first-child strong, .users-table td:first-child small { display: block; }
.users-table td:first-child small { margin-top: 3px; color: var(--muted); }
.badge.user-active { color: #072112; background: var(--green); }
.badge.user-pending { color: #1b1406; background: var(--amber); }
.badge.user-disabled { color: #fff; background: #7c2b35; }
.onboarding-dialog { width: min(470px, calc(100% - 28px)); padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); text-align: center; }
.onboarding-dialog::backdrop { background: #02060bdc; backdrop-filter: blur(4px); }
.onboarding-dialog img { border-radius: 18px; }
.onboarding-dialog h2 { margin: 12px 0 8px; }
.onboarding-dialog p { color: var(--muted); line-height: 1.6; }
.onboarding-dialog .button-row { justify-content: center; }
@keyframes pulse { 50% { transform: scale(.82); opacity: .65; } }

@media (max-width: 800px) {
  .topbar { padding: 16px; }
  .brand img { width: 42px; height: 42px; }
  .brand h1 { font-size: 1.1rem; }
  .clock { font-size: .75rem; }
  .main-nav { position: fixed; top: 75px; left: 10px; right: 10px; display: none; flex-direction: column; align-items: stretch; padding: 10px; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px #000b; }
  .main-nav.open { display: flex; }
  .nav-spacer { display: none; }
  .current-user { max-width: none; padding: 8px 12px; }
  main { padding: 14px 10px 36px; }
  .status-banner { padding: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 16px 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .quick-panel, .about-hero { align-items: flex-start; flex-direction: column; }
  .about-hero img { width: 100px; height: 100px; order: -1; }
  .about-grid, .admin-grid { grid-template-columns: 1fr; }
  .users-panel { min-width: 0; }
  .events-heading .filters { width: 100%; }
  .filters label { flex: 1; }
  select { width: 100%; min-width: 0; }
  .auth-card { margin-top: 0; padding: 24px 20px; }
  .password-rules { grid-template-columns: 1fr; }
}
