:root {
  --bg: #F5F7F9;
  --fg: #22313F;
  --body-fg: #22313F;
  --muted: #6C7A89;
  --accent: #16384C;
  --accent-hover: #0E2735;
  --accent-interactive: #2F6E8C;
  --accent-interactive-hover: #1F5A75;
  --accent-light: #EDF3F7;
  --border: #D6E0E8;
  --input-bg: #FBFCFD;
  --input-border: #C5D2DD;
  --warn-bg: #FFF4E8;
  --warn-border: #E8C08C;
  --water: #B7D4E2;
  --card: #FFFFFF;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(22, 56, 76, 0.08), 0 2px 6px rgba(22, 56, 76, 0.04);
  --inset-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.04);
  --gap: 1rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
}

.container { max-width: 1040px; margin: 0 auto; padding: 0 1.2rem; }

.site-header {
  background: var(--accent);
  color: #fff;
  padding: 1.5rem 0;
  border-bottom: 3px solid var(--accent-interactive);
}
.site-title {
  margin: 0;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 26px;
  font-weight: 600;
  color: #fff;
}
.site-tagline {
  margin: 0.3rem 0 0;
  color: #C9D8E2;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.95rem;
}

main.container { padding-top: 1.5rem; padding-bottom: 2rem; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  background: var(--card);
  padding: 0.4rem 0;
}
.site-footer p { margin: 0.7rem 0; color: var(--muted); font-size: 0.88rem; }
.site-footer .brand-line {
  text-align: right;
  color: #AEB7BF;
  font-size: 0.82rem;
  margin-top: 0.2rem;
}
.site-footer .brand-line strong { color: #6C7A89; font-weight: 600; }

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.calc-layout { display: grid; gap: var(--gap); }

/* ---------- card / section ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--inset-shadow);
  padding: 1.2rem 1.3rem;
}
form.card { background: var(--input-bg); }

.intro-heading {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-size: 1.4rem;
}
.intro p { margin: 0.5rem 0; }

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 0.8rem;
  margin: 0 0 1rem;
  background: var(--card);
}
.section:last-of-type { margin-bottom: 0.4rem; }
.section-title {
  font-weight: 600;
  color: var(--accent);
  padding: 0 0.4rem;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.section-title-text { line-height: 1.2; }
.section-desc { margin: 0.2rem 0 0.7rem; }

/* ---------- definition diagram ---------- */

.definition-diagram {
  margin: 0.4rem 0 1rem;
  padding: 0.8rem 0.4rem 0.4rem;
  background: #FCFDFE;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.definition-diagram object,
.definition-diagram img {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 0 auto;
}
.definition-diagram figcaption {
  font-size: 0.85rem;
  margin: 0.5rem 0.5rem 0.2rem;
  line-height: 1.4;
}
.definition-diagram .legend {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
}
.definition-diagram .legend strong { color: var(--accent); }

/* ---------- fields ---------- */

.section-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem 1.1rem;
  margin-top: 0.4rem;
}
.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field-label {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}
.field-unit { color: var(--muted); font-weight: 400; font-size: 0.88rem; }
.req { color: #C45A39; margin-left: 0.15rem; }

input[type="text"],
input[type="number"],
select {
  font-family: inherit;
  font-size: 0.98rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--fg);
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-interactive);
  box-shadow: 0 0 0 3px rgba(47, 110, 140, 0.15);
}

.field-help { font-size: 0.82rem; line-height: 1.3; }
.notes-refs { background: var(--accent-light); border-left: 3px solid var(--accent); }
.notes-refs h4 { margin-top: 0; }
.ref-list { padding-left: 1.5rem; margin: 0.25rem 0 0; }
.ref-list li { font-size: 0.85rem; line-height: 1.4; margin-bottom: 0.4rem; }
.ref-list a { word-break: break-all; font-family: "Courier New", Courier, monospace; font-size: 0.78rem; }
.field-preview {
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--accent-interactive);
  font-family: "Courier New", Courier, monospace;
  background: var(--accent-light);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius);
  display: inline-block;
  width: fit-content;
}

.radio-group {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.radio-group legend.field-label { padding: 0; }
.radio-option {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---------- logo card ---------- */

.logo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 0.9rem;
  margin: 0 0 1rem;
  background: var(--card);
}
.logo-card h3 {
  margin: 0 0 0.25rem;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 18px;
  color: var(--accent);
}
.logo-card .section-desc { margin: 0 0 0.6rem; }
.logo-form { display: flex; gap: 0.6rem; align-items: center; margin: 0.6rem 0; flex-wrap: wrap; }
.logo-status { min-height: 2rem; }
.logo-preview { display: flex; align-items: center; gap: 0.8rem; margin: 0.4rem 0; }
.logo-preview img {
  max-height: 3.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  padding: 2px;
}
.logo-preview figcaption { font-size: 0.85rem; color: var(--muted); }

/* ---------- buttons ---------- */

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--accent-light); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent-interactive);
  cursor: pointer;
  padding: 0;
  font-size: 0.88rem;
  text-decoration: underline;
}
.btn-link:hover { color: var(--accent-interactive-hover); }

/* ---------- alerts / notes ---------- */

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  margin: 0 0 1rem;
}
.alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: #8B4F1B;
}
.alert h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.alert ul { margin: 0; padding-left: 1.3rem; }

.notes {
  margin-top: 0.9rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #FCFDFE;
}
.notes h4 { margin: 0 0 0.3rem; color: var(--accent); font-size: 1rem; }
.notes ul { margin: 0; padding-left: 1.2rem; }
.notes li { margin: 0.15rem 0; }
.notes-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}
.notes-warn h4 { color: #8B4F1B; }

/* ---------- results ---------- */

.results-card {
  margin-top: 0.4rem;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.results-header h3 {
  margin: 0;
  color: var(--accent);
  font-size: 1.2rem;
}
.report-form { margin: 0; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 0.8rem;
  background: #fff;
}
.results-table caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  padding: 0.2rem 0 0.4rem;
  font-size: 0.95rem;
}
.results-table th,
.results-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  vertical-align: middle;
}
.results-table th {
  background: var(--accent-light);
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
}
.results-table tbody tr:nth-child(even) td { background: #FAFCFD; }

/* Slope-mode results: the headline computed slope gets a soft callout. */
.results-table.solved-slope th[scope="row"] {
  background: #E5EEF4;
}

/* ---------- FAQ details/summary ---------- */

.sample-calc { margin-top: 1rem; }
.sample-calc-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  font-size: 1.05rem;
  list-style: none;
}
.sample-calc-summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.15s ease;
  font-size: 0.85em;
}
.sample-calc[open] .sample-calc-summary::before { transform: rotate(90deg); }
.sample-calc-body { margin-top: 0.8rem; }
.sample-calc-body h3 {
  margin: 0.8rem 0 0.3rem;
  color: var(--accent);
  font-size: 1.05rem;
}
.sample-eq {
  background: var(--accent-light);
  border-left: 3px solid var(--accent-interactive);
  padding: 0.4rem 0.7rem;
  margin: 0.4rem 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95rem;
}

/* ---------- responsive tweaks ---------- */

@media (max-width: 600px) {
  .site-title { font-size: 22px; }
  .results-header { flex-direction: column; align-items: flex-start; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
}
