:root {
  --navy: #03081f;
  --surface: #0b1b2d;
  --surface2: #0f2438;
  --border: #16324a;
  --accent: #0e96c9;        /* overridden per-center from JS */
  --accent-dark: #0b7aa6;
  --text: #e8eef5;
  --muted: #93a4b8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--navy); color: var(--text); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.meta { color: var(--muted); font-size: 13px; }
.err { color: #fca5a5; font-size: 13px; min-height: 18px; margin-top: 8px; }

input, select, button { font-family: inherit; }
button { font-size: 14px; }
input, select { width: 100%; padding: 10px 12px; margin: 6px 0; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 16px; } /* 16px avoids iOS focus-zoom */
textarea { width: 100%; padding: 10px 12px; margin: 6px 0; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 14px; font-family: inherit; }
.legal-edit { direction: rtl; line-height: 1.6; }
.token-box { background: var(--surface2); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.token-val { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.token-val code, .token-box code { background: var(--navy); padding: 4px 8px; border-radius: 6px; direction: ltr; word-break: break-all; font-size: 13px; }
.code-row { display: flex; gap: 8px; align-items: center; }
.code-input { text-align: center; letter-spacing: 12px; font-size: 22px; font-family: "Courier New", monospace; padding-inline-start: 22px; }
.paste-btn { white-space: nowrap; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; }
label { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; }
label select, label input[type=checkbox] { width: auto; }
button { cursor: pointer; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 700; }
button.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 8px; }
button.primary:hover { background: var(--accent-dark); }
button.link { background: none; color: var(--accent); width: auto; padding: 6px; }
button.link.danger { color: #ef4444; }
.setting-card { background: rgba(255,255,255,0.03); border: 1px solid #1e2747; border-radius: 10px; padding: 16px; max-width: 520px; }
.setting-card h3 { font-size: 1rem; }
#preview-center { background: #03081F; color: #fff; border: 1px solid #2a3a66; border-radius: 6px; padding: 2px 6px; }
.agent-actions { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }
.ctl-guide { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 10px 0 14px; }
.ctl-guide summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.ctl-guide-body { margin-top: 10px; font-size: 13.5px; line-height: 1.7; }
.ctl-guide-body ol { padding-inline-start: 20px; }
.ctl-guide-body li { margin: 7px 0; }
.ctl-code { background: var(--navy); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 6px 0; direction: ltr; text-align: left; font-size: 12.5px; font-family: "Courier New", monospace; color: var(--text); }
.kbd { background: var(--navy); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 12px; direction: ltr; display: inline-block; }

.center { max-width: 380px; margin: 7vh auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; text-align: center; }
.card input { text-align: right; }
.card button { text-align: center; }
.logo-login { max-width: 180px; max-height: 64px; margin: 0 auto 14px; display: block; }
.qr { background: #fff; padding: 10px; border-radius: 8px; display: inline-block; margin: 8px auto; }
.qr svg, .qr img, .qr canvas { width: 180px; height: 180px; }
.secret-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.secret-row code { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; letter-spacing: 1px; direction: ltr; word-break: break-all; }
.secret-row button.link { white-space: nowrap; }
.back-link { display: block; width: 100%; margin-top: 12px; text-align: center; font-size: 13px; }

.topbar { background: var(--navy); border-bottom: 1px solid var(--border); }
.topbar-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; direction: ltr; } /* logo left, account right */
.brand-logo { max-height: 38px; max-width: 170px; }
.who { direction: rtl; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px 20px; border-top: 1px solid var(--border); direction: rtl; justify-content: flex-start; } /* separate row, RTL, right-aligned */
.tab { background: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; }
.tab.active { background: var(--surface); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.content { padding: 20px; max-width: 1100px; margin: 0 auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.row-between input { width: auto; display: inline-block; margin-inline-end: 6px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); font-size: 14px; }
.grid th { background: var(--surface2); color: var(--muted); font-weight: 600; font-size: 12px; }
.grid tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.armed { background: #7f1d1d; color: #fecaca; }
.disarmed { background: #14532d; color: #bbf7d0; }
.offline, .unknown { background: #475569; color: #e2e8f0; }
.btn-arm { background: #dc2626; color: #fff; padding: 6px 12px; }
.btn-disarm { background: #16a34a; color: #fff; padding: 6px 12px; margin-inline-start: 6px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.stale-banner { background: #7c2d12; border: 1px solid #ea580c; color: #fed7aa; border-radius: 10px; padding: 11px 14px; margin-bottom: 12px; font-size: 13.5px; line-height: 1.5; }
/* Stale rows: a subtle tint, NOT dimming — the disconnect warning must stay loud. */
.row-stale { background: rgba(234,88,12,.07); }
.badge.nodata { background: #78350f; color: #ffedd5; border: 1px solid #f59e0b; }
.last-known { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.nodata-act { color: #fdba74; font-weight: 700; }

#client-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #78350f; color: #ffedd5; border: 1px solid #f59e0b; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; font-weight: 700; }
#client-preview-bar button { background: #f59e0b; color: #1a2433; border: none; border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* ── Client panel (end customers) — white-label, single dominant action ───── */
#client-view { max-width: 460px; margin: 5vh auto; padding: 0 16px; }
.client-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px 24px 34px; text-align: center; margin-bottom: 18px; }
.client-site { font-size: 25px; margin: 0 0 20px; color: var(--text); font-weight: 700; }
.client-status { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 15px; font-weight: 800; padding: 11px 20px; border-radius: 999px; margin: 0 auto 28px; }
.client-status .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.client-status.armed { background: rgba(220,38,38,.14); color: #fca5a5; border: 1px solid #7f1d1d; }
.client-status.armed .dot { background: #ef4444; box-shadow: 0 0 10px #ef4444; }
.client-status.disarmed { background: rgba(22,163,74,.14); color: #86efac; border: 1px solid #14532d; }
.client-status.disarmed .dot { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.client-status.unknown { background: rgba(100,116,139,.16); color: #cbd5e1; border: 1px solid #475569; }
.client-status.unknown .dot { background: #94a3b8; }
.client-action { width: 100%; font-size: 23px; font-weight: 800; padding: 24px; border-radius: 16px; color: #fff; background: var(--accent); border: none; cursor: pointer; box-shadow: 0 8px 24px rgba(14,150,201,.35); transition: transform .08s, filter .15s; }
.client-action:hover { filter: brightness(1.08); }
.client-action:active { transform: scale(.98); }
.client-action:disabled { background: #475569; cursor: not-allowed; box-shadow: none; opacity: .7; }
.client-busy { color: var(--muted); font-size: 16px; padding: 24px; }
.client-updated { color: var(--muted); font-size: 12px; margin-top: 12px; }
#client-confirm { max-width: 460px; margin: 4px auto 0; text-align: center; }
.confirm-pref { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.confirm-pref > span { color: var(--text); font-size: 14px; }
.b-secure { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 18px; font-weight: 700; font-size: 15px; width: 100%; }
.b-secure:hover { background: rgba(14,150,201,.12); }
.confirm-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

.doc-links { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 6px; }
.doc-links a { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; width: 100%; max-width: 360px; }

/* ── Legal documents — card grid ────────────────────────────────────────── */
.legal-group { color: var(--accent); font-size: 0.95rem; margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.legal-group:first-child { margin-top: 8px; }
.legal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.legal-doc { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: inherit; transition: border-color .15s, transform .1s, background .15s; }
.legal-doc:hover { border-color: var(--accent); background: rgba(14,150,201,0.07); transform: translateY(-1px); }
.legal-doc-ic { font-size: 1.7rem; line-height: 1; flex: 0 0 auto; }
.legal-doc-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.legal-doc-tx b { color: #fff; font-size: 0.97rem; }
.legal-doc-tx span { color: var(--muted); font-size: 0.8rem; }
#u-docs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
#u-docs .meta { grid-column: 1 / -1; }

.guide { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.guide h3 { color: var(--accent); }
.guide .cat { font-size: 12px; color: var(--muted); }
.guide-pdf { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; padding: 9px 16px; border-radius: 8px; text-decoration: none; }
.guide-pdf:hover { background: var(--accent-dark); }

/* ── Pricing calculator / quote ─────────────────────────────────────────── */
.price-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.price-inputs label { display: block; color: var(--muted); font-size: 13px; margin-top: 8px; }
.price-inputs input[type=checkbox] { width: auto; margin-inline-end: 6px; }
.price-output { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-height: 200px; }
.quote .q-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--accent); padding-bottom: 8px; margin-bottom: 10px; font-size: 16px; }
.quote .q-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 3px 0; }
.q-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.q-table td { padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.q-table td:last-child { text-align: left; direction: ltr; font-weight: 600; }
.q-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 800; margin: 8px 0; padding: 8px 0; border-top: 1px solid var(--border); }
.q-total.pos b { color: #22c55e; } .q-total.neg b { color: #ef4444; }
.q-sep { border-top: 2px dashed var(--border); margin: 12px 0; }
.q-sub { font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.q-note { background: rgba(14,150,201,.08); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12.5px; margin-top: 12px; line-height: 1.6; }
.q-foot { color: var(--muted); font-size: 11px; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
@media (max-width: 760px) { .price-grid { grid-template-columns: 1fr; } }
@media print { body * { visibility: hidden !important; } #pr-output, #pr-output * { visibility: visible !important; } #pr-output { position: absolute; inset: 0; border: none; } }

/* ── Legal consent gate ─────────────────────────────────────────────── */
.legal-card { max-width: 760px; margin: 5vh auto; }
.legal-scroll { max-height: 52vh; overflow: auto; text-align: right; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin: 8px 0 14px; }
.legal-doc h1 { font-size: 20px; color: var(--accent); }
.legal-doc h2 { font-size: 16px; color: var(--text); margin-top: 18px; }
.legal-doc h3 { font-size: 14px; color: var(--muted); margin-top: 14px; }
.legal-doc p, .legal-doc li { font-size: 13px; line-height: 1.7; color: var(--text); }
.legal-doc ul { padding-inline-start: 20px; margin: 6px 0; }
.legal-doc blockquote { border-inline-start: 3px solid var(--accent); margin: 10px 0; padding: 6px 12px; color: var(--muted); background: rgba(14,150,201,.06); border-radius: 4px; }
.legal-doc code { background: var(--navy); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.legal-doc table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.legal-doc th, .legal-doc td { border: 1px solid var(--border); padding: 6px 9px; text-align: right; }
.legal-doc th { background: var(--surface); color: var(--muted); }
.legal-doc hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.legal-sep { border: none; border-top: 2px dashed var(--border); margin: 22px 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.legal-dl { display: inline-block; background: var(--surface); border: 1px solid var(--accent); color: var(--accent); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; text-decoration: none; }
.legal-dl:hover { background: var(--accent); color: #fff; }
.terms-agree { display: flex; align-items: flex-start; gap: 10px; text-align: right; color: var(--text); font-size: 14px; margin: 4px 0 10px; cursor: pointer; }
.terms-agree input { margin-top: 3px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 440px; max-width: 92vw; max-height: 90vh; overflow: auto; }
.sites-pick { margin-top: 10px; max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.sites-pick label { display: flex; align-items: center; gap: 8px; }

/* ── Responsive: tablet/phone ───────────────────────────────────────────── */
@media (max-width: 760px) {
  .content { padding: 12px; }
  .topbar-top { padding: 10px 12px; }
  .brand-logo { max-height: 32px; }
  .nav { padding: 6px 10px; gap: 2px; }
  .tab { padding: 7px 9px; font-size: 12.5px; }
  .row-between { gap: 6px; }
  .row-between > div { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .row-between input { width: 100%; margin: 4px 0; }
  h2 { font-size: 18px; }
  .tabpane { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .grid th, .grid td { padding: 6px 5px; font-size: 11.5px; }
  .btn-arm, .btn-disarm { display: block; width: 100%; margin: 3px 0; }
  .center { margin: 4vh 12px; max-width: none; }
  .card { padding: 22px 18px; }
  .legal-card { margin: 3vh 10px; max-width: none; }
  .legal-scroll { max-height: 46vh; }
}
@media (max-width: 420px) {
  .card { padding: 18px 14px; }
  .qr svg, .qr img { width: 160px; height: 160px; }
  .brand span { display: none; } /* keep just the logo on tiny screens */
}
