:root {
  --bg: #eef0f3;
  --card: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --line: #e5e7eb;
  --field: #f3f4f6;
  --accent: #6366f1;
  --dark: #121318;
  --dark-line: #2a2c33;
  --dark-muted: #9ca3af;
  --green: #34d399;
  --red: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 1136px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.topbar {
  position: relative;
  color: #fff;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(100deg, #0a1631 0%, #0f2b55 50%, #1b4f86 100%);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

/* Fade the grid in toward the right, as in the design */
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #0a1631 0%, rgba(15, 43, 85, 0.85) 45%, rgba(27, 79, 134, 0) 80%);
  pointer-events: none;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #38bdf8 0%, #6366f1 50%, #38bdf8 100%);
}

.topbar-inner {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-top: 22px;
  padding-bottom: 22px;
}

.brand { display: flex; flex-direction: column; gap: 4px; }

.brand-name {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.brand-full {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #cbd5e1;
}

.tag {
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.9rem;
  color: #dbe4f0;
  text-align: right;
}

/* Intro */
.intro { padding: 48px 0 36px; max-width: 620px; }

h1 {
  margin: 0 0 16px;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.lead { margin: 0; color: var(--muted); font-size: 1.02rem; }

/* Two panels */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.panel { border-radius: 18px; padding: 24px; }

.inputs { background: var(--card); }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.field {
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.grid > .field:first-child,
.grid > .field:nth-child(2) { padding-top: 0; }

.grid > .field:nth-last-child(-n+2) { border-bottom: 0; padding-bottom: 0; }

.field[hidden] { display: none; }
.full { grid-column: 1 / -1; }

.name {
  display: block;
  padding: 0;
  font-weight: 600;
  font-size: 0.88rem;
}

.opt { font-weight: 400; color: var(--muted); }

.hint { margin: 2px 0 12px; font-size: 0.78rem; color: var(--muted); }

.box {
  display: flex;
  align-items: center;
  background: var(--field);
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 0 14px;
}

.box:focus-within { border-color: var(--accent); background: #fff; }

.box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  padding: 10px 0;
}

.box input::placeholder { color: #9ca3af; font-weight: 400; }
.unit { font-size: 0.78rem; color: var(--muted); }

/* Segmented control */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--field);
  border-radius: 10px;
}

.seg label { position: relative; }

.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
}

.seg span {
  display: block;
  text-align: center;
  padding: 7px 6px;
  border-radius: 7px;
  font-size: 0.84rem;
  color: #4b5563;
  cursor: pointer;
}

.seg input:checked + span {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* Results */
.results {
  background: var(--dark);
  color: #fff;
  box-shadow: 0 20px 40px rgba(18, 19, 24, 0.18);
}

.results p { margin: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill:empty { display: none; }
.pill.pass { color: var(--green); background: rgba(52, 211, 153, 0.12); }
.pill.fail { color: var(--red); background: rgba(248, 113, 113, 0.12); }

.hero {
  margin-top: 14px !important;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 4.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero.text { font-size: 1.4rem; letter-spacing: 0; }
.hero.text .hero-unit { display: none; }
.hero-unit { font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--dark-muted); }

.out { padding: 20px 22px; }
.outputs { display: grid; gap: 14px; }
.out-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.out-title { font-weight: 700; font-size: 1rem; }
.out-sub { margin-top: 2px !important; font-size: 0.78rem; color: var(--dark-muted); }
.out .hero { font-size: 3.4rem; margin-top: 12px !important; }

.meter { position: relative; margin-top: 14px; }

.track {
  display: block;
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--dark-line);
  overflow: hidden;
}

.fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.fill.osha { background: var(--accent); }
.fill.niosh { background: var(--green); }
.fill.fail { background: var(--red); }

.tick { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 1.5px dashed #9ca3af; }
.meter-cap { display: flex; justify-content: space-between; margin-top: 6px !important; font-size: 0.72rem; color: var(--dark-muted); }

.small { font-size: 0.75rem; color: var(--dark-muted); }

.min-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 14px !important; padding-top: 12px; border-top: 1px solid var(--dark-line); }
.min { font-size: 1.2rem; font-weight: 700; line-height: 1.2; text-align: right; }

/* Light card (Real world) */
.out.light { background: #fff; color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.out.light .track { background: var(--field); }
.out.light .min-row { border-color: var(--line); }
.out.light .out-sub, .out.light .small, .out.light .meter-cap, .out.light .hero-unit { color: var(--muted); }
.out.light .pill.pass { color: #059669; background: #d1fae5; }
.out.light .pill.fail { color: #dc2626; background: #fee2e2; }

/* Program status and note */
.summary { background: #fff; border: 1px solid var(--line); padding: 16px 22px; }
.summary p { margin: 0; }
.summary .small { color: var(--muted); }

.status {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
}

.status + .status { margin-top: 12px; }

/* Footer */
.foot {
  max-width: 620px;
  padding: 36px 0 40px;
  font-size: 0.75rem;
  color: var(--muted);
}

.foot p { margin: 0 0 6px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .intro { padding: 24px 0 24px; }
  .tag { display: none; }
  .brand-name { font-size: 1.7rem; }
  .brand-full { font-size: 0.6rem; letter-spacing: 0.14em; }
  .panel { padding: 20px 16px; }
  .grid { grid-template-columns: 1fr; }
  .grid > .field:nth-child(2) { padding-top: 16px; }
  .grid > .field:nth-last-child(2) { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
  .spacer { display: none !important; }
  .seg.four { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .hero { font-size: 3.6rem; }
}

/* Legends sit oddly in fieldsets by default; float them so they line up with labels. */
legend.name { float: left; width: 100%; }
legend.name + .hint { clear: both; }

/* No spinner arrows on number inputs. */
.box input::-webkit-outer-spin-button,
.box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.box input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Disclaimer */
.foot { max-width: 720px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 24px; }
.foot-lead { color: var(--text); font-weight: 500; }
.terms { margin: 12px 0; padding-left: 18px; }
.terms li { margin-bottom: 8px; padding-left: 2px; }
.terms strong { color: var(--text); font-weight: 600; }
.copyright { margin-top: 14px !important; }

.auto-note {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
}
.auto-note[hidden] { display: none; }

/* Messages such as "Enter 2nd NRR" show at text size, not number size. */
.out .hero.text { font-size: 1.15rem; font-weight: 600; letter-spacing: 0; margin-top: 16px !important; }
.min.text { font-size: 0.9rem; font-weight: 600; }

@media (max-width: 900px) {
  .topbar .tag { display: none; }
}
