/* CaribeTek portal additions on top of caribe.css (the CaribeCore design system). */

.crumbs .sep { margin: 0 2px; }
.icon-btn.temp-btn { font-size: 13px; font-weight: 700; width: auto; padding: 0 10px; }

/* install: room choices */
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--border-solid);
          border-radius: 10px; background: var(--bg-2); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input[type=radio] { margin-top: 3px; accent-color: var(--accent); }
.choice > span { flex: 1; display: grid; gap: 2px; }

/* PowerMonitor setup: service cards, legs, CT table */
.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.service { display: grid; gap: 6px; padding: 14px 15px; border: 1px solid var(--border-solid); border-radius: 12px;
           background: var(--bg-2); cursor: pointer; }
.service input { justify-self: start; accent-color: var(--hue, var(--accent)); }
.service.on { border-color: var(--hue, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue, var(--accent)) 25%, transparent); }
.leg { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
       font-style: normal; font-size: 11.5px; font-weight: 800; color: #fff; margin-right: 3px; }
.leg-A { background: #e0464e; } .leg-B { background: #3b6fd8; } .leg-C { background: #d99a1e; }
.legs { display: flex; }
.ct-table td { vertical-align: middle; }
.ct-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.ct-row.off { opacity: .35; }
.leg-list { display: grid; gap: 10px; }
.leg-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border);
            border-radius: 10px; background: var(--bg-2); }
.leg-item .what { flex: 1; min-width: 0; font-size: 13px; }
.leg-item .what .sub { display: block; }
.leg-item .n { font-weight: 800; font-size: 15px; white-space: nowrap; text-align: right; }

/* Section hues: one per data family, like CaribeCore's per-section colours. */
:root {
  --c-overview: #818cf8; --c-buildings: #60a5fa; --c-devices: #2dd4bf;
  --c-power: #fbbf24; --c-climate: #22d3ee; --c-water: #60a5fa; --c-doors: #c084fc; --c-leak: #fb7185;
}
:root[data-theme="light"] {
  --c-overview: #4f46e5; --c-buildings: #2563eb; --c-devices: #0d9488;
  --c-power: #b7791f; --c-climate: #0891b2; --c-water: #2563eb; --c-doors: #7c3aed; --c-leak: #d9364c;
}
.hue-overview { --hue: var(--c-overview); } .hue-buildings { --hue: var(--c-buildings); }
.hue-devices { --hue: var(--c-devices); } .hue-power { --hue: var(--c-power); } .hue-climate { --hue: var(--c-climate); }
.hue-water { --hue: var(--c-water); } .hue-doors { --hue: var(--c-doors); } .hue-leak { --hue: var(--c-leak); }

.stat-icon svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-head .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
                 background: var(--hue, var(--accent)); box-shadow: 0 8px 18px -10px var(--hue, var(--accent)); }
.card-head .ic svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* status dot + text */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: ct-pulse 1.6s infinite; }
@keyframes ct-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* building: one row per floor, one tile per unit */
.floors { display: flex; flex-direction: column; gap: 6px; }
.floor-row { display: grid; grid-template-columns: 46px repeat(16, minmax(0, 1fr)); gap: 6px; align-items: center; }
.floor-row .fl { font-size: 11px; font-weight: 700; color: var(--ink-faint); text-align: right; padding-right: 4px; }
.unit-tile { height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700;
             background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-faint);
             font-variant-numeric: tabular-nums; transition: transform .08s; }
