.legend .purple { background: #8e44c4; }
.legend .blue { background: #1878f0; }
select:disabled { background: #eef2f5; color: #8a99a5; cursor: not-allowed; }
.download-card[hidden] { display: none !important; }
.svg-dim text { font-family: Tahoma, "Segoe UI", Arial, sans-serif; stroke: none; }
.hero > div:first-child { max-width: 920px; }
.calculated-details { margin-top: 18px; padding: 16px; border: 1px solid #cfe0ee; border-radius: 16px; background: linear-gradient(145deg, #f8fbfe, #fff); }
.calculated-details[hidden] { display: none; }
.calculated-details-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.calculated-details-title span { color: #168b60; background: #e9f8f1; border-radius: 20px; padding: 6px 10px; font-size: 9px; font-weight: 900; }
.calculated-details-title h3 { margin: 0; font-size: 13px; }
.calculated-details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.calculated-details-grid > div { min-width: 0; padding: 10px 11px; border: 1px solid #e1eaf1; border-radius: 11px; background: #fff; display: flex; flex-direction: column; gap: 5px; }
.calculated-details-grid small { color: #718597; font-size: 9px; }
.calculated-details-grid b { color: #102d46; font-size: 11px; overflow-wrap: anywhere; }
@media (max-width: 700px) { .calculated-details-grid { grid-template-columns: 1fr; } }

/* Header actions */
.header { position: relative; }
.header-actions {
  position: absolute;
  left: 22px;
  top: 50%;
  z-index: 5;
  margin: 0 !important;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(-50%);
}
.header-actions a {
  margin: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid #b9d9ef;
  border-radius: 12px;
  font-weight: 800;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 5px 15px rgba(29, 117, 173, .12);
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.header-actions a:first-child {
  color: #1677b5 !important;
  background: #fff !important;
  border-color: #a9d3ed !important;
}
.header-actions a:hover,
.header-actions a:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(29, 117, 173, .2);
  outline: none;
}
.header-actions a:first-child:hover,
.header-actions a:first-child:focus-visible {
  color: #0e659c !important;
  background: #eef8fe !important;
  border-color: #62b2e1 !important;
}
.header-actions .track-order-button {
  color: #fff !important;
  background: linear-gradient(135deg, #3aa8ec, #1479bd) !important;
  border-color: #1479bd !important;
  box-shadow: 0 6px 17px rgba(20, 121, 189, .28);
}
.header-actions .track-order-button:hover,
.header-actions .track-order-button:focus-visible {
  color: #fff !important;
  background: linear-gradient(135deg, #2699df, #0d68a5) !important;
  border-color: #0d68a5 !important;
}

/* Contextual image hints */
.field-title {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
}
.hint-button {
  position: relative;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  border: 1px solid #b8ddf3;
  border-radius: 50%;
  background: linear-gradient(145deg, #f2faff, #dff2fd);
  color: transparent;
  font-size: 0;
  text-align: center;
  cursor: help;
  box-shadow: 0 3px 9px rgba(75, 159, 207, .18), inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}
.hint-button::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6aaed6;
  font: 800 14px/22px "Segoe UI", Tahoma, Arial, sans-serif;
}
.hint-button:hover,
.hint-button:focus-visible,
.hint-button[aria-expanded="true"] {
  background: #d3edfc;
  border-color: #82c5e9;
  outline: none;
  transform: scale(1.06);
}
.hint-button:hover::before,
.hint-button:focus-visible::before,
.hint-button[aria-expanded="true"]::before {
  color: #318fc4;
}
.hint-preview {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 10px);
  right: 0;
  display: none !important;
  width: min(330px, 78vw);
  padding: 7px;
  border: 1px solid #c9dce9;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(16, 45, 70, .24);
}
.hint-preview::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 42px;
  width: 12px;
  height: 12px;
  border-top: 1px solid #c9dce9;
  border-right: 1px solid #c9dce9;
  background: #fff;
  transform: rotate(-45deg);
}
.hint-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  border-radius: 8px;
}
.hint-close {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid #a9d7f1;
  border-radius: 50%;
  color: #277fae;
  background: rgba(244, 251, 255, .96);
  font: 700 22px/1 "Segoe UI", Tahoma, Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(16, 83, 120, .2);
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.hint-close:hover,
.hint-close:focus-visible {
  color: #fff;
  background: #338fc2;
  border-color: #338fc2;
  outline: none;
  transform: scale(1.06);
}
.hint-preview-double {
  width: min(640px, 86vw);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.field-title:not(.hint-dismissed):hover .hint-preview,
.field-title:not(.hint-dismissed):focus-within .hint-preview,
.field-title:not(.hint-dismissed).hint-open .hint-preview {
  display: block !important;
}
.field-title:not(.hint-dismissed):hover .hint-preview-double,
.field-title:not(.hint-dismissed):focus-within .hint-preview-double,
.field-title:not(.hint-dismissed).hint-open .hint-preview-double {
  display: grid !important;
}

@media (max-width: 700px) {
  .header {
    flex-wrap: wrap;
  }
  .header-actions {
    position: static;
    width: 100%;
    margin: 0 !important;
    gap: 7px;
    transform: none;
  }
  .header-actions a {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
    font-size: 11px;
  }
  .hint-preview {
    position: fixed;
    top: 50%;
    right: 50%;
    width: min(420px, calc(100vw - 30px));
    max-height: calc(100vh - 40px);
    transform: translate(50%, -50%);
    padding: 9px;
  }
  .hint-preview::before { display: none; }
  .hint-preview img { max-height: calc(100vh - 60px); }
  .hint-preview-double {
    width: min(680px, calc(100vw - 24px));
    gap: 6px;
  }
  .hint-preview-double img { max-height: calc(100vh - 70px); }
}


/* Engineering preview grid: each CSS cell represents 40 mm in the top plan.
   JavaScript updates --grid-step in CSS pixels from the actual rendered SVG size. */
.drawing {
  background: #ffffff !important;
  border-radius: 18px;
  overflow: hidden;
}
.drawing #drawingSvg {
  display: block;
  width: 100%;
  height: auto;
  --grid-step: 12px;
  background-color: #ffffff !important;
  background-image:
    linear-gradient(to right, rgba(117, 137, 158, .16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(117, 137, 158, .16) 1px, transparent 1px) !important;
  background-size:
    var(--grid-step) var(--grid-step),
    var(--grid-step) var(--grid-step) !important;
  background-position: 0 0, 0 0 !important;
  background-repeat: repeat !important;
  border-radius: 18px;
}

.drawing svg.is-iso-view {
  background-color: #ffffff !important;
  background-image: none !important;
}

/* Dimension inputs always show the expected unit beside the entered value. */
.input-with-unit {
  position: relative;
  display: block;
  width: 100%;
}
.input-with-unit input {
  width: 100%;
  padding-left: 78px !important;
}
.input-unit {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  padding-right: 9px;
  border-right: 1px solid #d9e4ed;
  color: #607487;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  pointer-events: none;
  white-space: nowrap;
}

/* Highlight missing or invalid required values after the first calculation attempt. */
.form-panel.validation-attempted input:invalid,
.form-panel.validation-attempted select:invalid {
  border-color: #e62226 !important;
  background-color: #fff4f4 !important;
  box-shadow: 0 0 0 3px rgba(230, 34, 38, .12) !important;
}
.form-panel.validation-attempted input:invalid + .input-unit {
  color: #d71920;
  border-right-color: rgba(215, 25, 32, .35);
}
.form-panel .field-error {
  display: block;
  margin-top: 0;
  color: #d71920;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.7;
}
