:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --accent: #58c5ca;
  --accent-rgb: 88, 197, 202;
  --bg: #0a1114;
  --panel: rgba(20, 31, 37, .9);
  --panel-solid: #141f25;
  --field: #0b161b;
  --border: #344750;
  --text: #eef7f7;
  --muted: #a9bbc0;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body {
  min-height: 100vh;
  max-width: 1380px;
  margin: 0 auto;
  padding: 34px clamp(14px, 3vw, 36px) 60px;
  background: radial-gradient(circle at 50% -15%, rgba(var(--accent-rgb), .2), transparent 45%), var(--bg);
  text-align: center;
}
body.surface-admin { --accent: #ff5b67; --accent-rgb: 255, 91, 103; --bg: #13090c; --panel: rgba(38, 18, 23, .92); --panel-solid: #261217; --field: #16090d; --border: #68323a; --muted: #d6afb4; }
body.surface-operator { --accent: #42e28c; --accent-rgb: 66, 226, 140; --bg: #07130e; --panel: rgba(14, 37, 27, .92); --panel-solid: #0e251b; --field: #07170f; --border: #285f45; --muted: #a8ceba; }
[hidden] { display: none !important; }
a { color: var(--accent); font-weight: 700; }
h1 { margin: 5px 0 8px; font-size: clamp(2rem, 5vw, 3.35rem); line-height: 1; }
h2 { margin: 0 0 18px; font-size: 1.18rem; letter-spacing: .08em; text-transform: uppercase; }
h3 { margin: 14px 0 10px; }
p { color: var(--muted); }
small { color: var(--muted); }
.surface-header { max-width: 760px; margin: 0 auto 26px; }
.surface-header p { margin: 0; }
.identity-header { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.identity-header span { padding: 9px 13px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: var(--panel); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.identity-header strong { display: block; margin-top: 4px; color: var(--text); font-size: 1rem; text-transform: none; letter-spacing: 0; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.global-notice { min-height: 1.4em; color: #ffc0c0; white-space: pre-wrap; }
main { width: 100%; }
section, article, .login-card, .action-bar {
  margin: 16px 0;
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .22);
  backdrop-filter: blur(12px);
}
.login-card { width: min(430px, 100%); margin: 38px auto; }
.login-card label { margin: 0 0 12px; }
.action-bar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 16px; }
.operator-token-bar { display: grid; grid-template-columns: auto minmax(260px, 1fr) auto auto; }
.operator-token-bar label { margin: 0; }
.operator-token-bar input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
label { display: grid; align-content: end; gap: 7px; margin: 10px 0; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .04em; }
input, select, textarea, button {
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font: inherit;
}
input, select, textarea { width: 100%; }
select { min-width: 180px; }
button { width: auto; margin: 5px; cursor: pointer; background: rgba(var(--accent-rgb), .16); border-color: var(--accent); font-weight: 800; }
button:hover, button:focus-visible { background: var(--accent); color: var(--bg); }
button.danger { border-color: #ff6771; background: rgba(255, 70, 80, .17); }
button:disabled { opacity: .45; cursor: not-allowed; }
pre { overflow-wrap: anywhere; white-space: pre-wrap; }
.credential-output { color: var(--accent); }
.status-line, [role="status"] { white-space: pre-wrap; }
.form-matrix, .section-tools, .button-matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); align-items: end; gap: 10px; margin: 14px auto; }
.compact-form { max-width: 760px; }
.form-matrix button, .section-tools button { min-height: 42px; }
.section-tools { max-width: 900px; align-items: center; }
.section-tools label { margin: 0; }
.center-field { width: min(440px, 100%); margin: 12px auto; }
.check-field { display: flex; align-items: center; justify-content: center; }
.check-field input { width: auto; }
.operator-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.operator-grid section { margin: 0; }
.span-full { grid-column: 1 / -1; }
#zones, #zones-monitor { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
#zones article, #zones-monitor article { margin: 0; padding: 12px; }
.swatch { height: 65px; border-radius: 8px; }
.monitor-screen { position: relative; display: grid; place-items: center; height: 145px; overflow: hidden; border-radius: 10px; }
.monitor-screen img { max-width: 100%; max-height: 145px; object-fit: contain; }
.monitor-screen span { position: absolute; color: #fff; font-weight: 800; text-shadow: 0 1px 6px #000; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.metric-grid > div { padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--field); }
.metric-grid strong { display: block; color: var(--accent); font-size: 1.8rem; }
.metric-grid span { display: block; margin-top: 4px; color: var(--muted); font-size: .76rem; }
.metrics-scroll, .matrix-scroll, .management-scroll { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.mapping-matrix { min-width: 860px; table-layout: fixed; }
.fixture-matrix { min-width: 1480px; }
.fixture-matrix th:first-child { width: 72px; }
.fixture-matrix th:nth-child(2) { width: 140px; }
.mapping-matrix caption { margin: 0 0 12px; color: var(--muted); text-align: center; }
.mapping-matrix thead th { background: rgba(var(--accent-rgb), .1); }
.mapping-matrix tbody th { position: sticky; left: 0; z-index: 1; background: var(--panel-solid); }
.mapping-matrix tbody tr:nth-child(even) td { background: rgba(var(--accent-rgb), .035); }
.mapping-matrix input { min-width: 0; background: var(--field); text-align: center; font-variant-numeric: tabular-nums; }
.mapping-matrix input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; }
.asset-grid article { min-width: 0; margin: 0; }
.asset-grid img { width: 100%; height: 125px; object-fit: contain; background: var(--field); }
#asset-text { overflow-wrap: anywhere; }
#asset-text ol { max-height: 320px; overflow-y: auto; text-align: left; }
#offline-text { resize: vertical; }
.limit-matrix, .protocol-matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; max-width: 700px; margin: 14px auto; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: var(--border); }
.limit-matrix > *, .protocol-matrix > * { margin: 0; padding: 10px; background: var(--field); }
.protocol-matrix { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
.access-token input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.zone-name-matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; max-width: 1100px; margin: 14px auto; }
.fixture-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(34px, 1fr)); gap: 5px; }
.fixture-preview-grid span { display: grid; place-items: center; min-height: 34px; border: 1px solid var(--border); border-radius: 6px; color: #fff; font-size: .72rem; text-shadow: 0 1px 4px #000; }
.floor { display: flex; height: 180px; border: 2px solid #fff; }
.floor button { flex: 1; margin: 0; border-radius: 0; }
@media (max-width: 820px) {
  body { padding-inline: 10px; }
  .operator-grid { grid-template-columns: 1fr; }
  .span-full { grid-column: auto; }
  .protocol-matrix { grid-template-columns: 1fr 1fr; }
  .operator-token-bar { grid-template-columns: 1fr; }
}