.unit-tile:hover { transform: translateY(-1px); color: var(--ink); border-color: var(--accent); filter: none; }
.unit-tile.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.unit-tile.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.unit-tile.bad { background: var(--bad); color: #fff; border-color: var(--bad); animation: ct-pulse-bg 1.6s infinite; }
@keyframes ct-pulse-bg { 50% { box-shadow: 0 0 0 4px var(--bad-soft); } }
.unit-tile.none { opacity: .45; }
/* who is in (PlateSense occupancy, data.occupancy): a badge in the tile's corner */
.unit-tile { position: relative; }
.occ { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; flex: none; }
.occ svg.i { width: 10px; height: 10px; fill: currentColor; stroke: none; }
.occ.in { background: var(--c-climate); color: #0b1220; box-shadow: 0 0 0 2px var(--surface); }
.occ.away { background: var(--surface); color: var(--c-climate); border: 1.5px solid var(--c-climate); }
.occ.empty { background: var(--surface); color: var(--ink-faint); border: 1.5px dashed var(--border-solid); opacity: .8; }
.unit-tile .occ { position: absolute; top: -5px; right: -5px; }
.legends { display: flex; flex-direction: column; gap: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; gap: 7px; align-items: center; }
@media (max-width: 900px) { .floor-row { grid-template-columns: 38px repeat(8, minmax(0, 1fr)); } }

/* detector / door tiles (states-and-events family) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 12px 14px; }
.tile .where { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.tile .state { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 6px; }
.tile .state.ok { color: var(--ok); } .tile .state.bad { color: var(--bad); } .tile .state.warn { color: var(--warn); }
.tile .meta { font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 3px; }
.tile.alarm { border-color: var(--bad); background: var(--bad-soft); }

/* battery gauge */
.batt { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.batt i { width: 26px; height: 11px; border: 1.5px solid currentColor; border-radius: 3px; position: relative; opacity: .8; }
.batt i::after { content: ""; position: absolute; right: -4px; top: 2.5px; width: 2px; height: 4px; background: currentColor; border-radius: 1px; }
.batt b { position: absolute; left: 1px; top: 1px; bottom: 1px; border-radius: 1.5px; background: var(--ok); }
.batt.low b { background: var(--warn); } .batt.empty b { background: var(--bad); }

/* big numbers row inside a card */
.kpis { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 10px; }
.kpi .n { font-size: 26px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .n small { font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-left: 3px; }
.kpi .l { font-size: 12px; color: var(--ink-faint); }

/* charts (portal.js draws SVG) */
.chart { width: 100%; height: 230px; position: relative; }
.chart.sm { height: 170px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .gl { stroke: var(--border-solid); stroke-width: 1; }
.chart text { fill: var(--ink-faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-soft); margin: 4px 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface-3); color: var(--ink); border: 1px solid var(--border-solid);
              border-radius: 8px; padding: 6px 9px; font-size: 11.5px; white-space: nowrap; box-shadow: var(--shadow); display: none; z-index: 5; }
.chart .cursor { stroke: var(--ink-faint); stroke-dasharray: 3 3; }
/* zoom: drag across a line chart (portal.js) */
.chart svg.zoomable { cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .sel { fill: var(--accent); fill-opacity: .16; stroke: var(--accent); stroke-opacity: .5; }
.chart-top { display: flex; align-items: center; gap: 12px; min-height: 26px; }
.chart-top .chart-legend { margin: 0; flex: 1; }
.chart-zoom { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-soft);
              white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-zoom button { font: inherit; color: var(--ink); background: var(--surface-3); border: 1px solid var(--border-solid);
                     border-radius: 7px; padding: 2px 9px; cursor: pointer; }
.chart-zoom button:hover { border-color: var(--accent); }
.chart-hint { position: absolute; right: 14px; pointer-events: none; font-size: 11px; color: var(--ink-faint);
              opacity: 0; transition: opacity .15s; }
.chart:hover .chart-hint { opacity: 1; }
@media (hover: none) { .chart-hint { display: none; } }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.timeline li:first-child { border-top: 0; }
.timeline .when { width: 92px; flex: none; color: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline .what { flex: 1; min-width: 0; }
.timeline .what b { font-weight: 650; }

/* dashboard cards that open their details in place (portal.js) */
a.stat-card { color: inherit; text-decoration: none; cursor: pointer; transition: transform .12s, box-shadow .12s; }
a.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
a.stat-card[aria-expanded="true"] { outline: 2px solid var(--hue, var(--accent)); outline-offset: -2px; }
.stat-more { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--hue, var(--accent)); }
.stat-more::after { content: " ▾"; }
a.stat-card[aria-expanded="true"] .stat-more::after { content: " ▴"; }
.stat-panel[hidden] { display: none !important; }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover .l { color: var(--accent-2); }

/* leaks */
.leak-item { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0 12px 14px; border-top: 1px solid var(--border);
             border-left: 3px solid var(--bad); }
.leak-item:first-child { border-top: 0; }
.leak-item.warn { border-left-color: var(--warn); }
.leak-item.flat { border-left-color: var(--border); }
.leak-item .explain { margin: 10px 0 0; }
.leak-item h3 { margin: 12px 0 6px; font-size: 13px; }
.leak-item .leak-main { flex: 1; min-width: 0; }
.leak-item p { margin: 5px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.leak-banner { display: flex; gap: 14px; align-items: center; padding: 14px 18px; color: inherit; text-decoration: none;
               background: var(--bad-soft); border: 1px solid var(--bad); }
.leak-banner.warn { background: var(--warn-soft); border-color: var(--warn); }
.leak-banner .ic { color: var(--bad); } .leak-banner.warn .ic { color: var(--warn); }
.leak-banner > div { flex: 1; min-width: 0; }
/* unit page: banners, then the A/C watch while something is flagged, then the cards an alert is based on */
.unit-grid { grid-auto-flow: row dense; }
.unit-grid > .leak-banner { order: -3; }
.unit-grid > .ac-active { order: -2; }
.unit-grid > .trip { order: -1; border-color: var(--bad); animation: ct-pulse-card 1.6s infinite; }
@keyframes ct-pulse-card { 0%, 100% { box-shadow: 0 0 0 0 var(--bad-soft); } 50% { box-shadow: 0 0 0 6px var(--bad-soft); } }
@media (prefers-reduced-motion: reduce) { .unit-grid > .trip { animation: none; box-shadow: 0 0 0 3px var(--bad-soft); } }
.trip-tag { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
            font-size: 12px; font-weight: 600; color: var(--bad); background: var(--bad-soft); text-decoration: none; }
.trip-tag .i { width: 13px; height: 13px; }
tr.trip-row td { background: var(--bad-soft); }
.explain { margin: 0 0 16px; font-size: 14px; line-height: 1.6; }
ol.steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.55; }
ol.steps li { margin-bottom: 8px; }
ul.notes { list-style: none; margin: 0 0 14px; padding: 0; }
ul.notes li { padding: 10px 0; border-top: 1px solid var(--border); }
ul.notes li:first-child { border-top: 0; }
ul.notes .txt { margin-top: 4px; font-size: 13.5px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.note-form textarea { width: 100%; resize: vertical; min-height: 70px; font: inherit; }
.note-peek { max-width: 220px; margin-left: auto; white-space: normal; }

pre.json { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
           font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-soft); overflow: auto; max-height: 420px; margin: 0; }
.demo-tag { background: var(--warn-soft); color: var(--warn); font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; letter-spacing: .06em; }
