:root {
  --navy: #102a37;
  --navy-2: #173846;
  --green: #16866d;
  --green-dark: #0e6856;
  --green-soft: #e9f5f1;
  --blue: #2f6fed;
  --amber: #a76a10;
  --red: #c83c45;
  --ink: #17242d;
  --text: #53636f;
  --muted: #7b8993;
  --line: #dfe5e8;
  --line-soft: #edf0f2;
  --surface: #ffffff;
  --canvas: #f5f7f8;
  --radius: 12px;
  --shadow: 0 6px 22px rgb(16 42 55 / 6%);
}

* { box-sizing: border-box; }
html { background: var(--canvas); font-size: 16px; }
body { background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; min-height: 100vh; }
a { color: var(--green-dark); }
button, input, select, textarea { font: inherit; }
code { background: #f0f3f4; border-radius: 5px; color: #41535e; font-size: .75rem; padding: 2px 5px; }
[hidden] { display: none !important; }

/* Shell and navigation */
.portal-layout { display: flex; min-height: 100vh; }
.portal-sidebar { --bs-offcanvas-bg: var(--navy); background: var(--navy) !important; border: 0; color: #fff; flex: 0 0 236px; height: 100vh; position: sticky; top: 0; width: 236px !important; }
.sidebar-body { display: flex; flex-direction: column; height: 100%; padding: 22px 14px 14px; }
.sidebar-mobile-header { border-bottom: 1px solid rgb(255 255 255 / 10%); }
.portal-brand { align-items: center; color: #fff; display: flex; gap: 11px; text-decoration: none; }
.sidebar-brand { margin: 0 8px 28px; }
.brand-mark { background: #fff; border: 1px solid rgb(255 255 255 / 18%); border-radius: 10px; display: inline-flex; flex: 0 0 auto; height: 38px; overflow: hidden; width: 38px; }
.brand-mark img { display: block; height: 100%; width: 100%; }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { color: #fff; font-size: .94rem; letter-spacing: .08em; }
.brand-copy span { color: #a9bac2; font-size: .61rem; margin-top: 4px; }
.portal-nav { display: grid; gap: 3px; }
.nav-section-label { color: #7f97a2; font-size: .58rem; font-weight: 800; letter-spacing: .14em; margin: 10px 12px 6px; text-transform: uppercase; }
.nav-section-admin { border-top: 1px solid rgb(255 255 255 / 9%); margin-top: 16px; padding-top: 18px; }
.portal-nav-link { align-items: center; border-radius: 8px; color: #becbd1; display: flex; font-size: .76rem; font-weight: 650; gap: 11px; min-height: 41px; padding: 8px 11px; text-decoration: none; }
.portal-nav-link svg { fill: none; flex: 0 0 auto; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; width: 18px; }
.portal-nav-link:hover { background: rgb(255 255 255 / 6%); color: #fff; }
.portal-nav-link.active { background: #fff; color: var(--navy); }
.sidebar-account { align-items: center; border-top: 1px solid rgb(255 255 255 / 10%); display: grid; gap: 9px; grid-template-columns: auto minmax(0, 1fr) auto; margin-top: auto; padding: 15px 8px 2px; }
.user-avatar { align-items: center; background: #fff; border-radius: 8px; color: var(--navy); display: flex; font-size: .72rem; font-weight: 800; height: 31px; justify-content: center; width: 31px; }
.user-details { display: grid; min-width: 0; }
.user-details strong { color: #fff; font-size: .68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-details small { color: #8ea4ae; font-size: .56rem; }
.logout-button { background: none; border: 0; color: #8fa5af; padding: 4px; }
.logout-button svg { fill: none; height: 17px; stroke: currentColor; stroke-width: 1.7; width: 17px; }
.mobile-topbar { align-items: center; background: var(--navy); display: flex; height: 62px; justify-content: space-between; padding: 10px 14px; position: sticky; top: 0; z-index: 1030; }
.mobile-menu-button { align-items: center; background: transparent; border: 1px solid rgb(255 255 255 / 20%); border-radius: 8px; color: #fff; display: flex; height: 38px; justify-content: center; width: 38px; }
.mobile-menu-button svg { fill: none; height: 20px; stroke: currentColor; stroke-width: 2; width: 20px; }
.portal-workspace { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.portal-main { flex: 1; margin: 0 auto; max-width: 1500px; padding: 34px 38px 56px; width: 100%; }
.portal-footer { border-top: 1px solid var(--line); color: var(--muted); display: flex; font-size: .62rem; justify-content: space-between; padding: 15px 38px; }

/* Global type and controls */
.page-kicker, .eyebrow, .section-label { color: var(--green-dark); display: block; font-size: .63rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.page-intro { align-items: center; display: flex; gap: 28px; justify-content: space-between; margin: 0 0 24px; }
.page-intro > div:first-child { max-width: 820px; }
.page-intro h1 { color: var(--ink); font-size: clamp(1.85rem, 3vw, 2.65rem); letter-spacing: -.04em; line-height: 1.08; margin: 5px 0 8px; }
.page-intro p { color: var(--text); font-size: .82rem; line-height: 1.55; margin: 0; }
.page-summary { display: flex; }
.page-summary > span { border-left: 1px solid var(--line); display: grid; min-width: 105px; padding: 3px 18px; text-align: center; }
.page-summary strong { font-size: 1.45rem; letter-spacing: -.04em; }
.page-summary small { color: var(--muted); font-size: .62rem; }
.content-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-heading, .section-heading { align-items: center; display: flex; gap: 18px; justify-content: space-between; margin-bottom: 17px; }
.panel-heading h2, .section-heading h2 { font-size: 1.15rem; letter-spacing: -.02em; margin: 2px 0 0; }
.panel-heading > small { color: var(--muted); font-size: .68rem; }
.section-heading p { color: var(--text); font-size: .73rem; margin: 4px 0 0; }
.section-heading.compact { margin-bottom: 14px; }
.section-heading.compact > div, .editor-card-title { align-items: center; display: flex; gap: 10px; }
.section-heading-icon { align-items: center; background: #eef2f4; border-radius: 8px; color: var(--navy); display: flex; flex: 0 0 auto; font-size: 1.1rem; height: 34px; justify-content: center; width: 34px; }
.section-heading-icon svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; width: 18px; }
.section-heading-icon.is-red { background: #faecec; color: var(--red); }
.section-heading-icon.is-amber { background: #fff4df; color: var(--amber); }
.section-heading-icon.is-blue, .section-heading-icon.is-violet { background: #eaf0fc; color: var(--blue); }
.btn { border-radius: 8px; font-size: .75rem; font-weight: 750; min-height: 40px; padding: 8px 14px; }
.btn-primary { background: var(--green); border-color: var(--green); box-shadow: none; }
.btn-primary:hover, .btn-primary:focus { background: var(--green-dark); border-color: var(--green-dark); }
.btn-outline-primary { border-color: #8bbcaf; color: var(--green-dark); }
.btn-outline-secondary { border-color: var(--line); color: var(--text); }
.btn-sm { min-height: 34px; padding: 6px 11px; }
.portal-form { display: grid; gap: 14px; }
.portal-form label, .reading-filter label, .range-dates label { color: #40515d; display: block; font-size: .67rem; font-weight: 750; margin-bottom: 5px; }
.portal-form input:not([type="checkbox"]), .portal-form select, .portal-form textarea, .reading-filter input, .reading-filter select, .range-dates input, .plan-command input { background: #fff; border: 1px solid #cfd8dc; border-radius: 8px; color: var(--ink); min-height: 42px; padding: 8px 11px; width: 100%; }
.portal-form textarea { min-height: 90px; resize: vertical; }
.portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus, .plan-command input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(22 134 109 / 12%); outline: 0; }
.portal-form small, .helptext { color: var(--muted); display: block; font-size: .62rem; line-height: 1.45; margin-top: 4px; }
.errorlist { color: var(--red); font-size: .68rem; list-style: none; margin: 4px 0 0; padding: 0; }
.check-field { align-items: center; background: #f7f9f9; border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 9px; min-height: 44px; padding: 10px 12px; }
.check-field input { height: 17px; width: 17px; }
.check-field label { margin: 0; }
.action-bar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.text-link, .row-action { color: var(--green-dark); font-size: .68rem; font-weight: 800; text-decoration: none; }

/* Messages and status */
.message-stack { display: grid; gap: 8px; margin-bottom: 17px; }
.alert { border: 1px solid transparent; border-radius: 9px; font-size: .76rem; line-height: 1.45; margin: 0; padding: 12px 14px; }
.alert-danger { background: #fff0f0; border-color: #efb8bc; color: #922932; }
.alert-warning { background: #fff8e9; border-color: #ead39d; color: #72501d; }
.alert-info { background: #edf5f8; border-color: #c8dfe7; color: #315b6b; }
.alert-success { background: #edf8f4; border-color: #b9ddcf; color: #1d654f; }
.status { border-radius: 99px; display: inline-flex; font-size: .61rem; font-weight: 800; line-height: 1; padding: 6px 8px; white-space: nowrap; }
.status.success { background: #e9f6f1; color: #0c735b; }
.status.warning { background: #fff2d8; color: #8a5b0d; }
.status.danger { background: #fdebed; color: #a52e38; }
.status.muted { background: #edf0f2; color: #697781; }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green-dark) !important; }
.empty-state { color: var(--muted); font-size: .76rem; padding: 24px; text-align: center; }

/* Dashboard: operational summary, decisions, primary action */
.dashboard-header { align-items: stretch; display: grid; gap: 8px; grid-template-columns: 112px minmax(0, 1fr) 248px; margin-bottom: 8px; }
.dashboard-title { align-self: center; min-width: 0; }
.dashboard-facts { background: #fff; border: 1px solid var(--line); border-radius: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; }
.dashboard-facts article { display: grid; grid-template-columns: 1fr auto; min-height: 31px; padding: 4px 7px; }
.dashboard-facts article:nth-child(even) { border-left: 1px solid var(--line); }
.dashboard-facts article:nth-child(n+3) { border-top: 1px solid var(--line); }
.dashboard-facts article > span { color: var(--muted); font-size: .45rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.dashboard-facts strong { font-size: .61rem; letter-spacing: -.01em; line-height: 1.15; text-align: right; }
.dashboard-facts small { color: var(--muted); font-size: .43rem; grid-column: 1; line-height: 1.15; }
.dashboard-facts a { color: var(--green-dark); font-size: .44rem; font-weight: 750; grid-column: 1; line-height: 1.15; text-decoration: none; }
.plan-alert-grid { display: grid; gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; min-width: 0; }
.plan-alert-card { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 9px; display: grid; gap: 8px; grid-template-columns: auto minmax(0, 1fr); min-height: 64px; padding: 7px 9px; }
.plan-alert-card > i { background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px var(--green-soft); height: 8px; width: 8px; }
.plan-alert-card.is-danger > i { background: var(--red); box-shadow: 0 0 0 4px #fdebed; }
.plan-alert-card.is-warning > i { background: var(--amber); box-shadow: 0 0 0 4px #fff2d8; }
.plan-alert-card > div { display: grid; min-width: 0; }
.plan-alert-card span { color: var(--muted); font-size: .44rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.plan-alert-card strong { font-size: .62rem; letter-spacing: -.005em; line-height: 1.18; margin-top: 1px; }
.plan-alert-card small { color: var(--muted); font-size: .45rem; line-height: 1.18; margin-top: 2px; }
.dashboard-action-row { align-items: stretch; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) 190px; margin-bottom: 8px; }
.generate-panel { align-items: center; background: var(--navy); border-radius: 11px; color: #fff; display: grid; gap: 16px; grid-template-columns: minmax(185px, .55fr) minmax(330px, 1.45fr); margin: 0; padding: 10px 14px; }
.generate-panel-copy h2 { color: #fff; font-size: 1rem; letter-spacing: -.02em; margin: 0 0 2px; }
.generate-panel-copy p { color: #b8c8cd; font-size: .57rem; margin: 0; }
.plan-command { margin: 0; }
.plan-command-fields { align-items: end; display: grid; gap: 10px; grid-template-columns: minmax(180px, 1fr) auto; }
.plan-command-fields label { color: #d7e2e5; font-size: .54rem; font-weight: 700; margin-bottom: 3px; }
.plan-command-fields label span { color: #8fa6ae; font-weight: 500; }
.plan-command input { background: rgb(255 255 255 / 10%); border-color: rgb(255 255 255 / 22%); color: #fff; min-height: 38px; }
.generate-button { align-items: center; display: inline-flex; gap: 7px; min-height: 38px; padding-inline: 15px; white-space: nowrap; }
.generate-button svg { fill: none; height: 18px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; }
.generate-status { color: #b7cbc6; display: block; font-size: .65rem; margin-top: 8px; }
.production-live-summary { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; justify-content: center; padding: 8px 10px; text-align: center; }
.production-live-summary small { color: var(--muted); font-size: .5rem; margin-top: 3px; }
.dashboard-alerts { background: #fff; border: 1px solid #efc4c7; border-left: 4px solid var(--red); border-radius: 10px; margin-bottom: 22px; padding: 15px 17px; }
.dashboard-alerts > header { margin-bottom: 9px; }
.dashboard-alerts > header span { color: var(--red); font-size: .58rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.dashboard-alerts > header h2 { font-size: .95rem; margin: 2px 0 0; }
.attention-stack { display: grid; gap: 7px; }
.attention-card { align-items: flex-start; background: #f8fafb; border-radius: 8px; display: grid; gap: 10px; grid-template-columns: auto 1fr; padding: 10px 12px; }
.attention-card.is-danger { background: #fff3f3; }
.attention-card.is-warning { background: #fff8ea; }
.attention-icon { align-items: center; background: #fff; border: 1px solid currentColor; border-radius: 50%; color: var(--red); display: flex; font-size: .62rem; font-weight: 900; height: 22px; justify-content: center; width: 22px; }
.attention-card.is-warning .attention-icon { color: var(--amber); }
.attention-card strong { font-size: .75rem; }
.attention-card p, .attention-card li { color: var(--text); font-size: .67rem; line-height: 1.45; margin: 2px 0 0; }
.attention-card ul { margin: 5px 0 0; padding-left: 17px; }
.production-section { margin-top: 8px; }
.data-live-pill { align-items: center; color: var(--green-dark); display: inline-flex; font-size: .62rem; font-weight: 800; gap: 6px; }
.data-live-pill i, .plant-live-status i { background: var(--green); border-radius: 50%; height: 7px; width: 7px; }
.production-chart-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.production-chart-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); display: flex; flex-direction: column; min-width: 0; overflow: hidden; padding: 0; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.production-chart-card:hover, .production-chart-card:focus-visible { border-color: #9fc9bd; box-shadow: var(--shadow); outline: 0; transform: translateY(-1px); }
.plant-card-top { align-items: center; display: flex; gap: 12px; justify-content: space-between; padding: 14px 15px 5px; }
.plant-identity { align-items: center; display: flex; gap: 10px; min-width: 0; }
.plant-identity > span:last-child { display: grid; min-width: 0; }
.plant-type-icon, .plant-directory-icon { align-items: center; background: var(--green-soft); border-radius: 8px; color: var(--green-dark); display: flex; flex: 0 0 auto; height: 34px; justify-content: center; width: 34px; }
.is-hydro .plant-type-icon, .plant-group-card.is-hydro .plant-directory-icon { background: #eaf1f7; color: #356f94; }
.plant-type-icon svg, .plant-directory-icon svg { fill: none; height: 19px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; width: 19px; }
.plant-type-label { color: var(--muted); font-size: .54rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.plant-identity strong { font-size: .82rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-live-status { align-items: center; color: var(--green-dark); display: flex; font-size: .58rem; font-weight: 800; gap: 5px; }
.plant-reading-row { align-items: end; display: grid; gap: 12px; grid-template-columns: auto minmax(0, 1fr); padding: 9px 15px 0; }
.plant-main-reading { align-items: baseline; display: flex; flex-wrap: wrap; gap: 4px; }
.plant-main-reading strong { font-size: 1.65rem; letter-spacing: -.055em; line-height: 1; }
.plant-main-reading > span { color: var(--text); font-size: .67rem; font-weight: 750; }
.plant-main-reading small { color: var(--muted); flex-basis: 100%; font-size: .57rem; }
.plant-supporting-readings { display: grid; gap: 4px; justify-content: end; }
.plant-supporting-readings > span { align-items: center; color: var(--muted); display: flex; font-size: .58rem; gap: 5px; justify-content: flex-end; }
.plant-supporting-readings strong { color: var(--text); }
.key-production, .key-plan, .key-secondary { background: var(--green); border-radius: 2px; display: inline-block; height: 7px; width: 7px; }
.key-plan { background: var(--blue); }
.key-secondary { background: #c07a14; }
.mini-chart-shell { display: block; padding: 0 4px; }
.production-mini-chart { display: block; height: 150px; width: 100%; }
.plant-chart-legend { display: flex; flex-wrap: wrap; gap: 11px; padding: 0 15px 9px; }
.plant-chart-legend span { align-items: center; color: var(--muted); display: flex; font-size: .55rem; gap: 4px; }
.plant-card-footer { border-top: 1px solid var(--line-soft); color: var(--muted); display: flex; font-size: .56rem; justify-content: space-between; padding: 9px 15px; }
.plant-card-footer span:last-child { color: var(--green-dark); font-weight: 750; }

/* Expandable details */
.technical-details, .raw-data, .plant-group-details { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-top: 16px; overflow: clip; }
.technical-details > summary, .raw-data > summary, .plant-group-details > summary { align-items: center; cursor: pointer; display: flex; gap: 16px; justify-content: space-between; list-style: none; min-height: 58px; padding: 12px 15px; }
.technical-details > summary::-webkit-details-marker, .raw-data > summary::-webkit-details-marker, .plant-group-details > summary::-webkit-details-marker { display: none; }
.technical-details > summary > span:first-child, .raw-data > summary > span:first-child { display: grid; }
.technical-details summary strong, .raw-data summary strong { font-size: .74rem; }
.technical-details summary small, .raw-data summary small { color: var(--muted); font-size: .61rem; }
.summary-action { align-items: center; color: var(--green-dark); display: flex; font-size: .63rem; font-weight: 800; gap: 8px; }
.summary-action b, .plant-group-details summary b { align-items: center; background: var(--green-soft); border-radius: 50%; display: flex; font-size: .9rem; font-weight: 500; height: 26px; justify-content: center; transition: transform .16s; width: 26px; }
details[open] > summary .summary-action b, .plant-group-details[open] summary b { transform: rotate(45deg); }
details[open] > summary { border-bottom: 1px solid var(--line); }
.operations-grid { display: grid; gap: 12px; grid-template-columns: 1.1fr .9fr; padding: 12px; }
.operations-grid .content-card { padding: 17px; }
.source-status-list, .plan-timeline { display: grid; }
.source-status-row { align-items: center; border-top: 1px solid var(--line-soft); display: grid; gap: 10px; grid-template-columns: auto minmax(0, 1fr) auto auto; padding: 9px 0; }
.source-status-icon { align-items: center; background: #eaf1f7; border-radius: 7px; color: #356f94; display: flex; font-size: .6rem; font-weight: 850; height: 27px; justify-content: center; width: 27px; }
.source-status-icon.is-wind { background: var(--green-soft); color: var(--green-dark); }
.source-status-name, .source-status-time { display: grid; }
.source-status-name strong, .source-status-time strong { font-size: .68rem; }
.source-status-name small, .source-status-time small { color: var(--muted); font-size: .55rem; }
.plan-timeline a { align-items: center; border-top: 1px solid var(--line-soft); color: var(--ink); display: grid; gap: 9px; grid-template-columns: auto 1fr auto auto; padding: 11px 0; text-decoration: none; }
.timeline-dot { background: var(--green); border-radius: 50%; height: 7px; width: 7px; }
.timeline-copy, .timeline-count { display: grid; }
.timeline-copy strong, .timeline-count strong { font-size: .68rem; }
.timeline-copy small, .timeline-count small { color: var(--muted); font-size: .55rem; }
.timeline-arrow { color: var(--green-dark); }

/* Page tabs and summaries */
.view-tabs { border-bottom: 1px solid var(--line); display: flex; gap: 22px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.view-tabs::-webkit-scrollbar { display: none; }
.view-tabs a { border-bottom: 3px solid transparent; color: var(--muted); display: grid; flex: 0 0 auto; gap: 1px; margin-bottom: -1px; min-width: 118px; padding: 9px 2px 10px; text-decoration: none; }
.view-tabs a strong { color: inherit; font-size: .74rem; }
.view-tabs a small { font-size: .58rem; }
.view-tabs a.is-active { border-bottom-color: var(--green); color: var(--ink); }
.insight-strip { background: #fff; border: 1px solid var(--line); border-radius: 10px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.insight-strip article { display: grid; min-height: 100px; padding: 14px 16px; }
.insight-strip article + article { border-left: 1px solid var(--line); }
.insight-strip span { color: var(--muted); font-size: .58rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.insight-strip strong { align-self: end; font-size: 1.4rem; letter-spacing: -.04em; }
.insight-strip small { color: var(--muted); font-size: .58rem; }
.report-note, .section-note, .operator-hint { background: #eef4f6; border: 1px solid #d6e3e7; border-radius: 9px; color: #48606c; font-size: .7rem; line-height: 1.55; margin: 0 0 14px; padding: 11px 13px; }
.report-note { align-items: flex-start; display: flex; gap: 14px; }
.report-note > strong { color: var(--navy); flex: 0 0 auto; font-size: .68rem; }
.report-note p { margin: 0; }
.report-panel, .data-panel { margin-bottom: 14px; padding: 18px; }
.report-panel .section-note { background: transparent; border: 0; color: var(--text); padding: 0; }
.reading-group[hidden], [data-reading-group][hidden], [data-report-group][hidden] { display: none !important; }

/* Plants */
.plant-list-toolbar { align-items: center; display: flex; justify-content: space-between; margin-bottom: 12px; }
.directory-filters, .range-pills { background: #e9edef; border-radius: 8px; display: inline-flex; gap: 3px; padding: 3px; }
.filter-chip, .range-pills button, .chart-preset { background: transparent; border: 0; border-radius: 6px; color: var(--text); font-size: .67rem; font-weight: 750; min-height: 32px; padding: 6px 11px; }
.filter-chip.is-active, .range-pills button.is-active, .chart-preset.is-active { background: #fff; box-shadow: 0 1px 4px rgb(16 42 55 / 10%); color: var(--ink); }
.list-help { color: var(--muted); font-size: .64rem; }
.plant-group-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plant-group-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.plant-group-card[hidden] { display: none; }
.plant-group-head { align-items: center; display: grid; gap: 10px; grid-template-columns: auto minmax(0, 1fr) auto; padding: 15px; }
.plant-group-title { display: grid; min-width: 0; }
.plant-group-title > small { color: var(--green-dark); font-size: .56rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.plant-group-title > strong { font-size: .88rem; }
.plant-group-title > span { color: var(--muted); font-size: .57rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-group-facts { border-bottom: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 15px; padding: 11px 0; }
.plant-group-facts > span { display: grid; padding: 0 10px; }
.plant-group-facts > span:first-child { padding-left: 0; }
.plant-group-facts > span + span { border-left: 1px solid var(--line-soft); }
.plant-group-facts small, .plant-group-source small, .plant-unit-row small { color: var(--muted); font-size: .56rem; }
.plant-group-facts strong { font-size: .73rem; }
.plant-group-source { display: grid; gap: 10px; grid-template-columns: .8fr 1.2fr; padding: 12px 15px 14px; }
.plant-group-source > span { display: grid; min-width: 0; }
.plant-group-source strong { font-size: .66rem; }
.plant-group-source code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-group-details { border-width: 1px 0 0; border-radius: 0; margin: 0; }
.plant-group-details summary { color: var(--green-dark); font-size: .66rem; font-weight: 800; min-height: 48px; }
.plant-unit-list { background: #f7f9fa; padding: 7px 11px 11px; }
.plant-unit-row { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 7px; display: grid; gap: 9px; grid-template-columns: 1fr .55fr auto auto; margin-top: 5px; padding: 9px 10px; }
.plant-unit-row > span { display: grid; }
.plant-unit-row strong { font-size: .65rem; }
.plant-unit-row code { background: none; color: var(--muted); font-size: .55rem; padding: 0; }

/* HA integration and source status */
.integration-strip { align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 12px; grid-template-columns: auto 1fr; margin-bottom: 14px; padding: 15px; }
.integration-card-icon { align-items: center; background: var(--green-soft); border-radius: 8px; color: var(--green-dark); display: flex; height: 34px; justify-content: center; width: 34px; }
.integration-card-icon svg { fill: none; height: 18px; stroke: currentColor; stroke-width: 1.8; width: 18px; }
.integration-card-heading { align-items: center; display: flex; justify-content: space-between; }
.integration-card-heading h2 { font-size: .9rem; margin: 2px 0; }
.integration-strip p { color: var(--text); font-size: .65rem; margin: 6px 0 0; }
.integration-strip > div > code { display: inline-block; margin-top: 5px; }
.source-health-list { display: grid; gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source-health-row { border: 1px solid var(--line); border-radius: 9px; display: grid; gap: 10px; grid-template-columns: 1fr auto; padding: 13px; }
.source-health-name { display: grid; grid-column: 1 / -1; }
.source-health-name strong { font-size: .72rem; }
.source-health-name > small, .source-health-name code { color: var(--muted); font-size: .55rem; margin-top: 2px; }
.source-health-name code { background: transparent; padding: 0; }
.source-health-time { display: grid; }
.source-health-time span, .source-health-time small, .source-health-coverage small { color: var(--muted); font-size: .55rem; }
.source-health-time strong { font-size: .68rem; }
.source-health-status { align-self: end; }
.source-health-coverage { grid-column: 1 / -1; }
.source-health-coverage > span { display: flex; justify-content: space-between; }
.source-health-coverage strong { font-size: .65rem; }
.coverage-track { background: #e7ecee; border-radius: 99px; height: 5px; margin: 5px 0 3px; overflow: hidden; }
.coverage-track i { background: var(--green); display: block; height: 100%; max-width: 100%; }
.reading-filter { align-items: end; background: #f7f9fa; border: 1px solid var(--line); border-radius: 9px; display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 10px; padding: 11px; }
.reading-filter > div { min-width: 145px; }
.reading-filter input, .reading-filter select { min-height: 36px; }
.wind-export-actions { margin-bottom: 10px; }

/* Tables */
.table-responsive { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.portal-table { font-size: .7rem; margin: 0; min-width: 760px; }
.portal-table > :not(caption) > * > * { border-bottom-color: var(--line-soft); padding: 10px 11px; vertical-align: middle; }
.portal-table thead th { background: #f5f7f8; color: #65747e; font-size: .58rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.portal-table tbody tr:hover { background: #f8fbfa; }
.portal-table td small { color: var(--muted); display: block; font-size: .58rem; margin-top: 2px; }
.raw-data { margin-top: 12px; }
.raw-data .table-responsive { border: 0; border-radius: 0; }
.reading-pagination { align-items: center; border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding: 9px 11px; }
.reading-pagination > span { color: var(--muted); font-size: .62rem; }
.page-link { color: var(--green-dark); font-size: .64rem; }

/* Editors, settings and lists */
.editor-layout { align-items: start; display: grid; gap: 14px; grid-template-columns: minmax(280px, .65fr) minmax(420px, 1.35fr); }
.editor-form-card, .collection-card { padding: 18px; }
.editor-card-title { margin-bottom: 7px; }
.editor-card-title h2 { font-size: 1rem; margin: 2px 0 0; }
.item-list { display: grid; }
.item-list > div { align-items: center; border-top: 1px solid var(--line-soft); display: flex; gap: 16px; justify-content: space-between; padding: 11px 0; }
.item-list > div > div { display: grid; }
.item-list strong { font-size: .72rem; }
.item-list span, .item-list small { color: var(--text); font-size: .62rem; }
.operator-hint { align-items: center; display: flex; gap: 12px; }
.settings-layout { align-items: start; display: grid; gap: 16px; grid-template-columns: 190px minmax(0, 1fr); }
.settings-nav { background: #fff; border: 1px solid var(--line); border-radius: 10px; display: grid; padding: 10px; position: sticky; top: 18px; }
.settings-nav > span { color: var(--muted); font-size: .58rem; font-weight: 800; padding: 7px 8px; text-transform: uppercase; }
.settings-nav a { border-radius: 6px; color: var(--text); font-size: .67rem; padding: 8px; text-decoration: none; }
.settings-nav a:hover { background: var(--green-soft); color: var(--green-dark); }
.settings-page-form, .settings-form { gap: 12px; }
.settings-section { padding: 18px; }
.settings-section-heading { align-items: flex-start; display: grid; gap: 11px; grid-template-columns: auto 1fr; margin-bottom: 16px; }
.settings-section-heading > span { align-items: center; background: var(--navy); border-radius: 7px; color: #fff; display: flex; font-size: .62rem; font-weight: 800; height: 30px; justify-content: center; width: 30px; }
.settings-section-heading h2 { font-size: .95rem; margin: 0; }
.settings-section-heading p { color: var(--muted); font-size: .65rem; margin: 3px 0 0; }
.form-grid { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-savebar { align-items: center; background: var(--navy); border-radius: 10px; bottom: 12px; color: #c7d4d9; display: flex; font-size: .66rem; justify-content: space-between; padding: 12px 14px; position: sticky; z-index: 20; }

/* Modal and chart details */
.production-modal .modal-content { border: 0; border-radius: 12px; box-shadow: 0 20px 70px rgb(11 27 36 / 22%); }
.production-modal .modal-header { border-bottom: 1px solid var(--line); padding: 16px 18px; }
.history-title-block h2 { font-size: 1.25rem; margin: 2px 0; }
.history-title-block p, .chart-plan-note { color: var(--muted); font-size: .65rem; }
.history-toolbar { align-items: end; display: flex; gap: 12px; justify-content: space-between; }
.range-dates { align-items: end; display: flex; gap: 7px; }
.range-dates input { min-height: 34px; }
.range-dates .btn { align-items: center; display: inline-flex; justify-content: center; min-height: 34px; white-space: nowrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.production-large-chart-wrap { min-height: 350px; position: relative; }
.production-large-chart-wrap canvas { display: block; max-width: 100%; width: 100%; }
.chart-tooltip { background: var(--navy); border-radius: 6px; color: #fff; font-size: .62rem; padding: 7px 9px; pointer-events: none; position: absolute; z-index: 3; }
.chart-loading { align-items: center; background: rgb(255 255 255 / 86%); display: flex; inset: 0; justify-content: center; position: absolute; }
.loading-ring { animation: spin .8s linear infinite; border: 3px solid #dbe5e2; border-radius: 50%; border-top-color: var(--green); height: 24px; margin-right: 8px; width: 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.portal-main.is-login { align-items: center; display: flex; justify-content: center; max-width: none; min-height: 100vh; padding: 24px; }
.login-shell { max-width: 390px; width: 100%; }
.login-brand { align-items: center; color: var(--navy); display: flex; font-size: .9rem; font-weight: 850; gap: 6px; justify-content: center; margin-bottom: 17px; }
.login-brand img { border: 1px solid var(--line); border-radius: 10px; height: 40px; margin-right: 5px; width: 40px; }
.login-brand em { color: var(--muted); font-size: .65rem; font-style: normal; font-weight: 600; }
.login-panel { box-shadow: var(--shadow); padding: 24px; }
.login-panel h1 { font-size: 1.6rem; margin: 4px 0 8px; }

@media (max-width: 1199.98px) {
  .portal-main { padding: 28px 28px 48px; }
  .production-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-header { grid-template-columns: 120px minmax(0, 1fr); }
  .dashboard-facts { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
  .dashboard-facts article:nth-child(n) { border-top: 0; }
  .dashboard-facts article + article { border-left: 1px solid var(--line); }
}

@media (max-width: 991.98px) {
  .portal-layout { display: block; }
  .portal-sidebar { height: 100vh; position: fixed; width: min(286px, 88vw) !important; }
  .portal-main { padding-top: 24px; }
  .sidebar-body { padding-top: 12px; }
  .sidebar-brand { display: none; }
  .plant-group-grid, .editor-layout, .operations-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { display: none; }
  .source-health-list { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .portal-main { padding: 20px 14px 42px; }
  .portal-footer { display: none; }
  .brand-copy span { font-size: .55rem; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 12px; }
  .page-intro h1 { font-size: 1.9rem; }
  .dashboard-header { gap: 6px; grid-template-columns: 1fr; }
  .plan-alert-grid { -ms-overflow-style: none; display: flex; margin-left: -14px; margin-right: -14px; overflow-x: auto; padding: 0 14px 3px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .plan-alert-grid::-webkit-scrollbar { display: none; }
  .plan-alert-card { flex: 0 0 220px; min-height: 56px; scroll-snap-align: start; }
  .dashboard-action-row { grid-template-columns: 1fr; }
  .generate-panel { border-radius: 10px; gap: 8px; grid-template-columns: 1fr; padding: 10px 12px; }
  .generate-panel-copy h2 { font-size: .95rem; }
  .plan-command-fields { grid-template-columns: minmax(90px, 1fr) auto; }
  .generate-button { font-size: .6rem; justify-content: center; padding-inline: 10px; width: auto; }
  .production-live-summary { align-items: center; flex-direction: row; gap: 5px; min-height: 34px; padding: 5px 8px; }
  .production-live-summary small { margin: 0; }
  .dashboard-facts { grid-template-columns: 1fr 1fr; }
  .dashboard-facts article { min-height: 31px; padding: 4px 7px; }
  .dashboard-facts article:nth-child(n+3) { border-top: 1px solid var(--line); }
  .dashboard-facts article:nth-child(odd) { border-left: 0; }
  .dashboard-facts strong { font-size: .61rem; }
  .dashboard-facts small { font-size: .43rem; }
  .production-chart-grid { grid-template-columns: 1fr; }
  .production-mini-chart { height: 145px; }
  .section-heading { align-items: flex-start; }
  .data-live-pill { margin-top: 3px; }
  .page-summary { width: 100%; }
  .page-summary > span { flex: 1; min-width: 0; }
  .view-tabs { gap: 19px; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .view-tabs a { min-width: 125px; }
  .insight-strip { grid-template-columns: repeat(2, 1fr); }
  .insight-strip article:nth-child(odd) { border-left: 0; }
  .insight-strip article:nth-child(n+3) { border-top: 1px solid var(--line); }
  .report-note { display: block; }
  .report-note > strong { display: block; margin-bottom: 4px; }
  .plant-list-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .list-help { display: none; }
  .plant-group-source { grid-template-columns: 1fr; }
  .plant-unit-row { grid-template-columns: 1fr auto; }
  .plant-unit-row > span:nth-child(2) { display: none; }
  .plant-unit-row > span:nth-child(3) { grid-column: 1; }
  .plant-unit-row .row-action { grid-column: 2; grid-row: 2; }
  .reading-filter { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .reading-filter > div:first-child { grid-column: 1 / -1; }
  .reading-filter .btn { align-self: end; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-savebar { align-items: stretch; flex-direction: column; gap: 9px; }
  .settings-savebar .btn { width: 100%; }
  .item-list > div { align-items: flex-start; }
  .history-toolbar { align-items: stretch; flex-direction: column; }
  .range-dates { display: grid; grid-template-columns: 1fr 1fr; }
  .range-dates .btn { width: 100%; }
  .production-large-chart-wrap { min-height: 330px; overflow-x: auto; }
  .summary-action { font-size: 0; }
}
