/* EnviroSentry (envirosentry.js): units, charts, room heatmaps. Status colours
   are the manager's (ok / accent for "watch" / bad); --es-cold is the one extra,
   for a room under the comfortable temperature. */
:root { --es-cold: #60a5fa; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --es-cold: #1d4ed8; } }
:root[data-theme="light"] { --es-cold: #1d4ed8; }

.es-table td.num, .es-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.es-table tr[data-es] { cursor: pointer; }
.es-table tr.is-open > td { background: var(--bg-2); }
.es-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.es-v.warn { color: var(--accent-text); font-weight: 700; }
.es-v.bad { color: var(--bad); font-weight: 700; }
.es-v.cold { color: var(--es-cold); font-weight: 700; }
.es-detail { padding: 6px 4px 14px; }
.es-detail .envgrid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.es-detail .envcell.cold { border-color: var(--es-cold); } .es-detail .envcell.cold strong { color: var(--es-cold); }
.es-detail h4 { margin: 14px 0 6px; font-size: 13px; color: var(--fg-2); text-transform: uppercase; letter-spacing: .04em; }

/* 24 h charts: small multiples, one measure each (never two scales on one chart) */
.es-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.es-chart { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-2); padding: 10px 12px 6px; position: relative; }
.es-chart header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.es-chart header strong { color: var(--fg-0); }
.es-chart header span { color: var(--fg-2); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.es-chart svg { width: 100%; height: 96px; display: block; overflow: visible; touch-action: pan-y; }
.es-chart .es-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.es-chart .es-grid { stroke: var(--line); stroke-width: 1; }
.es-chart .es-thr { stroke: var(--fg-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.es-chart .es-vape { fill: var(--bad); }
.es-chart .es-occ { fill: var(--ok); opacity: .55; }
.es-chart .es-cross { stroke: var(--fg-2); stroke-width: 1; }
.es-chart .es-dot { fill: var(--accent); stroke: var(--bg-1); stroke-width: 2; }
.es-chart .es-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-3); margin-top: 2px; }
.es-tip { position: absolute; pointer-events: none; background: var(--bg-3); color: var(--fg-0); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 2; }
.es-tip small { color: var(--fg-2); display: block; }
.es-key { display: flex; gap: 14px; font-size: 12px; color: var(--fg-2); margin: 6px 0 0; flex-wrap: wrap; }
.es-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Room heatmaps: one plan per measure, side by side */
.es-maps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 14px; }
.es-map { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-2); padding: 10px 12px 12px; }
.es-map h3 { margin: 0 0 6px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.es-map h3 small { color: var(--fg-2); font-weight: 400; }
.es-map svg { width: 100%; height: auto; display: block; background: var(--bg-2); border-radius: 6px; }
.es-map image { opacity: .55; }
.es-room { fill: transparent; stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.es-fill { fill-opacity: .38; stroke-width: 2; vector-effect: non-scaling-stroke; }
.es-fill.ok { fill: var(--ok); stroke: var(--ok); }
.es-fill.warn { fill: var(--accent); stroke: var(--accent); }
.es-fill.bad { fill: var(--bad); stroke: var(--bad); }
.es-fill.cold { fill: var(--es-cold); stroke: var(--es-cold); }
.es-fill.occ { fill: var(--accent); stroke: var(--accent); }
.es-fill.none { fill: var(--fg-3); stroke: var(--fg-3); fill-opacity: .15; }
.es-fill.vape { stroke: var(--bad); stroke-width: 4; }
.es-val { fill: var(--fg-0); font-weight: 700; paint-order: stroke; stroke: var(--bg-1); stroke-linejoin: round; font-family: var(--font-mono); }
.es-rname { fill: var(--fg-1); paint-order: stroke; stroke: var(--bg-1); stroke-linejoin: round; }
.es-metrics { display: flex; gap: 6px; flex-wrap: wrap; }
.es-metrics button[aria-pressed="true"] { border-color: var(--accent); color: var(--fg-0); background: var(--accent-dim); }
.es-vaping { animation: es-pulse 1.2s ease-in-out infinite; }
@keyframes es-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .es-vaping { animation: none; } }
.es-key i.es-sw-ok { background: var(--ok); } .es-key i.es-sw-warn { background: var(--accent); } .es-key i.es-sw-bad { background: var(--bad); }
.es-key i.es-sw-cold { background: var(--es-cold); } .es-key i.es-sw-occ { background: var(--accent); } .es-key i.es-sw-none { background: var(--fg-3); opacity: .4; }
.es-inl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-2); }

/* The heatmaps' timeline (as the device heatmap's, positioning.js svTimeline) */
.es-tl { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-2); padding: 10px 12px; margin: 0 0 14px; }
.es-tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.es-tl-at { min-width: 9ch; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--fg-0); }
.es-tl.is-live .es-tl-at { color: var(--ok-text); }
.es-tl-track { position: relative; margin-top: 8px; }
.es-tl-track svg { width: 100%; height: 40px; display: block; }
.es-tl-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.es-tl-vape { fill: var(--bad); }
.es-tl-mark { stroke: var(--fg-0); stroke-width: 2; }
.es-tl-track input[type=range] { position: absolute; inset: 0; width: 100%; height: 40px; margin: 0; opacity: 0; cursor: ew-resize; }
.es-tl-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; margin-top: 4px; }
.es-tl-head select { width: auto; flex: 0 0 auto; }

