
:root {
  color-scheme: light;
  --bg: #f7f9f7;
  --surface: #ffffff;
  --surface-2: #f8fbf9;
  --text: #162019;
  --muted: #66736a;
  --line: #d8e2db;
  --strong-line: #9dafa3;
  --accent: #245f3d;
  --accent-dark: #17452d;
  --accent-text: #ffffff;
  --action: #245f3d;
  --action-hover: #17452d;
  --soft: #eef4f0;
  --table-head: #f1f6f2;
  --equation-bg: #f4f8f5;
  --success-bg: #eef7f1;
  --success-line: #8fbea0;
  --warning-bg: #fff7e8;
  --warning-line: #d8ad62;
  --error-bg: #fff0f0;
  --error-line: #d89292;
  --chart-grid: #e0e8e2;
  --chart-axis: #718078;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080b09;
  --surface: #0f1511;
  --surface-2: #141b16;
  --text: #edf2ee;
  --muted: #a2afa5;
  --line: #28352d;
  --strong-line: #526259;
  --accent: #2f7a4f;
  --accent-dark: #4c9a68;
  --accent-text: #ffffff;
  --action: #245f3d;
  --action-hover: #2f764d;
  --soft: #172019;
  --table-head: #18211b;
  --equation-bg: #151f18;
  --success-bg: #14251a;
  --success-line: #457759;
  --warning-bg: #2d2618;
  --warning-line: #806a3a;
  --error-bg: #2d1b1b;
  --error-line: #835353;
  --chart-grid: #27352c;
  --chart-axis: #8ca096;
}


* { 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(--text);
  line-height: 1.55;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  padding: 22px 0 18px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}

h1, h2, h3 { line-height: 1.2; }
h1 { margin: 0; font-size: 2rem; letter-spacing: -0.03em; }
h2 { margin-top: 0; font-size: 1.5rem; }
h3 { margin-bottom: 10px; font-size: 1.02rem; }

.version, .muted, .header-note { color: var(--muted); }
.version { margin: 2px 0 0; font-size: .88rem; }
.header-note { font-size: .95rem; }

main { padding: 28px 0 50px; }

.intro {
  max-width: none;
  width: 100%;
  margin-bottom: 24px;
}
.intro p { margin: 0 0 8px; }

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 24px 0 20px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px 9px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.tab-button:hover { color: var(--text); }
.tab-button.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}
.tab-panel.active { display: block; }

.lead {
  margin-top: -4px;
  color: var(--muted);
  max-width: none;
  width: 100%;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, .9fr);
  gap: 26px;
}
.compact-gap { margin-top: 18px; }

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.compact-table { width: fit-content; max-width: 100%; }
.compact-table.narrow { min-width: 360px; }

table {
  border-collapse: collapse;
  font-size: .88rem;
}
th, td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th {
  background: var(--success-bg);
  font-weight: 650;
}
tr:last-child td { border-bottom: 0; }

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

button, a.secondary-button {
  font: inherit;
}

.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.primary-button {
  border: 1px solid var(--action-hover);
  background: var(--action);
  color: var(--accent-text);
  font-weight: 650;
}
.primary-button:hover { background: var(--action-hover); }

.secondary-button {
  border: 1px solid var(--strong-line);
  background: var(--surface);
  color: var(--text);
}
.secondary-button:hover { background: var(--soft); }
.secondary-button.subtle { color: var(--muted); }

.upload-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  background: var(--soft);
  border-radius: 8px;
}

.file-field label, .form-grid label, .plot-controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 600;
  font-size: .9rem;
}

input, select {
  width: 100%;
  min-height: 39px;
  padding: 7px 9px;
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.status {
  margin: 18px 0;
  padding: 11px 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.status.good { background: var(--success-bg); border-color: var(--success-line); }
.status.warning { background: var(--warning-bg); border-color: var(--warning-line); }
.status.error { background: var(--error-bg); border-color: var(--error-line); }

.hidden { display: none !important; }

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 26px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px;
  background: var(--surface-2);
}
.metric-label {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  margin-bottom: 4px;
}
.metric strong { font-size: 1.2rem; }

.plot-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 10px;
}
.plot-controls label { width: 190px; }

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}
.chart-card h3 { margin: 0 0 8px; }
#result-chart { width: 100%; height: auto; min-height: 360px; }

