/* USG Sizing Tool — local testing UI.
   Direction: engineering instrument. Cool steel field, Barlow for UI text,
   IBM Plex Mono for part numbers / capacities / table numerics. The one loud
   element is the flame-orange Run Sizing action; the signature element is the
   spec-plate selection card. Everything else stays quiet. */

:root {
  --ink: #1c2b33;
  --ink-soft: #51626d;
  --ground: #f4f7f8;
  --panel: #ffffff;
  --line: #dde5e9;
  --line-strong: #b9c6cd;
  --brand: #125e8a;      /* gas-flame blue: structure, links, active tab */
  --brand-tint: #e7f0f6;
  --flame: #e8622c;      /* flame orange: the Run Sizing action only */
  --flame-press: #cc4f1d;
  --ok: #1f7a45;
  --ok-tint: #e7f3ec;
  --bad: #b42318;
  --bad-tint: #fdebe9;
  --warn-tint: #fdf5e2;
  --warn-line: #d9b23e;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Barlow", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The tab switcher relies on the hidden attribute; don't let display rules
   (e.g. .split's grid) override it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
}

/* ---- header: brand row + tab rail ---- */

header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 1.5rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.9rem 0 0.65rem;
}

h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--brand);
}

.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 2px 7px;
}

nav#tabs {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
  margin-bottom: -1px;
}

nav#tabs button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: 500 0.9rem var(--sans);
  color: var(--ink-soft);
  padding: 8px 14px 9px;
  cursor: pointer;
}

nav#tabs button:hover { color: var(--ink); }

nav#tabs button.active {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--flame);
}

main { padding: 1.5rem; max-width: 1280px; margin: 0 auto; }

/* ---- sizing view: sidebar form + results ---- */

.split {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

form#inputs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.25rem 1.25rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.form-section {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-top: 1.1rem;
}

.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

form label {
  display: block;
  margin: 0.65rem 0 0.2rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
}

form input, form select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font: 400 0.9rem var(--sans);
  color: var(--ink);
  background: var(--panel);
}

form input { font-family: var(--mono); font-size: 0.85rem; }

form input:focus-visible, form select:focus-visible,
button:focus-visible, details.raw summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.unit-row { display: grid; grid-template-columns: 1fr 88px; gap: 0.5rem; }

.field-error { color: var(--bad); font-size: 0.78rem; margin-top: 3px; }

.note { font-size: 0.76rem; color: var(--ink-soft); margin-top: 3px; }

button.primary {
  margin-top: 1.25rem;
  width: 100%;
  background: var(--flame);
  color: #fff;
  border: 0;
  padding: 11px;
  border-radius: 7px;
  font: 600 0.98rem var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 120ms ease;
}

button.primary:hover { background: var(--flame-press); }

.hint { color: var(--ink-soft); padding-top: 0.5rem; }

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

@media (prefers-reduced-motion: no-preference) {
  .result-enter { animation: rise 240ms ease-out; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}

.warning-banner, .error-banner {
  border-radius: 8px;
  padding: 9px 13px;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.warning-banner { background: var(--warn-tint); border: 1px solid var(--warn-line); }
.error-banner { background: var(--bad-tint); border: 1px solid var(--bad); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem 1.1rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.card ul { margin: 0; padding-left: 1.1rem; }
.card li { margin: 0.2rem 0; font-size: 0.9rem; }

/* The spec plate: the selection rendered like a regulator nameplate. */

.plate {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--brand);
  border-radius: 10px;
  padding: 1.1rem 1.4rem 1.2rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 2rem;
}

.plate-head { grid-column: 1; }

.plate-eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}

.plate-model {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.1;
}

.plate-capacity {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  text-align: right;
}

.cap-num {
  display: block;
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--brand);
  line-height: 1.1;
}

.cap-unit {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.plate-grid {
  grid-column: 1;
  margin: 0.8rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.7rem 1.5rem;
}

.plate-grid > div { border-top: 1px solid var(--line); padding-top: 0.45rem; }

.plate-grid dt {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.plate-grid dd { margin: 1px 0 0; font-size: 0.95rem; font-weight: 600; }

.pn {
  font-family: var(--mono);
  font-size: 0.86rem;
  background: var(--brand-tint);
  color: var(--brand);
  border: 1px solid #c3d9e7;
  padding: 4px 9px;
  border-radius: 5px;
  display: inline-block;
  margin: 2px 6px 2px 0;
}

/* ---- capacity tables ---- */

.tbl-group {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 1.4rem 0 0.2rem;
}

.tbl-title { font-weight: 600; font-size: 0.92rem; margin-top: 0.8rem; }

table {
  border-collapse: collapse;
  margin: 0.45rem 0 0.9rem;
  font-size: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th, td { padding: 6px 14px; text-align: left; border: 0; }

thead th {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--ground);
  border-bottom: 1px solid var(--line-strong);
}

tbody td { font-family: var(--mono); font-size: 0.82rem; }
tbody tr:nth-child(even) td { background: #fafcfc; }
tbody tr + tr td { border-top: 1px solid var(--line); }

details.raw { margin-top: 1.25rem; }
details.raw summary { cursor: pointer; font-size: 0.84rem; color: var(--ink-soft); }
details.raw pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
  font-size: 0.74rem;
}

/* ---- test cases ---- */

.tests-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.9rem; }

.tests-toolbar button {
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 9px 18px;
  border-radius: 7px;
  font: 600 0.9rem var(--sans);
  cursor: pointer;
}

.tests-toolbar button:disabled { opacity: 0.6; cursor: default; }

#tests-summary { font-family: var(--mono); font-size: 0.9rem; font-weight: 600; }

#tests-table table { width: 100%; }
#tests-table td:first-child { width: 2rem; text-align: center; font-weight: 700; }

tr.pass td:first-child { color: var(--ok); }
tr.fail td:first-child { color: var(--bad); }
tr.fail td { background: var(--bad-tint); }
tr.detail td {
  background: var(--ground);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 8px 14px 10px 3rem;
}

.diff-expected { color: var(--ok); }
.diff-actual { color: var(--bad); }

button.ghost {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--brand);
  border-radius: 5px;
  font: 500 0.78rem var(--sans);
  padding: 4px 10px;
  cursor: pointer;
}

button.ghost:hover:not(:disabled) { background: var(--brand-tint); }
button.ghost:disabled { opacity: 0.45; cursor: default; }

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

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  form#inputs { position: static; max-height: none; }
  main { padding: 1rem; }
  header { padding: 0 1rem; }
}
