/* Inline PV tools: roof fit, generation, payback and battery sizing.
   These sit in the page rather than taking it over, so the layout is a simple
   two-column reading order — inputs on the left, the result held in view on the
   right — that collapses to one column when there is no room for two. */

.pv-tool{
  --pv-ink: #1e2833;
  --pv-muted: #5b6875;
  --pv-line: rgba(0,0,0,.12);
  --pv-accent: #25513c;
  --pv-accent-soft: rgba(37,81,60,.08);
  --pv-pass: #1c6b3f;
  --pv-pass-bg: #e6f4ec;
  --pv-fail: #8c2320;
  --pv-fail-bg: #fbeceb;
  --pv-warn: #7a5a11;
  --pv-warn-bg: #fdf5e2;

  margin: 26px 0 0;
  color: var(--pv-ink);
}

/* ---------------------------------------------------------------- toolbar */

.pv-tool__bar{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--pv-line);
  border-radius: 14px 14px 0 0;
  background: #fff;
}

.pv-tool__version{
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 230px;
}

.pv-tool__version label{
  font-size: 12px;
  font-weight: 700;
  color: var(--pv-muted);
}

.pv-tool__actions{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.pv-tool__actions .btn,
.pv-tool__actions label.btn{
  cursor: pointer;
}

.pv-alert{
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--pv-line);
  border-top: 0;
  font-size: 14px;
  line-height: 1.45;
}

.pv-alert--ok{ background: var(--pv-pass-bg); color: var(--pv-pass); }
.pv-alert--error{ background: var(--pv-fail-bg); color: var(--pv-fail); }
.pv-alert[hidden]{ display: none; }

/* ----------------------------------------------------------------- layout */

.pv-tool__layout{
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--pv-line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  overflow: clip;
  background: #fff;
}

.pv-tool__inputs{
  padding: 18px;
  min-width: 0;
}

.pv-tool__results{
  padding: 18px;
  min-width: 0;
  background: linear-gradient(180deg, rgba(37,81,60,.05), rgba(37,81,60,.02));
  border-left: 1px solid var(--pv-line);
}

@media (max-width: 900px){
  .pv-tool__layout{ grid-template-columns: 1fr; }
  .pv-tool__results{ border-left: 0; border-top: 1px solid var(--pv-line); }
}

@media (min-width: 901px){
  .pv-tool__results-inner{ position: sticky; top: 18px; }
}

/* ----------------------------------------------------------------- panels */

.pv-panel{
  border: 1px solid var(--pv-line);
  border-radius: 12px;
  background: #fff;
  margin: 0 0 12px;
  overflow: clip;
}

.pv-panel > summary{
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.pv-panel > summary::-webkit-details-marker{ display: none; }

.pv-panel > summary::after{
  content: '';
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--pv-muted);
  border-bottom: 2px solid var(--pv-muted);
  transform: rotate(45deg);
  transition: transform .15s ease;
  flex: 0 0 auto;
}

.pv-panel[open] > summary::after{ transform: rotate(-135deg); }

.pv-panel__summary{
  font-weight: 500;
  font-size: 13px;
  color: var(--pv-muted);
  margin-left: auto;
  text-align: right;
}

.pv-panel__body{
  padding: 4px 14px 16px;
  border-top: 1px solid var(--pv-line);
}

/* ------------------------------------------------------------------ forms */

