:root {
  --ink: #13221c;
  --ink-2: #2f4239;
  --muted: #5a6b63;
  --faint: #8a9a92;
  --paper: #eef3ef;
  --card: #f4f8f4;
  --card-2: #ffffff;
  --teal: #0f6b5c;
  --teal-deep: #0a433a;
  --copper: #b86a2d;
  --line: rgba(19, 34, 28, 0.12);
  --line-soft: rgba(19, 34, 28, 0.07);
  --ok: #0f7a55;
  --warn: #a8761f;
  --danger: #c24141;
  --live-bg: #141d2e;
  --live-bg-2: #1b263a;
  --live-line: #2a3854;
  --live-label: #8ba1bf;
  --live-value: #ffffff;
  --live-accent: #f5a623;
  --live-good: #2bc48a;
  --pipe: #1f9ed6;
  --pipe-soft: #a9d8ef;
  --shell: min(1380px, calc(100% - 32px));
  --radius: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  background: #e9f0ea;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 88% -10%, rgba(15, 107, 92, 0.10), transparent 55%),
    radial-gradient(760px 460px at -10% 25%, rgba(15, 107, 92, 0.08), transparent 52%),
    linear-gradient(165deg, #eef4ef 0%, #e9f0ea 55%, #e3ebe5 100%);
}

.app {
  position: relative;
  z-index: 1;
  width: var(--shell);
  margin: 0 auto;
  padding: 14px 0 32px;
}
.hidden { display: none !important; }
.muted-note { color: var(--muted); font-size: 0.8rem; margin: 0; }

/* ---------------- header ---------------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text small { color: var(--muted); font-size: 0.76rem; }
.brand-partner { color: var(--faint); font-size: 0.72rem; }

.top-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}
@media (max-width: 760px) { .top-note { display: none; } }

/* action row under the inputs */
.action-row {
  display: grid;
  grid-template-columns: 1.45fr 1fr 1fr;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.action-row .btn { width: 100%; padding: 0.55rem 0.5rem; font-size: 0.8rem; }
/* the fitting rows grow to fill the card; the buttons keep their own height */
.fittings .action-row { flex: 0 0 auto; }
.action-row .btn.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 9px;
  padding: 0.58rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:disabled { opacity: 0.65; cursor: wait; }
.btn.primary { background: var(--teal-deep); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #0d5a4d; }
.btn.ghost {
  background: var(--card-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover:not(:disabled) { background: var(--paper); }
.btn.sm { font-size: 0.72rem; padding: 0.4rem 0.7rem; border-radius: 8px; }

/* ---------------- dashboard grid ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.params   { grid-column: 1; grid-row: 1; }
.topology { grid-column: 2; grid-row: 1; }
.fittings { grid-column: 3; grid-row: 1; }
.live     { grid-column: 4; grid-row: 1; }
.summary  { grid-column: 1; grid-row: 2; }
.detail   { grid-column: 2 / -1; grid-row: 2; }
.bom      { grid-column: 1 / -1; grid-row: 3; }

@media (max-width: 1200px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .params   { grid-column: 1; grid-row: 1 / span 2; }
  .live     { grid-column: 2; grid-row: 1; }
  .topology { grid-column: 2; grid-row: 2; }
  .fittings { grid-column: 1; grid-row: 3; }
  .summary  { grid-column: 2; grid-row: 3; }
  .detail   { grid-column: 1 / -1; grid-row: 4; }
  .bom      { grid-column: 1 / -1; grid-row: 5; }
}


.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px 15px;
  min-width: 0;
}
.card-title {
  margin: 0 0 11px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}
.card-title-row .card-title { margin: 0; }
.card-subtitle {
  margin: 12px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- form fields ---------------- */
.field-grid { display: grid; gap: 9px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid + .field-grid { margin-top: 9px; }
.card > .field + .field,
.card > .field-grid + .field,
.card > .field + .field-grid { margin-top: 9px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}
.field input,
.field select {
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.46rem 0.6rem;
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6b63' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 8px;
  padding-right: 1.7rem;
}
.field input:focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.14);
}

/* value paired with its unit in a single control */
.combo {
  display: flex;
  align-items: stretch;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.combo:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.14);
}
.combo input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.combo select {
  flex: 0 0 auto;
  width: auto;
  min-width: 92px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink-2);
  font-size: 0.78rem;
}
.combo input:focus-visible,
.combo select:focus-visible { outline: none; box-shadow: none; }

/* ---------------- BOM, collapsed until requested ---------------- */
.bom-actions { display: flex; align-items: center; gap: 8px; }
.bom.is-collapsed { align-self: start; }
.bom.is-collapsed .muted-note { margin-top: -4px; }
.bom-body { margin-top: 10px; }

/* ---------------- topology ---------------- */
.params,
.topology,
.fittings { display: flex; flex-direction: column; }
/* spread the input blocks so the card fills its row instead of ending short */
.params { justify-content: space-between; }
.params .card-title,
.topology .card-title,
.fittings .card-title { flex: 0 0 auto; }

.topo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  cursor: pointer;
  padding: 2px 0 6px;
}
.topo-head { display: flex; align-items: center; gap: 9px; }
.topo + .topo { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.topo input { position: absolute; opacity: 0; pointer-events: none; }
.topo-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--faint);
  display: grid;
  place-items: center;
  transition: border-color 0.15s;
}
.topo-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  transform: scale(0);
  transition: transform 0.15s;
}
.topo input:checked ~ .topo-head .topo-dot { border-color: var(--teal); }
.topo input:checked ~ .topo-head .topo-dot::after { transform: scale(1); }
.topo input:focus-visible ~ .topo-head .topo-dot { box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.18); }
.topo-label { font-size: 0.85rem; font-weight: 500; }
.topo-art {
  display: block;
  width: 100%;
  height: auto;
  min-height: 86px;
  margin-top: 4px;
  opacity: 0.5;
  filter: saturate(0.25);
  transition: opacity 0.18s, filter 0.18s;
}
.topo input:checked ~ .topo-art { opacity: 1; filter: none; }

