/* enDesk hotel demo: the enDesk style (design/brand/ENDESK-STYLE.md) with a bright sidebar in place of the navy rail. Light theme only. */
:root {
  --canvas: #f4f7fb;
  --card: #ffffff;
  --border: #dfe5ee;
  --fg: #111111;
  --muted: #647084;
  --link: #075dce;
  --accent: #1677ff;
  --accent-50: #eaf2ff;
  --row-hover: #eef3fa;
  --ok: #12b76a;
  --ok-fg: #067647;
  --ok-bg: #ecfdf3;
  --warn: #e07a00;
  --warn-fg: #b54708;
  --warn-bg: #fff6e8;
  --danger: #d92d20;
  --danger-fg: #b42318;
  --danger-bg: #fef3f2;
  --off: #c3ccd8;
  --brand-strip: linear-gradient(90deg, #7a3cff 0%, #2a86ff 45%, #10d48a 100%);
  --cat-strip: linear-gradient(90deg, #f97316, #ef4444);
  --cat-tint: #fff6ef;
  --cat-edge: #fbd9bf;
  --shadow-tile: 0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 14px -6px rgba(16, 24, 40, 0.16);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-float: 0 12px 32px -14px rgba(16, 24, 40, 0.28), 0 2px 6px rgba(16, 24, 40, 0.08);
  --radius-card: 14px;
  --radius-control: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--fg); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.025em; }
small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--link); display: flex; align-items: center; gap: 8px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100vh; height: 100dvh; transition: grid-template-columns 0.32s var(--ease-out); }
.sidebar { position: relative; z-index: 10; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--brand-strip); }
.brand { display: flex; align-items: center; gap: 10px; padding: 24px 20px 16px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand b { display: block; font-size: 21px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.brand small { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; color: var(--link); }
.building-card { position: relative; display: flex; align-items: center; gap: 10px; margin: 2px 14px 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--canvas); }
.building-card b { font-size: 13.5px; }
.building-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-50); color: var(--accent); flex: none; }
.nav-group { margin: 18px 22px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; margin: 2px 12px; padding: 9px 12px; border-radius: var(--radius-control); color: #344054; font-weight: 500; text-decoration: none; transition: background-color 0.15s, color 0.15s; }
.nav a:hover { background: #f2f5f9; }
.nav a[aria-current="page"] { background: var(--accent-50); color: #0b5bd3; font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-fg); font-size: 12px; font-style: normal; font-weight: 700; text-align: center; }
.rail-toggle { position: relative; display: flex; align-items: center; gap: 12px; margin: auto 12px 4px; padding: 9px 12px; border: 0; border-radius: var(--radius-control); background: none; color: var(--muted); font-weight: 500; text-align: left; cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.rail-toggle:hover { background: #f2f5f9; color: var(--fg); }
.sidebar-foot { margin: 0 22px 18px; font-size: 12px; color: var(--muted); }
.brand > div, .building-card > div, .nav a > span, .rail-toggle > span { white-space: nowrap; transition: opacity 0.2s; }
/* the rail: icons only by default, each name in a tooltip on hover or keyboard focus; the toggle at its foot expands it */
@media (min-width: 901px) {
  .rail-collapsed .app { grid-template-columns: 72px minmax(0, 1fr); }
  .rail-collapsed .sidebar { overflow: visible; }
  .rail-collapsed .brand { justify-content: center; padding: 24px 0 16px; gap: 0; }
  .rail-collapsed .brand > div, .rail-collapsed .building-card > div, .rail-collapsed .nav a > span, .rail-collapsed .rail-toggle > span { width: 0; opacity: 0; overflow: hidden; }
  .rail-collapsed .building-card { justify-content: center; gap: 0; margin: 2px 12px 8px; padding: 6px 0; }
  .rail-collapsed .nav-group { height: 1px; margin: 14px 18px; overflow: hidden; color: transparent; background: var(--border); }
  .rail-collapsed .nav a, .rail-collapsed .rail-toggle { justify-content: center; gap: 0; padding: 10px 0; }
  .rail-collapsed .nav .count { position: absolute; top: 2px; right: 5px; min-width: 17px; padding: 0 4px; font-size: 10px; line-height: 16px; }
  .rail-collapsed .sidebar-foot { display: none; }
  .rail-collapsed [data-label]::after { content: attr(data-label); position: absolute; left: calc(100% + 14px); top: 50%; z-index: 40; padding: 6px 10px; border-radius: 8px; background: #111827; color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-float); opacity: 0; transform: translate(-6px, -50%); pointer-events: none; transition: opacity 0.15s, transform 0.15s var(--ease-out); }
  .rail-collapsed [data-label]:hover::after, .rail-collapsed [data-label]:focus-visible::after { opacity: 1; transform: translate(0, -50%); transition-delay: 0.06s; }
}

.main { display: grid; grid-template-rows: 56px minmax(0, 1fr) 32px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--border); }
.crumb { display: flex; gap: 10px; margin: 0; color: var(--muted); }
.crumb b { color: var(--fg); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #f1ebff; color: #6a3fd6; font-size: 12px; font-weight: 700; }
.topbar .menu-btn { display: none; }
#content { position: relative; min-height: 0; overflow: hidden; }
.statusbar { display: flex; align-items: center; gap: 18px; padding: 0 16px; border-top: 1px solid var(--border); background: #fff; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.sb-state { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-fg); font-weight: 600; }
.sb-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.sb-src { overflow: hidden; text-overflow: ellipsis; }
.sb-clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 600; }

/* ---------- small pieces ---------- */
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; cursor: pointer; transition: background-color 0.15s, transform 0.1s; }
.icon-btn:hover { background: #f2f5f9; }
.icon-btn:active { transform: scale(0.96); }
.icon-btn[aria-pressed="true"] { background: var(--accent-50); border-color: #bcd6ff; color: #0b5bd3; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; font-weight: 600; color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f2f5f9; text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #0b68e8; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.pill--live { border: 1.5px solid var(--link); color: var(--link); }
.pill--live i { width: 7px; height: 7px; border-radius: 50%; background: var(--link); animation: beat 2s ease-in-out infinite; }
@keyframes beat { 50% { opacity: 0.25; } }
.state { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.state i { width: 7px; height: 7px; border-radius: 50%; }
.state--ok { background: var(--ok-bg); color: var(--ok-fg); } .state--ok i { background: var(--ok); }
.state--warn { background: var(--warn-bg); color: var(--warn-fg); } .state--warn i { background: var(--warn); }
.state--danger { background: var(--danger-bg); color: var(--danger-fg); } .state--danger i { background: var(--danger); }
.state--muted { background: #f2f4f7; color: #475467; } .state--muted i { background: #98a2b3; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--ok { background: var(--ok); } .dot--warn { background: var(--warn); }
.icon-chip { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 10px; color: var(--accent); background: #fff; }
.kpi--warn .icon-chip { color: var(--warn); }
.pill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.share { display: block; height: 4px; border-radius: 4px; background: #e9eef5; overflow: hidden; }
.share i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.6s var(--ease-out); }
/* a read-only switch carrying its word: the valve's state */
.vswitch { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.vswitch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--off); transition: background-color 0.3s; }
.vswitch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.3); transition: transform 0.3s var(--ease-out); }
.vswitch--on { color: var(--ok-fg); } .vswitch--on i { background: var(--ok); } .vswitch--on i::after { transform: translateX(14px); }
.vswitch--off { color: #475467; }
.vswitch--moving { color: var(--link); } .vswitch--moving i { background: #9cc2ff; } .vswitch--moving i::after { transform: translateX(7px); }
.vswitch--unknown { color: var(--danger-fg); } .vswitch--unknown i { background: repeating-linear-gradient(45deg, #f4c7c3 0 4px, #fbe3e1 4px 8px); } .vswitch--unknown i::after { transform: translateX(7px); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-3 { grid-template-columns: repeat(3, 1fr); }
.kv-4 { grid-template-columns: repeat(4, auto); gap: 6px 32px; }
.big { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.big b { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.big span { color: var(--muted); font-weight: 600; }
.big small { width: 100%; margin-top: -2px; }
.spark { height: 44px; }
.spark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-area { fill: rgba(22, 119, 255, 0.1); }

/* ---------- the 3D stage ---------- */
.stage { position: absolute; inset: 0; overflow: hidden; background: #eef3f9; }
.stage:fullscreen { width: 100vw; height: 100vh; }
.viewport { position: absolute; inset: 0; z-index: 0; } /* its own stacking context: CSS2DRenderer z-indexes the labels */
.viewport canvas { display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.float { position: absolute; z-index: 2; background: rgba(255, 255, 255, 0.86); -webkit-backdrop-filter: blur(12px) saturate(1.4); backdrop-filter: blur(12px) saturate(1.4); border: 1px solid rgba(223, 229, 238, 0.95); border-radius: var(--radius-card); box-shadow: var(--shadow-float); }
.w-overall { top: 16px; left: 16px; width: 292px; padding: 16px 18px; }
.w-overall .big { margin-top: 8px; }
.w-overall .big b { font-size: 34px; }
.collapsible { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.45s var(--ease-out), opacity 0.3s; }
.collapsible > div { overflow: hidden; min-height: 0; }
.is-focused .collapsible { grid-template-rows: 0fr; opacity: 0; }
.w-overall .spark { margin-top: 12px; }
.spark-cap { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.mini dt { font-size: 11.5px; color: var(--muted); }
.mini dd { margin: 0; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.w-list { top: 16px; right: 16px; width: 292px; max-height: calc(100% - 88px); display: flex; flex-direction: column; padding: 12px 8px 8px; }
.w-list header { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 10px 8px; font-size: 12.5px; }
.w-list ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.mrow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-control); background: none; text-align: left; cursor: pointer; transition: background-color 0.15s; }
.mrow:hover, .mrow.is-hover { background: var(--row-hover); }
.mrow[aria-current="true"] { background: var(--accent-50); box-shadow: inset 0 0 0 1px #bcd6ff; }
.mrow-main { flex: 1; min-width: 0; }
.mrow-main b { font-size: 13.5px; }
.mrow-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-main .share { margin-top: 6px; }
.mrow-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.is-focused .w-list { width: auto; }
.is-focused .w-list header span, .is-focused .mrow-main small, .is-focused .mrow-main .share, .is-focused .mrow-val { display: none; }
.w-meter { left: 16px; bottom: 16px; width: 360px; max-height: calc(100% - 140px); overflow-y: auto; padding: 16px 18px; animation: rise 0.45s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.w-meter header { display: flex; justify-content: space-between; gap: 12px; }
.w-meter h2 { margin-top: 6px; font-size: 19px; }
.w-meter .icon-btn { width: 32px; height: 32px; flex: none; }
.w-meter .pill-row { margin: 10px 0 12px; font-size: 12px; }
.energy { padding: 12px 14px; border: 1px solid var(--cat-edge); border-radius: 12px; background: linear-gradient(180deg, var(--cat-tint), #fff); box-shadow: var(--shadow-soft); }
.energy .spark { margin-top: 6px; height: 36px; }
.energy .spark-line { stroke: #ef6c1a; }
.energy .spark-area { fill: rgba(249, 115, 22, 0.1); }
.w-meter .kv { margin-top: 14px; }
.vlist { list-style: none; margin: 14px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.vlist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.vlist b { font-size: 13px; }
.w-meter footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.scene-crumb { top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap; animation: drop 0.4s var(--ease-out); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } }
.scene-crumb button { padding: 0; border: 0; background: none; color: var(--link); font-weight: 600; cursor: pointer; }
.scene-crumb span { color: var(--muted); }
.toolbar { right: 16px; bottom: 16px; display: flex; gap: 6px; padding: 6px; }
.toolbar .icon-btn { border-color: transparent; background: transparent; }
.toolbar .icon-btn[aria-pressed="true"] { background: var(--accent-50); }
.hint { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: rgba(17, 24, 39, 0.72); color: #fff; font-size: 12.5px; pointer-events: none; transition: opacity 0.8s; }
.hint.is-gone, .is-focused .hint { opacity: 0; }
.scene-tip { position: absolute; left: 0; top: 0; z-index: 3; max-width: 280px; padding: 8px 11px; border-radius: 10px; background: rgba(17, 24, 39, 0.88); color: #fff; font-size: 12.5px; pointer-events: none; }
.scene-tip b { display: block; }
.scene-tip span { color: #cbd5e1; }
/* pins and part tags float over the 3D (CSS2DRenderer) */
.pin-anchor { width: 0; height: 0; }
.pin-anchor::before { content: ""; position: absolute; left: -1px; bottom: 0; width: 2px; height: var(--stalk); background: linear-gradient(to top, rgba(22, 119, 255, 0.9), rgba(22, 119, 255, 0.15)); }
.pin-anchor::after { content: ""; position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9); }
.pin-warn::before { background: linear-gradient(to top, rgba(224, 122, 0, 0.9), rgba(224, 122, 0, 0.15)); }
.pin-warn::after { background: var(--warn); }
.pin { position: absolute; left: 0; bottom: var(--stalk); transform: translateX(-50%); width: max-content; white-space: nowrap; display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; border: 1px solid rgba(22, 119, 255, 0.35); border-radius: 999px; background: rgba(255, 255, 255, 0.94); box-shadow: var(--shadow-float); cursor: pointer; pointer-events: auto; text-align: left; transition: transform 0.2s var(--ease-out), box-shadow 0.2s; }
.pin:hover { transform: translateX(-50%) translateY(-3px) scale(1.06); box-shadow: 0 14px 28px -12px rgba(22, 119, 255, 0.55); }
.pin i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.18); position: relative; }
.pin i::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.pin b { display: block; font-size: 12px; line-height: 1.1; }
.pin em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pin-warn .pin { border-color: rgba(224, 122, 0, 0.45); }
.pin-warn .pin i { background: var(--warn); box-shadow: 0 0 0 4px rgba(224, 122, 0, 0.2); }
.tag { padding: 3px 8px; border-radius: 6px; background: rgba(17, 24, 39, 0.82); color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; animation: fade-in 0.6s 0.9s both; }
.tag-meter { background: var(--accent); }
.tag-valve { background: #1d4ed8; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }

/* ---------- pages ---------- */
.page { position: absolute; inset: 0; overflow-y: auto; padding: 32px 40px 48px; animation: page-in 0.35s var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 32px; font-weight: 700; }
.page-head .seg { margin-left: auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 22px; }
.page > * + * { margin-top: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; padding: 0 0 14px; }
.flush .card-head { padding: 20px 22px 14px; }
.card h2 { font-size: 19px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi .big { margin: 14px 0 6px; }
.kpi .big b { font-size: 34px; }
.kpi p.muted { margin: 0; }
.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; }
.events { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 14px; }
.events li { display: grid; gap: 4px; justify-items: start; }
.more { font-size: 13.5px; }
.bars { padding-top: 6px; }
.bars-plot { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 220px; margin-left: 52px; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px dashed #e3e8ef; }
.gl em { position: absolute; right: calc(100% + 8px); top: -8px; font-style: normal; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { position: relative; flex: 1; min-height: 2px; border-radius: 4px 4px 0 0; background: #3b82f6; transition: background-color 0.15s; }
.bar:hover { background: #0b5bd3; }
.bars-x { display: flex; gap: 4px; margin: 6px 0 0 52px; }
.bars-x span { flex: 1; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); text-align: left; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sharebar, .posbar { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.sharebar .share, .posbar .share { flex: 1; height: 6px; }
.sharebar small, .posbar small { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.note { margin-top: 14px; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tile { position: relative; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius-card); background: linear-gradient(180deg, var(--cat-tint), #fff 45%); box-shadow: var(--shadow-tile); overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--cat-strip); }
.tile header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile h3 { margin-top: 6px; font-size: 22px; }
.tile .energy { margin: 14px 0; }
.tile .big b { font-size: 26px; }
.valve-row { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; font-weight: 500; }
.tile footer { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.seg button { padding: 6px 14px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #111827; color: #fff; }
.alarm-list { display: grid; gap: 12px; }
.alarm { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: start; }
.alarm h3 { margin: 8px 0 4px; font-size: 16px; }
.alarm p:not(.pill-row) { margin: 0; color: #344054; }
.alarm-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #f2f4f7; color: #475467; }
.alarm--warn .alarm-ic { background: var(--warn-bg); color: var(--warn); }
.alarm--danger .alarm-ic { background: var(--danger-bg); color: var(--danger); }
.device { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.device h2 { margin: 6px 0; }
.device p { margin: 0; max-width: 60ch; }
.dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-float); }
.dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.dialog[open] { animation: rise 0.25s var(--ease-out); }
.dialog h2 { font-size: 20px; }
.dialog p { color: #344054; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; right: 24px; bottom: 48px; z-index: 20; padding: 12px 16px; border-radius: 12px; background: #111827; color: #fff; font-weight: 600; box-shadow: var(--shadow-float); animation: rise 0.3s var(--ease-out); }

/* ---------- narrow screens ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-row { grid-template-columns: 1fr; }
  .device { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 264px; transform: translateX(-100%); transition: transform 0.3s var(--ease-out); box-shadow: var(--shadow-float); }
  .nav-open .sidebar { transform: none; }
  .topbar .menu-btn { display: grid; }
  .page { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 26px; }
  .card.flush { overflow-x: auto; }
  .sb-src { display: none; }
  .w-overall { left: 12px; right: 12px; top: 12px; width: auto; padding: 12px 14px; }
  .w-overall .spark, .spark-cap { display: none; }
  .w-list { top: auto; bottom: 64px; left: 12px; right: 12px; width: auto; max-height: none; padding: 6px; }
  .w-list header { display: none; }
  .w-list ul { display: flex; gap: 4px; overflow-x: auto; }
  .w-list li { flex: none; }
  .mrow { width: auto; }
  .mrow-main small, .mrow-main .share { display: none; }
  .is-focused .w-list { display: none; }
  .w-meter { left: 12px; right: 12px; bottom: 64px; width: auto; max-height: 55%; }
  .toolbar { right: 12px; bottom: 12px; }
  .scene-crumb { display: none; }
  .hint { display: none; }
  .kv-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .top-right .pill, .crumb span:first-child, .crumb span[aria-hidden] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
