:root {
  color-scheme: dark;
  --bg: #06101d;
  --surface: rgba(14, 29, 47, 0.78);
  --surface-solid: #0e1d2f;
  --surface-raised: #14263b;
  --line: rgba(148, 177, 205, 0.16);
  --line-strong: rgba(148, 177, 205, 0.28);
  --text: #f2f7fb;
  --muted: #8fa4b8;
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --blue: #5ea8ff;
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #34d399;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(45, 212, 191, 0.16), transparent 28rem),
    radial-gradient(circle at 96% 5%, rgba(94, 168, 255, 0.14), transparent 30rem),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: min(100%, 420px);
  padding: 2.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(20, 38, 59, 0.96), rgba(8, 21, 35, 0.96));
  box-shadow: var(--shadow);
}
.auth-card .brand-mark { margin-bottom: 2rem; }
.auth-card h1 { margin: .35rem 0 .65rem; font-size: clamp(1.9rem, 6vw, 2.5rem); letter-spacing: -.045em; }
.auth-copy { margin: 0 0 1.8rem; color: var(--muted); line-height: 1.65; }
.auth-card label, .stack-form label, .settings-form label { display: grid; gap: .55rem; color: #c5d2df; font-size: .84rem; font-weight: 650; }
.auth-card input { margin-bottom: 1rem; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  padding: .76rem .9rem;
  color: var(--text);
  background: rgba(3, 12, 22, .6);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45, 212, 191, .13); background: rgba(3, 12, 22, .86); }