.result-table {
  max-height: 520px;
  margin-top: 10px;
}
.result-table table { width: max-content; min-width: 100%; }

.prose { max-width: none; }
.prose code {
  background: var(--soft);
  padding: 2px 5px;
  border-radius: 4px;
}
.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 18px 0 26px;
}
.flow span:nth-child(odd) {
  padding: 6px 9px;
  background: var(--soft);
  border-radius: 5px;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  padding: 18px 0;
  font-size: .86rem;
}


.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.theme-control {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.theme-button {
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
}

.theme-button:hover {
  color: var(--text);
  background: var(--surface);
}

.theme-button.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.methods-page {
  max-width: none;
}

.methods-page h3 {
  margin-top: 30px;
  font-size: 1.1rem;
}

.methods-page h4 {
  margin: 20px 0 8px;
  font-size: .98rem;
}

.method-step {
  margin-top: 26px;
  padding-top: 2px;
}

.methods-table {
  width: 100%;
}

.methods-table table {
  width: 100%;
}

.methods-table th,
.methods-table td {
  white-space: normal;
  text-align: left;
  vertical-align: top;
}

.methods-table th:nth-child(2),
.methods-table td:nth-child(2) {
  white-space: nowrap;
  width: 120px;
}

.constants-table th:nth-child(2),
.constants-table td:nth-child(2) {
  width: auto;
  white-space: nowrap;
}

.equation {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0;
  padding: 9px 12px;
  border-left: 3px solid var(--accent);
  background: var(--equation-bg);
  border-radius: 0 5px 5px 0;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif;
  font-size: 1.04rem;
}

.co2-box {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

a {
  color: var(--accent-dark);
}

input,
select {
  color-scheme: inherit;
}

@media (max-width: 820px) {
  .header-inner { align-items: flex-start; flex-direction: column; }
  .header-actions { align-items: flex-start; }
  .two-column, .form-grid, .upload-card, .metric-grid { grid-template-columns: 1fr; }
  .header-note { display: none; }
  .tab-panel { padding: 18px; }
}


.example-block {
  margin-top: 20px;
}

.example-block + .example-block {
  margin-top: 26px;
}

.full-example-table {
  width: 100%;
}

.full-example-table table {
  min-width: max-content;
}

.calibration-example {
  width: fit-content;
  min-width: 540px;
  max-width: 100%;
}

.math-display {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-width: min(420px, 100%);
  padding: 12px 18px;
}

.math-display math {
  font-size: 1.18rem;
}

@media (max-width: 640px) {
  .math-display {
    min-width: 100%;
  }
}


.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(360px, 44vw);
  height: auto;
  max-height: 92px;
  object-fit: contain;
  object-position: left center;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
}

.brand-meta .version {
  margin: 0;
  font-weight: 650;
  color: var(--accent-dark);
}

.brand-meta .header-note {
  font-size: .86rem;
}

.example-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.calibration-block {
  max-width: 680px;
}

.calibration-example {
  width: auto;
  min-width: 0;
  max-width: 100%;
  display: inline-block;
}

.calibration-example table {
  width: auto;
  min-width: 0;
}

.calibration-example th,
.calibration-example td {
  text-align: left;
}

.calibration-example th:nth-child(3),
.calibration-example th:nth-child(4),
.calibration-example td:nth-child(3),
.calibration-example td:nth-child(4) {
  text-align: right;
}

.usage-metric {
  width: min(320px, 100%);
  margin: 18px 0 28px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.usage-metric .metric-label {
  display: block;
  margin-bottom: 4px;
}

.usage-metric strong {
  display: block;
  color: var(--accent-dark);
  font-size: 2rem;
  line-height: 1.1;
}

@media (max-width: 760px) {
  .brand-block {
    width: 100%;
    align-items: flex-start;
  }

  .brand-logo {
    width: min(300px, 62vw);
  }

  .brand-meta {
    min-width: 0;
  }
}


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

.brand-text {
  flex: 0 0 auto;
}

.brand-text h1 {
  white-space: nowrap;
}

.brand-logo {
  width: 250px;
  max-height: 78px;
  object-fit: contain;
  object-position: left center;
}

.download-results-row {
  display: flex;
  justify-content: center;
  margin: 18px 0 24px;
}

.download-results-button {
  min-width: 230px;
  font-weight: 700;
}

.calibration-plot-section {
  margin: 26px 0 30px;
}

.prose p,
.prose li {
  max-width: none;
}

.method-step p,
.method-step li {
  max-width: none;
}

@media (max-width: 760px) {
  .brand-block {
    align-items: flex-start;
    gap: 12px;
  }

  .brand-logo {
    width: 180px;
  }
}


.tool-example-box {
  margin: 18px 0 24px;
  padding: 18px 20px;
  border-radius: 9px;
  background: var(--action);
  color: #ffffff;
}

.tool-example-box h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.tool-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.tool-example-grid p {
  margin: 5px 0 0;
  color: rgba(255,255,255,.92);
}

.contact-note {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.tab-panel > p,
.tab-panel > .lead {
  max-width: none;
}

.prose {
  width: 100%;
}

@media (max-width: 760px) {
  .tool-example-grid {
    grid-template-columns: 1fr;
  }
}


.intro p,
.tool-example-box p,
.tab-panel p,
.tab-panel .lead,
.prose p,
.method-step p {
  max-width: none;
}

.plot-option-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plot-checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 39px;
  padding: 7px 9px;
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
}

.plot-checkbox:hover {
  border-color: var(--accent);
}

.plot-checkbox input {
  width: 17px;
  min-height: 17px;
  height: 17px;
  flex: 0 0 17px;
  padding: 0;
  margin: 0;
  accent-color: var(--action);
}

.metrics-connect-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex-wrap: wrap;
  margin: 18px 0 28px;
}

.metrics-connect-row .usage-metric {
  margin: 0;
}

.connect-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 250px;
  padding: 17px 20px;
  border: 1px solid var(--success-line);
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--text);
  text-decoration: none;
}

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

