:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-strong: #172026;
  --surface-soft: #e8eef2;
  --ink: #172026;
  --muted: #69777f;
  --line: #d8e0e5;
  --accent: #cf2637;
  --accent-strong: #a81727;
  --blue: #1f6f8f;
  --green: #18764f;
  --amber: #9b6415;
  --shadow: 0 18px 50px rgba(23, 32, 38, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(207, 38, 55, 0.08), transparent 26rem),
    linear-gradient(45deg, rgba(31, 111, 143, 0.09), transparent 28rem),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto 20px;
  padding: 18px 22px;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 154px;
  height: 48px;
  padding: 9px 14px;
  background: #fff;
  border-radius: 6px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: auto;
}

.brandline {
  margin: 0 0 3px;
  color: #ffe8eb;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 8px;
  padding: 0 15px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 750;
}

.primary-button {
  color: var(--accent);
  background: #fff;
}

.primary-button:hover {
  background: #ffe8eb;
}

.ghost-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(290px, 390px) minmax(420px, 1fr) minmax(360px, 460px);
  gap: 18px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(216, 224, 229, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.panel-heading p,
.quote-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-pill,
.quote-ref,
#tableContext {
  flex: 0 0 auto;
  padding: 7px 9px;
  color: var(--accent);
  background: #fde8eb;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.method-grid {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.pricing-fieldset legend,
.metric-label {
  color: #40505a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(207, 38, 55, 0.14);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 44px;
  overflow: hidden;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.input-with-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(207, 38, 55, 0.14);
}

.input-with-unit input {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.input-with-unit span {
  padding: 0 12px;
  color: var(--muted);
}

.currency-input {
  grid-template-columns: auto minmax(0, 1fr);
}

.pricing-fieldset {
  margin: 4px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.pricing-fieldset legend {
  padding: 0 6px;
}

.method-note {
  padding: 11px 12px;
  color: #40505a;
  background: #fff0f2;
  border: 1px solid #f4cbd1;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.outlet-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px auto;
  gap: 10px;
  align-items: end;
}

.outlet-qty-field input {
  text-align: center;
}

.add-button {
  min-height: 44px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
}

.add-button:hover {
  background: var(--accent-strong);
}

.outlet-list {
  display: grid;
  gap: 8px;
}

.outlet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.outlet-row strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.outlet-row span,
.empty-outlets {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.outlet-row-actions {
  display: grid;
  grid-template-columns: 30px 22px 30px 30px;
  gap: 5px;
  align-items: center;
  text-align: center;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--ink);
  background: #eef3f6;
  border: 1px solid #d5e0e6;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 850;
  line-height: 1;
}

.icon-button:hover {
  background: #e2ebf0;
}

.icon-button.remove {
  color: var(--accent);
  background: #fff0f2;
  border-color: #f4cbd1;
}

.empty-outlets {
  padding: 12px;
  background: #fbfcfd;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.result-stack {
  display: grid;
  gap: 18px;
}

.recommendation-panel {
  min-height: 285px;
  padding: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(207, 38, 55, 0.92), rgba(23, 32, 38, 0.96)),
    var(--surface-strong);
  border-color: rgba(255, 255, 255, 0.1);
}

.product-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin-bottom: 7px;
  color: #ffd9dd;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.product-header h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

.product-image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 128px;
  width: 128px;
  height: 128px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
}

.product-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.capacity-row,
.demand-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.capacity-row {
  margin-top: 28px;
}

.demand-summary {
  margin-top: 12px;
}

.capacity-row > div,
.demand-summary > div {
  min-height: 90px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
}

.capacity-row .metric-total-flow {
  background: rgba(25, 170, 92, 0.42);
  border-color: rgba(138, 245, 179, 0.62);
  color: #a8f3bd;
}

.capacity-row .metric-hot-flow {
  background: rgba(210, 29, 48, 0.24);
  border-color: rgba(255, 176, 184, 0.4);
  color: #ffb6bf;
}

.capacity-row .metric-cold-flow {
  background: rgba(32, 104, 184, 0.26);
  border-color: rgba(155, 199, 255, 0.42);
  color: #a7d4ff;
}

.capacity-row .metric-total-flow .metric-label,
.capacity-row .metric-total-flow strong,
.capacity-row .metric-hot-flow .metric-label,
.capacity-row .metric-hot-flow strong,
.capacity-row .metric-cold-flow .metric-label,
.capacity-row .metric-cold-flow strong {
  color: inherit;
}

.capacity-row strong,
.demand-summary strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
}

