/* FirstPoint Energy theme — palette and type sampled from firstpoint.energy:
   cream paper, ink headings, espresso-olive primary buttons, terracotta
   accents, Exo 2 throughout, generous rounding and whitespace. */
:root {
  --paper: #F6EFE9;
  --card: #FFFFFF;
  --ink: #111827;
  --muted: #4B5563;
  --espresso: #3A3A26;
  --espresso-hover: #4A4A32;
  --terracotta: #BB5B37;
  --terracotta-soft: #F5E4DB;
  --red-dot: #F53030;
  --navy: #011630;
  --taupe: #A99886;
  --border: #E5DDD3;
  --error: #B3261E;
  --ok: #3F6212;
  --warn-bg: #FBF1EC;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Exo 2", "Inter", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
}

/* ---------- header ---------- */
.app-header {
  padding: 20px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo { height: 46px; width: auto; }
.brand-title h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--ink);
}
.brand-title h1::after {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--terracotta);
}
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 1.7fr;
  gap: 18px;
  padding: 22px 28px 56px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
}
.card-head {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.card-head::after {
  content: "";
  display: block;
  width: 40px;
  height: 2.5px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--terracotta);
}
/* card heading with inline help icon + popover */
.card-head-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card-head-row .card-head { flex: 1; }
.help-btn {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--terracotta);
  background: #fff;
  color: var(--terracotta);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.help-btn:hover, .help-btn[aria-expanded="true"] {
  background: var(--terracotta);
  color: #fff;
}
.help-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: min(460px, 92vw);
  max-height: min(72vh, 620px);
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid var(--terracotta);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 14px 32px rgba(17, 24, 39, 0.2);
}
.help-pop p, .help-pop ul { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }
.help-pop ul { padding-left: 18px; }
.help-pop a { color: var(--terracotta); word-break: break-all; }
.pop-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding-bottom: 5px;
  border-bottom: 2px solid var(--terracotta);
}
.pop-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.pop-title-row .pop-title { flex: 1; }
.segmented.mini { margin: 0; border-radius: 6px; flex: none; }
.segmented.mini button { padding: 3px 9px; font-size: 11px; }

.icon-btn {
  flex: none;
  height: 30px;
  max-width: 220px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1.5px solid var(--terracotta);
  background: #fff;
  color: var(--terracotta);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, color .15s;
}
.icon-btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] {
  background: var(--terracotta);
  color: #fff;
}
.icon-btn:hover .icon-btn-label, .icon-btn[aria-expanded="true"] .icon-btn-label { color: #fff; }

.max-stats { display: flex; gap: 14px; }
.max-stat {
  flex: 1;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.max-stat > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.max-stat strong { font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.max-stat strong span { display: inline; }

.report-section {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
}
.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.card-subhead {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  padding-bottom: 6px;
  border-bottom: 2px solid var(--terracotta);
}

/* ---------- form controls ---------- */
select, input[type="number"], input[type="search"], input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  margin: 2px 0 6px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s;
}
select:hover, input:hover { border-color: var(--taupe); }
input:focus, select:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(187, 91, 55, 0.15);
}

.hint { margin: 4px 0 0; font-size: 12.5px; }
.hint.error { color: var(--error); background: var(--warn-bg); padding: 7px 10px; border-radius: 8px; }
.hint.ok { color: var(--ok); font-weight: 600; background: none; padding: 0; }
.hint:empty, .hint[hidden] { display: none; }

dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 8px; padding: 3.5px 0; border-bottom: 1px solid var(--paper); }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.kv { display: flex; justify-content: space-between; gap: 8px; margin: 7px 0; }
.kv span { color: var(--muted); }

.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-weight: 600; margin-bottom: 3px; }

.note p, .note ul, .note-inline { font-size: 12.5px; color: var(--muted); }
.note a { color: var(--terracotta); word-break: break-all; }

/* ---------- typeahead panel search ---------- */
.typeahead { position: relative; }
.typeahead-list {
  position: absolute;
  z-index: 30;
  left: 0; right: 0;
  margin: -4px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1.5px solid var(--terracotta);
  border-radius: 0 0 10px 10px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.16);
}
.typeahead-list li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.typeahead-list li .watts { color: var(--muted); font-variant-numeric: tabular-nums; }
.typeahead-list li.active, .typeahead-list li:not(.group):hover { background: var(--terracotta-soft); }
.typeahead-list li mark { background: #F8D8C9; color: inherit; padding: 0; border-radius: 2px; }
.typeahead-list li.empty { color: var(--muted); cursor: default; }

/* add-a-panel chooser: two equal tiles, manual vs datasheet drop */
.add-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 6px 0 4px;
}
.add-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 18px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.add-choice .dz-icon { font-size: 28px; }
.add-choice strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.dropzone-choice { border-style: dashed; border-color: var(--taupe); }
.add-choice:hover, .add-choice:focus-visible, .dropzone-choice.drag {
  border-color: var(--terracotta);
  background: var(--terracotta-soft);
  color: var(--terracotta);
  outline: none;
}
.add-choice:hover strong, .dropzone-choice.drag strong { color: var(--terracotta); }
@media (max-width: 560px) { .add-choices { grid-template-columns: 1fr; } }