.topo-art .main {
  fill: none;
  stroke: var(--pipe);
  stroke-width: 7;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.topo-art .feed {
  fill: none;
  stroke: var(--pipe);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.topo-art .drops path {
  fill: none;
  stroke: var(--pipe-soft);
  stroke-width: 4;
  stroke-linecap: round;
}
.topo-art .drops circle { fill: #6b7b86; }
.topo-art .nodes rect { fill: #3f4c57; }
.topo-art .caps rect { fill: var(--pipe); }
.topo-art .tank { fill: #b9c4c0; }

/* ---------------- fittings ---------------- */
.fit {
  display: grid;
  grid-template-columns: 46px 1fr 58px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
}
.fit + .fit { border-top: 1px solid var(--line-soft); }
.fit { flex: 1 1 auto; }
.fit img {
  width: 46px;
  height: 40px;
  object-fit: contain;
}
.fit > span { font-size: 0.82rem; font-weight: 500; white-space: nowrap; }
.fit input {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.25rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fit input:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.14);
}

/* ---------------- live analysis ---------------- */
.live {
  background: var(--live-bg);
  border-color: var(--live-line);
  color: var(--live-value);
  display: flex;
  flex-direction: column;
}
.live .card-title { color: #dce6f3; }
.live-rule { border: 0; border-top: 1px solid var(--live-line); margin: 12px 0; }

.gauge { margin: 2px 0 8px; }
.gauge svg { display: block; width: 100%; height: auto; max-height: 118px; }
.gauge-track {
  fill: none;
  stroke: var(--live-bg-2);
  stroke-width: 18;
  stroke-linecap: round;
}
.gauge-fill {
  fill: none;
  stroke: var(--live-good);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-dasharray: 0 258;
  transition: stroke-dasharray 0.5s ease, stroke 0.3s ease;
}
.gauge-fill.empty { visibility: hidden; }
.gauge-fill.warn { stroke: var(--live-accent); }
.gauge-fill.over { stroke: #e5634d; }

.live .stat-label {
  margin: 0 0 2px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--live-label);
  text-align: center;
}
.stat-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--live-value);
}
.stat-value.accent { color: var(--live-accent); }
.live .stat-sub {
  margin: 3px 0 0;
  font-size: 0.7rem;
  color: var(--live-label);
  text-align: center;
}
.live .stat-sub.bad { color: #f0a08f; font-weight: 600; }
.live .stat-sub.ok { color: var(--live-good); }

.size-pick {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.size-pick label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--live-label);
}
.size-pick select {
  width: 100%;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--live-value);
  background-color: var(--live-bg-2);
  border: 1px solid var(--live-line);
  border-radius: 8px;
  padding: 0.4rem 1.6rem 0.4rem 0.55rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238ba1bf' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 8px;
}
.size-pick select:disabled { opacity: 0.45; }
.size-pick select:focus-visible {
  outline: none;
  border-color: var(--live-accent);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.2);
}
.size-reset {
  grid-column: 1 / -1;
  justify-self: start;
  font: inherit;
  font-size: 0.68rem;
  color: var(--live-accent);
  background: none;
  border: 0;
  padding: 2px 0 0;
  cursor: pointer;
  text-decoration: underline;
}

.live-list { margin: 0; display: grid; gap: 0; }
.live-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--live-line);
}
.live-list > div:last-child { border-bottom: 0; }
.live-list dt { font-size: 0.72rem; color: var(--live-label); }
.live-list dd {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.live-list dd.good { color: var(--live-good); }
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--live-good);
  background: rgba(43, 196, 138, 0.14);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}
