:root {
  --background: #f7f9f5;
  --foreground: #172019;
  --panel: #ffffff;
  --muted: #667067;
  --line: #dfe7dc;
  --solar: #f3b229;
  --leaf: #2f7d57;
  --sky: #2473a6;
  --alert: #b85c38;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--background); color: var(--foreground); }
body { margin: 0; min-width: 320px; background: var(--background); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--sky), white 20%); outline-offset: 3px; }
h1, h2, p { margin-top: 0; }
h2 { margin-bottom: .35rem; font-size: 1.2rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: .75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.eyebrow {
  margin-bottom: .3rem;
  color: var(--leaf);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.plant-title { min-width: 0; }
.plant-title h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.1rem; }
.header-kpis { display: grid; grid-template-columns: repeat(2, minmax(76px, 1fr)); min-width: 230px; border: 1px solid var(--line); border-radius: .5rem; background: #fbfcfa; }
.header-kpis div { padding: .5rem .75rem; text-align: right; }
.header-kpis div + div { border-left: 1px solid var(--line); }
.header-kpis span { display: block; color: var(--muted); font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.header-kpis strong { font-size: .88rem; }

.layout { max-width: 1280px; margin: 0 auto; padding: 2rem; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .9fr); gap: 1.5rem; }
.primary-column, .side-column, .stack { display: grid; align-content: start; gap: 1rem; }
.primary-column { gap: 1.5rem; }
.panel { border: 1px solid var(--line); border-radius: .6rem; padding: 1.5rem; background: var(--panel); box-shadow: 0 2px 7px rgba(23,32,25,.045); }
.compact-panel { padding: 1.1rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1.25rem; align-items: end; }
.hero h2 { margin: .2rem 0 .55rem; font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: -.035em; }
.muted, .muted-label { color: var(--muted); }
.muted { margin-bottom: 0; font-size: .88rem; line-height: 1.55; }
.muted-label { margin-bottom: 0; font-size: .88rem; font-weight: 600; }

.sun-card { position: relative; height: 112px; overflow: hidden; border: 1px solid var(--line); border-radius: .55rem; background: #fbfcfa; }
.sun-orbit { position: absolute; left: 10%; right: 10%; bottom: 30px; height: 60px; border-top: 2px dashed rgba(243,178,41,.75); border-radius: 50% 50% 0 0; }
.sun-symbol { position: absolute; left: 48%; bottom: 57px; width: 30px; height: 30px; border-radius: 50%; background: var(--solar); box-shadow: 0 0 0 9px rgba(243,178,41,.16); }
.sun-card p { position: absolute; left: 1rem; right: 1rem; bottom: .65rem; margin: 0; color: var(--muted); font-size: .74rem; font-weight: 650; }

.range-panel { padding: 1.1rem 1.25rem; }
.range-tabs { margin-top: .9rem; padding: .25rem; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: .5rem; background: #f7f9f5; }
.range-tabs button { min-height: 44px; border: 0; border-radius: .35rem; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.range-tabs button[aria-current="page"] { background: white; color: var(--foreground); box-shadow: 0 1px 5px rgba(23,32,25,.1); }
.range-tabs button:disabled { cursor: wait; }
.loading-state { min-height: 1rem; margin: .45rem 0 -.45rem; color: var(--muted); font-size: .72rem; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.summary-card { min-height: 116px; padding: 1rem; border: 1px solid var(--line); border-radius: .55rem; background: white; box-shadow: 0 2px 7px rgba(23,32,25,.04); }
.summary-card span { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.summary-card strong { display: block; margin-top: .8rem; font-size: 1.45rem; line-height: 1.15; }
.summary-card small { display: block; margin-top: .5rem; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.section-heading { margin-bottom: 1rem; }
.split-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.count-badge, .tag { flex: 0 0 auto; border-radius: .3rem; font-size: .72rem; font-weight: 750; }
.count-badge { padding: .3rem .55rem; border: 1px solid var(--line); color: var(--muted); }

.chart-shell { min-height: 276px; overflow: hidden; border: 1px solid var(--line); border-radius: .55rem; background: #fbfcfa; }
.chart-meta { padding: .8rem 1rem 0; display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; font-weight: 700; }
.chart-shell svg { display: block; width: 100%; height: 250px; }
.chart-shell text { fill: var(--muted); font-size: 10px; }
.empty { padding: 1rem; border: 1px dashed var(--line); border-radius: .5rem; background: #fbfcfa; color: var(--muted); font-size: .85rem; }

.inverter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.inverter-card { padding: 1rem; border: 1px solid var(--line); border-radius: .55rem; background: #fbfcfa; }
.inverter-card.new { border-color: rgba(243,178,41,.5); background: rgba(243,178,41,.06); }
.inverter-title { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.inverter-title strong { line-height: 1.25; }
.serial { margin: .3rem 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: .72rem; }
.new-tag { padding: .22rem .45rem; background: rgba(243,178,41,.16); color: #af7300; letter-spacing: .1em; text-transform: uppercase; }
.power-box { margin-top: 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: .45rem; background: rgba(255,255,255,.8); }
.power-box span { color: var(--muted); font-size: .64rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.power-box strong { display: block; margin-top: .35rem; font-size: 1.55rem; }
.power-box p, .detail { margin: .35rem 0 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.energy-row { margin-top: .9rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.energy-row strong { font-size: 1.15rem; }
.source-kostal { padding: .22rem .5rem; background: rgba(36,115,166,.09); color: var(--sky); }
.source-refu { padding: .22rem .5rem; background: rgba(47,125,87,.1); color: var(--leaf); }

.info-list { margin: 1rem 0 0; }
.info-list div { padding: .7rem 0; display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); font-size: .84rem; }
.info-list div:last-child { border: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; text-align: right; font-weight: 700; }
.source-card, .error-card { padding: .8rem; border: 1px solid var(--line); border-radius: .5rem; }
.source-card header, .error-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.source-card strong, .error-card strong { font-size: .82rem; }
.source-card p, .error-card p { margin: .35rem 0 0; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.status-ok { color: var(--leaf); }
.status-warn { color: #a36b00; }
.status-error { color: var(--alert); }
.logout-button { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: .5rem; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }

.login-page { min-height: 100vh; padding: 2rem; display: grid; place-items: center; }
.login-card { width: min(100%, 380px); padding: 1.5rem; border: 1px solid var(--line); border-radius: .65rem; background: white; box-shadow: 0 8px 30px rgba(23,32,25,.08); }
.login-card h1 { margin-bottom: .45rem; font-size: 1.6rem; }
.login-form { margin-top: 1.4rem; display: grid; gap: .75rem; }
.login-form label { font-size: .85rem; font-weight: 700; }
.login-form input { min-height: 48px; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .5rem; background: white; }
.login-form button { min-height: 48px; border: 0; border-radius: .5rem; background: var(--foreground); color: white; cursor: pointer; font-weight: 750; }
.login-error { margin: 0; padding: .7rem; border: 1px solid rgba(184,92,56,.3); border-radius: .45rem; background: rgba(184,92,56,.08); color: var(--alert); font-size: .82rem; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-column form { grid-column: 1 / -1; }
  .inverter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .topbar-inner, .layout { padding-left: 1rem; padding-right: 1rem; }
  .header-kpis { min-width: 170px; }
  .header-kpis div { padding: .45rem .55rem; }
  .layout { padding-top: 1rem; gap: 1rem; }
  .primary-column { gap: 1rem; }
  .panel { padding: 1rem; }
  .hero { grid-template-columns: 1fr; }
  .sun-card { display: none; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .inverter-grid, .side-column { grid-template-columns: 1fr; }
}
