:root {
  --navy: #02295C; --navy-2: #0a3d82; --red: #D42337; --ink: #1A1A1A; --gray: #5A6472; --line: #D9E2F1; --bg: #F4F7FB; --card: #fff;
  --ok: #1f8a4c; --warn: #d98200; --font: "Century Gothic", "URW Gothic", "Questrial", "Avenir Next", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--navy-2); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray); }
.muted { color: var(--gray); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.right { text-align: right; } .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; }

/* shell */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 14px; padding: calc(8px + env(safe-area-inset-top)) 18px 8px; position: sticky; top: 0; z-index: 10; border-bottom: 3px solid var(--red); }
.topbar img { height: 34px; background: #fff; border-radius: 6px; padding: 2px 6px; }
.topbar .title { font-weight: 700; letter-spacing: .02em; } .topbar .user { margin-left: auto; font-size: 12px; opacity: .9; text-align: right; }
.topbar button.link { color: #fff; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 54px); }
nav.side { background: #fff; border-right: 1px solid var(--line); padding: 14px 10px; }
nav.side a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); margin-bottom: 2px; }
nav.side a:hover { background: var(--bg); text-decoration: none; } nav.side a.on { background: var(--line); color: var(--navy); font-weight: 700; box-shadow: inset 3px 0 0 var(--red); }
main { padding: 20px 22px 60px; min-width: 0; max-width: 1280px; }
.demo { background: #fff4d6; color: #7a5200; padding: 6px 18px; font-size: 12px; text-align: center; border-bottom: 1px solid #f1d58a; }

/* cards & tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(2,41,92,.04); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 10px; padding: 12px 14px; }
.tile.bad { border-top-color: var(--red); } .tile .v { font-size: 26px; font-weight: 700; color: var(--navy); } .tile.bad .v { color: var(--red); } .tile .l { font-size: 12px; color: var(--gray); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--gray); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f1f6fd; }

/* badges, dots */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--line); color: var(--navy); white-space: nowrap; }
.badge.red { background: #fde7ea; color: var(--red); } .badge.green { background: #e1f4e8; color: var(--ok); } .badge.amber { background: #fff1d6; color: #9a5b00; } .badge.gray { background: #eceff3; color: var(--gray); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: #b6bfcb; }
.dot.online { background: var(--ok); } .dot.degraded { background: var(--warn); } .dot.offline { background: var(--red); }

/* ratio bar */
.ratio { display: flex; align-items: center; gap: 8px; min-width: 190px; }
.bar { flex: 1; height: 10px; border-radius: 6px; background: var(--navy); overflow: hidden; position: relative; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--red); }
.bar::after { content: ""; position: absolute; left: 10%; top: -2px; bottom: -2px; width: 2px; background: #fff; box-shadow: 0 0 0 1px var(--ink); opacity: .7; }
.bar.big { height: 18px; border-radius: 9px; }

/* forms */
label { display: block; font-size: 12px; font-weight: 700; color: var(--gray); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #b8c4d8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(10,61,130,.25); border-color: var(--navy-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; padding: 8px 16px; font-weight: 700; }
button:hover { background: var(--navy-2); } button.red { background: var(--red); border-color: var(--red); } button.red:hover { background: #b51d2e; }
button.ghost { background: #fff; color: var(--navy); } button.ghost:hover { background: var(--line); }
button.link { background: none; border: 0; color: var(--navy-2); padding: 2px 6px; font-weight: 400; text-decoration: underline; } button.sm { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--gray); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; } .tabs a.on { color: var(--navy); font-weight: 700; border-color: var(--red); } .tabs a:hover { text-decoration: none; color: var(--navy); }
.err { color: var(--red); font-size: 13px; margin-top: 8px; } .note { background: var(--bg); border-left: 3px solid var(--navy); padding: 8px 12px; margin: 10px 0; font-size: 13px; }

/* login */
.authwrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0 38%, var(--bg) 38%); padding: 20px; }
.authcard { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 26px 26px 22px; box-shadow: 0 12px 40px rgba(2,41,92,.25); border-top: 4px solid var(--red); }
.authcard img { height: 56px; display: block; margin: 0 auto 8px; } .authcard h1 { text-align: center; font-size: 18px; } .authcard .sub { text-align: center; color: var(--gray); margin-bottom: 12px; }
.authcard button { width: 100%; margin-top: 14px; } .authcard .qr { display: block; margin: 8px auto; }
.codeinput { font-size: 22px; letter-spacing: .3em; text-align: center; }

/* chart */
.chart { width: 100%; height: 230px; } .chart text { font: 11px var(--font); fill: var(--gray); } .chart .grid { stroke: var(--line); } .chart .thr { stroke: var(--red); stroke-dasharray: 5 4; } .chart .tgt { stroke: var(--navy-2); stroke-dasharray: 2 4; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--gray); margin-top: 4px; flex-wrap: wrap; } .legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { display: flex; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--line); position: sticky; top: 53px; z-index: 9; gap: 4px; }
  nav.side a { white-space: nowrap; margin: 0; } main { padding: 14px 14px 60px; }
  .topbar .title { font-size: 13px; } .topbar .user span { display: none; }
}

