:root {
  --bg-start: #f4f8ff;
  --bg-end: #eaf6ef;
  --surface: #ffffff;
  --surface-border: #d7dee9;
  --text-main: #102038;
  --text-muted: #4d5e77;
  --accent: #0a4abf;
  --accent-strong: #07358a;
  --warn: #9a5a00;
  --warn-bg: #fff5df;
  --pass-bg: #d8f4e3;
  --caution-bg: #ffeac7;
  --fail-bg: #ffd8d8;
  --unsupported-bg: #e7ecf4;
  --error-bg: #ffe4ea;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow: 0 14px 36px rgba(24, 43, 77, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: linear-gradient(145deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
}

.page-shell {
  width: min(980px, 92vw);
  margin: 40px auto 64px;
  display: grid;
  gap: 20px;
}

.result-shell {
  width: min(1040px, 94vw);
}

.result-shell-loading {
  visibility: hidden;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 32px;
}

.section-stack {
  display: grid;
  gap: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h4 {
  margin: 0;
  line-height: 1.2;
  font-size: 0.95rem;
}

h1 {
  font-size: clamp(1.65rem, 2.5vw, 2.2rem);
  letter-spacing: 0.01em;
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0;
}

.lead {
  color: var(--text-muted);
  max-width: 70ch;
  line-height: 1.5;
}

.identity-line {
  font-weight: 600;
  color: #153766;
}

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

.small {
  font-size: 0.9rem;
}

.muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.coverage-banner {
  background: #e8f0ff;
  border: 1px solid #c9dafd;
  color: #1f3d75;
  padding: 10px 12px;
  border-radius: var(--radius-md);
}

.form-grid {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-main);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text-main);
  border-radius: 10px;
  border: 1px solid #bfcbe0;
  padding: 10px 12px;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus,
.button:focus {
  outline: 3px solid #9cc0ff;
  outline-offset: 1px;
}

.form-banner {
  border-radius: var(--radius-md);
  border: 1px solid #e3a4a4;
  background: #ffe9e9;
  color: #7a1b1b;
  padding: 10px 12px;
}

.field-error {
  color: #a42323;
  font-size: 0.86rem;
  font-weight: 500;
}

.assumption-review {
  border-radius: var(--radius-md);
  border: 1px solid #d4dded;
  background: #f5f8fd;
  padding: 14px;
}

.warning-note {
  border-radius: 10px;
  border: 1px solid #ebb56a;
  background: var(--warn-bg);
  color: #744201;
  padding: 8px 10px;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.plain-list a {
  color: #0f3b88;
}

.assumption-groups {
  display: grid;
  gap: 12px;
}

.assumption-group {
  border: 1px solid #d4deee;
  border-radius: var(--radius-md);
  background: #f8fbff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.button {
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.button-primary:hover {
  filter: brightness(1.04);
}

.button-ghost {
  border-color: #b5c5df;
  background: #fff;
  color: #17325d;
}

.state-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.state-pass {
  background: var(--pass-bg);
  color: #1a5f36;
}

.state-caution {
  background: var(--caution-bg);
  color: #7d5007;
}

.state-fail {
  background: var(--fail-bg);
  color: #8e1f1f;
}

.state-unsupported {
  background: var(--unsupported-bg);
  color: #243f5f;
}

.state-error {
  background: var(--error-bg);
  color: #95214b;
}

.source-details {
  border: 1px solid #d4ddeb;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: #f8faff;
}

#limitingFactorCard,
#confidenceCard,
#availabilityCard {
  min-height: 112px;
}

/* Limiting Factor UI */
.lf-label {
  font-weight: 600;
}

.lf-constraints {
  display: grid;
  gap: 6px;
}

.lf-constraint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #d4deee;
  background: #f8fbff;
  gap: 12px;
}

.lf-constraint-row.lf-binding.lf-positive {
  border-color: #8fd0b0;
  background: #edfaf3;
}

.lf-constraint-row.lf-binding.lf-negative {
  border-color: #e8a0a0;
  background: #fff0f0;
}

.lf-constraint-name {
  flex: 1;
  font-size: 0.9rem;
}

.lf-constraint-name.lf-binding-name {
  font-weight: 700;
}

.lf-binding-chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.lf-binding-chip.lf-positive {
  background: var(--pass-bg);
  color: #1a5f36;
}

.lf-binding-chip.lf-negative {
  background: var(--fail-bg);
  color: #8e1f1f;
}

.lf-margin {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}

.lf-margin.lf-positive {
  color: #1a5f36;
}

.lf-margin.lf-negative {
  color: #8e1f1f;
}

.lf-margin.lf-zero {
  color: var(--text-muted);
}

.lf-proof {
  border-top: 1px solid #d4deee;
  padding-top: 10px;
  font-size: 0.88rem;
  display: grid;
  gap: 4px;
}

.lf-proof-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.lf-proof a {
  color: #0f3b88;
  font-weight: 500;
  word-break: break-word;
}

@media (max-width: 740px) {
  .page-shell {
    width: min(100%, 95vw);
    margin-top: 20px;
    margin-bottom: 32px;
    gap: 14px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .action-row,
  .form-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
