:root { --bg: #f4f6f9; --panel: #fff; --text: #1d2433; --muted: #66708a; --line: #e2e6ee; --accent: #2f5bea; --accent-d: #2447bd; --ok: #1a8f4f; --ok-bg: #e4f6ec; --bad: #c0352b; --bad-bg: #fde9e7; --warn: #a66a00; --warn-bg: #fff3d6; --side: #151b2b; --side-t: #c9d1e6; }
@media (prefers-color-scheme: dark) { :root { --bg: #0f1420; --panel: #181f2f; --text: #e6e9f2; --muted: #98a2bd; --line: #2a3350; --accent: #6f8dff; --accent-d: #8ea5ff; --ok: #4cd08a; --ok-bg: #12301f; --bad: #ff7b70; --bad-bg: #3a1a18; --warn: #f2b84b; --warn-bg: #3a2d10; --side: #0b0f19; } }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Myanmar", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { background: var(--side); color: var(--side-t); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
nav.side h1 { font-size: 15px; color: #fff; margin: 4px 10px 14px; }
nav.side a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--side-t); text-decoration: none; margin-bottom: 2px; }
nav.side a:hover { background: rgba(255,255,255,.07); }
nav.side a.on { background: var(--accent); color: #fff; }
nav.side .who { margin: 18px 10px 0; font-size: 12px; color: #8b95b3; word-break: break-all; }
nav.side button { margin: 8px 10px 0; }
main { padding: 22px 28px 60px; max-width: 1200px; width: 100%; }
h2 { margin: 0 0 4px; font-size: 20px; } h3 { margin: 0 0 8px; font-size: 15px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 10px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
input, select, textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 160px; }
textarea { min-height: 70px; width: 100%; }
button { padding: 7px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
button:hover { background: var(--accent-d); } button:disabled { opacity: .5; cursor: default; }
button.sec { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.mini { padding: 3px 9px; font-size: 12px; } button.danger { background: var(--bad); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; } tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--line); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.msg { padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; } .msg.err { background: var(--bad-bg); color: var(--bad); } .msg.ok { background: var(--ok-bg); color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; } .stat b { display: block; font-size: 24px; } .stat span { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); } code { background: var(--line); padding: 1px 5px; border-radius: 4px; }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; } .perms label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.perms input { min-width: 0; }
.login { max-width: 400px; margin: 9vh auto; }
.keybox { font-family: ui-monospace, Menlo, monospace; background: var(--line); padding: 10px; border-radius: 8px; word-break: break-all; user-select: all; }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; } nav.side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; } nav.side h1, nav.side .who { width: 100%; } main { padding: 16px; } }

pre { margin: 0; padding: 10px 12px; background: var(--line); border-radius: 8px; overflow-x: auto; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.codewrap { position: relative; margin: 6px 0 10px; } .codewrap button { position: absolute; top: 6px; right: 6px; }
ol li { margin-bottom: 12px; } a { color: var(--accent); }

.selbar { align-items:center; gap:10px; margin-bottom:8px; } td:first-child input[type=checkbox], th:first-child input[type=checkbox] { min-width:0; width:16px; height:16px; }
button:disabled.danger { opacity:.35; }

/* ---- floor plan editor (diagram.js) */
.fp { display: flex; flex-direction: column; gap: 8px; }
.fp-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.fp-tools .grow { flex: 1; } .fp-tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.fp-tools button.tool { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 5px 11px; }
.fp-tools button.tool.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.fp-tools label.inl, label.inl { flex-direction: row; align-items: center; gap: 5px; color: var(--text); font-size: 13px; }
label.inl input { min-width: 0; }
.fp-main { display: grid; grid-template-columns: 1fr 300px; gap: 12px; align-items: start; }
.fp-stage { background: #cfd5e3; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; height: min(72vh, 760px); }
.fp-svg { width: 100%; height: 100%; display: block; touch-action: none; outline: none; user-select: none; background: #cfd5e3; }
.fp-side { display: flex; flex-direction: column; gap: 10px; max-height: min(72vh, 760px); overflow: auto; }
.card.sm { padding: 12px 14px; margin: 0; } .card.sm label { margin-bottom: 8px; } .card.sm input[type=text], .card.sm input[type=number] { width: 100%; min-width: 0; }
.card.sm input[type=color] { padding: 0; height: 30px; width: 100%; min-width: 0; } .card.sm input[type=range] { padding: 0; min-width: 0; width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 70px; gap: 8px; align-items: center; }
.camrow { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.camrow:last-child { border-bottom: 0; } .camrow.on { background: var(--ok-bg); }
.camrow a { flex: 1; text-decoration: none; word-break: break-word; }
.fp-hint { color: var(--muted); font-size: 12px; } .fp-status { font-size: 12px; }
.fp-ro .fp-tools { opacity: .6; }
@media (max-width: 1000px) { .fp-main { grid-template-columns: 1fr; } .fp-side { max-height: none; } }

.avatar { width:36px; height:36px; border-radius:50%; object-fit:cover; display:inline-grid; place-items:center; background:var(--line); color:var(--muted); font-weight:700; }

/* ---- live map / tracking */
.maplist { max-height: 340px; overflow: auto; margin-top: 8px; }
.maplist .camrow { align-items: flex-start; padding: 6px 4px; } .maplist .camrow:hover { background: var(--line); }
tr.cur td { background: var(--ok-bg); }

.card.editing { animation: editflash 1.4s ease-out; border-color: var(--accent); }
@keyframes editflash { 0% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* live map toolbar + full screen */
.mapbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 10px; } .mapbar .grow { flex: 1; }
button.icon { padding: 5px 11px; font-size: 18px; line-height: 1; } button.icon.spin { animation: fmspin .8s linear infinite; }
@keyframes fmspin { to { transform: rotate(360deg); } }
.mapwrap:fullscreen, .mapwrap.fs-fake { background: var(--bg); padding: 14px 18px; overflow: auto; }
.mapwrap.fs-fake { position: fixed; inset: 0; z-index: 100; }
.mapwrap:fullscreen .fp-stage, .mapwrap.fs-fake .fp-stage { height: calc(100vh - 80px); }
.mapwrap:fullscreen .fp-side, .mapwrap.fs-fake .fp-side { max-height: calc(100vh - 80px); }
.mapwrap:fullscreen .fp-main, .mapwrap.fs-fake .fp-main { grid-template-columns: 1fr 340px; }
