:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #18211e;
  --muted: #62706a;
  --line: #d9dfd9;
  --accent: #1f6b53;
  --accent-dark: #164d3d;
  --warm: #b87938;
  --soft: #edf3ef;
  --error: #8b1e16;
  --error-bg: #fff1ee;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.brand {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  font-size: 13px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 4.4vw, 52px); line-height: 1; }
h2 { margin-bottom: 0; font-size: 24px; }
h3 { margin-bottom: 8px; font-size: 20px; }

.status {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 16px 40px rgba(24, 33, 30, .08);
}

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

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.field, fieldset {
  display: block;
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  margin-top: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(31, 107, 83, .18);
  border-color: var(--accent);
}

textarea { resize: vertical; }

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend { padding: 0 7px; }

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 15px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented label {
  margin: 0;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  min-height: 42px;
  padding: 11px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.segmented input:checked + span {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(24, 33, 30, .08);
}

.checks {
  display: grid;
  gap: 10px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.checks input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.checks small {
  color: var(--warm);
  font-size: 12px;
  font-weight: 900;
}

button {
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:hover { background: var(--accent-dark); }
button:disabled { opacity: .62; cursor: wait; }

.fine-print, .legal {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.fine-print { margin: 12px 0 0; }

.preview, .generated {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--soft);
}

.preview {
  max-height: 250px;
  margin: -4px 0 15px;
}

.generated {
  max-height: 620px;
}

.empty, .loading {
  min-height: 430px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 20px;
}

.empty p, .loading p { margin-bottom: 0; }

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.estimate {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.summary {
  margin-bottom: 4px;
  color: var(--muted);
}

.range {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 900;
  color: var(--accent-dark);
}

.estimate table {
  width: 100%;
  border-collapse: collapse;
}

.estimate td {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  vertical-align: top;
}

.estimate td:last-child {
  width: 130px;
  text-align: right;
  font-weight: 900;
}

.error {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #efbbb3;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

@media (max-width: 920px) {
  .topbar {
    display: block;
  }

  .status {
    display: inline-block;
    margin-top: 12px;
  }

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

  .section-title {
    display: block;
  }

  .section-title p {
    margin-top: 5px;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .panel {
    padding: 16px;
  }

  .two-cols,
  .segmented {
    grid-template-columns: 1fr;
  }

  .range {
    font-size: 22px;
  }
}