.recommendation-panel .metric-label {
  color: #ffc8ce;
}

.callout {
  margin-top: 16px;
  padding: 14px;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  border-left: 4px solid #fff;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
}

.quote-panel {
  padding-bottom: 18px;
}

.buffer-panel {
  padding-bottom: 18px;
}

.buffer-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.buffer-metrics > div {
  min-height: 92px;
  padding: 13px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.buffer-metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.15;
}

.quote-lines {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.quote-config {
  padding: 18px 18px 0;
}

.quote-config.is-hidden {
  display: none;
}

.quote-line {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(115px, auto) minmax(52px, auto) minmax(90px, auto);
  gap: 14px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.quote-line:last-child {
  border-bottom: 0;
}

.quote-line h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.quote-line p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.datasheet-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.datasheet-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.quote-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quote-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.line-code,
.line-qty,
.line-price {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  font-weight: 850;
  white-space: nowrap;
}

.line-code span,
.line-qty span,
.line-price span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.line-code strong,
.line-qty strong {
  color: var(--ink);
}

.totals {
  display: grid;
  gap: 9px;
  margin: 0 18px;
  padding: 16px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.totals > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.totals strong {
  color: var(--ink);
}

.totals .grand-total {
  margin-top: 7px;
  padding-top: 12px;
  color: var(--ink);
  border-top: 1px solid var(--line);
  font-size: 17px;
  font-weight: 850;
}

.save-selection-box,
.email-quote {
  display: grid;
  gap: 8px;
  margin: 12px 18px 0;
  padding: 16px;
  background: #fff1f2;
  border: 1px solid #ffcbd2;
  border-radius: var(--radius);
}

.save-selection-box > span {
  color: #40505a;
  font-size: 12px;
  font-weight: 800;
}

.save-selection-row,
.email-quote-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.save-selection-box p,
.email-quote p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.range-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  padding: 16px 18px 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 300px;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

tbody tr.selected {
  background: #fff0f2;
}

tbody tr.unavailable {
  color: #9aa5ab;
}

.result-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.result-tag.fit {
  color: var(--green);
  background: #e6f4ee;
}

.result-tag.selected {
  color: var(--accent);
  background: #fde8eb;
}

.result-tag.short {
  color: var(--amber);
  background: #fff2d9;
}

.result-tag.zero {
  color: #69777f;
  background: #eef2f4;
}

.recommendation-panel.no-match {
  background:
    linear-gradient(135deg, rgba(155, 100, 21, 0.92), rgba(23, 32, 38, 0.96)),
    var(--surface-strong);
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: minmax(290px, 390px) minmax(0, 1fr);
  }

  .range-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .brand-mark {
    width: 142px;
    height: 44px;
  }

  .topbar-actions,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .workspace,
  .field-grid,
  .capacity-row,
  .demand-summary,
  .buffer-metrics,
  .outlet-builder,
  .email-quote-row,
  .save-selection-row {
    grid-template-columns: 1fr;
  }

  .outlet-row {
    grid-template-columns: 1fr;
  }

  .quote-line {
    grid-template-columns: 1fr;
  }

  .line-code,
  .line-qty,
  .line-price {
    justify-items: start;
    text-align: left;
  }

  .outlet-row-actions {
    justify-content: start;
  }

  .panel-heading {
    flex-direction: column;
  }

  .product-header h2 {
    font-size: 36px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    padding: 0;
  }

  .topbar-actions,
  .inputs-panel,
  .range-panel {
    display: none;
  }

  .topbar,
  .workspace,
  .result-stack {
    display: block;
    max-width: none;
    margin: 0;
  }

  .topbar,
  .panel,
  .recommendation-panel {
    color: #172026;
    background: #fff;
    box-shadow: none;
    border-color: #cfd8dd;
  }

  .recommendation-panel .metric-label,
  .eyebrow,
  .brandline {
    color: #40505a;
  }

  .brand-mark {
    padding-left: 0;
    background: transparent;
  }
}
