/* Editor section "Fotovoltika" (views/editor/pv.js, docs/SPEC_PV.md §4). Prefix .pv-. Phone first:
   everything fits 360 px without horizontal page scroll; tap targets ≥ 40 px on touch. */

.pv-root { min-width: 0; }
.pv-calc { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.pv-card { min-width: 0; }
.pv-card .card-body { min-width: 0; }
.pv-h4 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }

/* ---- intro ---------------------------------------------------------------- */
.pv-intro {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 32px 24px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface);
}
.pv-intro-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--warning-soft); color: var(--warning-text); }
.pv-intro-title { margin: 0; font-size: 19px; font-weight: 650; line-height: 1.3; }
.pv-intro-text, .pv-intro-note { max-width: 620px; margin: 0; color: var(--text-2); line-height: 1.5; }
.pv-intro-note { font-size: 12.5px; }
.pv-intro-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---- 1 Spotreba: appliance cards --------------------------------------- */
.pv-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; min-width: 0; }
.pv-apps:empty { display: none; }
.pv-app {
  position: relative; min-width: 0;
  padding: 4px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.pv-app-fold { min-width: 0; }
.pv-app-sum {
  display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: 44px; padding: 4px 40px 4px 0;
  cursor: pointer; list-style: none;
}
.pv-app-sum::-webkit-details-marker { display: none; }
.pv-app-sum-name { font-weight: 600; overflow-wrap: anywhere; }
.pv-app-sum-calc { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pv-app-sum-calc::after { content: " ▾"; color: var(--link); }
.pv-app-fold[open] .pv-app-sum-calc::after { content: " ▴"; }
/* unfolded: the name is edited in the field below, the row keeps the live formula */
.pv-app-fold[open] .pv-app-sum-name { display: none; }
.pv-app-fold[open] .pv-app-kwh { display: none; }
/* room for a two-line formula: switching „Ako zadať spotrebu“ between a one-line („0,28 kWh/deň · špička 2 000 W“) and
   a two-line formula does not move the choice under the finger */
.pv-app-fold[open] .pv-app-sum { min-height: 47px; }
.pv-app-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 2px 0 8px; }
.pv-app-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pv-app-head .pv-app-name { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.pv-app-del { position: absolute; top: 6px; right: 6px; }
.pv-app-fields { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pv-app-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.pv-app-row-label { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text-2); }
.pv-app-row > .input-affix { flex: 0 0 148px; width: 148px; }
/* „Ako zadať spotrebu“ (SPEC_PV §6): full-width choice of four above the fields (Výkon × hodiny | Za deň | Za cyklus |
   Za rok). One row of equal parts; on a phone a long label wraps to two lines, the part grows with it (never clipped). */
.pv-app-mode { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pv-app-mode-label { font-size: 13px; color: var(--text-2); }
.pv-app-mode-seg { display: flex; width: 100%; }
.pv-app-mode-seg .segmented-item {
  flex: 1 1 0; justify-content: center; min-width: 0; height: auto; min-height: 30px; padding: 2px 4px;
  white-space: normal; overflow-wrap: break-word; line-height: 1.15; text-align: center;
}
.pv-app-row-label { display: flex; flex-direction: column; gap: 1px; }
.pv-app-row-sub { font-size: 11.5px; color: var(--text-2); opacity: 0.85; }
.pv-app-hint { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text-2); overflow-wrap: anywhere; }
.pv-app-foot { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pv-app-kwh { align-self: flex-end; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.pv-app-more { min-width: 0; border-top: 1px solid var(--border); }
.pv-app-more > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-height: 40px; padding: 4px 0;
  font-size: 13px; cursor: pointer; color: var(--link);
}
.pv-app-more-sum { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.pv-app-more-body { display: flex; flex-direction: column; gap: 12px; padding: 6px 0 4px; min-width: 0; }
.pv-app-more-body .input-affix { max-width: 148px; }
.pv-app-actions, .pv-apply-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.pv-stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.pv-stepper > .input-affix { flex: 0 0 60px; width: 60px; }
.pv-stepper .input { height: 36px; padding-inline: 4px; text-align: center; font-weight: 600; }
.pv-stepper .pv-stepper-btn { flex: none; width: 36px; height: 36px; padding: 0; }
.field .pv-stepper > .input-affix { flex-basis: 72px; width: 72px; }

.pv-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pv-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.pv-stat-label { font-size: 12.5px; color: var(--text-2); }
.pv-stat-value { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pv-totals-note, .pv-running { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }

.pv-note { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; background: var(--surface); }
.pv-note > summary { display: flex; align-items: center; min-height: 40px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.pv-note[open] { padding-bottom: 12px; }
.pv-note-list { margin: 4px 0 8px; padding-left: 20px; font-size: 13.5px; line-height: 1.5; }
.pv-note-list li + li { margin-top: 6px; }
.pv-note-list a, .pv-price-cat a, .pv-src a { overflow-wrap: anywhere; }
.pv-note-body { padding-top: 4px; }
.pv-toggle-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pv-toggle-field .field-hint { margin: 0; }

/* template picker (modal) */
.pv-tpls { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pv-tpls-title { margin: 10px 0 0; font-size: 13px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.pv-tpls-note { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); }
.pv-tpl {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.pv-tpl:hover { background: var(--surface-2); }
.pv-tpl:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.pv-tpl--custom { border-style: dashed; }
.pv-tpl-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.pv-tpl-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.pv-tpl-sub, .pv-tpl-note { font-size: 12.5px; line-height: 1.4; color: var(--text-2); overflow-wrap: anywhere; }
.pv-tpl-src { font-size: 11.5px; line-height: 1.35; color: var(--text-2); opacity: 0.85; overflow-wrap: anywhere; }
.pv-tpl-count { flex: none; font-size: 12.5px; font-weight: 600; color: var(--good-text); }
.pv-tpl-plus { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }

/* ---- 3 Stratégia ---------------------------------------------------------- */
.pv-choices { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.pv-choice { min-height: 44px; }
.pv-sub { padding: 12px; border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.pv-sub.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- 4 Výsledok ----------------------------------------------------------- */
.pv-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; min-width: 0; }
.pv-tile {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.pv-tile-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.pv-tile-value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pv-tile-sub { font-size: 12.5px; line-height: 1.4; color: var(--text-2); overflow-wrap: anywhere; }
.pv-tile--own { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.pv-tile-own { margin-top: 2px; }
.pv-tile-own[hidden] { display: none; }
/* own values (SPEC_PV §5): Automaticky ↔ Vlastná hodnota per component, stepper with 44 px tap targets */
.pv-own { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pv-own .pv-h4 { margin: 0; }
.pv-own-intro { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.pv-own-row {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.pv-own-row.is-own { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.pv-own-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; min-width: 0; }
.pv-own-label { font-size: 14px; font-weight: 600; }
.pv-own-mode { max-width: 100%; }
.pv-own-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.pv-own-body[hidden] { display: none; }
.pv-own-body .pv-stepper > .input-affix { flex: 0 0 88px; width: 88px; }
.pv-own-body .pv-stepper .input { height: 44px; font-size: 16px; }
.pv-own-body .pv-stepper .pv-stepper-btn { width: 44px; height: 44px; }
.pv-own-unit { font-size: 14px; font-weight: 600; }
.pv-own-hint { flex: 1 1 100%; font-size: 12.5px; color: var(--text-2); }
.pv-own-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; min-width: 0; }
.pv-own-rec { min-width: 0; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pv-own-reset[hidden] { display: none; }
.pv-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; min-width: 0; }
.pv-charts > *, .pv-card .chart-card { min-width: 0; }
.pv-warnings:empty, .pv-hh-note:empty, .pv-apply-status:empty { display: none; }
.pv-warn-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.5; }
.pv-meaning-box { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.pv-meaning p { margin: 0; font-size: 14px; line-height: 1.55; }
.pv-meaning p + p { margin-top: 8px; }
.pv-disclaimer-short { margin: 0; }

/* ---- 5 Cena ---------------------------------------------------------------- */
.pv-prices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; min-width: 0; }
.pv-prices:empty { display: none; }
.pv-price {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.pv-price-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.pv-price-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.pv-price-label { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.pv-price-amount { flex: none; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pv-price-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pv-price-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.pv-price-edit-label { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text-2); }
.pv-price-edit > .input-affix { flex: 0 0 150px; width: 150px; }
.pv-price-cat { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; }
.pv-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); min-width: 0; }
.pv-total-label { font-size: 14px; font-weight: 600; }
.pv-total-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pv-total-range { flex: 1 1 100%; font-size: 12.5px; color: var(--text-2); }
.pv-repl, .pv-plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; min-width: 0; }
.pv-repl li, .pv-plan li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0;
  padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}
.pv-repl li:first-child, .pv-plan li:first-child { border-top: 0; }
.pv-repl strong, .pv-plan strong { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- 6 Porovnanie so sieťou ---------------------------------------------- */
.pv-tiles--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---- 7 Do scenára ---------------------------------------------------------- */
.pv-plan-box { min-width: 0; }
.pv-plan-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pv-plan-sub { font-size: 12.5px; color: var(--text-2); }
.pv-plan-empty { color: var(--text-2); }
.pv-apply-status p { margin: 0; }
.pv-items-link { align-self: flex-start; display: inline-flex; align-items: center; min-height: 40px; font-size: 14px; }
.pv-attribution { margin: 0; }

/* ---- live read-out (sticks to the bottom while the result card is below the screen) -------- */
.pv-card-result { scroll-margin-top: calc(var(--header-h) + 12px); }
.pv-live {
  position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 15;
  display: flex; align-items: center; align-self: center; gap: 8px; width: min(100%, 520px); min-width: 0; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.pv-live[hidden] { display: none; }
.pv-live:focus-visible { outline: none; box-shadow: var(--shadow), 0 0 0 3px var(--focus-ring); }
.pv-live-icon { flex: none; display: grid; place-items: center; color: var(--warning-text); }
.pv-live-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pv-live-go { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; color: var(--link); }

/* ---- phones ---------------------------------------------------------------- */
@media (max-width: 480px) {
  .pv-intro { padding: 24px 16px; }
  .pv-intro-actions { flex-direction: column; align-self: stretch; }
  .pv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pv-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pv-tile { padding: 12px; }
  .pv-tile-value, .pv-total-value { font-size: 20px; }
  .pv-app-actions > .btn, .pv-apply-actions > .btn { flex: 1 1 100%; max-width: 100%; height: auto; min-height: 44px; white-space: normal; line-height: 1.25; text-align: center; }
  /* „Elektrocentrála“ in a 2-column tile of a 320 px phone: the label wraps (phone review 14 Oct 2026) */
  .pv-tile-label { min-width: 0; overflow-wrap: anywhere; }
  .pv-tile-label > span { min-width: 0; }
  .pv-app-row > .input-affix, .pv-price-edit > .input-affix { flex-basis: 136px; width: 136px; }
  .pv-own-mode { display: flex; flex: 1 1 100%; }
  .pv-own-mode .segmented-item { flex: 1 1 0; justify-content: center; min-width: 0; padding: 0 6px; }
  .pv-own-foot > .btn { margin-left: auto; }
  .pv-live { padding-inline: 12px; font-size: 13px; }
  .pv-live-go-label { display: none; }
  .pv-live-word { display: none; } /* „6,75 kWp · 17,4 kWh · 12 806 €“ must fit 360 px */
}
@media (max-width: 340px) {
  .pv-tile { padding: 10px; }
  .pv-tile-label { font-size: 12px; gap: 4px; }
}
@media (pointer: coarse), (max-width: 720px) {
  .pv-stepper .input { height: 40px; }
  .pv-stepper .pv-stepper-btn { width: 40px; height: 40px; }
  .pv-app-del.btn-icon.btn-sm { width: 40px; height: 40px; }
  .pv-price-reset.btn-sm, .pv-own-reset.btn-sm { height: 40px; }
  .pv-tpl { min-height: 52px; }
  .pv-root .segmented-item { height: 40px; }
  .pv-root .pv-app-mode-seg .segmented-item { height: auto; min-height: 40px; }
  .pv-root .chart-card__toggle { min-height: 40px; }
  .pv-app-actions > .btn, .pv-apply-actions > .btn, .pv-intro-actions > .btn { min-height: 44px; }
  .pv-toggle-field .toggle { min-height: 40px; }
  .pv-root .slider-input { height: 40px; }
  /* links: a list of sources is a list of full tap targets; a link inside a sentence gets a taller hit area */
  .pv-links { padding-left: 0; list-style: none; }
  .pv-links li + li { margin-top: 0; }
  .pv-links a { display: flex; align-items: center; min-height: 40px; }
  .pv-price-cat a, .pv-src a { padding-block: 13px; }
}

@media print {
  .pv-app-actions, .pv-apply-actions, .pv-app-del, .pv-stepper-btn, .pv-price-reset, .pv-own-reset, .pv-own-intro, .pv-own-row:not(.is-own), .pv-intro-actions, .pv-items-link, .pv-live { display: none !important; }
  .pv-app, .pv-price, .pv-tile, .pv-own-row { break-inside: avoid; }
}