/* Site layout: an EnviroSentry tile is the unit, seen from below, with its room's readings (layout_edge.js) */
.tile.es-tile { grid-column: span 2; flex-direction: row; align-items: flex-start; gap: 12px; }
.es-face { flex: none; display: grid; place-items: center; padding: 4px; border-radius: var(--radius-1); background: var(--bg-2); }
.es-dev { display: block; }
.es-dev.is-pulse rect:last-child { animation: es-flash .65s steps(2, jump-none) 2; }
@keyframes es-flash { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .es-dev.is-pulse rect:last-child { animation: none; } }
.es-side { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.es-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; margin-top: 4px; }
.es-st { display: flex; flex-direction: column; min-width: 0; }
.es-st small { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-3); }
.es-st b { font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; color: var(--fg-0); white-space: nowrap; }
.es-st.warn b { color: var(--accent-text); } .es-st.bad b { color: var(--bad); } .es-st.cold b { color: var(--es-cold); }
.es-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.eicon.big .es-dev { width: 104px; height: 104px; }
@media (max-width: 520px) { .tile.es-tile { grid-column: 1 / -1; } }
.es-mw { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; margin: 6px 0 10px; }
.es-mw-f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--fg-2); }
.es-mw-f input { width: 100%; }
.es-mw-f small { color: var(--fg-3); }

/* Ventilation and mould, drawn (envirosentry.js esVentCard / esMouldCard / the tile's marks).
   Status colour is the manager's (ok / accent for watch / bad), always beside the words. */
.es-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 12px 0 4px; }
.es-card { background: var(--bg-1); border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius-2); padding: 10px 12px; }
.es-card h5 { margin: 0 0 4px; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--fg-2); }
.es-card.es-ok { border-left-color: var(--ok); } .es-card.es-warn { border-left-color: var(--accent); } .es-card.es-bad { border-left-color: var(--bad); }
.es-card-word { margin: 2px 0 0; font-weight: 700; color: var(--fg-0); }
.es-card.es-warn .es-card-word { color: var(--accent-text); } .es-card.es-bad .es-card-word { color: var(--bad); }
.es-card-sub { margin: 2px 0 0; font-size: 12px; color: var(--fg-2); }
.es-gauge { width: 132px; height: 77px; display: block; }
.es-g-track { fill: none; stroke: var(--bg-3); stroke-width: 10; stroke-linecap: round; }
.es-g-val { fill: none; stroke-width: 10; stroke-linecap: round; stroke: var(--ok); }
.es-warn .es-g-val { stroke: var(--accent); } .es-bad .es-g-val { stroke: var(--bad); }
.es-g-tick { stroke: var(--bg-1); stroke-width: 2; }
.es-g-num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; fill: var(--fg-0); }
.es-meter { width: 150px; height: 38px; display: block; margin: 4px 0; }
.es-m-off { fill: var(--bg-3); }
.es-m-on.es-m-ok { fill: var(--ok); } .es-m-on.es-m-warn { fill: var(--accent); } .es-m-on.es-m-bad { fill: var(--bad); }
.es-marks { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.es-mark { display: inline-flex; align-items: center; gap: 4px; color: var(--fg-1); }
.es-mark svg { width: 16px; height: 16px; flex: none; }
.es-mark.es-ok svg { color: var(--ok); } .es-mark.es-warn svg { color: var(--accent); } .es-mark.es-bad svg { color: var(--bad); }
.es-mark.es-bad { color: var(--bad); font-weight: 700; }
.es-stats.es-pm { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-top: 4px; border-top: 1px dashed var(--line); }

/* The PM chart's four series: the validated palette's slots 1-4 (blue, orange, aqua, yellow),
   each stepped for the dark surface. */
:root { --es-s1: #2a78d6; --es-s2: #eb6834; --es-s3: #1baf7a; --es-s4: #eda100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --es-s1: #3987e5; --es-s2: #d95926; --es-s3: #199e70; --es-s4: #c98500; } }
:root[data-theme="dark"] { --es-s1: #3987e5; --es-s2: #d95926; --es-s3: #199e70; --es-s4: #c98500; }
.es-pmline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.es-pmline.es-s1 { stroke: var(--es-s1); } .es-pmline.es-s2 { stroke: var(--es-s2); }
.es-pmline.es-s3 { stroke: var(--es-s3); } .es-pmline.es-s4 { stroke: var(--es-s4); }
.es-key i.es-s1-bg { background: var(--es-s1); } .es-key i.es-s2-bg { background: var(--es-s2); }
.es-key i.es-s3-bg { background: var(--es-s3); } .es-key i.es-s4-bg { background: var(--es-s4); }
.es-chart-wide { grid-column: 1 / -1; }
