/* =====================================================================
   Light Glass Digital Twin — portable theme
   Tokens + reusable components, taken from the Factory Restroom HVAC
   dashboard (digitaltwin.kmce.io) with project-specific parts removed.
   Pages keep only layout (positions, grids, breakpoints) in their own
   <style>. Everything visual lives here. See DESIGN-LANGUAGE.md.
   ===================================================================== */

:root {
  /* surface & ink (Tailwind slate) */
  --bg: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: rgba(15, 23, 42, 0.08);
  --hover: rgba(15, 23, 42, 0.035);
  --well: rgba(15, 23, 42, 0.03);
  --card: rgba(255, 255, 255, 0.86);

  /* brand & status */
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-line: rgba(37, 99, 235, 0.35);
  --ok: #10b981;
  --ok-ring: rgba(16, 185, 129, 0.15);
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --off: #cbd5e1;

  /* chart series (categorical) — c1 is always the main series */
  --c1: #2563eb;
  --c2: #10b981;
  --c3: #f59e0b;
  --c4: #8b5cf6;
  --c5: #0ea5e9;
  --c6: #94a3b8;

  /* shape & depth */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 28px rgba(15, 23, 42, .08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .10);

  /* type & layout */
  --font: "Inter", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 24px;
}
@media (max-width: 820px) { :root { --gutter: 16px; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Surfaces ---------- */
.glass { background: var(--card); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.card { padding: 10px 8px 8px; }
.note { margin: 0 8px 10px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }

/* ---------- Typography ---------- */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--accent); border-radius: 2px; }
.title { margin: 8px 0 4px; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.title span { color: var(--faint); font-weight: 500; }
.section-label { margin: 4px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }

/* ---------- Card header ---------- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 8px 10px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-head small { color: var(--muted); font-size: 12px; }
.chev { display: none; width: 7px; height: 7px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-135deg) translate(-2px, -2px); transition: transform .2s; }
.collapsed .chev { transform: rotate(45deg); }

/* ---------- Segmented control & icon buttons ---------- */
.seg { display: flex; background: rgba(15, 23, 42, .04); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button, .icon-btn { border: 0; background: transparent; padding: 7px 13px; border-radius: var(--radius-xs); font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; white-space: nowrap; }
.seg button:hover, .icon-btn:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.icon-btn { padding: 7px 10px; display: inline-flex; align-items: center; gap: 6px; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); transition: border-color .15s, color .15s; }
.btn:hover { border-color: var(--accent-line); color: var(--accent); }
.btn-primary { border: 0; border-radius: var(--radius-sm); padding: 9px 14px; font-weight: 600; font-size: 13px; cursor: pointer; background: var(--accent); color: #fff; }
.btn-danger { border-color: rgba(239, 68, 68, .3); color: var(--danger); }

/* ---------- Form fields & chips ---------- */
.field { font: inherit; font-size: 12.5px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 6px 9px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
select.field { padding-right: 26px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 11px; font-size: 12px; cursor: pointer; color: var(--ink-2); transition: all .15s; }
.chips button:hover { border-color: var(--accent-line); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Popover (anchored under a toolbar button) ---------- */
.popover { position: absolute; top: calc(100% + 8px); right: 0; padding: 8px; width: 262px; display: none; z-index: 10; }
.popover.open { display: block; animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Toggle row (label + switch) ---------- */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px; border-radius: var(--radius-xs); cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
.toggle:hover { background: var(--hover); }
.toggle .sw { width: 30px; height: 18px; border-radius: 99px; background: var(--off); position: relative; transition: background .2s; flex: none; }
.toggle .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { transform: translateX(12px); }
.toggle .lbl { display: flex; align-items: center; gap: 8px; }
.chip { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.slider-row { padding: 2px 8px 8px 26px; display: none; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.slider-row.show { display: flex; }
input[type=range] { flex: 1; accent-color: var(--accent); }

/* ---------- Mini switch (inline in list rows) ---------- */
.mini-sw { width: 28px; height: 16px; border-radius: 99px; background: var(--accent); position: relative; border: 0; cursor: pointer; padding: 0; flex: none; }
.mini-sw::after { content: ""; position: absolute; top: 2px; left: 14px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .2s; }
.off .mini-sw { background: var(--off); }
.off .mini-sw::after { left: 2px; }

/* ---------- Status dot, badge, live dot ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-ring); flex: none; }
.off .dot, .dot.off { background: var(--off); box-shadow: none; }
.fault .dot, .dot.fault { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }
.warn .dot, .dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: var(--muted); background: var(--well); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.warn { color: #b45309; background: var(--warn-soft); border-color: transparent; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); animation: live 2s ease-out infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse-red 1.4s ease-out infinite; }
.pulse-dot.amber { background: var(--warn); animation-name: pulse-amber; }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); } 80%, 100% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); } }
@keyframes pulse-amber { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); } 80%, 100% { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0); } }

/* ---------- Big numbers ---------- */
.bigval { font-size: 40px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.bigval small { font-size: 18px; color: var(--muted); font-weight: 500; }
.stat-big { padding: 0 8px 10px; }
.stat-big > span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.stat-big > span b { color: var(--ink-2); font-weight: 600; }
.stat-big.tight { padding: 0; }
.stat-big.tight .bigval { font-size: 30px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 6px 10px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kpi { background: var(--well); border-radius: var(--radius-sm); padding: 9px 11px; }
.kpi b { display: block; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi b small { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi span { font-size: 11.5px; color: var(--muted); }
.kpi.accent b { color: var(--accent); }
.kpis.three .kpi { padding: 8px 9px; }
.kpis.three .kpi b { font-size: 16px; }
.kpis.three .kpi span { font-size: 11px; }
/* wide KPI row on full pages: tile = label · value · delta vs previous period */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi-grid .kpi { background: rgba(255, 255, 255, .7); border: 1px solid var(--line); display: grid; gap: 2px; }
.kpi-grid .kpi b { font-size: 19px; }
.delta { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta.good { color: #047857; }
.delta.bad { color: #b45309; }

/* ---------- Sparkline (inline SVG area chart) ---------- */
.spark { padding: 0 8px 10px; }
.spark svg { display: block; width: 100%; height: 72px; overflow: visible; }
.spark .area { fill: var(--accent); opacity: .10; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .grid { stroke: var(--line); stroke-width: 1; }
.spark .fc { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: .72; }
.spark .band { fill: var(--accent); opacity: .07; }
.spark .now { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.spark .axis { font-size: 9.5px; fill: var(--faint); font-family: var(--font); }

/* ---------- Device dots (one square per device, clickable) ---------- */
.unit-dots { display: grid; grid-template-columns: repeat(6, 14px); gap: 6px; }
.unit-dots button { width: 14px; height: 14px; border-radius: 4px; border: 0; padding: 0; cursor: pointer; background: var(--accent); transition: transform .15s, background .2s; }
.unit-dots button:hover { transform: scale(1.2); }
.unit-dots button.off { background: var(--off); }
.unit-dots button.fault { background: var(--danger); }
.unit-dots button.sel { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- List rows: dot · name/sub · value · action ---------- */
.list { overflow-y: auto; flex: 1; padding: 0 2px; scrollbar-width: thin; }
.row { display: grid; grid-template-columns: 10px 1fr auto auto; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--accent-soft); }
.row .name { font-size: 13px; font-weight: 600; }
.row .sub { font-size: 11.5px; color: var(--muted); display: block; font-weight: 400; margin-top: 1px; }
.row .val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.off .val { color: var(--faint); }

/* ---------- Detail card (selected item) ---------- */
.detail { margin: 0 6px 10px; padding: 14px; border-radius: 12px; background: linear-gradient(160deg, #eff6ff, #ffffff 70%); border: 1px solid rgba(37, 99, 235, .15); display: none; }
.detail.show { display: block; }
.detail .top { display: flex; justify-content: space-between; align-items: flex-start; }
.detail h4 { margin: 0; font-size: 16px; }
.detail .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.detail .close { border: 0; background: transparent; cursor: pointer; color: var(--faint); font-size: 18px; line-height: 1; padding: 2px 4px; }
.detail .btn-primary { margin-top: 12px; width: 100%; }
.detail.isoff .btn-primary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.detail.isoff .bigval { color: var(--faint); }
.setpoint { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.stepper { display: flex; gap: 6px; }
.stepper button { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; color: var(--ink-2); }
.stepper button:hover { color: var(--accent); border-color: var(--accent-line); }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.meta div { font-size: 11px; color: var(--muted); }
.meta b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; margin-top: 2px; }

/* ---------- Progress, meter, battery, saving ---------- */
.progress { height: 6px; border-radius: 99px; background: rgba(15, 23, 42, .08); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s ease; }
.progress.warn i { background: var(--warn); }
.progress.danger i { background: var(--danger); }
.meter { display: grid; gap: 6px; padding: 0 8px 8px; }
.meter-row { display: grid; grid-template-columns: 74px 1fr 64px; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.meter-row b { text-align: right; color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-row .bar { height: 8px; border-radius: 99px; background: var(--well); overflow: hidden; }
.meter-row .bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ok); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.meter-row.base .bar i { background: var(--off); }
.battery { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.battery .cell { width: 26px; height: 10px; border: 1.5px solid var(--faint); border-radius: 3px; padding: 1px; position: relative; }
.battery .cell::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; border-radius: 0 1px 1px 0; background: var(--faint); }
.battery .cell i { display: block; height: 100%; border-radius: 1px; background: var(--ok); }
.battery.low .cell i { background: var(--warn); }
.saving { margin: 2px 6px 4px; padding: 9px 11px; border-radius: var(--radius-sm); background: rgba(16, 185, 129, .08); color: #047857; font-size: 12.5px; line-height: 1.45; }
.saving b { font-weight: 600; }
.saving.neg { background: var(--warn-soft); color: #b45309; }

/* ---------- Alerts ----------
   .alert-card  floating red-tinted glass card, one per unacknowledged fault (.task = amber job)
   .alert-item  the same content inline inside another card
   .alert-mini  compact summary of overflow / acknowledged alerts */
.alert { border-color: rgba(239, 68, 68, .35); background: linear-gradient(160deg, rgba(254, 226, 226, .94), rgba(255, 255, 255, .92) 70%); }
.alert-card { padding: 12px 12px 10px; }
.alert-card.task { border-color: rgba(245, 158, 11, .4); background: linear-gradient(160deg, rgba(254, 243, 199, .95), rgba(255, 255, 255, .92) 70%); }
.alert-item { padding: 10px; margin: 0 2px 6px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .75); border: 1px solid rgba(239, 68, 68, .18); }
:is(.alert-item, .alert-card) .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
:is(.alert-item, .alert-card) .what { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.alert-card .what { font-size: 14px; }
:is(.alert-item, .alert-card) .what small { color: var(--muted); font-weight: 500; font-size: 12px; }
:is(.alert-item, .alert-card) .where { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
:is(.alert-item, .alert-card) .advice { font-size: 11.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.5; }
:is(.alert-item, .alert-card) .acts { display: flex; gap: 6px; margin-top: 8px; }
:is(.alert-item, .alert-card) .acts .btn { padding: 5px 10px; font-size: 12px; }
.alert-card .acts .btn:first-child { background: var(--danger); border-color: var(--danger); color: #fff; }
.alert-card.task .acts .btn:first-child { background: var(--warn); border-color: var(--warn); }
.alert-mini { padding: 8px 6px 6px; }
.alert-mini .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 6px; font-size: 12.5px; font-weight: 600; }
.alert-mini .rows { max-height: 152px; overflow-y: auto; scrollbar-width: thin; }
.alert-mini .mrow { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; padding: 6px; border-radius: var(--radius-xs); cursor: pointer; font-size: 12px; }
.alert-mini .mrow:hover { background: var(--hover); }
.alert-mini .mrow .dot { width: 7px; height: 7px; box-shadow: none; }
.alert-mini .mrow.ack .dot { background: var(--warn); }
.alert-mini .mrow.active .dot { background: var(--danger); }
.alert-mini .mrow small { color: var(--muted); }
.enter { animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ---------- Toast (top centre, auto-hides) ---------- */
.toasts { position: fixed; top: 78px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 40; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .3s cubic-bezier(.2, .8, .2, 1); cursor: pointer; }
.toast.danger { background: var(--danger); }
.toast .t-sub { opacity: .8; font-size: 12px; }
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Drawer (slides up from the bottom edge) + data table ---------- */
.drawer { display: flex; flex-direction: column; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(24px) scale(.98); transform-origin: bottom left; transition: opacity .22s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s; }
.drawer.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .22s ease, transform .3s cubic-bezier(.2, .8, .2, 1); }
.drawer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 2px 6px 10px; }
.drawer-bar .spacer { flex: 1; }
.table-wrap { overflow: auto; flex: 1; border-top: 1px solid var(--line); scrollbar-width: thin; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.table th { position: sticky; top: 0; z-index: 1; background: rgba(248, 250, 252, .97); text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.active td { background: rgba(254, 226, 226, .45); }
.table td.strong { color: var(--ink); font-weight: 600; }
.table .empty { text-align: center; color: var(--faint); padding: 28px; cursor: default; }

/* ---------- Loading splash & camera-swap veil ---------- */
.splash { position: fixed; inset: 0; background: #fff; display: grid; place-items: center; z-index: 50; transition: opacity .8s ease; }
.splash.hide { opacity: 0; pointer-events: none; }
.splash .ld { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.splash .ld i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.veil { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 2; }
.veil.on { opacity: 1; }

/* ---------- 3D labels (three.js CSS2DRenderer) ----------
   .tag3d         device pill: dot · id · value   (.sel .off .fault)
   .tag3d-sensor  sensor pill, smaller             (.on = sees someone, .offline)
   .tag3d-mini    tiny square label for secondary items
   Put .hide-tags on the label layer to hide them all. */
.tag3d { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border-radius: 99px; background: rgba(255, 255, 255, .94); border: 1px solid rgba(37, 99, 235, .22); box-shadow: var(--shadow-sm); font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; transition: border-color .2s, background .2s; }
.tag3d i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.tag3d span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.tag3d:hover, .tag3d.sel { border-color: var(--accent); background: #fff; }
.tag3d.sel { background: var(--accent); color: #fff; }
.tag3d.sel span { color: rgba(255, 255, 255, .8); }
.tag3d.sel i { background: #fff; box-shadow: none; }
.tag3d.off { border-color: var(--line); color: var(--muted); }
.tag3d.off i { background: var(--off); box-shadow: none; }
.tag3d.fault { background: var(--danger); border-color: var(--danger); color: #fff; animation: tag-alarm 1.2s ease-in-out infinite; }
.tag3d.fault span { color: rgba(255, 255, 255, .9); }
.tag3d.fault i { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
@keyframes tag-alarm { 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, .22), var(--shadow-sm); } }
.tag3d-sensor { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 99px; background: rgba(255, 255, 255, .92); border: 1px solid rgba(15, 23, 42, .12); box-shadow: var(--shadow-sm); font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.tag3d-sensor b { font-weight: 600; color: var(--ink); }
.tag3d-sensor span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag3d-sensor i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.tag3d-sensor.on { border-color: rgba(16, 185, 129, .45); }
.tag3d-sensor.on i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-ring); }
.tag3d-sensor.on span { color: #047857; }
.tag3d-sensor.warn { border-color: rgba(245, 158, 11, .5); }
.tag3d-sensor.warn i { background: var(--warn); }
.tag3d-sensor.warn span { color: #b45309; }
.tag3d-sensor.offline { opacity: .55; }
.tag3d-mini { font-size: 10px; font-weight: 600; color: #475569; background: rgba(255, 255, 255, .9); border: 1px solid rgba(15, 23, 42, .12); border-radius: 5px; padding: 1px 5px; letter-spacing: .03em; }
.hide-tags :is(.tag3d, .tag3d-sensor, .tag3d-mini), .hide-sensors .tag3d-sensor { display: none; }
@media (max-width: 820px) {
  .tag3d { font-size: 10.5px; padding: 3px 7px 3px 6px; gap: 5px; }
  .tag3d span, .tag3d-sensor, .tag3d-mini { display: none; }
}

/* ---------- AI assistant dock ----------
   .dock-bar   glass pill: avatar circle · name/status · mic button
   .mic-btn    round primary action (.live = in a session → red stop)
   .levels     tiny live audio meter (set --l 0..1 on each <i>)
   .bubble     speech bubble for the assistant (.err for problems)
   .said       muted line with what the user said */
.dock-bar { position: relative; display: flex; align-items: center; gap: 10px; height: 56px; padding: 6px 6px 6px 58px; border-radius: 99px; }
.dock-avatar { position: absolute; left: 6px; top: 6px; width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #f8fbff, #dbeafe 75%); box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .15); }
.dock-text { min-width: 0; flex: 1; line-height: 1.25; }
.dock-text b { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.dock-text span { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mic-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: var(--accent); box-shadow: 0 6px 16px rgba(37, 99, 235, .32); transition: background .2s, box-shadow .2s, transform .15s; }
.mic-btn:hover { transform: scale(1.05); }
.mic-btn:active { transform: scale(.95); }
.mic-btn svg { width: 19px; height: 19px; }
.mic-btn.live { background: var(--danger); box-shadow: 0 6px 16px rgba(239, 68, 68, .32); }
.mic-btn .ring { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .8s linear infinite; }
.levels { display: inline-flex; align-items: center; gap: 2px; height: 12px; }
.levels i { width: 3px; border-radius: 2px; background: var(--accent); height: calc(3px + var(--l, 0) * 9px); transition: height .08s; }
.bubble { padding: 11px 14px; border-radius: 16px 16px 16px 5px; font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.bubble .who { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 3px; }
.bubble.err .who { color: var(--danger); }
.bubble .tool { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.bubble .tool::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.said { margin-top: 6px; font-size: 12px; color: var(--muted); padding-left: 2px; }
.said b { color: var(--ink-2); font-weight: 600; }

/* ---------- Full pages (over the faded, paused 3D scene) ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h2 { margin: 8px 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 0; max-width: 620px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.feature { padding: 16px; border-radius: var(--radius); background: rgba(255, 255, 255, .7); border: 1px solid var(--line); }
.feature h3 { margin: 12px 0 4px; font-size: 14px; font-weight: 600; }
.feature p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.feature-ic { width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.feature-ic svg { width: 18px; height: 18px; }

/* ---------- Chart cards (chart left, computed insights right) ---------- */
.chart-card { background: rgba(255, 255, 255, .82); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; min-width: 0; }
.chart-card > header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.chart-card h4 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; }
.chart-card header small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.chart-card .acts { margin-left: auto; display: flex; gap: 2px; }
.chart-ic { flex: none; width: 30px; height: 30px; border-radius: var(--radius-xs); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chart-ic svg { width: 16px; height: 16px; }
.chart-body { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.chart-box { position: relative; height: 260px; min-width: 0; }
.chart-box.sm { height: 118px; }
.chart-box canvas { max-width: 100%; }
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.insights li { position: relative; padding-left: 14px; }
.insights li::before { content: ""; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.empty-box { padding: 22px; border: 1px dashed rgba(15, 23, 42, .14); border-radius: var(--radius); text-align: center; font-size: 12.5px; color: var(--muted); }
/* heatmap in plain HTML: hours across, rows = days. Cell colour = accent at opacity --a */
.heat { display: grid; grid-template-columns: 48px repeat(var(--cols), minmax(0, 1fr)); gap: 2px; font-size: 10px; color: var(--muted); }
.heat .hr { white-space: nowrap; padding-right: 6px; text-align: right; line-height: 13px; }
.heat i { height: 13px; border-radius: 2px; background: rgba(37, 99, 235, var(--a)); }
.heat i.na { background: var(--well); }

@media (max-width: 1180px) {
  .chart-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .page-head { flex-direction: column; gap: 10px; }
  .page-head h2 { font-size: 20px; }
  .chart-box { height: 220px; }
}

/* =====================================================================
   PZENT additions — components this project needs on top of the kit.
   Everything here follows the same tokens; no new colours.
   ===================================================================== */

/* ---------- Chart extras: small multiples, donut, heatmap legend ---------- */
.chart-box.sm + .chart-box.sm { margin-top: 6px; }
.donut-wrap { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: center; }
.donut-wrap > * { min-width: 0; }
.chart-box.donut { height: 210px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: 11px; color: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; max-width: 300px; display: grid; gap: 5px; font-size: 12px; max-height: 210px; overflow: auto; }
.donut-legend li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; color: var(--ink-2); }
.donut-legend i { width: 9px; height: 9px; border-radius: 3px; }
.donut-legend b { font-weight: 600; font-variant-numeric: tabular-nums; }
.heat .hc { text-align: left; white-space: nowrap; overflow: visible; height: 14px; }
.heat-legend { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.heat-legend b { width: 120px; height: 7px; border-radius: 99px; background: linear-gradient(90deg, rgba(37, 99, 235, .06), rgb(37, 99, 235)); }

/* ---------- Analysis feed (cards the data page and น้องฉ่ำ open) ---------- */
.an-section { margin-top: 24px; }
.an-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.an-top .section-label { margin: 0; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ask-chips button { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; color: var(--ink-2); background: rgba(255, 255, 255, .8); border: 1px solid var(--line); border-radius: 99px; padding: 6px 11px; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.ask-chips button svg { width: 13px; height: 13px; color: var(--accent); }
.ask-chips button:hover { border-color: var(--accent-line); color: var(--accent); background: #fff; }
.an-feed { display: grid; gap: 14px; }
.chart-card.enter { animation: an-in .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes an-in { from { opacity: 0; transform: translateY(-8px); } }
.chart-card.flash { box-shadow: 0 0 0 2px var(--accent-line); transition: box-shadow 1.2s; }
.chart-card .acts .icon-btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
.an-src { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-size: 10.5px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 1px 7px; vertical-align: 1px; }
.an-empty { padding: 22px; border: 1px dashed rgba(15, 23, 42, .14); border-radius: var(--radius); text-align: center; font-size: 12.5px; color: var(--muted); }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.data-grid .chart-body { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.data-grid .insights { grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 12px; }

/* ---------- Carbon: tree equivalence row ---------- */
.trees { display: flex; gap: 4px; padding: 2px 8px 4px; flex-wrap: wrap; }
.trees .tree { position: relative; width: 22px; height: 26px; flex: none; }
.trees .tree > span { position: absolute; inset: 0; }
.trees .tree svg { display: block; width: 22px; height: 26px; }
.trees .tree .bg { color: rgba(15, 23, 42, .1); }
.trees .tree .fg { color: var(--ok); clip-path: inset(var(--empty, 100%) 0 0 0); transition: clip-path .8s cubic-bezier(.2, .8, .2, 1); }
.trees-note { margin: 0 8px 10px; font-size: 11.5px; color: var(--muted); }
.trees-note b { color: var(--ink-2); }

/* ---------- Floor tree (rail): floor meter with its room meters under it ---------- */
.floors { display: grid; gap: 2px; padding: 2px 0 4px; }
.floor-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--radius-xs); cursor: pointer; border: 0; background: none; font: inherit; text-align: left; color: var(--ink); width: 100%; transition: background .15s; }
.floor-row:hover { background: var(--hover); }
.floor-row.sel { background: var(--accent-soft); }
.floor-row.muted { cursor: default; }
.floor-row.muted:hover { background: none; }
.floor-row .nm { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; }
.floor-row .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.floor-row small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.floor-row .v { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.floor-row .v small { font-size: 10.5px; font-weight: 500; }
.floor-row.child { padding-left: 22px; }
.floor-row.child .nm { font-size: 12.5px; color: var(--ink-2); }
.floor-row.child::before { content: ""; position: absolute; }
.floor-row.off .v, .floor-row.off .nm { color: var(--faint); }
.floor-bar { grid-column: 1 / -1; height: 3px; border-radius: 99px; background: var(--well); overflow: hidden; }
.floor-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Solar flow (PV → load → grid) ---------- */
/* ---------- Solar flow: PV above, load and grid below, wired together ----------
   Series colours (--c1/--c3/--c4), not status colours: this is a diagram of where the
   energy goes, so it may be coloured like a chart. Status colours stay with the meters. */
.pvflow { position: relative; height: 196px; margin: 4px 0 2px; }
.pvnode { position: absolute; width: 104px; margin-left: -52px; text-align: center; }
.pvnode.pv { left: 50%; top: 0; }
.pvnode.load { left: 25%; top: 104px; }
.pvnode.grid { left: 75%; top: 104px; }
.pvring { width: 52px; height: 52px; margin: 0 auto 7px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; background: #fff; color: var(--faint); transition: border-color .3s, color .3s, background .3s; }
.pvring svg { width: 21px; height: 21px; }
.pvnode.on.pv .pvring { border-color: var(--c3); color: #b45309; background: #fffbeb; }
.pvnode.on.load .pvring { border-color: var(--c1); color: var(--c1); background: var(--accent-soft); }
.pvnode.on.grid .pvring { border-color: var(--c4); color: var(--c4); background: #f5f3ff; }
.pvnode b { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.pvnode b small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.pvnode > span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.pvwire { position: absolute; background: var(--line); border-radius: 99px; overflow: hidden; }
.pvwire.v { left: calc(50% - 1px); top: 58px; width: 2px; height: 71px; }
.pvwire.h { left: 25%; right: 25%; top: 128px; height: 2px; }
.pvwire i { position: absolute; border-radius: 99px; background: currentColor; }
.pvwire.v i { left: -1px; width: 4px; height: 30%; color: var(--c3); animation: pv-down 1.9s linear infinite; }
.pvwire.h i { top: -1px; height: 4px; width: 22%; color: var(--c4); animation: pv-right 1.9s linear infinite; }
.pvwire.h.rev i { animation-direction: reverse; }
.pvwire.idle i { display: none; }
@keyframes pv-down { from { top: -30%; } to { top: 102%; } }
@keyframes pv-right { from { left: -22%; } to { left: 102%; } }
.flow-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 8px 0; font-size: 11px; color: var(--muted); }
.flow-legend b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Gauge: today vs normal ---------- */
.gauge { position: relative; padding: 2px 8px 0; }
.card.tight .gauge { max-width: 168px; margin: 0 auto; padding-top: 0; }
.card.tight .gauge-mid { padding-top: 10px; }
.card.tight .gauge-mid b { font-size: 19px !important; }
.card.tight .kpis { gap: 6px; }
.card.tight .kpi { padding: 7px 9px; }
.card.tight .kpi b { font-size: 15px; }
.card.tight .note { font-size: 11px; margin-top: 6px; }
.gauge svg { display: block; width: 100%; height: auto; }
.gauge .track { fill: none; stroke: var(--well); stroke-width: 11; stroke-linecap: round; }
.gauge .val { fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1), stroke .3s; }
.gauge.over .val { stroke: var(--warn); }
.gauge.under .val { stroke: var(--ok); }
.gauge .mark { stroke: var(--ink-2); stroke-width: 2; }
.gauge-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding-top: 14px; pointer-events: none; }

/* ---------- Report (A4 document) ---------- */
.report-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.report-bar .field { min-width: 210px; }
.report-bar .btn, .report-bar .btn-primary { display: inline-flex; align-items: center; gap: 6px; }
.report-bar svg { width: 15px; height: 15px; }
.report-bar .btn-primary:disabled { opacity: .65; cursor: progress; }
.report-bar .note { margin: 0; font-size: 12px; color: var(--warn); }
.report-doc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; justify-items: center; padding-bottom: 12px; }
.a4 { min-width: 0; width: min(820px, 100%); aspect-ratio: 210 / 297; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 40px 44px 30px; display: flex; flex-direction: column; gap: 18px; font-size: 12.5px; line-height: 1.6; }
.rep-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--accent); }
.rep-org { display: flex; align-items: center; gap: 10px; }
.rep-org b { display: block; font-size: 13px; }
.rep-org span { font-size: 11px; color: var(--muted); }
.rep-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #60a5fa); flex: none; }
.rep-meta { font-size: 11px; color: var(--muted); text-align: right; }
.rep-tag { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.rep-title h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.rep-title p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.a4 h2 { margin: 0 0 8px; font-size: 14px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.a4 h2 small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.a4 h3 { margin: 10px 0 4px; font-size: 12.5px; font-weight: 600; }
.rep-summary { background: var(--well); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 16px; transition: opacity .3s; }
.rep-summary.writing { opacity: .45; }
.rep-summary p { margin: 0; text-align: justify; }
.rep-summary ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.rep-by { font-size: 10.5px; font-weight: 500; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; }
.rep-by.ai { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.rep-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rep-kpis > div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 2px; }
.rep-kpis > div.save { background: rgba(16, 185, 129, .06); border-color: rgba(16, 185, 129, .25); }
.rep-kpis span { font-size: 11px; color: var(--muted); }
.rep-kpis b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rep-kpis b small { font-size: 11px; font-weight: 500; color: var(--muted); }
.rep-d { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rep-d.good { color: #047857; }
.rep-d.bad { color: #b45309; }
.rep-block, .rep-chart { min-width: 0; }
.rep-note { margin: 4px 0 6px; font-size: 11px; color: var(--muted); }
.rep-chart { position: relative; }
.rep-chart .chart-box { height: 300px; }
.rep-chart.sm .chart-box.donut { height: 150px; }
.rep-chart.sm .donut-wrap { grid-template-columns: 150px minmax(0, 1fr); gap: 12px; }
.rep-chart.sm .donut-legend { font-size: 11px; }
.rep-img { width: 100%; height: auto; display: block; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.rep-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px; padding: 6px 6px; border-bottom: 1.5px solid rgba(15, 23, 42, .15); white-space: nowrap; }
.rep-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.rep-table .n { text-align: right; }
.rep-table tr.flag td { background: var(--warn-soft); }
.rep-two { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; }
.rep-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.rep-facts li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.rep-facts span { color: var(--muted); }
.rep-facts b { font-weight: 600; text-align: right; }
.rep-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 10px; color: var(--faint); }

/* ---------- Policy page ---------- */
.pol-act { display: flex; align-items: center; gap: 10px; flex: none; }
.pol-draft { margin-bottom: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 13px; }
.pol-draft .pd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pol-draft ul { margin: 0 0 8px; padding-left: 20px; }
.pol-draft p { margin: 0 0 10px; }
.pol-draft small { color: var(--muted); }
.pd-acts { display: flex; gap: 8px; }
.pol-tl-wrap { margin-top: 22px; min-width: 0; }
.pol-tl { --tl-label: 92px; position: relative; display: grid; gap: 4px; padding: 4px 0 8px; overflow-x: clip; }
.tl-row { position: relative; display: grid; grid-template-columns: var(--tl-label) 1fr; align-items: center; min-height: 24px; }
.tl-row em { font-style: normal; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }
.tl-row.ruler { display: block; height: 16px; min-height: 0; margin-left: var(--tl-label); }
.tl-row.ruler b { position: absolute; transform: translateX(-50%); font-size: 10px; font-weight: 500; color: var(--faint); }
.tl-row.ruler b:first-child { transform: none; }
.tl-row.ruler b:last-child { transform: translateX(-100%); }
.tl-track { position: relative; height: 24px; border-radius: 6px; background: var(--well); overflow: hidden; }
.tl-track i { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; font-style: normal; }
.tl-track i span { font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.tl-track .ok { background: var(--accent-soft); }
.tl-track .bad { background: var(--danger-soft); }
.tl-track .cap { background: rgba(245, 158, 11, .25); }
.tl-now { position: absolute; top: 18px; bottom: 30px; width: 2px; background: var(--danger); pointer-events: none; }
.tl-now span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 600; color: var(--danger); white-space: nowrap; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 0 var(--tl-label); font-size: 11px; color: var(--muted); }
.tl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tl-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.pol-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; margin-top: 22px; align-items: start; }
.rules { display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, .75); padding: 12px 14px; transition: border-color .2s, background .2s; }
.rule.on { border-color: var(--accent-line); background: #fff; }
.rule-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.rule-ic { width: 32px; height: 32px; border-radius: var(--radius-xs); display: grid; place-items: center; background: var(--well); color: var(--muted); }
.rule.on .rule-ic { background: var(--accent-soft); color: var(--accent); }
.rule-ic svg { width: 16px; height: 16px; }
.rule-txt h4 { margin: 0; font-size: 13.5px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rule-txt p { margin: 2px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.rule-tag { font-size: 10px; font-weight: 500; color: var(--muted); background: var(--well); border-radius: 99px; padding: 1px 7px; }
.rule-tag.bad { color: #b45309; background: var(--warn-soft); }
.rule .toggle { padding: 4px; background: none; border: 0; }
.rule-params { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0 42px; font-size: 12px; color: var(--ink-2); }
.rule-params label { display: inline-flex; align-items: center; gap: 6px; }
.rule-params .field { width: 72px; padding: 4px 6px; font-size: 12px; }
.rule-params select.field { width: auto; }
.rule:not(.on) .rule-params { opacity: .5; }
.rule-eff { margin: 8px 0 0 42px; font-size: 11.5px; color: #047857; }
.rule:not(.on) .rule-eff { color: var(--faint); }
.rule-eff.cost { color: #b45309; }
.viol { display: grid; gap: 6px; }
.viol-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 10px; border-radius: var(--radius-xs); background: var(--well); font-size: 12.5px; }
.viol-row b { font-weight: 600; }
.viol-row small { display: block; font-size: 11px; color: var(--muted); }
.viol-row .n { text-align: right; font-variant-numeric: tabular-nums; color: #b45309; font-weight: 600; }

/* ---------- Misc ---------- */
.stale-note { display: flex; align-items: center; gap: 6px; margin: 0 8px 8px; font-size: 11.5px; color: #b45309; }
.skeleton { background: linear-gradient(90deg, var(--well), rgba(15,23,42,.06), var(--well)); background-size: 200% 100%; animation: sk 1.4s linear infinite; border-radius: 6px; color: transparent !important; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 1180px) { .pol-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) { .data-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .donut-wrap { grid-template-columns: minmax(0, 1fr); }
  .heat .hc { font-size: 8.5px; }
  .a4 { aspect-ratio: auto; padding: 20px 16px; font-size: 12px; }
  .rep-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-two { grid-template-columns: minmax(0, 1fr); }
  .rep-head { flex-wrap: wrap; }
  .rep-block:has(.rep-table) { overflow-x: auto; }
  .rep-title h1 { font-size: 18px; }
  .rep-chart.sm .donut-wrap { grid-template-columns: 120px minmax(0, 1fr); }
  .pol-act { width: 100%; }
  .pol-tl { --tl-label: 72px; }
  .tl-track i span { font-size: 9px; }
  .rule-params, .rule-eff { margin-left: 0; }
}

/* Print / PDF: only the report copy in #printRoot (see report.js) */
#printRoot { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { height: auto; background: #fff; }
  body.printing > :not(#printRoot) { display: none !important; }
  body.printing #printRoot { display: block; }
  #printRoot .a4 { width: 210mm; height: 297mm; aspect-ratio: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 14mm 15mm 10mm; break-after: page; overflow: hidden; }
  #printRoot .a4:last-child { break-after: auto; }
  #printRoot * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Period picker (data + solar pages) ---------- */
.period-pick { position: relative; display: inline-block; }
.period-pick .popover { width: 248px; }
.range-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-2); }
.range-row .field { width: 100%; padding: 6px 8px; font-size: 12.5px; }
.period-pick .note { margin: 2px 0 9px; }
.period-pick .btn-primary { width: 100%; }
.period-pick .btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Floor picker (3D toolbar) ---------- */
.floor-pick { display: grid; gap: 2px; min-width: 188px; }
.floor-pick button { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--radius-xs); background: none; font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer; text-align: left; }
.floor-pick button:hover { background: var(--hover); }
.floor-pick button.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.floor-pick button i { font-style: normal; font-size: 11px; font-weight: 600; color: var(--faint); text-align: center; }
.floor-pick button.on i { color: var(--accent); }
.floor-pick button small { font-size: 10.5px; color: var(--muted); }