textarea { resize: vertical; line-height: 1.5; }
option { color: var(--text); background: var(--surface-solid); }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 max(1.2rem, calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(6, 16, 29, .78);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none; }
.brand > span:last-child { display: grid; gap: .12rem; }
.brand strong { font-size: .93rem; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #04241f;
  background: linear-gradient(145deg, #5eead4, #2dd4bf);
  box-shadow: 0 8px 28px rgba(45, 212, 191, .22);
  font-weight: 900;
  font-size: 1.15rem;
}
.brand-mark.small { width: 37px; height: 37px; border-radius: 11px; font-size: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.live-pill { display: inline-flex; align-items: center; gap: .48rem; padding: .48rem .75rem; border: 1px solid rgba(52, 211, 153, .23); border-radius: 999px; color: #9cecc9; background: rgba(52, 211, 153, .08); font-size: .75rem; font-weight: 700; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(52, 211, 153, .1); }
.live-pill.disconnected { color: #fdb5bf; border-color: rgba(251, 113, 133, .25); background: rgba(251, 113, 133, .08); }
.live-pill.disconnected i { background: var(--danger); box-shadow: 0 0 0 5px rgba(251, 113, 133, .1); }

.workspace { width: min(1380px, calc(100% - 2.4rem)); margin: 0 auto; padding: 3rem 0 4rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2.2rem; }
.hero h1 { max-width: 760px; margin: .38rem 0 .7rem; font-size: clamp(2rem, 4.5vw, 3.65rem); line-height: 1.04; letter-spacing: -.058em; }
.hero p:last-child { max-width: 700px; margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.65; }
.eyebrow { margin: 0; color: var(--primary); font-size: .68rem; font-weight: 850; letter-spacing: .18em; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.3rem; }
.metric-card { min-height: 138px; display: grid; align-content: space-between; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(20, 38, 59, .72), rgba(11, 27, 44, .72)); box-shadow: 0 10px 38px rgba(0, 0, 0, .12); }
.metric-card span { color: #b9c7d4; font-size: .76rem; font-weight: 700; }
.metric-card strong { font-size: 2.2rem; letter-spacing: -.05em; }
.metric-card small { color: var(--muted); font-size: .72rem; }
.metric-card.accent { border-color: rgba(251, 113, 133, .33); background: linear-gradient(145deg, rgba(78, 25, 43, .52), rgba(21, 28, 45, .78)); }
.metric-card.accent strong { color: #fda4af; }
.metric-card.warning strong { color: var(--warning); }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 12px 44px rgba(0, 0, 0, .14); backdrop-filter: blur(12px); }
.panel-heading { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.3rem; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: .22rem 0 0; font-size: 1.08rem; letter-spacing: -.02em; }
.toolbar-heading { align-items: center; }
.toolbar { display: flex; align-items: center; gap: .65rem; }
.search-control { min-width: min(360px, 40vw); display: flex; align-items: center; gap: .55rem; padding-left: .8rem; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: rgba(3, 12, 22, .38); }
.search-control input { border: 0; padding-left: 0; background: transparent; box-shadow: none; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border: 1px solid transparent; border-radius: 10px; padding: .72rem 1rem; cursor: pointer; text-decoration: none; font-size: .8rem; font-weight: 750; transition: transform .16s, border-color .16s, background .16s, opacity .16s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { color: #032b25; background: linear-gradient(135deg, #5eead4, #2dd4bf); box-shadow: 0 8px 22px rgba(45, 212, 191, .14); }
.button.primary:hover { background: linear-gradient(135deg, #7ef4e2, #39dcc7); }
.button.ghost { border-color: var(--line-strong); color: #d9e4ed; background: rgba(16, 35, 54, .7); }
.button.ghost:hover { border-color: rgba(45, 212, 191, .5); background: rgba(25, 51, 72, .86); }
.button.danger { border-color: rgba(251, 113, 133, .22); color: #fda4af; background: rgba(251, 113, 133, .08); }
.button.compact { padding: .52rem .72rem; font-size: .72rem; }
.button.wide { width: 100%; }

.section-tabs { display: flex; gap: .35rem; margin: 1.3rem 0 .75rem; padding: .35rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: rgba(7, 21, 35, .68); width: max-content; max-width: 100%; }
.tab-button { border: 0; border-radius: 9px; padding: .66rem .95rem; color: var(--muted); background: transparent; cursor: pointer; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.tab-button.active { color: #dffffa; background: rgba(45, 212, 191, .13); box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .18); }

.table-wrap { overflow: auto; }
table { width: 100%; min-width: 1240px; border-collapse: collapse; }
th { padding: .8rem 1.05rem; color: #7f94a8; background: rgba(4, 15, 26, .3); text-align: left; font-size: .64rem; letter-spacing: .11em; text-transform: uppercase; }
td { padding: .9rem 1.05rem; border-top: 1px solid var(--line); color: #cfdae4; font-size: .78rem; vertical-align: middle; }
tbody tr { transition: background .16s; }
tbody tr:hover { background: rgba(94, 168, 255, .035); }
.device-name { display: grid; gap: .2rem; }
.device-name strong { color: var(--text); font-size: .84rem; }
.device-name small, .muted { color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; letter-spacing: .02em; }
.status { display: inline-flex; align-items: center; gap: .42rem; font-weight: 720; font-size: .72rem; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 12%, transparent); }
.status.online { color: var(--success); }
.status.offline { color: #71869a; }
.status.pending { color: var(--warning); }
.key-badge, .seat-badge, .priority-badge { display: inline-flex; padding: .28rem .48rem; border: 1px solid var(--line); border-radius: 7px; color: #bdcad5; background: rgba(3, 12, 22, .35); font-size: .67rem; font-weight: 700; }
.key-badge.pending { color: #ffd66b; border-color: rgba(251, 191, 36, .2); background: rgba(251, 191, 36, .07); }
.password-pill { min-width: 74px; border: 1px solid var(--line); border-radius: 8px; padding: .38rem .5rem; color: #d4e0e9; background: rgba(3, 12, 22, .42); cursor: pointer; font-size: .69rem; }
.password-pill:hover { border-color: rgba(45, 212, 191, .42); color: #aafff2; }
.password-pill:disabled { cursor: default; opacity: .48; }
.row-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.empty-state { padding: 3.5rem 1rem; color: var(--muted); text-align: center; }
.seat-select { min-width: 92px; padding: .46rem .55rem; font-size: .72rem; }

.alert-center { margin-bottom: 1.25rem; border-color: rgba(251, 113, 133, .3); background: linear-gradient(145deg, rgba(59, 23, 39, .6), rgba(11, 27, 44, .82)); }
.alert-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 310px; overflow: auto; }
.compact-alert { min-width: 0; padding: .7rem .8rem; }
.compact-alert .alert-message { margin-block: .38rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-alert .alert-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-repeat-badge { padding: 2px 6px; border-radius: 999px; color: #07111f; background: #f4b75d; font-size: .58rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.chat-alert { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 1rem 1.25rem; border-top: 1px solid rgba(251, 113, 133, .12); }
.chat-alert:first-child { border-top: 0; }
.chat-alert.urgent { background: rgba(251, 113, 133, .055); }
.alert-identity { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .42rem; }
.alert-identity strong { font-size: .84rem; }
.alert-message { margin: 0 0 .4rem; color: #f0f4f8; line-height: 1.45; overflow-wrap: anywhere; }
.alert-meta { color: #9eafbf; font-size: .68rem; }
.alert-actions { display: flex; gap: .4rem; }
.priority-badge.urgent { color: #ffc1c9; border-color: rgba(251, 113, 133, .3); background: rgba(251, 113, 133, .12); }
.priority-badge.normal { color: #a9cfff; border-color: rgba(94, 168, 255, .25); background: rgba(94, 168, 255, .1); }
.counter { min-width: 30px; height: 30px; display: grid; place-items: center; padding: 0 .45rem; border: 1px solid var(--line); border-radius: 999px; color: #cad7e1; font-size: .72rem; font-weight: 850; }
.danger-bg { border-color: transparent; color: white; background: var(--danger); }
.danger-text { color: #fb8da0; }

.map-note { display: block; margin-top: .35rem; color: var(--muted); font-size: .68rem; font-weight: 500; }
.room-map-scroll { position: relative; height: clamp(540px, 68vh, 760px); overflow: hidden; background: radial-gradient(circle at 50% 45%, rgba(30, 61, 75, .38), rgba(3, 12, 22, .62)); cursor: grab; isolation: isolate; touch-action: none; user-select: none; }
.room-map-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.room-map-scroll.is-dragging { cursor: grabbing; }
.map-controls { position: absolute; z-index: 12; top: 14px; right: 14px; display: grid; grid-template-columns: 38px 38px 38px auto; align-items: center; overflow: hidden; border: 1px solid rgba(177, 205, 218, .24); border-radius: 12px; background: rgba(6, 18, 30, .9); box-shadow: 0 10px 30px rgba(3, 12, 22, .32), inset 0 1px rgba(255,255,255,.05); backdrop-filter: blur(12px); }
.map-controls button { width: 38px; height: 38px; border: 0; border-right: 1px solid rgba(177, 205, 218, .16); color: #e9f8f6; background: transparent; cursor: pointer; font-size: 20px; font-weight: 750; transition: color .18s, background .18s, transform .12s; }
.map-controls button:hover { color: #76ead7; background: rgba(45, 212, 191, .12); }
.map-controls button:active { transform: scale(.92); }
.map-controls button:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--accent); outline-offset: -3px; }
.map-controls .map-fit-button { font-size: 18px; }
.map-controls output { min-width: 54px; padding: 0 10px; color: #9fb3c2; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; font-variant-numeric: tabular-nums; text-align: center; }
.map-help { position: absolute; z-index: 11; left: 50%; bottom: 14px; max-width: calc(100% - 28px); padding: 7px 12px; transform: translateX(-50%); border: 1px solid rgba(177, 205, 218, .18); border-radius: 8px; color: #a9bbc7; background: rgba(6, 18, 30, .82); box-shadow: 0 8px 24px rgba(3, 12, 22, .25); pointer-events: none; font-size: 10px; font-weight: 650; letter-spacing: .02em; white-space: nowrap; backdrop-filter: blur(9px); }
.room-plan {
  position: absolute;
  top: 0;
  left: 0;
  width: 1260px;
  min-width: 1260px;
  padding: 14px 16px 10px;
  overflow: hidden;
  border: 8px solid #bfc5c9;
  border-radius: 10px;
  background-color: #e9ece9;
  background-image:
    linear-gradient(rgba(106, 117, 124, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(106, 117, 124, .08) 1px, transparent 1px);
  background-size: 44px 44px;
  box-shadow: inset 0 0 35px rgba(36, 49, 58, .16), 0 18px 50px rgba(0, 0, 0, .2);
  transform-origin: 0 0;
  transform-style: flat;
}
.room-top-wall { position: relative; height: 58px; border-bottom: 4px solid #c9cdd0; }
.rear-window { position: absolute; top: -8px; width: 135px; height: 32px; display: grid; place-items: center; border: 5px solid #30383d; border-radius: 2px; color: #8b1d25; background: repeating-linear-gradient(90deg, #1d252a 0 25px, #11181c 25px 29px); box-shadow: 0 7px 10px rgba(0, 0, 0, .22); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.rear-window::before { content: ""; position: absolute; top: -17px; padding: 2px 8px; border: 1px solid #c3c3c3; border-radius: 3px; background: #fff; }
.window-one { left: 16%; }
.window-two { right: 24%; }
.window-one::before, .window-two::before { content: "CỬA SỔ"; }
.server-cabinet { position: absolute; top: -5px; right: 3px; width: 90px; height: 52px; display: grid; place-items: center; border: 7px solid #272e32; border-radius: 3px; color: #a51f28; background: #f5efe4; box-shadow: 0 6px 12px rgba(0, 0, 0, .22); font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.room-body { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 16px; }
.seat-area { display: grid; gap: 15px; padding: 12px 0 15px; }
.room-row { min-height: 122px; display: grid; grid-template-columns: 62px minmax(0, 1fr); align-items: center; }
.room-row-label { margin: 0; color: #706700; font-size: 17px; font-weight: 850; text-shadow: 0 1px #fff; }
.desk-line { display: grid; grid-template-columns: repeat(9, minmax(92px, 1fr)); gap: 12px; align-items: start; padding-right: 2px; }
.desk {
  position: relative;
  min-width: 0;
  height: 72px;
  display: grid;
  grid-template-rows: 20px 31px 13px;
  gap: 1px;
  padding: 3px 4px;
  border: 2px solid #75431f;
  border-radius: 4px;
  color: #17242d;
  background:
    linear-gradient(90deg, rgba(255,255,255,.1), transparent 24%, rgba(65,31,9,.1) 25% 27%, transparent 28% 70%, rgba(255,255,255,.08)),
    linear-gradient(115deg, #9a5c2a, #cb8c4a 48%, #8a4e22);
  box-shadow: 0 3px 0 #5e3519, 0 7px 11px rgba(56, 39, 25, .26);
  cursor: pointer;
  transition: filter .16s, border-color .16s, box-shadow .16s;
}
.desk.lower { grid-template-rows: 31px 13px 20px; transform: translateY(38px); }
.desk.lower .desk-codes { grid-row: 1; }
.desk.lower .desk-device { grid-row: 2; align-self: stretch; }
.desk.lower .desk-equipment { grid-row: 3; }
.desk:hover { z-index: 2; border-color: #0f9f89; box-shadow: 0 0 0 3px rgba(15, 159, 137, .2), 0 8px 15px rgba(35, 43, 47, .28); filter: brightness(1.04); }
.desk.selected { z-index: 3; border-color: #0b8f7d; box-shadow: 0 0 0 4px rgba(45, 212, 191, .44), 0 10px 18px rgba(23, 78, 74, .28); filter: brightness(1.08); }
.desk-equipment { position: relative; display: block; }
.desk-monitor { position: absolute; left: 50%; top: 0; width: 34px; height: 17px; transform: translateX(-50%); border: 3px solid #24292c; border-radius: 2px; background: linear-gradient(145deg, #233944, #0c151a); box-shadow: inset 0 0 0 1px #64737a, 0 2px 2px rgba(0,0,0,.2); }
.desk-monitor::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 12px; height: 4px; transform: translateX(-50%); border-radius: 0 0 2px 2px; background: #252c30; }
.desk-pc { position: absolute; left: 7px; top: -1px; width: 9px; height: 20px; border-radius: 2px; background: linear-gradient(90deg, #182126, #3e484d, #11191d); box-shadow: inset 0 0 0 1px #4e595e; }
.desk-pc::after { content: ""; position: absolute; left: 3px; top: 4px; width: 2px; height: 2px; border-radius: 50%; background: #6ee7d2; }
.desk-chair { position: absolute; left: 50%; top: -25px; width: 31px; height: 15px; transform: translateX(-50%); border: 3px solid #4b2b18; border-radius: 48% 48% 42% 42%; background: linear-gradient(#9b673f, #714326); box-shadow: 0 2px 2px rgba(42,25,14,.25); }
.desk-chair::before { content: ""; position: absolute; left: 2px; right: 2px; top: -9px; height: 11px; border: 3px solid #4b2b18; border-bottom: 0; border-radius: 50% 50% 0 0; }
.desk-chair::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -7px; height: 5px; border-left: 2px solid #4b2b18; border-right: 2px solid #4b2b18; }
.desk.lower .desk-monitor { top: 3px; }
.desk.lower .desk-pc { top: 2px; }
.desk.lower .desk-chair { top: 25px; transform: translateX(-50%) rotate(180deg); }
.desk-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.desk-code { min-width: 0; display: grid; place-items: center; align-content: center; border-radius: 2px; background: #f8f5ed; box-shadow: inset 0 0 0 1px #d5cec0; line-height: 1; }
.desk-code small { margin-bottom: 1px; color: #69747b; font-size: 6.5px; font-weight: 850; letter-spacing: .06em; }
.desk-code strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; font-weight: 900; }
.photo-code { border-left: 3px solid #8b5cf6; }
.photo-code strong { color: #7c3aed; }
.seat-code { border-left: 3px solid #0f9f89; }
.seat-code strong { color: #087f6e; }
.desk-device { min-width: 0; overflow: hidden; padding: 1px 5px; border-radius: 1px; color: #e3edf0; background: rgba(22, 28, 30, .74); font-size: 7.5px; font-weight: 700; line-height: 11px; text-overflow: ellipsis; white-space: nowrap; }
.desk::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 50%; background: #68757c; }
.desk.online { border-color: #169c72; box-shadow: 0 0 0 2px rgba(22, 156, 114, .18), 0 5px 8px rgba(56, 39, 25, .28); }
.desk.online::after { background: #14b87d; box-shadow: 0 0 8px #14b87d; }
.desk.pending { border-color: #e8a714; }
.desk.pending::after { background: #f7b51e; box-shadow: 0 0 7px rgba(247, 181, 30, .7); }
.service-zone { display: grid; grid-template-rows: 80px 1fr 125px; gap: 12px; padding: 12px 5px 14px 0; }
.teacher-desk { position: relative; display: grid; place-items: start center; align-self: start; height: 70px; padding-top: 10px; border: 3px solid #805025; border-radius: 4px; color: #8f1720; background: linear-gradient(110deg, #99612f, #c58a4c, #845025); box-shadow: 0 5px 0 #66401f, 0 9px 13px rgba(55, 39, 26, .23); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.teacher-desk::before { content: ""; position: absolute; left: 50%; bottom: 10px; width: 40px; height: 20px; transform: translateX(-50%); border: 4px solid #20272b; border-radius: 2px; background: #0e181d; box-shadow: 0 4px 0 -1px #20272b; }
.teacher-desk::after { content: "●"; position: absolute; left: 10px; bottom: 12px; color: #2d7655; font-size: 18px; text-shadow: 5px -4px #3c946c; }
.podium { display: grid; place-items: center; min-height: 220px; border: 4px solid #6c7479; border-radius: 3px; color: #9c2228; background: linear-gradient(90deg, #787f83, #aab0b3, #777e82); box-shadow: 0 7px 13px rgba(44, 52, 57, .23); font-size: 11px; font-weight: 900; letter-spacing: .08em; writing-mode: vertical-rl; }
.storage-cabinet { display: grid; place-items: center; border: 5px solid #704218; border-radius: 3px; color: #f7e1bf; background: repeating-linear-gradient(90deg, #8b5425 0 17px, #714117 17px 20px); box-shadow: 0 7px 12px rgba(51, 35, 20, .24); font-size: 10px; font-weight: 900; letter-spacing: .08em; writing-mode: vertical-rl; }
.room-bottom-wall { min-height: 48px; display: grid; grid-template-columns: 120px 1fr 120px; align-items: end; justify-items: center; border-top: 5px solid #c5c9cc; }
.front-door { width: 72px; padding: 3px 8px; border: 2px solid #aeb4b8; border-bottom: 0; border-radius: 5px 5px 0 0; color: #a41922; background: #fff; text-align: center; font-size: 11px; font-weight: 900; }
.room-sign { align-self: center; padding: 4px 15px; border: 3px solid #324a5d; border-radius: 7px; color: #153858; background: #f4cc3a; box-shadow: 0 3px 7px rgba(0, 0, 0, .18); font-size: 17px; letter-spacing: .12em; }
.map-legend { display: flex; flex-wrap: wrap; gap: .8rem; color: var(--muted); font-size: .7rem; }
.map-legend span { display: flex; align-items: center; gap: .35rem; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: #71869a; }
.legend-dot.online { background: var(--success); }
.legend-dot.pending { background: var(--warning); }

.key-layout { display: grid; grid-template-columns: minmax(320px, .72fr) minmax(420px, 1.28fr); gap: .9rem; align-items: start; }
.stack-form, .settings-form { display: grid; gap: 1rem; padding: 1.25rem; }
.field-row { display: grid; grid-template-columns: .7fr 1.3fr; gap: .75rem; }
.key-result { display: grid; gap: .65rem; margin: 0 1.25rem 1.25rem; padding: 1rem; border: 1px solid rgba(45, 212, 191, .24); border-radius: 12px; background: rgba(45, 212, 191, .07); }
.key-result span { color: #8fb9b3; font-size: .68rem; }
.key-result strong { overflow-wrap: anywhere; white-space: pre-wrap; color: #adfff2; font-family: "SFMono-Regular", Consolas, monospace; font-size: .78rem; }
.key-list { max-height: 610px; overflow: auto; }
.key-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 1rem 1.25rem; border-top: 1px solid var(--line); }
.key-item:first-child { border-top: 0; }
.key-item.inactive { opacity: .52; }
.key-item-main { display: grid; gap: .35rem; min-width: 0; }
.key-item-title { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.key-item-title strong { font-size: .82rem; }
.key-item-meta { color: var(--muted); font-size: .68rem; overflow-wrap: anywhere; }
.key-item-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.key-edit-form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: .5rem; padding: .7rem; border: 1px solid rgba(45, 212, 191, .2); border-radius: 10px; background: rgba(45, 212, 191, .055); }
.key-edit-input { min-width: 0; border: 1px solid rgba(45, 212, 191, .3); border-radius: 8px; padding: .58rem .7rem; color: #dffff9; background: rgba(3, 12, 22, .7); font-family: "SFMono-Regular", Consolas, monospace; font-size: .76rem; letter-spacing: .04em; outline: none; }
.key-edit-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 191, .11); }
.settings-form { max-width: 800px; }
.settings-form > p { margin: 0; color: var(--muted); line-height: 1.6; }
.form-actions { display: flex; align-items: center; gap: .8rem; }
.form-message { min-height: 1.1em; margin: .7rem 0 0; color: var(--muted); font-size: .76rem; }
.form-message.danger { color: #fda4af; }
.form-message.success { color: #79e7ba; }

.modal-card { width: min(92vw, 470px); padding: 1.5rem; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--text); background: #0d1d2e; box-shadow: var(--shadow); }
.modal-card::backdrop { background: rgba(2, 8, 15, .75); backdrop-filter: blur(5px); }
.modal-card h2 { margin: .3rem 0 1.2rem; }
.modal-close-row { display: flex; justify-content: flex-end; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.2rem; }
.modal-device { display: grid; gap: .8rem; }
.modal-info { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(3, 12, 22, .35); font-size: .76rem; }
.modal-info span { color: var(--muted); }
.modal-info strong { min-width: 0; overflow-wrap: anywhere; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }

.toast { position: fixed; z-index: 60; right: 1.2rem; bottom: 1.2rem; max-width: min(390px, calc(100vw - 2.4rem)); padding: .82rem 1rem; border: 1px solid rgba(45, 212, 191, .27); border-radius: 11px; color: #dffff9; background: rgba(12, 39, 48, .96); box-shadow: 0 16px 50px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; font-size: .78rem; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-layout { grid-template-columns: 1fr; }
  .hero { align-items: start; flex-direction: column; }
}

@media (max-width: 680px) {
  .topbar { height: auto; align-items: flex-start; padding: .8rem 1rem; }
  .topbar-actions { justify-content: flex-end; flex-wrap: wrap; }
  .live-pill { order: 3; }
  .brand small { display: none; }
  .workspace { width: min(100% - 1.2rem, 1380px); padding-top: 2rem; }
  .metrics { gap: .55rem; }
  .metric-card { min-height: 118px; padding: .9rem; }
  .metric-card strong { font-size: 1.75rem; }
  .toolbar-heading, .chat-alert { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
  .toolbar, .search-control { width: 100%; min-width: 0; }
  .search-control { flex: 1; }
  .alert-actions { justify-content: flex-end; }
  .field-row { grid-template-columns: 1fr; }
  .panel-heading { padding: 1rem; }
  .room-map-scroll { height: min(72vh, 640px); }
  .map-help { font-size: 9px; }
  .key-item { grid-template-columns: 1fr; }
  .key-item-actions { justify-content: flex-start; }
  .key-edit-form { grid-template-columns: 1fr 1fr; }
  .key-edit-input { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Operations dashboard */
:root {
  --bg: #071019;
  --surface: rgba(15, 27, 39, .9);
  --surface-solid: #101d29;
  --surface-raised: #172737;
  --line: rgba(178, 198, 215, .12);
  --line-strong: rgba(178, 198, 215, .22);
  --text: #f4f7f9;
  --muted: #8d9eac;
  --primary: #4ed8c3;
  --primary-strong: #29bda8;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
}

html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 72% -20%, rgba(78, 216, 195, .09), transparent 34rem),
    linear-gradient(180deg, #08121c 0, #071019 46rem);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.topbar {
  height: 64px;
  padding: 0 1.1rem;
  background: rgba(7, 16, 25, .88);
  box-shadow: 0 8px 30px rgba(0, 7, 14, .18);
}
.brand-mark {
  color: #09241f;
  background: var(--primary);
  box-shadow: none;
}
.dashboard-layout {
  width: min(1600px, 100%);
  min-height: calc(100dvh - 64px);
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  margin: 0 auto;
}
.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1.4rem .85rem 1rem;
  border-right: 1px solid var(--line);
  background: rgba(8, 18, 28, .72);
}
.sidebar-context {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 0 .45rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}
.context-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(52, 211, 153, .08); }
.sidebar-context div { display: grid; gap: .12rem; }
.sidebar-context strong { font-size: .78rem; }
.sidebar-context small { color: var(--muted); font-size: .62rem; }
.sidebar .section-tabs {
  width: 100%;
  max-width: none;
  display: grid;
  gap: .3rem;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: none;
}
.sidebar .tab-button {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: .65rem;
  padding: .72rem .7rem;
  border-radius: 10px;
  text-align: left;
}
.sidebar .tab-button > span {
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 8px;
  color: #90a4b5;
  background: rgba(255,255,255,.035);
  font-size: .9rem;
}
.sidebar .tab-button b { color: #c7d1da; font-size: .76rem; font-weight: 650; }
.sidebar .tab-button small { margin-top: .12rem; color: #697d8d; font-size: .6rem; }
.sidebar .tab-button.active { background: rgba(78, 216, 195, .095); box-shadow: inset 2px 0 var(--primary); }
.sidebar .tab-button.active > span { color: #bafff4; background: rgba(78, 216, 195, .12); }
.sidebar .tab-button.active b { color: #ecfffc; }
.sidebar-help {
  margin-top: auto;
  padding: .85rem;
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255,255,255,.025);
}
.sidebar-help span { color: #d8e2e9; font-size: .68rem; font-weight: 700; }
.sidebar-help p { margin: .4rem 0 0; font-size: .62rem; line-height: 1.5; }
.workspace {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 2rem clamp(1rem, 2.5vw, 2.5rem) 4rem;
}
.hero {
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  max-width: 800px;
  margin: .3rem 0 .45rem;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.hero p:last-child { font-size: .88rem; }
.hero-actions { display: flex; align-items: center; gap: .65rem; }
.sync-note { display: inline-flex; align-items: center; gap: .42rem; color: var(--muted); font-size: .68rem; white-space: nowrap; }
.sync-note i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.metrics { gap: .65rem; margin-bottom: .85rem; }
.metric-card {
  min-height: 112px;
  padding: .9rem 1rem;
  border: 0;
  border-radius: 13px;
  background: rgba(17, 31, 44, .88);
  box-shadow: inset 0 1px rgba(255,255,255,.035);
}
.metric-card::before { content: ""; width: 28px; height: 2px; border-radius: 2px; background: #536a7d; }
.metric-card.accent::before { background: var(--danger); }
.metric-card.warning::before { background: var(--warning); }
.metric-card strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.metric-card span { font-size: .7rem; }
.metric-card small { font-size: .63rem; }
.panel {
  border-radius: 14px;
  background: rgba(15, 28, 40, .9);
  box-shadow: 0 16px 50px rgba(0, 7, 14, .1);
  backdrop-filter: none;
}
.panel-heading { min-height: 72px; padding: 1rem 1.15rem; }
.panel-heading h2 { font-size: 1rem; }
.toolbar { flex-wrap: wrap; justify-content: flex-end; }
.search-control { min-width: min(320px, 35vw); }
.filter-control { width: 148px; }
.filter-control select { padding: .58rem .65rem; font-size: .68rem; }
.button { border-radius: 8px; }
.button:active { transform: translateY(1px) scale(.985); }
.button.primary { background: var(--primary); box-shadow: none; }
.button.primary:hover { background: #6fe3d1; }
th { position: sticky; top: 0; z-index: 1; background: #0d1b28; }
td, th { font-variant-numeric: tabular-nums; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.012); }
.device-sos-active,
.device-sos-active:nth-child(even) {
  background: linear-gradient(90deg, rgba(239, 68, 68, .2), rgba(239, 68, 68, .055));
  box-shadow: inset 4px 0 #ef4444;
  animation: device-sos-row-pulse 1.15s ease-in-out infinite;
}
.device-sos-active:hover { background: rgba(239, 68, 68, .24); }
.device-sos-badge {
  display: block;
  width: max-content;
  margin-top: 6px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  color: #fff;
  background: #e52f45;
  box-shadow: 0 0 16px rgba(229, 47, 69, .55);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .09em;
}
@keyframes device-sos-row-pulse {
  50% { background-color: rgba(239, 68, 68, .13); }
}
.alert-center { margin-bottom: .85rem; border-color: rgba(251, 113, 133, .22); }
.modal-card { border-radius: 14px; }
.chat-dock {
  position: fixed;
  z-index: 45;
  right: 1rem;
  bottom: 0;
  max-width: calc(100vw - 2rem);
  display: flex;
  align-items: flex-end;
  gap: .65rem;
  overflow-x: auto;
  pointer-events: none;
  scrollbar-width: thin;
}
.chat-window {
  width: min(370px, calc(100vw - 2rem));
  height: min(590px, calc(100dvh - 90px));
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(178, 198, 215, .24);
  border-bottom: 0;
  border-radius: 13px 13px 0 0;
  background: #0d1925;
  box-shadow: 0 24px 80px rgba(0, 6, 12, .5);
  pointer-events: auto;
  transform-origin: bottom right;
  animation: chat-window-in .24s cubic-bezier(.2,.8,.2,1);
  transition: width .2s, height .2s, transform .2s, border-color .2s;
}
.chat-window.attention { border-color: var(--primary); transform: translateY(-4px); }
.chat-window.minimized { width: 230px; height: 44px; }
.chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 35, 49, .98);
}
.chat-window-identity {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 0 .8rem;
  border: 0;
  color: #e6edf2;
  background: transparent;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
}
.chat-window-identity i { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(52,211,153,.08); }
.chat-window-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-window-controls { display: flex; align-items: center; padding-right: .35rem; }
.chat-window-controls button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
}
.chat-window-controls button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.chat-window iframe { width: 100%; height: 100%; border: 0; background: #0d1925; }
@keyframes chat-window-in {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* Room map uses the same operations design system while preserving the P204 layout. */
.room-map-scroll {
  height: clamp(560px, 72vh, 820px);
  border-radius: 0 0 13px 13px;
  background:
    radial-gradient(circle at 50% 45%, rgba(78, 216, 195, .055), transparent 36rem),
    #09141f;
}
.room-plan {
  padding: 16px 18px 12px;
  border: 1px solid rgba(159, 184, 203, .2);
  border-radius: 14px;
  background-color: #0d1a26;
  background-image:
    linear-gradient(rgba(127, 153, 174, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 153, 174, .045) 1px, transparent 1px);
  background-size: 32px 32px;
  box-shadow: 0 24px 70px rgba(0, 5, 10, .4), inset 0 1px rgba(255,255,255,.035);
}
.room-top-wall { border-bottom-color: rgba(159, 184, 203, .14); }
.rear-window {
  border-color: #314455;
  color: #b8c9d5;
  background: repeating-linear-gradient(90deg, #152635 0 25px, #0b1722 25px 29px);
  box-shadow: none;
}
.rear-window::before {
  border-color: rgba(159, 184, 203, .22);
  color: #b8c9d5;
  background: #142534;
}
.server-cabinet {
  border-color: #344858;
  color: #d4e0e8;
  background: #142534;
  box-shadow: none;
}
.room-row-label { color: #7f94a5; text-shadow: none; }
.desk {
  border: 1px solid #3b5264;
  border-radius: 7px;
  color: #d8e2e9;
  background: #172938;
  box-shadow: 0 5px 14px rgba(0, 5, 10, .24);
}
.desk:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 216, 195, .12), 0 10px 24px rgba(0, 5, 10, .32);
  filter: none;
}
.desk.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(78, 216, 195, .18), 0 12px 28px rgba(0, 5, 10, .36);
  filter: none;
}
.desk-code {
  border: 1px solid rgba(159, 184, 203, .14);
  color: #e7eef2;
  background: #0e1b27;
  box-shadow: none;
}
.desk-code small { color: #6f8595; }
.photo-code { border-left: 3px solid #91a7ff; }
.photo-code strong { color: #b9c5ff; }
.seat-code { border-left: 3px solid var(--primary); }
.seat-code strong { color: #8df3e3; }
.desk-device { color: #9fb0bd; background: #0a1621; }
.desk-monitor { border-color: #6b8190; background: #07121b; box-shadow: inset 0 0 0 1px #263d4e; }
.desk-monitor::after, .desk-pc { background: #2b4050; }
.desk-chair, .desk-chair::before {
  border-color: #526879;
  background: #253c4d;
  box-shadow: none;
}
.desk-chair::after { border-color: #526879; }
.desk.online { border-color: #32c997; box-shadow: 0 0 0 2px rgba(50, 201, 151, .12); }
.desk.pending { border-color: #e4ae3a; }
.desk-key-badge {
  position: absolute;
  z-index: 4;
  top: -8px;
  right: -8px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border: 2px solid #0d1a26;
  border-radius: 999px;
  color: #261900;
  background: #f3b93f;
  box-shadow: 0 5px 14px rgba(243, 185, 63, .3);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1;
  pointer-events: none;
}
.device-color-tag,
.map-device-tag {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 110px;
  overflow: hidden;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 70%, #fff 10%);
  border-radius: 999px;
  color: #fff;
  background: color-mix(in srgb, var(--tag-color) 72%, #08131d);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-color-tag { margin-top: 5px; }
.map-device-tag {
  position: absolute;
  z-index: 4;
  right: 5px;
  bottom: -8px;
}
.desk-hover-card {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 12px);
  width: 210px;
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid #395469;
  border-radius: 9px;
  color: #dbe7ee;
  background: rgba(7, 18, 28, .97);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .48);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity .14s ease, transform .14s ease;
}
.desk:hover .desk-hover-card,
.desk:focus-visible .desk-hover-card {
  opacity: 1;
  transform: translate(-50%, 0);
}
.desk-hover-line {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  text-align: left;
}
.desk-hover-line small { color: #7890a1; font-size: 8px; }
.desk-hover-line strong { overflow: hidden; color: #edf5f8; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.setting-toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 9px;
}
.setting-toggle input { width: 16px; height: 16px; }
.seat-detail {
  display: block;
  margin-top: 5px;
  color: #7890a1;
  font-size: 9px;
  white-space: nowrap;
}
.chat-action-button { position: relative; padding-left: 24px !important; }
.chat-action-button::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 9px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.chat-action-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #0d1a26;
  border-radius: 999px;
  color: #fff;
  background: #3978e8;
  font-size: 8px;
  font-weight: 900;
}
.chat-action-count.urgent {
  background: #ef5368;
  animation: urgent-desk-ping 1.25s ease-out infinite;
}
.groups-layout {
  grid-template-columns: minmax(260px, .42fr) minmax(420px, 1fr);
  gap: 14px;
}
.device-group-list { display: grid; gap: 8px; padding: 12px; }
.device-group-card {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(159, 184, 203, .14);
  border-radius: 9px;
  background: #0d1b28;
}
.device-group-card div:nth-child(2) { display: grid; gap: 3px; }
.device-group-card small { color: #7890a1; }
.group-color-dot { width: 10px; height: 28px; border-radius: 999px; box-shadow: 0 0 12px color-mix(in srgb, currentColor 40%, transparent); }
.device-group-select {
  max-width: 150px;
  margin-top: 5px;
  padding: 4px 7px;
  font-size: 9px;
}
.device-taxonomy-controls { display: flex; flex-wrap: wrap; gap: 5px; }
.device-tag-select { border-left: 3px solid var(--tag-color, #7890a1); }
.grouped-device-sections { display: grid; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: rgba(4,13,23,.18); }
.grouped-device-sections:empty { display: none; }
.grouped-device-section { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: rgba(10,25,39,.72); }
.grouped-device-section > summary { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 11px 13px; cursor: pointer; user-select: none; list-style: none; }
.grouped-device-section > summary::-webkit-details-marker { display: none; }
.grouped-device-section > summary:hover { background: rgba(255,255,255,.025); }
.grouped-device-section > summary div { display: grid; gap: 2px; }
.grouped-device-section > summary strong { color: #e8f1f5; font-size: .75rem; }
.grouped-device-section > summary small, .group-section-hint { color: var(--muted); font-size: .58rem; }
.grouped-device-section[open] > summary { border-bottom: 1px solid var(--line); }
.grouped-table-wrap { border-radius: 0; }
@media (max-width: 900px) {
  .groups-layout { grid-template-columns: 1fr; }
}
.desk-alert-badge {
  position: absolute;
  z-index: 5;
  top: -9px;
  left: -9px;
  min-width: 31px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  border: 2px solid #0d1a26;
  border-radius: 999px;
  color: #fff;
  background: #3978e8;
  box-shadow: 0 5px 16px rgba(57, 120, 232, .38);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.desk-alert-icon {
  position: relative;
  width: 9px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: transparent;
}
.desk-alert-icon::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: -3px;
  width: 3px;
  height: 3px;
  border-left: 1.5px solid #fff;
  transform: skewY(-35deg);
}
.desk-alert-count {
  color: #fff;
  font: inherit;
}
.desk-alert-badge.urgent {
  color: #fff;
  background: #ef5368;
  box-shadow: 0 0 0 0 rgba(239, 83, 104, .55), 0 7px 20px rgba(239, 83, 104, .42);
  animation: urgent-desk-ping 1.25s ease-out infinite;
}
.desk.has-sos-alert {
  border-color: #ef344f;
  box-shadow: 0 0 0 3px rgba(239, 52, 79, .22), 0 0 26px rgba(239, 52, 79, .3);
  animation: sos-desk-pulse 1.05s ease-in-out infinite;
}
@keyframes sos-desk-pulse {
  50% {
    border-color: #ff7b8d;
    box-shadow: 0 0 0 5px rgba(239, 52, 79, .09), 0 0 34px rgba(239, 52, 79, .48);
  }
}
@keyframes urgent-desk-ping {
  0% { box-shadow: 0 0 0 0 rgba(239, 83, 104, .55), 0 7px 20px rgba(239, 83, 104, .42); }
  65%, 100% { box-shadow: 0 0 0 12px rgba(239, 83, 104, 0), 0 7px 20px rgba(239, 83, 104, .28); }
}
.teacher-desk {
  border: 1px solid #456174;
  border-radius: 7px;
  color: #dbe6ec;
  background: #183043;
  box-shadow: none;
}
.teacher-desk::before { border-color: #637b8c; background: #08131d; box-shadow: none; }
.podium {
  border: 1px solid #536b7d;
  border-radius: 7px;
  color: #bac9d3;
  background: #1a2e3d;
  box-shadow: none;
}
.storage-cabinet {
  border: 1px solid #526b7d;
  border-radius: 7px;
  color: #bac9d3;
  background: repeating-linear-gradient(90deg, #1a3040 0 17px, #132635 17px 20px);
  box-shadow: none;
}
.room-bottom-wall { border-top-color: rgba(159, 184, 203, .18); }
.front-door {
  border-color: #526a7b;
  color: #d1dce3;
  background: #152838;
}
.room-sign {
  border-color: #4ed8c3;
  color: #bffff5;
  background: rgba(78, 216, 195, .1);
  box-shadow: none;
}
.map-controls, .map-help {
  border-color: rgba(159, 184, 203, .18);
  background: rgba(12, 27, 40, .9);
  box-shadow: 0 12px 34px rgba(0, 5, 10, .3);
}
.audit-table { min-width: 980px; }
.audit-table-wrap { max-height: min(68vh, 720px); }
.audit-table thead { position: sticky; top: 0; z-index: 2; }
.audit-action { color: #e7eef2; font-weight: 650; }
.audit-detail { max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 1.15fr);
  gap: 2rem;
  align-items: center;
  margin: 0 1.25rem 1.25rem;
  padding: 1.1rem;
  border: 1px solid rgba(251, 113, 133, .24);
  border-radius: 12px;
  background: rgba(251, 113, 133, .045);
}
.danger-zone h3 { margin: .25rem 0 .35rem; font-size: .95rem; }
.danger-zone p:last-child { margin: 0; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.danger-zone-actions { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: .55rem; }
.button.solid-danger { color: #fff; background: #c94f62; }
.button.solid-danger:hover { background: #df6174; }
.health-layout { display: grid; grid-template-columns: 1fr; gap: .75rem; align-items: start; }
.health-overview { display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(260px, .65fr); align-items: start; }
.health-overview > .panel-heading { grid-column: 1 / -1; }
.health-summary { grid-column: 2; display: grid; grid-template-columns: 1fr; gap: .55rem; padding: 1rem 1rem 0 .35rem; }
.health-card { display: grid; gap: .4rem; padding: .8rem; border-radius: 10px; background: rgba(255,255,255,.025); box-shadow: inset 2px 0 #657b8c; }
.health-card.good { box-shadow: inset 2px 0 var(--success); }
.health-card.bad { box-shadow: inset 2px 0 var(--danger); background: rgba(251,113,133,.045); }
.health-card span { color: var(--muted); font-size: .64rem; }
.health-card strong { overflow: hidden; color: #eaf1f5; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.health-visuals { grid-column: 1; grid-row: 2 / span 2; display: grid; grid-template-columns: minmax(280px, .65fr) minmax(420px, 1.35fr); gap: .65rem; padding: 1rem .65rem 1rem 1rem; }
.health-gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.health-gauge { display: grid; justify-items: center; align-content: center; gap: .35rem; min-height: 190px; padding: .8rem .5rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(3,12,22,.22); text-align: center; }
.health-gauge > div { display: grid; width: 84px; aspect-ratio: 1; place-items: center; border-radius: 50%; background: conic-gradient(var(--success) calc(var(--gauge-value) * 1%), rgba(115,139,157,.14) 0); position: relative; }
.health-gauge > div::after { content: ""; position: absolute; inset: 8px; border-radius: inherit; background: #0c1b2a; box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
.health-gauge.warning > div { background: conic-gradient(var(--danger) calc(var(--gauge-value) * 1%), rgba(115,139,157,.14) 0); }
.health-gauge strong { position: relative; z-index: 1; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.health-gauge span { color: #dce6ec; font-size: .69rem; font-weight: 700; }
.health-gauge small { max-width: 120px; color: var(--muted); font-size: .58rem; line-height: 1.4; }
.health-history { display: grid; grid-template-rows: auto auto auto auto auto auto; min-height: 190px; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(3,12,22,.22); }
.health-history header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.health-history h3 { margin: 0; color: #dce6ec; font-size: .72rem; }
.health-history header small { color: var(--muted); font-size: .57rem; }
.health-history header > strong { color: #b9c7d4; font-size: .63rem; font-variant-numeric: tabular-nums; }
#health-history-chart { display: block; width: 100%; height: 125px; margin-top: .35rem; overflow: visible; }
#health-history-chart, #bandwidth-history-chart, #bandwidth-daily-chart { cursor: crosshair; touch-action: pan-y; }
#bandwidth-history-chart { display: block; width: 100%; height: 72px; margin-top: .35rem; }
#bandwidth-history-chart text { fill: var(--muted); font-size: .65rem; }
.bandwidth-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-top: .8rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.bandwidth-heading strong { color: #dce6ec; font-size: .68rem; }
.bandwidth-heading small { color: var(--muted); font-size: .56rem; }
.chart-grid path { fill: none; stroke: rgba(115,139,157,.14); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-line { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: chart-draw .75s cubic-bezier(.2,.8,.2,1) forwards; }
.chart-line.cpu { stroke: #4ed8c3; }
.chart-line.ram { stroke: #8ca8ff; }
.chart-line.disk { stroke: #f4b75d; }
.chart-line.download { stroke: #4ed8c3; }
.chart-line.upload { stroke: #d597ff; }
.chart-area.ram { fill: url(#ram-area); }
.chart-dot { stroke: #07111f; stroke-width: 2; }
.chart-dot { transform-box: fill-box; transform-origin: center; animation: chart-dot-in .45s .55s both, chart-dot-pulse 2.4s 1s ease-in-out infinite; }
.chart-dot.cpu { fill: #4ed8c3; }
.chart-dot.ram { fill: #8ca8ff; }
.chart-dot.disk { fill: #f4b75d; }
.chart-legend { display: flex; gap: 1rem; color: var(--muted); font-size: .58rem; }
.chart-legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin: 0 .35rem .18rem 0; background: currentColor; }
.chart-legend .cpu { color: #4ed8c3; }
.chart-legend .ram { color: #8ca8ff; }
.chart-legend .disk { color: #f4b75d; }
.chart-legend .download { color: #4ed8c3; }
.chart-legend .upload { color: #d597ff; }
.bandwidth-accounting { grid-column: 1 / -1; display: grid; gap: .8rem; margin: 0 1rem 1rem; padding: 1rem; border: 1px solid rgba(78,216,195,.2); border-radius: 13px; background: linear-gradient(135deg, rgba(78,216,195,.045), rgba(3,12,22,.28) 42%); }
.bandwidth-accounting > header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.bandwidth-accounting h3 { margin: .2rem 0 0; color: #edf6f8; font-size: 1rem; }
.bandwidth-accounting > header > small { max-width: 420px; color: var(--muted); font-size: .59rem; line-height: 1.5; text-align: right; }
.bandwidth-accounting > header > small.collector-ok { color: #75d9c5; }
.bandwidth-accounting > header > small.collector-waiting { color: #f4b75d; }
.bandwidth-accounting > header > small.collector-error { color: #fb7185; }
.collector-actions { display: flex; align-items: center; justify-content: flex-end; gap: .65rem; }
.collector-actions small { max-width: 360px; color: var(--muted); font-size: .59rem; line-height: 1.5; text-align: right; }
.collector-actions small.collector-ok { color: #75d9c5; }
.collector-actions small.collector-waiting { color: #f4b75d; }
.collector-actions small.collector-error { color: #fb7185; }
.bandwidth-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.bandwidth-kpis article { display: grid; gap: .3rem; min-width: 0; padding: .85rem; border-right: 1px solid var(--line); }
.bandwidth-kpis article:last-child { border-right: 0; }
.bandwidth-kpis span { color: var(--muted); font-size: .6rem; }
.bandwidth-kpis strong { overflow: hidden; color: #edf6f8; font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bandwidth-kpis small { min-height: 2.4em; color: #89a0b1; font-size: .55rem; line-height: 1.35; }
.bandwidth-kpis .cost strong { color: #f4b75d; }
.bandwidth-daily-chart { min-width: 0; }
.chart-axis-label { margin-bottom: .3rem; color: var(--muted); font-size: .56rem; }
#bandwidth-daily-chart { display: block; width: 100%; height: 150px; overflow: visible; }
.daily-bar { transform-box: fill-box; transform-origin: bottom; animation: daily-bar-rise .5s cubic-bezier(.2,.8,.2,1) both; }
.daily-bar.rx { fill: #4ed8c3; opacity: .72; }
.daily-bar.tx { fill: #d597ff; opacity: .9; }
.chart-tooltip { position: fixed; inset: 0 auto auto 0; z-index: 80; min-width: 150px; padding: .65rem .75rem; border: 1px solid rgba(126,232,213,.28); border-radius: 9px; color: #edf7f8; background: rgba(5,16,27,.94); box-shadow: 0 14px 42px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.05); backdrop-filter: blur(12px); pointer-events: none; white-space: pre-line; font: 600 .65rem/1.65 var(--mono, monospace); font-variant-numeric: tabular-nums; }
@keyframes daily-bar-rise { from { transform: scaleY(0); opacity: 0; } }
@keyframes chart-draw { to { stroke-dashoffset: 0; } }
@keyframes chart-dot-in { from { opacity: 0; transform: scale(.25); } to { opacity: 1; transform: scale(1); } }
@keyframes chart-dot-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .chart-line, .chart-dot { animation: none; stroke-dashoffset: 0; }
}
.health-technical { grid-column: 1 / -1; margin: 0 1rem 1rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(3,12,22,.22); }
.health-technical summary { padding: .85rem 1rem; color: #cdd9e1; font-size: .7rem; font-weight: 700; cursor: pointer; user-select: none; }
.health-technical[open] summary { border-bottom: 1px solid var(--line); }
.health-columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; padding: .75rem; }
.health-columns section, .health-failures { padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(3,12,22,.22); }
.health-columns h3, .health-failures h3 { margin: 0 0 .7rem; color: #dce6ec; font-size: .72rem; }
.health-columns dl { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(0, 1.2fr); gap: .48rem .8rem; margin: 0; font-size: .67rem; }
.health-columns dt { color: var(--muted); }
.health-columns dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #d6e0e7; text-align: right; font-variant-numeric: tabular-nums; }
.health-failures { grid-column: 1 / -1; margin: 0 1rem 1rem; }
.health-failure { display: flex; justify-content: space-between; gap: 1rem; padding: .52rem 0; border-top: 1px solid var(--line); font-size: .66rem; }
.health-failure:first-of-type { border-top: 0; }
.health-failure span, .empty-health { color: var(--muted); }
.empty-health { margin: 0; font-size: .68rem; }
.health-settings-panel { width: 100%; }
.settings-groups { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.settings-groups fieldset { min-width: 0; display: grid; align-content: start; gap: .75rem; margin: 0; padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(3,12,22,.18); }
.settings-groups > .button, .settings-groups > .form-message { grid-column: 1 / -1; }
.settings-preset { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr minmax(240px, 340px); gap: 1rem; align-items: center; padding: .85rem 1rem; border: 1px solid rgba(78,216,195,.2); border-radius: 12px; background: rgba(78,216,195,.045); }
.settings-preset > div { display: grid; gap: .18rem; }
.settings-preset strong { color: #edf6f8; font-size: .78rem; }
.settings-preset small { color: var(--muted); font-size: .62rem; }
.settings-section-label { display: grid; grid-template-columns: 30px 1fr; gap: .7rem; align-items: center; margin-top: .45rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.settings-section-label:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.settings-section-label > span { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(78,216,195,.25); border-radius: 8px; color: var(--accent); background: rgba(78,216,195,.07); font: 700 .61rem/1 var(--mono, monospace); }
.settings-section-label div { display: grid; gap: .12rem; }
.settings-section-label strong { color: #eef5f8; font-size: .76rem; }
.settings-section-label small { color: var(--muted); font-size: .58rem; font-weight: 500; }
.settings-groups fieldset > label:not(.setting-toggle) { padding: .7rem; border-radius: 10px; background: rgba(255,255,255,.018); }

@media (max-width: 1080px) {
  .dashboard-layout { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: .6rem; }
  .sidebar-context { justify-content: center; padding: .7rem; }
  .sidebar-context div, .sidebar-help, .sidebar .tab-button b, .sidebar .tab-button small { display: none; }
  .sidebar .tab-button { grid-template-columns: 1fr; padding: .55rem; }
  .sidebar .tab-button > span { grid-row: auto; margin: auto; }
}

@media (max-width: 720px) {
  .topbar { position: sticky; height: 60px; }
  .dashboard-layout { display: block; min-height: calc(100dvh - 60px); }
  .sidebar {
    position: sticky;
    top: 60px;
    z-index: 18;
    width: 100%;
    height: auto;
    padding: .45rem .6rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 16, 25, .94);
    backdrop-filter: blur(14px);
  }
  .sidebar-context, .sidebar-help { display: none; }
  .sidebar .section-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .sidebar .tab-button { padding: .42rem; box-shadow: none; }
  .sidebar .tab-button > span { width: 28px; height: 28px; }
  .workspace { padding: 1.2rem .7rem 3rem; }
  .hero { align-items: stretch; gap: 1rem; }
  .hero-actions { justify-content: space-between; }
  .sync-note { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { justify-content: stretch; }
  .toolbar .button { flex: 1; }
  .alert-list { grid-template-columns: 1fr; max-height: 280px; }
  .search-control { min-width: 100%; }
  .filter-control { width: 100%; }
  .chat-dock { right: .5rem; max-width: calc(100vw - 1rem); gap: .4rem; }
  .chat-window { width: calc(100vw - 1rem); height: min(70dvh, 590px); }
  .chat-window.minimized { width: 190px; }
  .danger-zone { grid-template-columns: 1fr; gap: 1rem; margin-inline: .75rem; }
  .danger-zone-actions { grid-template-columns: 1fr; }
  .health-overview { grid-template-columns: 1fr; }
  .health-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-summary, .health-visuals, .health-failures { grid-column: 1; grid-row: auto; margin-inline: 1rem; padding-inline: 0; }
  .health-visuals { grid-template-columns: 1fr; }
  .bandwidth-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bandwidth-kpis article { border-bottom: 1px solid var(--line); }
  .health-columns, .settings-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .health-gauges { grid-template-columns: 1fr; }
  .health-gauge { grid-template-columns: auto 1fr; justify-items: start; min-height: 0; text-align: left; }
  .health-gauge > div { grid-row: span 2; width: 68px; }
  .health-columns, .settings-groups { grid-template-columns: 1fr; }
  .settings-preset { grid-template-columns: 1fr; }
  .bandwidth-accounting > header { align-items: start; flex-direction: column; }
  .bandwidth-accounting > header > small { text-align: left; }
  .collector-actions { align-items: flex-start; flex-direction: column; }
  .collector-actions small { text-align: left; }
  .bandwidth-kpis { grid-template-columns: 1fr; }
}
