:root {
  --bg: #0B1220;
  --panel: #111A2C;
  --panel-2: #16223A;
  --line: #22314D;
  --text: #E6ECF5;
  --muted: #8A9BB7;
  --accent: #22D3EE;
  --red: #E53935;
  --ok: #4ADE80;
  --warn: #F59E0B;
  --working: #3B82F6;
  --scheduled: #14B8A6;
  --idle: #64748B;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.45 Inter, system-ui, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- sign-in screens ---------- */
.center-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; text-align: center; }
.brand-title { margin: 0; font: 800 20px/1.1 Inter, sans-serif; letter-spacing: .14em; color: #fff; }
.brand-title span { color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: left; }
.stack { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--muted); }
input[type=email] { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
input[type=email]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #04202A; border-color: var(--accent); }
.btn-small { padding: 6px 10px; font-size: 13px; }
.muted { color: var(--muted); }
.or { text-align: center; margin: 2px 0; font-size: 13px; }
.msg { min-height: 1.2em; margin: 0; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); background: #0A1020; }
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.place { color: var(--muted); font-size: 13px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.live.on .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(74, 222, 128, .15); }
.live.stale .dot { background: var(--warn); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.viewonly { font-size: 12px; font-weight: 600; border: 1px dashed var(--line); color: var(--muted); padding: 3px 8px; border-radius: 6px; }

/* ---------- layout ---------- */
.layout { display: flex; flex-wrap: wrap; min-height: calc(100vh - 58px); }
.twin-wrap { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; }
.panel { flex: 1 1 340px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--line); padding: 18px 18px 28px; display: flex; flex-direction: column; gap: 12px; overflow: auto; max-height: calc(100vh - 58px); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0D1528; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; }
.seg-btn { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.seg-btn:focus-visible { outline: 2px solid var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.twin { position: relative; flex: 1 1 auto; min-height: 520px; overflow: hidden; }
.twin canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.twin-labels { position: absolute; inset: 0; pointer-events: none; }
.twin-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); z-index: 2; }
.hint { position: absolute; left: 12px; bottom: 10px; margin: 0; font-size: 12px; color: rgba(15, 23, 42, .75); background: rgba(255, 255, 255, .7); padding: 4px 8px; border-radius: 6px; pointer-events: none; z-index: 1; }
.twin[data-daylight="night"] .hint { color: #CBD5E1; background: rgba(15, 23, 42, .6); }

/* 3D labels */
.lbl { font: 600 12px/1 Inter, sans-serif; white-space: nowrap; color: #fff; background: rgba(15, 23, 42, .86); border: 1px solid rgba(255, 255, 255, .14); border-radius: 7px; padding: 5px 8px; display: inline-flex; align-items: center; gap: 7px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.lbl.agent { pointer-events: auto; cursor: pointer; }
.lbl.agent:hover { border-color: var(--accent); }
.lbl.agent:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lbl.agent.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(34, 211, 238, .45); }
.lbl.planned { background: rgba(255, 255, 255, .8); color: #334155; border: 1px dashed #64748B; font-weight: 600; box-shadow: none; }
.lbl.you { background: #FACC15; color: #1C1917; border-color: #CA8A04; }
.lbl.walker { background: #FACC15; color: #1C1917; border-color: #CA8A04; transition: opacity .3s; }
.lbl.walker.paused { opacity: 0; }
.chip { font: 700 11px/1 Inter, sans-serif; padding: 3px 6px; border-radius: 5px; }
.chip.working { background: var(--working); color: #fff; }
.chip.attention { background: var(--warn); color: #1C1917; }
.chip.scheduled { background: var(--scheduled); color: #fff; }
.chip.idle { background: #334155; color: #CBD5E1; }
.chip.delivered { background: #FACC15; color: #1C1917; animation: pulse .6s ease-in-out 6; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.zone { font: 700 10px/1 Inter, sans-serif; letter-spacing: .12em; color: rgba(15, 23, 42, .78); background: rgba(255, 255, 255, .62); padding: 3px 6px; border-radius: 4px; white-space: nowrap; }
.floor-tag button { pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: rgba(11, 18, 32, .9); color: #fff; border: 0; border-left: 4px solid var(--red); border-radius: 6px; padding: 6px 10px; }
.floor-tag button strong { font: 800 13px/1 Inter, sans-serif; letter-spacing: .04em; }
.floor-tag button span { font: 500 11px/1.2 Inter, sans-serif; color: #A5B4CC; }
.floor-tag button:hover, .floor-tag button:focus-visible { border-left-color: var(--accent); outline: none; }

/* status bar */
.statusbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.stat { background: #0D1528; padding: 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font: 700 15px/1.2 "JetBrains Mono", monospace; color: #fff; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }

/* side panel */
.panel-h { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.agent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agent-row { width: 100%; display: grid; grid-template-columns: 10px 1fr auto; grid-template-areas: "dot name status" "dot room status"; column-gap: 10px; align-items: center; text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px 10px; cursor: pointer; }
.agent-row:hover { border-color: #35507A; }
.agent-row.selected { border-color: var(--accent); }
.agent-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dot-status { grid-area: dot; width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.dot-status.working { background: var(--working); box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); }
.dot-status.attention { background: var(--warn); }
.dot-status.scheduled { background: var(--scheduled); }
.row-name { grid-area: name; font-weight: 600; }
.row-room { grid-area: room; font-size: 12px; color: var(--muted); }
.row-status { grid-area: status; font: 700 12px/1 "JetBrains Mono", monospace; color: var(--muted); }
.row-status.working { color: #93C5FD; }
.row-status.attention { color: var(--warn); }
.row-status.scheduled { color: #5EEAD4; }
.planned-note { margin: 0; font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }

.agent-head { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.agent-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.agent-id h2 { margin: 0; font-size: 18px; color: #fff; }
.pill { font: 700 12px/1 Inter, sans-serif; padding: 5px 9px; border-radius: 999px; background: #334155; color: #CBD5E1; white-space: nowrap; }
.pill.working { background: var(--working); color: #fff; }
.pill.attention { background: var(--warn); color: #1C1917; }
.pill.scheduled { background: var(--scheduled); color: #fff; }
.facts { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.facts div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; }
.report { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; font-size: 13px; max-height: 260px; overflow: auto; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.activity li { display: grid; grid-template-columns: 120px 1fr; gap: 8px; }
.activity time { color: var(--muted); font: 500 12px/1.4 "JetBrains Mono", monospace; }
.activity .bad { color: #FCA5A5; }

@media (max-width: 760px) {
  .twin { min-height: 62vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .hint { display: none; }
  .floor-tag button { display: none; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
  .lbl { font-size: 11px; padding: 4px 6px; }
}
/* screen-saver display: nothing to click */
.display-mode [data-signout], .display-mode #user-email, .display-mode .hint { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .chip.delivered { animation: none; }
}