.pv-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.pv-grid--wide{ grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pv-field--full{ grid-column: 1 / -1; }

.pv-field{
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pv-field > label,
.pv-field .calc-field-label > label{
  font-size: 13px;
  font-weight: 700;
}

.pv-field input,
.pv-field select,
.pv-field textarea{
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid rgba(0,0,0,.16);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: inherit;
}

.pv-field textarea{ min-height: 78px; resize: vertical; }

.pv-field input:focus-visible,
.pv-field select:focus-visible,
.pv-field textarea:focus-visible{
  outline: 3px solid var(--pv-accent);
  outline-offset: 2px;
}

/* Repeating inputs, one row per item. The three fields belonging to a dwelling
   type have to stay on one line or the floor area and the quantity read as
   though they belong to the type above; a plain auto-fit grid wraps them apart.
   Column names are given once in the head row, so each field's own label is
   there for a screen reader and appears only when the rows stack. */
.pv-entry{
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.pv-entry__head,
.pv-entry__row{
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 150px 120px 34px;
  gap: 10px;
  align-items: center;
}

.pv-entry__head{
  font-size: 12px;
  font-weight: 700;
  color: var(--pv-muted);
}

.pv-entry__head-help{
  display: flex;
  align-items: center;
  gap: 6px;
}

.pv-entry__index-word{
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.pv-entry__index{
  font-size: 12px;
  font-weight: 700;
  color: var(--pv-muted);
  text-align: right;
}

.pv-entry__cell{ min-width: 0; }

.pv-entry__label{
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.pv-entry__cell input{
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid rgba(0,0,0,.16);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: inherit;
}

.pv-entry__cell input:focus-visible{
  outline: 3px solid var(--pv-accent);
  outline-offset: 2px;
}

.pv-entry__list{
  display: grid;
  gap: 8px;
}

.pv-entry__remove{
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--pv-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.pv-entry__remove:hover{
  color: #a12626;
  border-color: rgba(161, 38, 38, .35);
  background: rgba(161, 38, 38, .06);
}

.pv-entry__actions{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-top: 12px;
}

.pv-entry__add{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--pv-ink, inherit);
  background: #fff;
  border: 1px solid rgba(0,0,0,.22);
  border-radius: 8px;
  cursor: pointer;
}

.pv-entry__add span{ font-size: 16px; line-height: 1; }
.pv-entry__add:hover:not(:disabled){ border-color: var(--pv-accent); }
.pv-entry__add:disabled{ opacity: .5; cursor: not-allowed; }

.pv-entry__count{
  margin: 0;
  font-size: 12px;
  color: var(--pv-muted);
}

/* Stacked, each field needs its own visible label again. */
@media (max-width: 720px){
  .pv-entry{ gap: 14px; }
  .pv-entry__head{ display: none; }
  .pv-entry__row{
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--pv-line);
    border-radius: 10px;
  }
  /* Stacked, the index heads the card and the remove button sits beside it. */
  .pv-entry__row > .pv-entry__index{ grid-column: 1; grid-row: 1; }
  .pv-entry__row > .pv-entry__remove{ grid-column: 2; grid-row: 1; justify-self: end; }
  .pv-entry__row > .pv-entry__cell{ grid-column: 1 / -1; }
  .pv-entry__index{
    text-align: left;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .pv-entry__index-word{
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip-path: none;
  }
  .pv-entry__label{
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 4px;
    clip-path: none;
    display: block;
    font-size: 13px;
    font-weight: 700;
  }
}

.pv-hint{
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--pv-muted);
}

.pv-note{
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  border-left: 4px solid var(--pv-accent);
  background: var(--pv-accent-soft);
  font-size: 13px;
  line-height: 1.5;
}

.pv-note--warn{
  border-left-color: #c8a13a;
  background: var(--pv-warn-bg);
}

/* ---------------------------------------------------------------- results */

.pv-result{
  border: 1px solid var(--pv-line);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  margin-bottom: 12px;
}

.pv-result__label{
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--pv-muted);
}

.pv-result__value{
  font-size: 38px;
  font-weight: 800;
  line-height: 1.05;
  margin-top: 6px;
  color: var(--pv-accent);
  font-variant-numeric: tabular-nums;
}

.pv-result__unit{
  font-size: 15px;
  font-weight: 600;
  color: var(--pv-muted);
  margin-left: 4px;
}

.pv-result__detail{
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--pv-muted);
}

.pv-kpis{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.pv-kpi{
  border: 1px solid var(--pv-line);
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
}

.pv-kpi__label{
  font-size: 11.5px;
  font-weight: 700;
  color: var(--pv-muted);
  line-height: 1.3;
}

.pv-kpi__value{
  font-size: 20px;
  font-weight: 800;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.pv-kpi__unit{
  font-size: 12px;
  font-weight: 600;
  color: var(--pv-muted);
}

.pv-rows{
  border: 1px solid var(--pv-line);
  border-radius: 10px;
  background: #fff;
  overflow: clip;
  margin-bottom: 12px;
}

.pv-row{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--pv-line);
}

.pv-row:last-child{ border-bottom: 0; }
.pv-row > span:first-child{ color: var(--pv-muted); }
.pv-row > span:last-child{ font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.pv-badge{
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid currentColor;
}

.pv-badge.is-pass{ color: var(--pv-pass); background: var(--pv-pass-bg); }
.pv-badge.is-fail{ color: var(--pv-fail); background: var(--pv-fail-bg); }
.pv-badge.is-warn{ color: var(--pv-warn); background: var(--pv-warn-bg); }
.pv-badge.is-info{ color: var(--pv-accent); background: var(--pv-accent-soft); }

/* ----------------------------------------------------------------- tables */

.pv-table-wrap{
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--pv-line);
  border-radius: 10px;
  background: #fff;
}

.pv-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 440px;
}

.pv-table th,
.pv-table td{
  padding: 8px 10px;
  border-bottom: 1px solid var(--pv-line);
  text-align: left;
  vertical-align: top;
}

.pv-table thead th{
  background: rgba(0,0,0,.03);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pv-table tbody tr:last-child td{ border-bottom: 0; }
.pv-table tfoot td,
.pv-table tfoot th{
  border-top: 2px solid var(--pv-line);
  border-bottom: 0;
  font-weight: 800;
  background: rgba(0,0,0,.02);
}

.pv-table .num{ text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------------------- drawings */

.pv-figure{
  margin: 14px 0 0;
  border: 1px solid var(--pv-line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.pv-figure svg{ width: 100%; height: auto; display: block; }

.pv-figure figcaption{
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--pv-muted);
}

/* A simple bar chart for the monthly profile, drawn from divs so it needs no
   script and stays legible when the text is enlarged. */
.pv-chart{
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 3px;
  height: 132px;
  margin-top: 12px;
}

.pv-chart__bar{
  position: relative;
  background: var(--pv-accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.pv-chart__bar span{
  position: absolute;
  inset: auto 0 -18px;
  text-align: center;
  font-size: 10px;
  color: var(--pv-muted);
}

.pv-chart__bar--split{ background: linear-gradient(180deg, #7fae93 0 var(--split), var(--pv-accent) var(--split) 100%); }

.pv-chart-wrap{ padding-bottom: 20px; }

.pv-legend{
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--pv-muted);
}

.pv-legend span::before{
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  background: var(--pv-accent);
}

.pv-legend span.is-exported::before{ background: #7fae93; }

/* ------------------------------------------------------------ page intro */

.pv-intro__grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

/* The intro sits outside .pv-tool, so the tool's custom properties are not in
   scope here and the border would collapse to nothing. */
.pv-intro__card{
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
}

.pv-intro__card h2{
  margin: 0 0 6px;
  font-size: 16px;
}

.pv-intro__card p{
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #5b6875;
}

/* Table captions name each table for a screen reader without repeating a
   heading that is already visible above it. */
.pv-tool .visually-hidden{
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