.connect-card span {
  color: var(--muted);
  font-size: .83rem;
}

.connect-card strong {
  margin-top: 2px;
  color: var(--accent-dark);
  font-size: 1.2rem;
}

.connect-card small {
  margin-top: 2px;
  color: var(--muted);
}


.metrics-connect-row {
  align-items: stretch;
}

.metrics-connect-row .usage-metric,
.metrics-connect-row .connect-card {
  box-sizing: border-box;
  flex: 0 1 320px;
  width: 320px;
  min-width: 0;
  min-height: 108px;
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--success-line);
  border-radius: 8px;
  background: var(--success-bg);
}

.metrics-connect-row .usage-metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metrics-connect-row .connect-card {
  justify-content: center;
}

@media (max-width: 980px) {
  .upload-card {
    grid-template-columns: 1fr 1fr;
  }

  .metrics-connect-row .usage-metric,
  .metrics-connect-row .connect-card {
    flex: 1 1 280px;
    width: auto;
  }
}

@media (max-width: 620px) {
  .upload-card {
    grid-template-columns: 1fr;
  }
}


/* Keep the Excel plot option visually aligned with the file inputs. */
.plot-option-field > label:first-child {
  display: block;
  margin: 0;
  font-weight: 600;
  font-size: .9rem;
}

.plot-option-field .plot-checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  height: 39px;
  min-height: 39px;
  max-height: 39px;
  padding: 7px 9px;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--strong-line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1;
}

.plot-option-field .plot-checkbox input {
  width: 17px;
  min-width: 17px;
  max-width: 17px;
  height: 17px;
  min-height: 17px;
  max-height: 17px;
  padding: 0;
  margin: 0;
  flex: 0 0 17px;
}

.plot-option-field .plot-checkbox span {
  display: inline;
  white-space: nowrap;
}