.lang { font-style: normal; margin: 0 8px; } .lang button.link { padding: 2px 5px; font-size: 12px; text-decoration: none; opacity: .65; } .lang button.link.on { font-weight: 700; opacity: 1; text-decoration: underline; }
.authcard .lang button.link { color: var(--navy); }
.lang button.link { width: auto; display: inline-block; margin: 0; }

/* ---------- exchange portal additions ---------- */
.topbar .tenant { font-size: 12px; opacity: .85; border-left: 1px solid rgba(255,255,255,.35); padding-left: 14px; }
.topbar .idle { font-size: 11px; opacity: .75; margin-right: 6px; font-variant-numeric: tabular-nums; }
.topbar .idle.warn { opacity: 1; color: #ffd0d6; font-weight: 700; }
nav.side .count { float: right; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; margin-top: 1px; }
nav.side .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; } .pagehead h1 { margin: 0; } .pagehead .grow { flex: 1; }
.tile .s { font-size: 11px; color: var(--gray); margin-top: 2px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; } td.num, th.num { text-align: right; }
.addr { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.badge.blue { background: #e3ecfa; color: var(--navy-2); } .badge.navy { background: var(--navy); color: #fff; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--gray); margin: 1px 2px; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; } @media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: minmax(96px, 32%) minmax(0, 1fr); gap: 6px 14px; margin: 0; } dl.kv dt { color: var(--gray); font-size: 12px; font-weight: 700; padding-top: 2px; } dl.kv dd { margin: 0; word-break: break-word; }
.big { font-size: 20px; font-weight: 700; color: var(--navy); }
.steps { display: flex; gap: 6px; margin: 4px 0 16px; } .steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); } .steps span.done { background: var(--ok); } .steps span.on { background: var(--navy); }
.checklist { list-style: none; padding: 0; margin: 0; } .checklist li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); } .checklist li:last-child { border: 0; }
.ico { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; background: var(--line); color: var(--gray); }
.ico.ok { background: #e1f4e8; color: var(--ok); } .ico.bad { background: #fde7ea; color: var(--red); } .ico.wait { background: #fff1d6; color: #9a5b00; } .ico.na { background: #eceff3; color: #9aa3ae; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); } .timeline li { position: relative; padding: 0 0 12px 16px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }
.timeline li.custodian::before { background: var(--red); } .timeline .t { color: var(--gray); font-size: 11px; }
details.raw summary { cursor: pointer; color: var(--navy-2); font-size: 13px; margin: 6px 0; } details.raw pre { background: #0f1b2d; color: #d8e3f5; padding: 12px; border-radius: 8px; overflow: auto; font-size: 11.5px; max-height: 340px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hint { font-size: 12px; color: var(--gray); margin-top: 4px; }
.warnbox { background: #fff4d6; border-left: 3px solid var(--warn); padding: 8px 12px; margin: 10px 0; font-size: 13px; }
.okbox { background: #e1f4e8; border-left: 3px solid var(--ok); padding: 8px 12px; margin: 10px 0; font-size: 13px; }
.radios { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; } .radios label { display: flex; gap: 6px; align-items: center; font-weight: 400; color: var(--ink); margin: 0; font-size: 14px; } .radios input { width: auto; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); font-size: 13px; } label.check input { width: auto; margin-top: 3px; }
.empty { color: var(--gray); text-align: center; padding: 24px; }
.qrbox { text-align: center; } .qrbox img { width: 180px; height: 180px; }
.demo-users { margin-top: 16px; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.demo-users button.link { padding: 1px 4px; font-size: 12px; width: auto; margin: 0; display: inline; }
.demo-users table td { padding: 3px 4px; border: 0; }
.bar.hotcold { height: 14px; } .bar.hotcold > i { min-width: 2px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(2,41,92,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; border-top: 4px solid var(--red); box-shadow: 0 20px 60px rgba(2,41,92,.35); }
.modal header { padding: 16px 20px 0; display: flex; align-items: center; } .modal header h2 { margin: 0; flex: 1; } .modal .body { padding: 10px 20px 20px; }
.modal header button.x { background: none; border: 0; color: var(--gray); font-size: 22px; padding: 0 4px; line-height: 1; }
.keyart { display: flex; gap: 14px; align-items: center; background: var(--bg); border-radius: 10px; padding: 12px; margin: 10px 0; }
.keyart .k { width: 46px; height: 64px; border-radius: 8px; background: var(--ink); position: relative; flex: none; } .keyart .k::after { content: ""; position: absolute; left: 13px; top: 22px; width: 20px; height: 20px; border-radius: 50%; background: #d4a93a; box-shadow: 0 0 0 4px rgba(212,169,58,.25); }
.keyart.pulse .k::after { animation: pulse 1.2s infinite; } @keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(212,169,58,0); } }
.pin { font-size: 22px; letter-spacing: .4em; text-align: center; }

/* liveness */
.live { position: relative; width: 280px; height: 280px; margin: 8px auto; border-radius: 50%; overflow: hidden; background: #0f1b2d; box-shadow: 0 0 0 4px var(--line); }
.live.go { box-shadow: 0 0 0 4px var(--ok); } .live video { width: 100%; height: 100%; object-fit: cover; } .live video.mirror { transform: scaleX(-1); }
.live .cue { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #fff; font-weight: 700; text-shadow: 0 1px 3px #000; font-size: 15px; }
.live .count { position: absolute; top: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 30px; font-weight: 700; text-shadow: 0 1px 4px #000; }
.cuelist { display: flex; justify-content: center; gap: 6px; margin: 6px 0; } .cuelist span { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--gray); } .cuelist span.done { background: #e1f4e8; color: var(--ok); } .cuelist span.on { background: var(--navy); color: #fff; }
.hidden { display: none !important; }
.langrow { margin-top: 14px; text-align: center; } .mt8 { margin-top: 8px; }
.legend i.lg-hot { border-color: var(--red); } .legend i.lg-cold { border-color: var(--navy); }
.tabs select { width: auto; margin: 4px 0 4px auto; padding: 5px 8px; font-size: 13px; }
.authcard .checklist li { font-size: 13px; } .authcard .checklist button.sm { width: auto; margin: 0; }
.authcard .actions button { width: auto; flex: 1; margin-top: 4px; }
.authcard button.link { width: auto; display: block; margin: 10px auto 0; }
.authcard .lang button.link, .authcard .demo-users button.link { display: inline; margin: 0; }
.demo-users td:first-child { width: 45%; }
.authcard .qrbox img { width: 170px; height: 170px; }
.modal .card { margin: 8px 0; padding: 12px 14px; }
td select.sm { padding: 4px 6px; font-size: 12px; width: auto; }
.nowrap { white-space: nowrap; word-break: normal; }
.modal.wide { max-width: 760px; }
.lvapp { display: block; width: 100%; height: min(660px, calc(100vh - 220px)); border: 0; border-radius: 12px; background: #0f1115; margin-top: 8px; }
.row.keylogin { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
