:root {
  color-scheme: light;
  --bg: #f6f7f1;
  --surface: #ffffff;
  --surface-2: #eef2ed;
  --ink: #20241f;
  --muted: #687066;
  --line: #dfe5dc;
  --accent: #1f7a5b;
  --accent-2: #d89b32;
  --danger: #b94a3c;
  --blue: #2f6f9f;
  --shadow: 0 16px 40px rgba(28, 35, 29, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), rgba(246,247,241,0.92)),
    radial-gradient(circle at 18% 0%, rgba(216,155,50,0.16), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(246,247,241,0.96), rgba(238,242,237,0.98)),
    var(--bg);
  padding: 20px;
}

.login-gate.hidden {
  display: none;
}

.login-panel {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel .brand-mark {
  display: block;
  margin-bottom: 18px;
}

.login-panel h1 {
  margin-bottom: 10px;
}

.login-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.login-status {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 0.84rem;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 16px;
  max-width: 1440px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31,122,91,0.88), rgba(47,111,159,0.88)),
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(255,255,255,0.32) 9px 11px);
  box-shadow: inset 0 -9px 0 rgba(0,0,0,0.08);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.top-actions,
.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-chip {
  max-width: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 9px 11px;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(28, 35, 29, 0.06);
}

.icon-button:hover,
.text-button:hover,
.tab:hover,
.project-item:hover {
  border-color: rgba(31,122,91,0.42);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(300px, 370px);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
}

.project-panel,
.capture-panel,
.insights-panel {
  min-width: 0;
}

.project-panel,
.capture-panel,
.insights-panel > section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow);
}

.project-panel {
  align-self: start;
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-heading span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-item {
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
  padding: 10px;
}

.project-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.project-item strong,
.project-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
}

.capture-panel {
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #f8faf6;
}

.tab {
  min-height: 46px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.step-guidance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 12px 18px;
}

.step-guidance strong,
.step-guidance span {
  display: block;
}

.step-guidance strong {
  font-size: 0.9rem;
}

.step-guidance span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

#completionBadge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(31,122,91,0.12);
  color: var(--accent);
  padding: 7px 10px;
  font-weight: 800;
}

#surveyForm {
  padding: 18px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title p {
  max-width: 360px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: #31372f;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d6ded3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,122,91,0.13);
}

textarea {
  resize: vertical;
  min-height: 150px;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.inline-field .text-button {
  min-height: 43px;
}

.solar-map {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #eef7fa, #f7f4ea);
}

.sun-track {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 44px;
  align-items: end;
  padding: 8px 18px;
  color: #6b5f3d;
  font-size: 0.78rem;
  font-weight: 800;
}

.sun-track span:nth-child(2) {
  text-align: center;
}

.sun-track span:nth-child(3) {
  text-align: right;
}

.roof-visual {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 180px;
  padding: 26px;
  background:
    linear-gradient(120deg, transparent 35%, rgba(185,74,60,0.16) 36% 54%, transparent 55%),
    linear-gradient(135deg, #dfe7df, #eef0e8);
}

.module-row {
  width: 72%;
  height: 34px;
  border: 1px solid rgba(47,111,159,0.35);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.38) 0 2px, transparent 2px 16.6%),
    linear-gradient(180deg, #245e89, #173f62);
  box-shadow: 0 10px 20px rgba(23,63,98,0.14);
}

.module-row.short {
  width: 52%;
}

.shade-zone {
  position: absolute;
  right: 22px;
  bottom: 22px;
  border-radius: 999px;
  background: rgba(185,74,60,0.12);
  color: var(--danger);
  padding: 7px 10px;
  font-size: 0.75rem;
  font-weight: 800;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.checklist label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  font-size: 0.84rem;
}

.checklist input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.notes-grid {
  align-items: start;
}

.file-drop {
  margin-top: 14px;
}

.file-drop input,
.import-button input,
.evidence-card input {
  display: none;
}

.file-drop span {
  display: grid;
  place-items: center;
  min-height: 72px;
  border: 1px dashed #b8c6b4;
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--muted);
}

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

.photo-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.photo-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.photo-item img {
  border: 0;
  border-radius: 0;
}

.photo-item div {
  display: grid;
  gap: 3px;
  padding: 8px;
}

.photo-item strong {
  overflow: hidden;
  color: #30372f;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-item span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.evidence-section {
  margin-top: 18px;
}

.section-title.compact {
  margin-bottom: 12px;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.evidence-card {
  min-height: 92px;
  border: 1px dashed #b8c6b4;
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.evidence-card.ready {
  border-style: solid;
  border-color: rgba(31,122,91,0.52);
  background: rgba(31,122,91,0.07);
}

.evidence-card span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.insights-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.score-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.risk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 32px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.risk.low {
  background: rgba(31,122,91,0.12);
  color: var(--accent);
}

.risk.medium {
  background: rgba(216,155,50,0.16);
  color: #8a5c15;
}

.risk.high {
  background: rgba(185,74,60,0.12);
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.metrics div {
  min-height: 96px;
  padding: 14px;
  background: #fff;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 1.15rem;
}

.fit-status,
.report-box {
  padding: 16px;
}

.fit-status p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.report-box pre {
  max-height: 360px;
  min-height: 240px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf6;
  padding: 12px;
  color: #2e352c;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.text-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.report-actions {
  margin-top: 12px;
  flex-wrap: wrap;
}

.submit-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.submit-status.success {
  color: var(--accent);
  font-weight: 800;
}

.submit-status.error {
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .insights-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .project-panel {
    order: 2;
  }

  .capture-panel {
    order: 1;
  }

  .insights-panel {
    order: 3;
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(80px, 1fr));
    overflow-x: auto;
  }

  .field-grid.two,
  .field-grid.three,
  .checklist,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    display: block;
  }

  .section-title p {
    margin-top: 6px;
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 1.25rem;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .session-chip {
    max-width: 150px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  #surveyForm {
    padding: 14px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .step-guidance,
  .wizard-actions {
    align-items: stretch;
    flex-direction: column;
  }

  #completionBadge {
    width: max-content;
  }
}

@media print {
  body {
    background: #fff;
  }

  .top-actions,
  .project-panel,
  .capture-panel,
  .report-actions,
  .text-button {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .workspace,
  .insights-panel {
    display: block;
  }

  .insights-panel > section {
    box-shadow: none;
    border: 0;
    page-break-inside: avoid;
  }

  .report-box pre {
    max-height: none;
    border: 0;
    padding: 0;
    font-size: 10pt;
  }
}