.add-panel-line { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

.temp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.temp-fields .field { margin-bottom: 4px; }

.panel-actions { display: flex; gap: 16px; margin-top: 2px; }
.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--terracotta);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linklike:hover { color: var(--espresso); }

.checkline { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-top: 8px; }
.checkline input { width: auto; margin: 0; accent-color: var(--terracotta); }

/* ---------- mounting method buttons ---------- */
.mount-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mount-buttons button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 6px 11px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  color: var(--taupe);
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.mount-buttons button svg { width: 56px; height: 42px; }
.mount-buttons button span { font-weight: 600; font-size: 13px; color: var(--ink); }
.mount-buttons button small { font-size: 11px; line-height: 1.25; text-align: center; color: var(--muted); }
.mount-buttons button:hover { border-color: var(--terracotta); color: var(--terracotta); }
.mount-buttons button.active {
  border-color: var(--terracotta);
  background: var(--terracotta-soft);
  color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(187, 91, 55, 0.15);
}
.mount-buttons button.active span { color: var(--terracotta); }
@media (max-width: 420px) { .mount-buttons { grid-template-columns: 1fr; } }

.bifacial-block { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
#bifacial-gain-field input:disabled { background: var(--paper); border-color: var(--border); color: var(--muted); }

/* ---------- segmented unit toggle ---------- */
.segmented {
  display: inline-flex;
  border: 1.5px solid var(--espresso);
  border-radius: 8px;
  overflow: hidden;
  margin: 2px 0 6px;
}
.segmented button {
  padding: 8px 24px;
  border: none;
  background: #fff;
  font: inherit;
  font-weight: 600;
  color: var(--espresso);
  cursor: pointer;
}
.segmented button + button { border-left: 1.5px solid var(--espresso); }
.segmented button.active { background: var(--espresso); color: #fff; }

.locate {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
  border: 1.5px solid var(--espresso);
  border-radius: 8px;
  color: var(--espresso);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.locate:hover { background: var(--espresso); color: #fff; }
.locate:disabled { opacity: .6; cursor: wait; }

/* ---------- readiness checklist ---------- */
.ready-list { list-style: none; margin: 12px 0 0; padding: 0; }
.ready-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--paper);
}
.ready-list li:last-child { border-bottom: none; }
.ready-list .tick {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: #fff;
  color: #fff;
}
.ready-list li.done { color: var(--ink); }
.ready-list li.done .tick { background: var(--terracotta); border-color: var(--terracotta); }

.custom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.custom-grid label { font-size: 12.5px; font-weight: 600; }

/* ---------- report table ---------- */
.table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.report-table th:first-child, .report-table td:first-child { text-align: left; white-space: normal; }
.report-table thead th { background: var(--navy); color: #fff; font-weight: 600; }
.report-table thead th:first-child { border-radius: 8px 0 0 0; }
.report-table thead th:last-child { border-radius: 0 8px 0 0; }
.report-table tr.section td {
  background: var(--paper);
  font-weight: 600;
  color: var(--espresso);
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.report-table tr.highlight td { background: var(--terracotta-soft); font-weight: 700; }
.report-table td.warn { color: var(--terracotta); font-weight: 700; }
.report-table td.ok { color: var(--ok); font-weight: 700; }
.report-table input { width: 70px; margin: 0; padding: 4px 6px; }

.report-actions { display: flex; gap: 10px; margin-top: 14px; }
.report-actions button {
  padding: 9px 16px;
  border: 1.5px solid var(--espresso);
  background: #fff;
  color: var(--espresso);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.report-actions button:hover { background: var(--espresso); color: #fff; }

.disclaimer p { font-size: 11.5px; color: var(--muted); }

/* ---------- AI extraction modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 20px;
  max-width: 860px;
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(17, 24, 39, 0.35);
}
.modal .table-wrap { overflow: auto; flex: 1; margin-top: 4px; }
.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 6px;
  padding: 7px 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.brand-chip img { border-radius: 6px; flex: none; }
.brand-chip strong { display: block; font-size: 14px; color: var(--ink); }
.brand-chip small { color: var(--muted); font-size: 11.5px; }
.variant-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.variant-table th, .variant-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.variant-table th:first-child, .variant-table td:first-child { text-align: left; }
.variant-table thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}
.variant-table tbody tr { cursor: pointer; }
.variant-table tbody tr:hover { background: var(--warn-bg); }
.variant-table tbody tr.selected { background: var(--terracotta-soft); font-weight: 600; }
.variant-table tbody tr.selected td:first-child { color: var(--terracotta); }
.extract-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 44px 20px;
  color: var(--muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--terracotta-soft);
  border-top-color: var(--terracotta);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--espresso);
  background: #fff;
  color: var(--espresso);
}
.modal-actions button:hover { background: var(--paper); }
.modal-actions .modal-primary {
  background: var(--espresso);
  color: #fff;
}
.modal-actions .modal-primary:hover:not(:disabled) { background: var(--espresso-hover); }
.modal-actions .modal-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .col:not(.col-wide), .note-inline, .report-actions,
  .icon-btn, .help-pop, .hint { display: none !important; }
  .layout { display: block; padding: 0; }
  .card { border: none; box-shadow: none; page-break-inside: avoid; }
}
