:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --panel: #ffffff;
  --panel-soft: #eef4ee;
  --ink: #1d2620;
  --muted: #68746d;
  --line: #dbe3dc;
  --accent: #1f6f5b;
  --accent-strong: #165343;
  --accent-soft: #dff0ea;
  --warn: #a44a2a;
  --warn-soft: #f7e8df;
  --good: #1f6f45;
  --good-soft: #dff0e6;
  --neutral-soft: #eceff3;
  --shadow: 0 18px 48px rgba(29, 38, 32, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(18px, 4vw, 56px) 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  max-width: 820px;
  margin: 4px 0 0;
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.top-actions,
.row-actions,
.paste-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.top-actions {
  justify-content: flex-end;
  min-width: 300px;
}

.layout {
  display: grid;
  gap: 20px;
  width: min(1440px, calc(100% - 36px));
  margin: 24px auto 40px;
}

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

.panel {
  padding: clamp(16px, 2.5vw, 24px);
}

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

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cbd6ce;
  border-radius: 7px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input,
select {
  padding: 0 11px;
}

textarea {
  min-height: 128px;
  padding: 11px;
  resize: vertical;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
  background: #ffffff;
  border: 1px solid #b9cbc1;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.button:active {
  transform: translateY(0);
}

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

.button.primary:hover {
  background: var(--accent-strong);
}

.button.ghost {
  background: var(--panel-soft);
}

.button.danger {
  color: var(--warn);
  border-color: #e1b9a9;
}

.status-pill,
.trend-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: 999px;
}

.status-pill {
  color: var(--muted);
  background: var(--neutral-soft);
}

.status-pill.pass {
  color: var(--good);
  background: var(--good-soft);
}

.status-pill.fail,
.trend-bad {
  color: var(--warn);
  background: var(--warn-soft);
}

.trend-good {
  color: var(--good);
  background: var(--good-soft);
}

.trend-flat,
.trend-neutral {
  color: #59636d;
  background: var(--neutral-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  color: #425047;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #f0f5f1;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.input-table input {
  min-width: 116px;
  background: #fbfdfb;
}

.compact-col {
  width: 72px;
  text-align: center;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--warn);
  font-weight: 800;
  background: var(--warn-soft);
  border: 1px solid #e4bda9;
  border-radius: 7px;
  cursor: pointer;
}

.paste-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.paste-panel summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.paste-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  margin-top: 12px;
}

.paste-actions {
  align-content: start;
  max-width: 230px;
}

.quiet {
  width: 100%;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(29, 38, 32, 0.08);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: clamp(1.55rem, 2.5vw, 2.25rem);
  line-height: 1;
  letter-spacing: 0;
}

.results-table {
  min-width: 980px;
}

.results-table td:last-child {
  min-width: 280px;
  color: #425047;
}

.formula-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 1px;
  overflow: hidden;
  color: #3f4b43;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(29, 38, 32, 0.08);
}

.formula-strip div {
  min-height: 74px;
  padding: 16px;
  background: #ffffff;
}

.test-list {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.test-list:not([hidden]) {
  margin-bottom: 16px;
}

.test-list li {
  padding: 9px 10px;
  font-size: 0.9rem;
  border-radius: 7px;
}

.test-pass {
  color: var(--good);
  background: var(--good-soft);
}

.test-fail {
  color: var(--warn);
  background: var(--warn-soft);
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .control-grid,
  .summary-grid,
  .formula-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .paste-actions {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .layout {
    width: min(100% - 24px, 1440px);
    margin-top: 14px;
  }

  .topbar {
    padding: 24px 14px 16px;
  }

  .top-actions,
  .row-actions {
    width: 100%;
  }

  .button {
    flex: 1 1 136px;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .control-grid,
  .summary-grid,
  .formula-strip {
    grid-template-columns: 1fr;
  }

  .data-table th,
  .data-table td {
    padding: 10px;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --shadow: none;
  }

  body {
    background: #ffffff;
  }

  .topbar,
  .panel,
  .metric-card,
  .formula-strip {
    box-shadow: none;
  }

  .top-actions,
  .row-actions,
  .paste-panel,
  .controls-panel {
    display: none;
  }

  .layout {
    width: 100%;
    margin: 0;
    gap: 14px;
  }

  .topbar {
    padding: 0 0 14px;
    border-bottom-color: #000000;
  }

  .panel {
    padding: 0;
    border: 0;
  }

  .table-wrap {
    overflow: visible;
    border-color: #777777;
  }

  .data-table {
    min-width: 0;
    font-size: 10pt;
  }

  .data-table th,
  .data-table td {
    padding: 6px;
    border-color: #999999;
  }

  .summary-grid,
  .formula-strip {
    grid-template-columns: repeat(4, 1fr);
  }
}
