:root {
  --bg: #f3efe4;
  --panel: rgba(255, 251, 244, 0.9);
  --panel-strong: #fffdf8;
  --text: #1d2a1f;
  --muted: #5e675e;
  --accent: #0e6b56;
  --accent-2: #bf5a36;
  --line: rgba(29, 42, 31, 0.12);
  --shadow: 0 18px 40px rgba(25, 39, 28, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(14, 107, 86, 0.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(191, 90, 54, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f4ea 0%, var(--bg) 100%);
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.hero {
  padding: 16px 4px 32px;
  max-width: 76rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 0.78rem;
  margin: 0 0 10px;
}

h1, h2, h3 {
  font-weight: 600;
  margin-top: 0;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 0.95;
  max-width: 9ch;
  margin-bottom: 12px;
}

.lead {
  max-width: 72ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.hero-card {
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 251, 244, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-card-feature {
  background:
    linear-gradient(135deg, rgba(14, 107, 86, 0.12), rgba(191, 90, 54, 0.08)),
    rgba(255, 251, 244, 0.88);
}

.hero-card h2 {
  margin: 8px 0 10px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
}

.hero-facts {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
}

.hero-facts div {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hero-facts div:first-child {
  padding-top: 0;
  border-top: none;
}

.hero-facts dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-facts dd {
  margin: 6px 0 0;
  font-size: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  max-width: 920px;
}

.workspace > * {
  min-width: 0;
}

.workspace-main {
  display: grid;
  gap: 20px;
}

.workspace + .detail-panel {
  margin-top: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.subpanel {
  margin-top: 20px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(14, 107, 86, 0.05);
  border: 1px solid rgba(14, 107, 86, 0.12);
}

.panel-lite {
  margin-top: 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.75);
  border: 1px dashed rgba(14, 107, 86, 0.2);
}

.error-panel {
  border-color: rgba(191, 90, 54, 0.35);
  color: #7d2f16;
  margin-bottom: 20px;
}

.result-warning-panel {
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(191, 90, 54, 0.10);
  border: 1px solid rgba(191, 90, 54, 0.35);
  color: #7d2f16;
}

.result-warning-panel h3 {
  margin-bottom: 8px;
}

.result-warning-panel p {
  margin: 0;
}

.result-warning-panel p + p {
  margin-top: 8px;
}

.calculator-form,
.grid,
.facts,
.section-panel,
.detail-panel,
.result-panel {
  display: grid;
  gap: 16px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading-tight {
  margin-bottom: 2px;
}

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

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

.grid-span-two {
  grid-column: 1 / -1;
}

.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.section-lead {
  max-width: 68ch;
  margin: 10px 0 0;
  color: var(--muted);
}

.panel-badge {
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 107, 86, 0.08);
  border: 1px solid rgba(14, 107, 86, 0.16);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

label span,
.field-label,
small,
dt,
.metric-label {
  display: block;
  color: var(--muted);
}

.field-disabled {
  opacity: 0.55;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
}

input,
select,
textarea {
  margin-top: 6px;
  background: var(--panel-strong);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: rgba(255, 253, 248, 0.55);
  color: var(--muted);
  cursor: not-allowed;
}

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

button {
  margin-top: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #0b5444 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  background: linear-gradient(135deg, rgba(14, 107, 86, 0.28) 0%, rgba(11, 84, 68, 0.4) 100%);
  color: rgba(255, 255, 255, 0.92);
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-button,
.icon-button {
  width: auto;
  margin-top: 0;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(14, 107, 86, 0.2);
  box-shadow: none;
}

.secondary-button {
  padding-inline: 16px;
}

.icon-button {
  padding: 10px 12px;
  font-size: 0.9rem;
}

.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-primary-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid rgba(14, 107, 86, 0.12);
}

.history-primary-status {
  margin: 6px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.history-primary-help {
  max-width: 64ch;
}

.history-workspace {
  display: grid;
  gap: 16px;
}

.history-submit-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 240px;
}

.history-submit-actions button {
  width: auto;
  min-width: 220px;
  margin-top: 0;
}

.history-submit-status {
  margin: 0;
  text-align: right;
}

.history-submit-status[data-state="error"] {
  color: #7d2f16;
}

.history-submit-status[data-state="ready"] {
  color: var(--accent);
}

.history-section {
  display: grid;
  gap: 12px;
}

.history-block-panel {
  display: grid;
  gap: 14px;
}

.history-feedback {
  min-height: 1.2rem;
}

.history-feedback[data-state="error"] {
  color: #7d2f16;
}

.history-feedback[data-state="info"] {
  color: var(--accent);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.history-overview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.history-overview-head .history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  justify-content: stretch;
}

.history-stat {
  min-width: 92px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(14, 107, 86, 0.06);
  border: 1px solid rgba(14, 107, 86, 0.12);
}

.history-stat strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.1;
}

.history-stat span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.75);
}

.history-block-wrap {
  background: rgba(255, 255, 255, 0.62);
}

.history-table {
  margin-bottom: 0;
  width: 100%;
}

.history-table th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.history-table td {
  vertical-align: middle;
}

.history-block-open td {
  background: rgba(191, 90, 54, 0.04);
}

.history-table input {
  margin-top: 0;
  min-width: 0;
  width: 100%;
}

.history-table select {
  margin-top: 0;
  min-width: 0;
  width: 100%;
}

.row-action-cell {
  width: 84px;
  min-width: 84px;
  white-space: nowrap;
}

.row-action-cell .icon-button {
  min-width: 0;
  width: auto;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.history-block-count {
  white-space: nowrap;
  color: var(--muted);
}

.history-block-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

.history-block-status.is-open {
  background: rgba(191, 90, 54, 0.12);
  color: #7d2f16;
}

.history-block-status.is-filled {
  background: rgba(14, 107, 86, 0.12);
  color: var(--accent);
}

.history-block-action {
  white-space: nowrap;
}

.history-block-empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
}

.history-months-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(14, 107, 86, 0.12);
  background: rgba(255, 253, 248, 0.62);
}

.history-months-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.scenario-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
}

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

.scenario-summary-text strong {
  display: block;
  color: var(--text);
  font-size: 1.08rem;
}

.scenario-summary-meta {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.scenario-content {
  display: grid;
  gap: 16px;
  padding-top: 6px;
}

.scenario-help {
  color: var(--muted);
}

.trash-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.metric-card {
  background: linear-gradient(135deg, rgba(14, 107, 86, 0.95), rgba(11, 84, 68, 0.95));
  color: white;
  padding: 22px;
  border-radius: 20px;
  margin-bottom: 0;
}

.metric-card .metric-label {
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 4px;
}

.metric-value {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.result-panel-summary {
  position: static;
  width: 100%;
}

.result-section + .result-section {
  margin-top: 10px;
}

.result-section h3 {
  margin-bottom: 12px;
}

.facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 24px;
}

.facts div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.compact-facts {
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 0;
}

.compact-facts div {
  padding: 10px 0;
}

dd {
  margin: 4px 0 0;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

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

.scope-cell {
  white-space: nowrap;
  width: 1%;
}

.summary-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
}

.summary-groups {
  display: grid;
  gap: 10px;
  min-width: 760px;
}

.summary-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.6);
  overflow: hidden;
  min-width: 760px;
}

.summary-group-header {
  display: grid;
  grid-template-columns: 20px minmax(72px, 0.9fr) minmax(88px, 0.8fr) minmax(90px, 0.9fr) minmax(86px, 0.85fr) minmax(124px, 1fr) minmax(110px, 0.9fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  min-width: 760px;
}

.summary-group-header-static {
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.summary-group > .summary-group-header {
  cursor: pointer;
  list-style: none;
}

.summary-group > .summary-group-header::-webkit-details-marker {
  display: none;
}

.summary-toggle-indicator {
  color: var(--accent);
  font-size: 0.95rem;
  line-height: 1;
}

.summary-group > .summary-group-header .summary-toggle-indicator::before {
  content: "▸";
}

.summary-group[open] > .summary-group-header .summary-toggle-indicator::before {
  content: "▾";
}

.summary-group-header span {
  min-width: 0;
}

.summary-group-body {
  padding: 0 16px 8px;
}

.summary-group-body table {
  min-width: 100%;
  margin-bottom: 0;
}

.notes,
.placeholder {
  color: var(--muted);
}

.notes {
  margin: 0;
  padding-left: 20px;
}

.result-placeholder {
  display: grid;
  gap: 12px;
}

.workflow-list {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.table-intro {
  margin: 0 0 12px;
  color: var(--muted);
}

.detail-toggle {
  margin-bottom: 0;
}

.detail-toggle summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 12px;
}

@media (max-width: 920px) {
  .workspace,
  .hero-grid,
  .grid.two,
  .grid.three,
  .facts,
  .summary-group-header {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .history-primary-actions,
  .scenario-panel > summary,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-group-header-static {
    display: none;
  }

  .summary-group > .summary-group-header {
    padding-left: 24px;
  }

  .history-stats {
    justify-content: start;
  }

  .history-overview-head .history-stats {
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  }

  .page-shell {
    width: min(100% - 20px, 720px);
  }

  .section-actions {
    flex-direction: column;
  }

  .history-submit-actions button {
    width: 100%;
    min-width: 0;
  }

  .history-submit-actions {
    justify-items: stretch;
    min-width: 0;
  }

  .history-submit-status {
    text-align: left;
  }

  .panel-badge,
  .scenario-summary-meta {
    text-align: left;
  }

  .history-stat {
    min-width: 0;
    flex: 1 1 110px;
  }
}

@media (min-width: 921px) {
  .history-overview-head {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  }
}
