:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #17201b;
  --muted: #667069;
  --line: #d8ded7;
  --accent: #0f7b68;
  --accent-2: #385c9c;
  --warn: #a85f00;
  --bad: #a53434;
  --good: #14724f;
  --shadow: 0 16px 36px rgba(23, 32, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 440px);
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.12rem;
}

.intro-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(460px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.input-grid {
  display: grid;
  gap: 18px;
}

.panel,
.results-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.results-panel {
  position: sticky;
  top: 16px;
  padding: 22px;
}

.panel-header,
.results-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.icon-text-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
  white-space: nowrap;
}

.icon-text-button:hover {
  border-color: var(--accent);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.checkbox-field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-self: end;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 123, 104, 0.22);
  outline-offset: 1px;
}

.suffix-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.suffix-field input {
  border: 0;
  min-height: 42px;
}

.suffix-field span {
  padding-right: 12px;
  color: var(--muted);
  font-weight: 700;
}

.field-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.is-hidden {
  display: none;
}

.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.results-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.detail-link:hover {
  background: var(--surface-2);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.05;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.metric.good strong {
  color: var(--good);
}

.metric.bad strong {
  color: var(--bad);
}

.chart-wrap {
  width: 100%;
  aspect-ratio: 5 / 2;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.comparison-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  background: var(--line);
}

.comparison-table div {
  display: grid;
  gap: 7px;
  background: #fff;
  padding: 14px;
}

.comparison-table span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.comparison-table strong {
  font-size: 1.05rem;
}

.warnings {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.warning {
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  background: #fff7e8;
  color: #583500;
  padding: 12px 14px;
  line-height: 1.4;
}

.warning.bad {
  border-left-color: var(--bad);
  background: #fff0f0;
  color: #631d1d;
}

.detail-shell {
  width: min(1660px, calc(100% - 32px));
}

.detail-intro h1 {
  max-width: 960px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 1px;
  overflow: hidden;
  padding: 0;
  margin-bottom: 18px;
  background: var(--line);
}

.detail-summary div,
.detail-summary .detail-link {
  background: #fff;
  border: 0;
  border-radius: 0;
  padding: 16px;
}

.detail-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-summary strong {
  font-size: 1.12rem;
}

.monthly-panel {
  padding: 20px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.monthly-table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.monthly-table th,
.monthly-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
}

.monthly-table th:first-child,
.monthly-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  text-align: left;
}

.monthly-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.monthly-table thead th:first-child {
  z-index: 3;
}

.monthly-table tfoot th,
.monthly-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 2px solid var(--accent);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
}

.monthly-table tfoot th:first-child {
  left: 0;
  z-index: 3;
  text-align: left;
}

@media (max-width: 1080px) {
  .workspace,
  .intro {
    grid-template-columns: 1fr;
  }

  .results-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

  h1 {
    font-size: 2.15rem;
  }

  .field-grid,
  .metric-grid,
  .comparison-table {
    grid-template-columns: 1fr;
  }

  .panel,
  .results-panel {
    padding: 16px;
  }

  .panel-header,
  .results-header {
    display: grid;
  }

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

  .results-actions {
    justify-items: stretch;
  }

  .icon-text-button {
    width: 100%;
  }

  .chart-wrap {
    min-height: 230px;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }
}
