@font-face {
  font-family: "Noto Sans";
  src: url("/noto-sans.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #261b20;
  --muted: #686069;
  --red: #bd1730;
  --deep-red: #971329;
  --rose: #fff0f2;
  --line: #e9e0e2;
  font: 16px/1.45 "Noto Sans", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; color: var(--ink); background: #f7f4f5; }
header { background: white; border-top: 5px solid var(--red); border-bottom: 1px solid var(--line); }
.masthead, header nav, main { max-width: 1680px; margin: auto; padding-inline: 24px; }
.masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px; padding-block: 12px; }
.masthead > p { text-align: center; color: var(--red); font-size: clamp(1.05rem, 2.5vw, 1.8rem); font-weight: 800; }
.brand { display: block; width: min(100%, 176px); height: auto; }
.masthead-tools { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 8px 14px; }
#clock { border: 1px solid #dfcbd1; border-radius: 7px; padding: .43rem .7rem; background: #fff8f9; font-size: 1rem; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
#user-button { margin-inline-start: auto; color: var(--deep-red); }
.signed-out { width: min(100%, 1120px); margin: clamp(1rem, 4vh, 3rem) auto 0; display: grid; gap: 1rem; }
.welcome-intro { position: relative; display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; min-height: 260px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px #6026330a; }
.welcome-intro::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--red); }
.welcome-copy { position: relative; padding: clamp(1.3rem, 3vw, 2.75rem); }
.welcome-copy h1 { color: var(--ink); font-size: clamp(1.65rem, 2.75vw, 2.25rem); line-height: 1.2; font-weight: 800; margin-bottom: .85rem; }
.welcome-copy p { color: var(--muted); line-height: 1.6; font-size: .98rem; text-align: justify; }
.welcome-art { position: relative; min-width: 0; align-self: stretch; min-height: 260px; display: grid; background: #fff7f8; overflow: hidden; }
.welcome-slide { position: absolute; inset: 0; margin: 0; opacity: 0; z-index: 0; }
.welcome-slide.is-previous { opacity: 1; z-index: 1; }
.welcome-slide.is-active { opacity: 1; z-index: 2; transition: opacity .85s ease-in-out; }
.welcome-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.welcome-team-slide img { object-position: center 64%; }
@media (prefers-reduced-motion: reduce) { .welcome-slide.is-active { transition: none; } }
.signed-out, body:has(#signed-out:not([hidden])) .site-footer, body:has(#signed-out:not([hidden])) #account-dialog { text-transform: uppercase; }
.signed-out button, body:has(#signed-out:not([hidden])) #account-dialog button { text-transform: uppercase; }
.signed-out .welcome-metric strong, #account-dialog input { text-transform: none; }
.welcome-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .8rem; }
.welcome-metric { display: flex; align-items: center; gap: .9rem; min-width: 0; padding: 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 5px 18px #60263308; }
.welcome-icon { display: grid; place-items: center; flex: 0 0 3rem; height: 3rem; background: var(--rose); color: var(--red); border-radius: 12px; }
.welcome-icon svg { width: 1.6rem; height: 1.6rem; }
.welcome-metric > div { min-width: 0; }
.welcome-metric > div > span, .welcome-metric small { display: block; font-size: .8rem; color: var(--muted); }
.welcome-metric strong { display: block; margin-top: .22rem; font-weight: 800; font-size: clamp(1.15rem, 2vw, 1.65rem); letter-spacing: -.02em; overflow-wrap: anywhere; }
.welcome-metric small { margin-top: .2rem; }
.welcome-login { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .9rem; padding: .8rem .25rem; color: var(--muted); }
.welcome-login button { display: inline-flex; align-items: center; gap: 1.2rem; padding: .65rem 1.2rem; border-radius: 8px; }
nav, .controls { display: flex; flex-wrap: wrap; gap: 6px; }
nav button { border-color: transparent; border-radius: 8px 8px 0 0; }
nav button[aria-current] { background: var(--red); color: white; }
main { width: 100%; min-width: 0; margin-block: 0; padding-block: 20px 30px; }
.site-footer { position: relative; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .25rem 1rem; padding: .55rem max(24px, calc((100vw - 1632px) / 2)); border-top: 1px solid var(--line); background: white; color: var(--muted); font-size: .76rem; }
.site-footer strong { color: var(--deep-red); letter-spacing: .045em; }
.site-footer a { color: inherit; text-underline-offset: .15em; }
#support-button { position: absolute; right: max(12px, calc((100vw - 1632px) / 2)); bottom: calc(100% + .65rem); z-index: 5; display: flex; align-items: center; gap: .38rem; min-height: 32px; padding: .38rem .72rem; background: #ffc62d; border: 1px solid #dfac17; color: #171717; border-radius: 8px; box-shadow: 0 3px 12px #0002; font-size: .82rem; }
.support-button-icon { display: grid; place-items: center; flex: 0 0 1.35rem; width: 1.35rem; height: 1.35rem; background: #137c53; color: #fff; border-radius: 50%; animation: support-pulse 2.4s ease-out infinite; }
.support-button-icon svg { width: .95rem; height: .95rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@keyframes support-pulse { 0%, 100% { box-shadow: 0 0 0 0 #137c5300; } 15% { box-shadow: 0 0 0 0 #137c5377; } 65% { box-shadow: 0 0 0 .35rem #137c5300; } }
@media (prefers-reduced-motion: reduce) { .support-button-icon { animation: none; } }
#support-dialog { position: fixed; inset: auto max(12px, calc((100vw - 1632px) / 2)) 3.5rem auto; margin: 0; width: min(340px, calc(100vw - 24px)); padding: 1rem 1.15rem 1.25rem; border: 1px solid #ffc62d; border-top: 5px solid #ffc62d; background: #fff; color: #171717; text-align: center; box-shadow: 0 12px 35px #0004; font-size: .86rem; }
#support-dialog::backdrop { background: #0002; }
#support-title { padding-inline: 20px; color: #171717; font-size: 1rem; }
#close-support { position: absolute; right: .45rem; top: .4rem; background: transparent; color: #8b6100; border: 0; min-height: 28px; padding: 0 .4rem; font-size: 1.25rem; line-height: 1; }
.support-logo { display: block; width: 92.4px; height: 57.4px; object-fit: contain; margin: .65rem auto; }
#support-dialog .support-company { font-weight: 700; margin: .25rem 0 .65rem; font-size: .71rem; letter-spacing: -.015em; white-space: nowrap; }
#support-dialog p + p { margin-top: .3rem; }
.support-contacts { width: fit-content; max-width: 100%; margin-inline: auto; text-align: left; }
.support-contacts p { display: flex; gap: .45rem; align-items: flex-start; }
.support-contacts svg { flex: 0 0 1rem; width: 1rem; height: 1rem; margin-top: .13rem; stroke: #a66f00; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.support-contacts p > span { min-width: 0; }
@media (max-width: 370px) { #support-dialog .support-company { font-size: clamp(.5rem, 3vw, .71rem); } }
#support-dialog a { color: #8b6100; text-underline-offset: .15em; overflow-wrap: anywhere; }
#support-button:focus-visible, #support-dialog :focus-visible { outline: 2px solid #e3aa00; outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.42rem, 3vw, 1.9rem); }
h2 { font-size: 1.13rem; }
h3 { font-size: 1rem; }
.heading, .panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 9px; }
.overview-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.environment-period { margin: .7rem 0; }
.eyebrow { color: var(--deep-red); font-size: .78rem; font-weight: bold; }
.sample { background: var(--rose); color: var(--deep-red); border-radius: 999px; padding: 5px 10px; font-size: .82rem; font-weight: bold; }
.metrics { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 9px; margin: 13px 0 16px; }
.metric, .panel { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 12px; }
.metric { padding: 11px 12px; }
.metric span, .metric small { display: block; color: var(--muted); font-size: .8rem; }
.metric strong { display: block; margin-block: 5px 2px; font-size: clamp(1rem, 1.6vw, 1.35rem); }
.panel-head { padding: 13px 15px; }
.operations { display: grid; grid-template-columns: minmax(170px, .64fr) minmax(0, 1.85fr) minmax(290px, 1.3fr); gap: 12px; align-items: stretch; }
.layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.project-detail { display: grid; align-content: start; gap: 10px; min-width: 0; }
.site-heading { border-bottom: 1px solid var(--line); }
.site-heading > div:first-child { flex: 1 1 12rem; min-width: 0; }
.site-heading-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.secondary { min-height: 1.8rem; padding: .25rem .48rem; color: var(--deep-red); border-color: #e2a5b0; font-size: .8rem; }
.muted { color: var(--muted); font-size: .85rem; }
.weather { padding: 6px 9px; border-radius: 7px; background: #f7f4f5; font-size: .79rem; }
.weather small { display: block; color: var(--muted); margin-top: 2px; }
.energy-body { padding: 12px 15px; }
.flow { margin: 8px 0 12px; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.flow-nodes { display: grid; grid-template-columns: minmax(0, 1fr) .19fr minmax(0, 1fr) .19fr minmax(0, 1fr); align-items: center; width: 100%; min-height: 116px; height: clamp(116px, 18vw, 175px); padding: 0 .3rem; text-align: center; font-size: .72rem; }
.flow-node { position: relative; display: grid; place-items: center; min-width: 0; height: 100%; container-type: size; }
.flow-illustration { display: block; width: min(100%, 112cqh); height: 100%; background: url("/energy-flow.png") center 42% / 300% auto no-repeat; transform: translateY(-9%) scale(.85); }
.power-value { position: absolute; bottom: .2rem; inset-inline: 3%; justify-self: center; padding: .14rem .36rem; border-radius: 6px; border: 1px solid #e0adb7; background: #fff9faf5; line-height: 1.2; }
.pv-art { background-position-x: left; }
.grid-art { background-position-x: right; clip-path: inset(0 0 0 9%); }
.flow strong { display: block; color: var(--deep-red); font-size: .93rem; }
.flow-link { display: block; position: relative; z-index: 1; margin-inline: -.3rem; border-top: 2px solid #a69ba0; transform: translateY(-.35rem); }
.flow-link:not([data-direction="right"], [data-direction="left"]) { border-top-style: dashed; }
.flow-link[data-direction="right"], .flow-link[data-direction="left"] { color: var(--deep-red); border-color: currentColor; }
.flow-link[data-direction="right"]::after, .flow-link[data-direction="left"]::after { content: ''; position: absolute; top: -5px; border-block: 4px solid transparent; }
.flow-link[data-direction="right"]::after { right: 0; border-left: 6px solid currentColor; }
.flow-link[data-direction="left"]::after { left: 0; border-right: 6px solid currentColor; }
.site-indicators { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.site-indicators > div { padding: 6px 7px; border-left: 2px solid #e9b1b9; }
.site-indicators dt { color: var(--muted); font-size: .76rem; }
.site-indicators dd { font-size: .94rem; font-weight: bold; }
.power-trend { display: flex; flex-direction: column; min-height: 0; }
.trend-chart { position: relative; flex: 1; min-height: 115px; }
.trend-chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#power-empty { padding: .5rem; }
.power-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .17rem .7rem; padding: .2rem .45rem .45rem; font-size: .72rem; }
.power-legend span { display: inline-flex; align-items: center; gap: .22rem; }
.power-legend span::before { content: ''; width: .75rem; border-top: 2px solid var(--series-color); }
.chart-tooltip { position: absolute; z-index: 1; right: .5rem; top: 0; max-width: calc(100% - 1rem); padding: .25rem .45rem; border: 1px solid var(--line); border-radius: 5px; background: #fffefc; font-size: .74rem; pointer-events: none; }
.history { padding-bottom: 12px; }
.period { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.period button { padding: 4px 8px; min-height: 32px; font-size: .79rem; border: 0; border-radius: 0; }
.period button[aria-pressed="true"] { background: var(--rose); color: var(--deep-red); }
#chart { display: grid; grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr)); gap: 5px; }
#chart { padding-inline: 15px; }
.bar { min-width: 0; text-align: center; color: var(--muted); font-size: .75rem; }
.bar small { display: block; overflow-wrap: anywhere; margin-top: 4px; }
.bar-track { display: flex; align-items: end; justify-content: center; height: 66px; border-bottom: 1px solid var(--line); }
.bar i { width: min(68%, 37px); display: block; background: var(--red); border-radius: 4px 4px 0 0; }
.map-panel { display: flex; flex-direction: column; }
.map-status { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 0 12px 9px; font-size: .75rem; }
.map-status span::before { content: '●'; margin-right: 4px; }
.normal, .status { color: #176940; }
.warn, .status.warn { color: #9f2814; }
.unknown, .status.unknown { color: #555c68; }
#map { position: relative; flex: 1; min-height: 430px; overflow: hidden; background: #d9eaf1; border-radius: 0 0 11px 11px; cursor: grab; touch-action: pan-y; }
#map.dragging { cursor: grabbing; }
#map:focus-visible { outline: 2px solid var(--deep-red); outline-offset: -2px; }
.map-controls { display: flex; flex-wrap: wrap; gap: .25rem; }
.map-controls button { min-height: 1.65rem; padding: .12rem .42rem; font-size: .79rem; }
.map-tooltip { position: absolute; z-index: 2; width: max-content; max-width: calc(100% - 12px); padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 3px 13px #0003; pointer-events: none; font-size: .76rem; overflow-wrap: anywhere; }
#map-background, #pins { position: absolute; inset: 0; }
#map-background { width: 100%; height: 100%; }
#map-error { position: absolute; z-index: 1; top: 8px; left: 8px; padding: 4px 7px; background: white; font-size: .8rem; }
.pin { --pin-color: #198554; --pin-edge: white; position: absolute; transform: translate(-50%,-50%); width: 21px; height: 21px; min-height: 0; padding: 0; border: 0; background: transparent; }
.pin::before, .pin::after { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); clip-path: polygon(50% 0%, 63% 35%, 100% 37%, 71% 61%, 82% 100%, 50% 77%, 18% 100%, 29% 61%, 0% 37%, 37% 35%); }
.pin::before { width: 10.5px; height: 10.5px; background: var(--pin-edge); }
.pin::after { width: 7.5px; height: 7.5px; background: var(--pin-color); }
.pin.warn { --pin-color: #eb5131; animation: pulse 2s infinite; }
.pin.unknown { --pin-color: #667383; }
.pin.selected { --pin-edge: #ffe05e; }
.attribution { position: absolute; bottom: 0; right: 0; max-width: 100%; background: #182433ed; color: white; padding: 3px 6px; font-size: .68rem; text-align: right; }
.attribution a { color: inherit; }
.filter, #cards, #project-list, #group-form, #group-list { margin: 0 13px 13px; }
.filter { width: auto; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 9px; border-top: 1px solid var(--line); padding: 10px 0; }
.card { display: flex; flex-direction: column; gap: .25rem; padding: .48rem .58rem; border: 1px solid var(--line); border-radius: 8px; background: white; }
.card + .card { margin-top: .42rem; }
.card.selected { background: var(--rose); border-color: #efd0d6; border-left: 3px solid var(--red); padding-left: calc(.58rem - 2px); }
.card .card-summary { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; min-height: 0; }
.card-title { display: flex; align-items: center; gap: .4rem; line-height: 1.25; font-size: .92rem; }
.card-title > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.card-status-dot { flex: 0 0 .62rem; width: .62rem; height: .62rem; border-radius: 50%; background: #e4a11b; }
.card-status-dot.normal { background: #198554; }
.card-status-dot.fault { background: #e5483f; }
.card-readings { display: grid; gap: .18rem; margin-top: .4rem; font-size: .78rem; color: var(--muted); }
.card-reading { display: flex; align-items: baseline; justify-content: space-between; gap: .35rem; flex-wrap: wrap; }
.card-reading strong { color: var(--ink); font-size: .8rem; white-space: nowrap; }
.card .card-detail { align-self: flex-end; min-height: 1.65rem; padding: .12rem .45rem; background: white; }
.status { font-size: .78rem; }
.alerts { margin-top: 14px; padding: 12px 16px; }
.workspace-view > .heading { padding-bottom: .5rem; }
.site-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.site-metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.site-metrics .metric strong { font-size: 1.2rem; }
.site-titlebar .controls { align-items: center; }
.site-back { min-height: auto; margin-bottom: .42rem; padding: .15rem .35rem; color: var(--deep-red); font-size: .82rem; }
.detail-readings { padding: 0 .85rem .55rem; }
.detail-readings > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: .45rem; padding-block: .45rem; border-top: 1px solid var(--line); font-size: .84rem; }
.detail-readings dt { color: var(--muted); }
.detail-readings dd { text-align: right; overflow-wrap: anywhere; font-weight: 650; }
.environment-methods { padding-inline: 0; }
.environment-methods dd { text-align: left; font-weight: 500; }
.report-filters { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem 1rem; padding: .7rem .85rem; }
.report-filters label { width: min(100%, 15.5rem); margin: 0; }
.report-filters p { margin: 0 0 .6rem; }
.report-section { margin-block: .8rem; }
.report-section h2 { margin-bottom: .45rem; }
.report-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .5rem; }
.report-metrics .metric { padding: .58rem .7rem; }
.report-metrics .metric strong { margin-top: .25rem; font-size: clamp(1rem, 1.45vw, 1.45rem); overflow-wrap: anywhere; }
.report-progress { display: block; margin-top: .28rem; width: 100%; height: .42rem; accent-color: var(--red); }
.report-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: .7rem; margin-bottom: .75rem; align-items: start; }
.finance-trend { margin-bottom: .75rem; }
.report-summary { padding: 0 .8rem .35rem; }
.report-legend { display: flex; flex-wrap: wrap; gap: .5rem; color: var(--muted); font-size: .74rem; }
.report-legend span::before { display: inline-block; content: ''; vertical-align: middle; width: .65rem; height: .65rem; border-radius: 2px; margin-right: .26rem; background: #d9c5cc; }
.report-legend span + span::before { background: var(--red); }
.report-energy-chart { display: grid; grid-template-columns: repeat(var(--report-days, 1), minmax(0, 1fr)); gap: 2px; padding: .25rem .75rem .6rem; }
.report-day small { display: block; text-align: center; font-size: .66rem; color: var(--muted); }
.report-bars { height: clamp(106px, 15vh, 220px); display: flex; justify-content: center; align-items: end; gap: 1px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), #ece4e7 calc(25% - 1px) 25%); }
.report-bars i { width: min(41%, 19px); display: block; border-radius: 3px 3px 0 0; }
.report-plan { background: #d9c5cc; }
.report-actual { background: var(--red); }
#report-meter { padding: 0 .8rem .65rem; }
.report-meter-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin-top: .35rem; }
#meter-form input { min-height: 2rem; width: 100%; }
.meter-note { margin-top: .3rem; font-size: .75rem; }
#meter-error { margin-top: .35rem; color: var(--deep-red); }
#meter-result { padding: .45rem 0 0; }
#meter-result > div:last-child { padding-bottom: 0; }
.report-table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.report-table :is(th, td) { padding: .57rem .72rem; border-top: 1px solid var(--line); text-align: right; }
.report-table thead { background: var(--rose); }
.report-table :is(th, td):first-child { text-align: left; }
.report-table td { white-space: nowrap; }
button, input, select { font: inherit; min-height: 40px; border: 1px solid #cabbbe; border-radius: 7px; padding: 7px 9px; background: white; color: inherit; }
button { cursor: pointer; font-weight: 700; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--deep-red); outline-offset: 2px; }
.primary { background: var(--red); color: white; border-color: var(--red); }
input, select, label { display: block; width: 100%; }
label { font-size: .86rem; margin-bottom: 8px; }
label input, label select { margin-top: 3px; }
#coordinates-help { margin: -4px 0 10px; }
dialog { width: min(94vw, 520px); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
dialog::backdrop { background: #261b20b3; }
#message, #form-error, #system-error { margin-top: 12px; color: var(--deep-red); }
.system-note { margin-block: .45rem .75rem; }
.system-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
#message { padding: 10px 12px; margin: 0 0 12px; background: var(--rose); border-left: 3px solid var(--red); }
#account-dialog form, #user-management, #account-identity { margin: 12px 0; }
#account-message { margin-top: 10px; color: var(--deep-red); }
.user-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto; gap: 7px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.user-row select, .user-row button { font-size: .82rem; }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .pin.warn { animation: none; } }
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .operations { grid-template-columns: minmax(145px, .55fr) minmax(0, 1.45fr); }
  .map-panel { grid-column: 1 / -1; }
  #map { min-height: 435px; }
  .report-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .signed-out { margin-top: .75rem; gap: .7rem; }
  .welcome-intro { grid-template-columns: 1fr; min-height: auto; }
  .welcome-copy { padding: 1.4rem; }
  .welcome-copy h1 { max-width: none; }
  .welcome-art { min-height: 190px; }
  .welcome-metrics { grid-template-columns: 1fr; gap: .65rem; }
  .welcome-metric { padding: .75rem 1rem; }
  .welcome-login { text-align: center; padding: .7rem 0; }
  .masthead, header nav, main { padding-inline: 12px; }
  .site-footer { padding-inline: 12px; }
  .masthead { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; }
  .masthead > p { grid-column: 1 / -1; grid-row: 2; }
  #clock { font-size: .8rem; padding: .36rem .4rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operations, .layout { grid-template-columns: minmax(0, 1fr); }
  #map { min-height: 400px; }
  .site-indicators { grid-template-columns: 1fr 1fr; }
  .site-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Fit the overview to a landscape TV, while keeping the settings and alerts scrollable. */
@media (min-width: 1152px) and (min-height: 650px) and (min-aspect-ratio: 3/2) {
  :root:has(#main-nav:not([hidden])) { font-size: clamp(13px, 1.5vh, 28px); }
  body:has(#overview:not([hidden])) {
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  body:has(#main-nav:not([hidden])) :is(.masthead, header nav, main, .site-footer) {
    max-width: none;
    padding-inline: clamp(16px, 2vw, 72px);
  }
  body:has(#main-nav:not([hidden])) .masthead { padding-block: .18rem; }
  body:has(#main-nav:not([hidden])) .masthead > p { font-size: 1.55rem; }
  body:has(#main-nav:not([hidden])) .brand { width: min(100%, 9.5rem); }
  body:has(#main-nav:not([hidden])) header button { min-height: 2rem; padding-block: .25rem; }
  body:has(#main-nav:not([hidden])) main { padding-block: .48rem; }
  body:has(#overview:not([hidden])) main {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  body:has(#overview:not([hidden])) #message { margin-bottom: .35rem; padding: .25rem .6rem; }
  #overview:not([hidden]) {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: .52rem;
    flex: 1;
    min-height: 0;
  }
  body:has(#main-nav:not([hidden])) h1 { font-size: 1.55rem; }
  #overview .metrics { margin: 0; }
  body:has(#main-nav:not([hidden])) .metrics { gap: .42rem; }
  body:has(#main-nav:not([hidden])) .metric { padding: .38rem .6rem; }
  body:has(#main-nav:not([hidden])) .metric strong { margin-block: .09rem; font-size: 1.2rem; }
  #overview .operations { grid-template-columns: minmax(0, .64fr) minmax(0, 1.85fr) minmax(0, 1.3fr); grid-template-rows: minmax(0, 1fr); gap: .58rem; }
  body:has(#main-nav:not([hidden])) .panel-head { padding: .42rem .62rem; gap: .3rem; }
  #overview .project-tree { display: flex; flex-direction: column; min-height: 0; }
  #overview .filter { margin: 0 .6rem .35rem; }
  #overview .filter select { min-height: 2rem; padding-block: .25rem; }
  #overview #cards { min-height: 0; overflow: auto; margin: 0 .6rem .42rem; }
  #overview .card { padding-block: .38rem; }
  #overview .project-detail { min-height: 0; grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr) auto; align-content: stretch; gap: .42rem; }
  #overview .energy { display: flex; flex-direction: column; min-height: 0; }
  #overview .weather { padding: .22rem .4rem; }
  #overview .energy-body { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: .42rem .62rem; }
  #overview .flow { display: flex; flex: 1; flex-direction: column; min-height: 0; margin: .27rem 0 .35rem; }
  #overview .flow-nodes { flex: 1; min-height: 0; height: auto; }
  #overview .site-indicators > div { padding: .18rem .36rem; }
  #overview .trend-chart { min-height: 0; }
  #overview .history { padding-bottom: .4rem; }
  #overview .period button { min-height: 1.65rem; padding: .12rem .34rem; }
  #overview #chart { padding-inline: .62rem; }
  #overview .bar-track { height: clamp(30px, 5.7vh, 130px); }
  #overview .map-panel { grid-column: 3; min-height: 0; }
  #overview .project-detail[hidden] + .map-panel { grid-column: 2 / -1; }
  #overview .map-status { padding: 0 .58rem .35rem; }
  #overview #map { min-height: 0; }
}

@media (min-width: 1152px) and (min-height: 650px) and (max-height: 800px) and (min-aspect-ratio: 3/2) {
  #overview .project-detail { grid-template-rows: minmax(0, 1.6fr) minmax(0, 1fr) auto; }
  #overview .power-value { bottom: .12rem; }
}
.workspace-view#settings .user-row { grid-template-columns: minmax(6rem, 1fr) minmax(6rem, auto) minmax(7rem, auto) auto; }
#settings .panel { min-width: 0; padding: 1rem; }
#settings #create-user { display: grid; gap: .6rem; margin-top: 1rem; }
#settings #audit-panel { margin-top: 1rem; }
#audit-list details { border-top: 1px solid var(--line); padding: .65rem 0; overflow-wrap: anywhere; }
#audit-list summary { cursor: pointer; }
@media (max-width: 750px) {
  .workspace-view#settings .user-row { grid-template-columns: 1fr 1fr; }
  #settings .layout { grid-template-columns: 1fr; }
}

.settings-columns { display: grid; grid-template-columns: minmax(210px, 1fr) minmax(0, 2.25fr); gap: clamp(14px, 2vw, 28px); align-items: start; margin-top: 14px; }
#settings .settings-columns > .panel { padding: clamp(14px, 2vw, 28px); margin: 0; }
.settings-columns .users-card { container-type: inline-size; }
#settings .users-card h2, #settings .backup-setting h2 { margin: 0; }
.users-tabs { display: flex; gap: 6px; margin: 16px 0 20px; padding: 0 0 7px; border-bottom: 1px solid var(--line); }
.users-tabs button { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 7px; min-height: 42px; padding: 8px 15px; font: inherit; font-weight: 650; }
.users-tabs button[aria-selected="true"] { color: white; background: var(--deep-red); }
.users-tabs button:hover:not([aria-selected="true"]) { background: var(--rose); }
.users-tabs button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.users-directory { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; }
.users-directory thead { background: #f8f5f6; color: var(--muted); }
.users-directory th, .users-directory td { padding: 11px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.users-directory thead th:first-child { width: 46%; }
.user-state { display: inline-flex; align-items: baseline; gap: 6px; }
.user-state::before { content: ''; align-self: center; width: 7px; height: 7px; flex: none; border-radius: 50%; background: #197648; }
.user-state.locked::before { background: #9c622a; }
.users-forms { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; align-items: stretch; }
#settings #create-user.users-form, #settings .users-form { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: clamp(12px,1.4vw,22px); border: 1px solid var(--line); border-radius: 10px; }
.users-form h3 { margin: 0 0 2px; }
.users-form label { display: grid; gap: 5px; min-width: 0; }
.users-form fieldset { display: grid; gap: 12px; min-width: 0; border: 0; margin: 0; padding: 0; }
.users-form input, .users-form select { width: 100%; min-width: 0; min-height: 40px; }
.users-form .primary { align-self: flex-start; margin-top: auto; }
.users-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.users-form .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#manage-message:empty { display: none; }
#settings #audit-panel { margin: 0; padding: 0; }
.audit-tools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
#audit-list summary { display: grid; grid-template-columns: 1.3rem minmax(9rem,1fr) minmax(0,2fr) minmax(5rem,1fr); align-items: center; gap: 8px; }
#audit-list summary::before { content: '▸'; color: var(--deep-red); }
#audit-list details[open] summary::before { content: '▾'; }
#audit-list summary small { display: block; color: var(--muted); }
#audit-list details p { margin: 7px 0 0 1.8rem; }
.backup-row { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; padding-top: 14px; margin-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
 .settings-columns { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 620px) {
 .users-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 3px; margin: 12px 0; }
 .users-tabs:has(#ut-history[hidden]) { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .users-tabs button { padding: 7px 3px; line-height: 1.25; font-size: .86rem; }
 .users-forms { grid-template-columns: 1fr; gap: 12px; }
 .users-directory th, .users-directory td { padding: 9px 5px; font-size: .9rem; }
 .users-directory thead th:first-child { width: 40%; }
 #audit-list summary { grid-template-columns: 1rem 1fr; gap: 4px 7px; }
 #audit-list summary > :not(:first-child) { grid-column: 2; }
}


#projects .layout.manage{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:start;gap:16px}
#projects .panel,#pv-plan,#alert-list{min-width:0}
.group-tabs,.group-edit,.gateway-row,.masthead-tools{display:flex;gap:.55rem;align-items:center}
.group-tabs button[aria-pressed=true]{background:#863249;color:white}
.gateway-row input{min-width:0;flex:1}.gateway-row input[readonly]{background:#eef1f4;color:#657182}
#user-button{display:grid;place-items:center;border:0;background:transparent}.tv-action{margin-left:auto;align-self:center;color:inherit}
.op-card{display:grid;gap:.4rem;align-content:start;padding:.9rem;border:1px solid #d8dfe3;border-radius:10px;background:white;min-width:0;overflow-wrap:anywhere}
.op-card :is(h3,p){margin:0}.op-card button{justify-self:start}.op-card small{color:#53616e}
#project-list,#group-list,#manage-groups,#plan-tools{display:grid;gap:.65rem}#group-list{padding:0}
#alert-list{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:.7rem}
.signal::before{content:"";display:inline-block;border-radius:50%;width:.65em;height:.65em;background:#77838e;margin-right:.4em}
.online::before{background:#178150}.offline::before{background:#c02d37}.signal:is(.online,.offline)::before,.has-warning{animation:ghs-pulse 2s infinite}.has-warning{color:#946000}
@keyframes ghs-pulse{50%{opacity:.55}}.fault-detail{background:#a82130;color:white;box-shadow:0 0 7px #b5213038}
.plan-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:.5rem}.plan-grid input{width:100%}
#overview .flow-nodes{display:grid;grid-template:repeat(3,minmax(48px,1fr))/repeat(3,minmax(0,1fr));position:relative;height:clamp(205px,22vw,330px);min-height:205px;gap:0;isolation:isolate}
.flow-node:has(.pv-art){grid-area:1/1}.flow-node:has(.load-art){grid-area:2/2}.flow-node:has(.grid-art){grid-area:1/3}
#overview .flow-node{z-index:2;background:#fff;border-radius:8px;height:100%}#overview .flow-illustration{min-height:24px}
.bess-node{grid-area:3/1;align-self:center;display:grid;background:#eceef0;color:#67717b;border:1px solid #c5cbd0;border-radius:8px;padding:.35em}
.bess-node>span{font-size:1.6em}.bess-branch{grid-area:2/1;height:100%;border-left:3px dashed #bdc3c8;justify-self:center}
#overview .flow-link{position:absolute;top:30%;height:20%;width:17%;margin:0;border:0;border-bottom:3px solid #b9bfc4;transform:none;z-index:1}
#overview .solar-link{left:16.6%;border-left:3px solid #b9bfc4}#overview .grid-link{right:16.6%;border-right:3px solid #b9bfc4}
#overview .solar-link[data-direction=right]{border-color:#1a9957;color:#1a9957}
#overview .grid-link:is([data-direction=left],[data-direction=right]){border-color:#de7833;color:#de7833}
#overview .flow-link::after{top:auto;bottom:-5px}
#overview .grid-link[data-direction=right]::after{top:0;right:-5px;bottom:auto;border:4px solid transparent;border-bottom-color:currentColor}
#overview .flow-link[data-direction=""]::after{display:none}
@media(max-width:1100px){#alert-list{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:740px){#projects .layout.manage{grid-template-columns:1fr}#alert-list{grid-template-columns:repeat(2,minmax(0,1fr))}.group-edit{flex-wrap:wrap}}
@media(max-width:440px){#alert-list{grid-template-columns:1fr}}
@media(prefers-reduced-motion:reduce){.signal::before,.has-warning{animation:none!important}}
#user-button[hidden],#group-list[hidden],#group-tools[hidden],#group-manager[hidden]{display:none}


#report-legacy{margin-top:1rem}
#pv-plan{padding:1rem}



.bess-node>span{font-size:0;height:24px;width:48px;margin:2px auto;border:2px solid #858c92;border-radius:4px;background:repeating-linear-gradient(90deg,#d0d5d8 0 12px,#858c92 12px 14px);box-shadow:0 2px 0 #a8adb0}.bess-node>span::after{content:"";display:block;width:3px;height:8px;background:#858c92;float:right;transform:translate(5px,6px)}