.live-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.live-badge.busy { color: var(--live-accent); background: rgba(245, 166, 35, 0.16); }
.live-badge.busy::before { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }


.stat-label {
  margin: 0 0 1px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-sub { margin: -7px 0 10px; font-size: 0.72rem; color: var(--muted); }
.stat-sub.ok { color: var(--ok); }
.stat-sub.bad { color: var(--danger); font-weight: 600; }

.alert {
  margin-top: auto;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: rgba(194, 65, 65, 0.1);
  color: #8f2f2f;
  font-size: 0.8rem;
}

/* ---------------- calculation summary ---------------- */
.summary { display: flex; flex-direction: column; }
.sum-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.sum-list > div { flex: 1 1 auto; align-items: center; }
.sum-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.sum-list > div:last-child { border-bottom: 0; }
.sum-list dt { font-size: 0.78rem; color: var(--ink-2); max-width: 58%; }
.sum-list dd {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------- bill of materials ---------------- */
.exports { display: flex; gap: 6px; flex-wrap: wrap; }
.bom-body { margin-top: 2px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.82rem;
  vertical-align: top;
}
tbody tr:hover td { background: rgba(255, 255, 255, 0.6); }
.right { text-align: right; }
.bom-table .grouprow td {
  background: rgba(19, 34, 28, 0.04);
  padding: 0.45rem 0.6rem;
  border-top: 1px solid var(--line);
}
.bom-table .grouprow b {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-deep);
}
.bom-table .grouprow .cnt {
  float: right;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.drv {
  display: inline-block;
  font-size: 0.56rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 0.45rem;
  vertical-align: 1px;
}
.drv.s { color: var(--teal); background: rgba(15, 107, 92, 0.12); }
.drv.i { color: var(--copper); background: rgba(184, 106, 45, 0.14); }
.bom-table .it { color: var(--faint); font-size: 0.72rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bom-table .code { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bom-table .desc b { font-weight: 500; }
.bom-table .desc small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 1px; }
.bom-table .sizecol { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bom-table .qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.bom-table .unit { color: var(--muted); font-size: 0.74rem; }
.bom-table .why { color: var(--muted); font-size: 0.72rem; line-height: 1.45; max-width: 26ch; }
.bom-table .sp { color: var(--copper); font-weight: 600; }
.bom-table tfoot td {
  padding: 0.6rem;
  font-weight: 600;
  font-size: 0.8rem;
  background: rgba(19, 34, 28, 0.04);
  border-top: 2px solid var(--line);
}
.bom-flags {
  margin: 0 0 0.6rem;
  padding: 0.55rem 0.8rem 0.55rem 1.7rem;
  background: rgba(184, 106, 45, 0.09);
  border-radius: 8px;
  color: var(--copper);
  font-size: 0.74rem;
}
.src { padding: 0.65rem 0.85rem; border-radius: 0 10px 10px 0; margin-bottom: 0.6rem; background: rgba(255, 255, 255, 0.7); }
.src.a { border-left: 3px solid var(--teal); }
.src.b { border-left: 3px solid var(--copper); }
.src-cap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-bottom: 0.5rem; }
.src-cap b { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; }
.src.a .src-cap b { color: var(--teal); }
.src.b .src-cap b { color: var(--copper); }
.src-cap span { font-size: 0.72rem; color: var(--muted); }
.locked { display: flex; flex-wrap: wrap; gap: 0.45rem 1.4rem; }
.locked div span {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.locked div b { font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 0.5rem; }
.g-grid .field span { font-size: 0.68rem; color: var(--muted); }
.g-grid .field select { padding: 0.4rem 1.7rem 0.4rem 0.5rem; font-size: 0.78rem; }
.bom-note { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.55; }
.bom-note strong { color: var(--ink); }
.bom-note .k-s { color: var(--teal); font-weight: 600; }
.bom-note .k-i { color: var(--copper); font-weight: 600; }
.bom-empty { padding: 1.4rem 0; color: var(--muted); font-size: 0.82rem; }

/* ---------------- detail: comparison + charts ---------------- */
.detail { display: flex; flex-direction: column; }
.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 12px;
  align-items: start;
  flex: 1 1 auto;
}
.detail-grid > * { min-width: 0; }
.chart-box canvas { max-width: 100%; }
.detail h4 {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chart-box { position: relative; height: 148px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.al { background: #0ea5e9; }
.dot.ns { background: #cbd5e1; }
.dot.rs { background: var(--danger); }
.cost-ok { color: var(--ok); font-weight: 600; }

/* ---------------- footer ---------------- */
.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  color: var(--faint);
  font-size: 0.75rem;
}
.foot p { margin: 0; }

/* ---------------- embed ---------------- */
html.is-embed,
html.is-embed body { min-height: 0; height: auto; overflow: hidden; background: #e9f0ea; }
html.is-embed .atmosphere { position: absolute; }
html.is-embed .app { width: 100%; max-width: none; margin: 0; padding: 14px 16px 18px; }
html.is-embed .foot { display: none; }
html.is-embed .top { margin-bottom: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .no-print { display: none !important; }
}

/* comparison table sits in a narrow column - tighten so it never scrolls */
.detail table { font-size: 0.72rem; }
.detail thead th { padding: 0.4rem 0.35rem; font-size: 0.56rem; letter-spacing: 0.07em; }
.detail tbody td { padding: 0.4rem 0.35rem; font-size: 0.72rem; }
.detail .dot { width: 7px; height: 7px; margin-right: 5px; }

/* ============================================================
   Responsive overrides - kept last so they win the cascade
   ============================================================ */
@media (max-width: 1200px) {
  /* the parameters card spans two rows in this layout, so spreading its
     fields would tear gaping holes between them */
  .params { justify-content: flex-start; }
}

/* ---------------- tablet ---------------- */
@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid > :first-child { grid-column: 1 / -1; }
}

/* ---------------- phone ---------------- */
@media (max-width: 760px) {
  :root { --shell: calc(100% - 20px); }
  .app { padding: 10px 0 24px; }

  .grid { grid-template-columns: 1fr; gap: 10px; }
  .grid > .card {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  /* inputs first, then the numbers they produce */
  .params   { order: 1; }
  .topology { order: 2; }
  .fittings { order: 3; }
  .live     { order: 4; }
  .summary  { order: 5; }
  .detail   { order: 6; }
  .bom      { order: 7; }

  .top { gap: 10px; margin-bottom: 10px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text strong { font-size: 1.02rem; }
  .brand-text small { font-size: 0.7rem; }
  .brand-partner { display: none; }

  .card { padding: 12px 13px 14px; }

  /* 16px keeps iOS from zooming the page on focus */
  .field input,
  .field select,
  .combo input,
  .combo select,
  .fit input,
  .size-pick select,
  .g-grid .field select { font-size: 16px; }
  .field input, .field select { padding: 0.55rem 0.65rem; }
  .combo select { min-width: 84px; padding-right: 1.5rem; }

  .action-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .action-row .btn { min-height: 44px; font-size: 0.86rem; }

  .fit { grid-template-columns: 44px 1fr 68px; gap: 10px; padding: 7px 0; }
  .fit img { width: 44px; height: 38px; }
  .fit > span { font-size: 0.86rem; }
  .fit input { min-height: 40px; }

  .topo { padding: 4px 0 8px; }
  .topo-art { max-height: 130px; margin-inline: auto; }
  .topo-label { font-size: 0.9rem; }

  .gauge svg { max-height: 104px; }
  .stat-value { font-size: 1.5rem; }
  .size-pick { grid-template-columns: 1fr; gap: 5px; }
  .size-pick label { letter-spacing: 0.08em; }

  .sum-list dt, .live-list dt { font-size: 0.8rem; }
  .sum-list dd, .live-list dd { font-size: 0.84rem; }

  .detail-grid { grid-template-columns: 1fr; gap: 14px; }
  .detail-grid > :first-child { grid-column: auto; }
  .chart-box { height: 200px; }
  .detail table { font-size: 0.8rem; }
  .detail tbody td { padding: 0.5rem 0.4rem; font-size: 0.8rem; }
  .detail thead th { font-size: 0.6rem; padding: 0.45rem 0.4rem; }

  /* the take-off is wide by nature: let it scroll inside its own card */
  .bom-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .bom-table table { min-width: 560px; }
  .g-grid { grid-template-columns: 1fr 1fr; }
  .locked { gap: 0.4rem 1rem; }
  .card-title-row { flex-wrap: wrap; }

  .foot { font-size: 0.7rem; }
}

/* ---------------- small phone ---------------- */
@media (max-width: 480px) {
  .field-grid.two { grid-template-columns: 1fr; }
  .action-row { grid-template-columns: 1fr 1fr; }
  .action-row .btn:first-child { grid-column: 1 / -1; }

  /* drop the two widest BOM columns so the rest fits the screen */
  .bom-table table { min-width: 0; }
  .bom-table thead th:nth-child(1),
  .bom-table thead th:nth-child(6),
  .bom-table thead th:nth-child(7),
  .bom-table tbody tr:not(.grouprow) td:nth-child(1),
  .bom-table tbody tr:not(.grouprow) td:nth-child(6),
  .bom-table tbody tr:not(.grouprow) td:nth-child(7),
  .bom-table tfoot td:nth-child(3),
  .bom-table tfoot td:nth-child(4) { display: none; }
  .bom-table .code { font-size: 0.74rem; }
  .bom-table td { padding: 0.45rem 0.35rem; }
  .g-grid { grid-template-columns: 1fr; }
  .exports { width: 100%; }
  .exports .btn { flex: 1; }
}
