:root {
      --primary: #2563eb;
      --primary-dark: #1d4ed8;
      --bg: #f8fafc;
      --card-bg: #ffffff;
      --text: #1e293b;
      --text-muted: #64748b;
      --border: #e2e8f0;
      --radius: 10px;
      --shadow: 0 2px 8px rgba(0,0,0,0.08);
      --font: system-ui, -apple-system, sans-serif;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

    header {
      background: linear-gradient(135deg, #1e3a5f, #2563eb);
      color: white;
      padding: 1.5rem 2rem;
      text-align: center;
    }
    header h1 { font-size: 1.5rem; font-weight: 700; }
    header p { font-size: 0.9rem; opacity: 0.8; margin-top: 0.25rem; }

    .container { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }

    /* === MODE SELECTOR === */
    .mode-selector {
      display: flex;
      gap: 0;
      background: var(--bg);
      border-radius: var(--radius);
      padding: 4px;
      border: 1px solid var(--border);
      margin-bottom: 1.5rem;
    }
    .mode-btn {
      flex: 1;
      padding: 14px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      cursor: pointer;
      border-radius: 8px;
      font-size: 1rem;
      font-weight: 600;
      transition: all 0.2s;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
    }
    .mode-btn .mode-icon { font-size: 1.8rem; }
    .mode-btn .mode-desc { font-size: 0.75rem; font-weight: 400; opacity: 0.7; }
    .mode-btn.active {
      background: var(--primary);
      color: white;
    }
    .mode-btn:hover:not(.active) { background: var(--border); }

    /* === FORM === */
    .card {
      background: var(--card-bg);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 1.5rem;
      margin-bottom: 1.5rem;
    }
    .card h2 { font-size: 1rem; margin-bottom: 1rem; color: var(--text); }

    .form-group { margin-bottom: 1.25rem; }
    .form-group label {
      display: block;
      font-size: 0.85rem;
      font-weight: 600;
      margin-bottom: 0.4rem;
      color: var(--text);
    }
    .form-group label span {
      font-weight: 400;
      color: var(--text-muted);
      font-size: 0.8rem;
    }
    .input-with-unit {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .input-with-unit input {
      flex: 1;
      padding: 10px 14px;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      font-size: 1rem;
      font-family: inherit;
      transition: border-color 0.2s;
    }
    .input-with-unit input:focus {
      outline: none;
      border-color: var(--primary);
    }
    .unit-label {
      font-size: 0.85rem;
      color: var(--text-muted);
      font-weight: 600;
      min-width: 24px;
    }

    /* === COMPUTE BUTTON === */
    .btn-calculate {
      width: 100%;
      padding: 14px;
      background: var(--primary);
      color: white;
      border: none;
      border-radius: var(--radius);
      font-size: 1rem;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.2s;
    }
    .btn-calculate:hover { background: var(--primary-dark); }

    /* === RESULTS === */
    .results { display: none; }
    .results.show { display: block; }

    .result-section {
      background: var(--card-bg);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 1.5rem;
      margin-bottom: 1.5rem;
    }
    .result-section h3 {
      font-size: 0.9rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 1rem;
    }

    /* O-ring card */
    .oring-card {
      background: linear-gradient(135deg, #eff6ff, #ffffff);
      border: 2px solid var(--primary);
      border-radius: var(--radius);
      padding: 1.25rem;
      margin-bottom: 1rem;
    }
    .oring-card .oring-title {
      font-size: 1.1rem;
      font-weight: 700;
      color: var(--primary-dark);
      margin-bottom: 0.75rem;
    }
    .oring-dims {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 0.75rem;
    }
    .oring-dim {
      text-align: center;
      padding: 0.75rem;
      background: white;
      border-radius: 8px;
      border: 1px solid var(--border);
    }
    .oring-dim .dim-label {
      font-size: 0.7rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .oring-dim .dim-value {
      font-size: 1.1rem;
      font-weight: 700;
      color: var(--text);
      margin-top: 4px;
    }

    /* Gland card */
    .gland-card {
      border: 2px solid #059669;
      border-radius: var(--radius);
      padding: 1.25rem;
      margin-bottom: 1rem;
      background: linear-gradient(135deg, #ecfdf5, #ffffff);
    }
    .gland-card h4 {
      font-size: 0.9rem;
      color: #059669;
      margin-bottom: 1rem;
    }
    .gland-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.5rem 1.5rem;
    }
    .gland-row {
      display: flex;
      justify-content: space-between;
      padding: 0.4rem 0;
      border-bottom: 1px solid #e6f7ef;
    }
    .gland-row:last-child { border-bottom: none; }
    .gland-label { font-size: 0.82rem; color: var(--text-muted); }
    .gland-value { font-size: 0.9rem; font-weight: 700; color: var(--text); }

    /* Parker legend (kleurcodering vs Parker Design Chart 4-2) */
    .parker-legend {
      margin-top: 0.75rem;
      padding: 0.75rem 1rem;
      background: #f1f5f9;
      border: 1px solid #cbd5e1;
      border-radius: 8px;
      font-size: 0.82rem;
      color: var(--text);
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      align-items: center;
    }
    .parker-legend strong { color: var(--primary); margin-right: 0.5rem; }
    .legend-pill {
      background: #fff;
      border: 1px solid #cbd5e1;
      border-radius: 999px;
      padding: 0.2rem 0.7rem;
      font-size: 0.78rem;
      white-space: nowrap;
    }
    .legend-pill strong { color: #1e40af; margin: 0 0.15rem; }

    /* Notes */
    .note-box {
      background: #fffbeb;
      border: 1px solid #fcd34d;
      border-radius: 8px;
      padding: 0.75rem 1rem;
      font-size: 0.82rem;
      color: #92400e;
      margin-top: 1rem;
    }

    /* Errors */
    .error-box {
      background: #fee2e2;
      border: 1px solid #fca5a5;
      border-radius: 8px;
      padding: 0.75rem 1rem;
      font-size: 0.85rem;
      color: #991b1b;
      margin-bottom: 1rem;
      display: none;
    }
    .error-box.show { display: block; }

    .info-box {
      background: #eff6ff;
      border: 1px solid #93c5fd;
      border-radius: 8px;
      padding: 0.75rem 1rem;
      font-size: 0.85rem;
      color: #1e3a8a;
      margin-bottom: 1rem;
      display: none;
    }
    .info-box.show { display: block; }

    /* Pressure advice boxes (in tolerance-note) */
    .pressure-ok {
      background: #ecfdf5;
      border-left: 4px solid #10b981;
      padding: 0.6rem 0.8rem;
      margin-top: 0.75rem;
      border-radius: 4px;
      color: #065f46;
      font-size: 0.85rem;
    }
    .pressure-warning {
      background: #fffbeb;
      border-left: 4px solid #f59e0b;
      padding: 0.6rem 0.8rem;
      margin-top: 0.75rem;
      border-radius: 4px;
      color: #92400e;
      font-size: 0.85rem;
    }
    .pressure-critical {
      background: #fef2f2;
      border-left: 4px solid #ef4444;
      padding: 0.6rem 0.8rem;
      margin-top: 0.75rem;
      border-radius: 4px;
      color: #991b1b;
      font-size: 0.85rem;
    }

    /* Expert consult — buiten Parker limiet */
    .expert-box {
      background: #fef9c3;
      border: 2px solid #ca8a04;
      border-radius: 8px;
      padding: 1rem 1.25rem;
      font-size: 0.88rem;
      color: #713f12;
      margin-bottom: 1rem;
      line-height: 1.5;
    }
    .expert-box strong { color: #854d0e; }

    /* Toggle unit */
    .unit-toggle {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 1rem;
    }
    .unit-toggle label { font-size: 0.82rem; color: var(--text-muted); }
    .std-btn {
      padding: 8px 16px;
      border: 1.5px solid var(--border);
      background: white;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      border-radius: 8px;
      color: var(--text-muted);
      transition: all 0.2s;
    }
    .std-btn.active {
      background: var(--primary);
      color: white;
      border-color: var(--primary);
    }
    .std-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }
    .toggle-group {
      display: flex;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 2px;
    }
    .toggle-group button {
      padding: 4px 12px;
      border: none;
      background: transparent;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      border-radius: 4px;
      color: var(--text-muted);
    }
    .toggle-group button.active {
      background: var(--primary);
      color: white;
    }

    @media (max-width: 600px) {
      .oring-dims { grid-template-columns: 1fr 1fr; }
      .gland-grid { grid-template-columns: 1fr; }
    }

    /* === VISUAL DESIGNER (vd) === */
    .vd-row {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 12px;
      margin-bottom: 12px;
    }
    .vd-field label {
      display: block;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.4px;
      margin-bottom: 4px;
    }
    .vd-diameter {
      margin: 16px 0 12px 0;
      padding: 14px;
      background: linear-gradient(135deg, #eff6ff, #dbeafe);
      border: 2px solid var(--primary);
      border-radius: 12px;
    }
    .vd-diameter label {
      display: block;
      font-size: 0.85rem;
      font-weight: 700;
      color: var(--primary-dark);
      margin-bottom: 6px;
    }
    .vd-diameter input {
      width: 100%;
      padding: 10px 12px;
      border: 1.5px solid var(--primary);
      border-radius: 8px;
      font-size: 1.4rem;
      font-weight: 700;
      color: var(--primary-dark);
      background: white;
    }
    .vd-diameter input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }
    .vd-hint {
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-top: 6px;
      font-style: italic;
    }
    .vd-visual {
      margin: 12px 0;
      padding: 0;
      background: #fafbfc;
      border: 1px solid var(--border);
      border-radius: 10px;
      min-height: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }
    .vd-visual svg { width: 100%; height: auto; max-height: 360px; display: block; }
    .vd-visual-hint {
      color: var(--text-muted);
      font-style: italic;
      font-size: 0.9rem;
      padding: 40px 20px;
      text-align: center;
    }
    .vd-overrides {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: end;
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px dashed var(--border);
    }
    .vd-overrides .vd-override-field { flex: 1 1 140px; min-width: 140px; }
    .vd-overrides .vd-override-toggle { flex: 0 0 auto; }
    .vd-override-field label {
      display: block;
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: 3px;
    }
    .vd-override-field input {
      width: 100%;
      padding: 6px 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-size: 0.9rem;
      background: var(--bg);
    }
    .vd-override-field input:disabled {
      color: var(--text-muted);
      cursor: not-allowed;
    }
    .vd-override-field input:not(:disabled) {
      background: #fff;
      border-color: var(--primary);
      font-weight: 600;
    }
    .vd-auto {
      color: var(--text-muted);
      font-weight: 400;
      font-size: 0.65rem;
      font-style: italic;
    }
    .vd-override-toggle {
      padding: 6px 12px;
      background: white;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
      white-space: nowrap;
    }
    .vd-override-toggle:hover { color: var(--primary); border-color: var(--primary); }
    .vd-override-toggle.active { background: var(--primary); color: white; border-color: var(--primary); }

    @media (max-width: 600px) {
      .vd-row { grid-template-columns: 1fr; }
      .vd-overrides { grid-template-columns: 1fr; }
    }


/* ± tolerance badge next to gland values */
.gland-value-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.tol-pm {
  font-size: 0.72rem;
  font-weight: 600;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.tol-pm:empty { display: none; }
.tol-source {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.35;
}


/* Constructeur-advies (Shore A + Ra) */
.constructor-advice {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.45;
}
.constructor-advice strong { color: var(--primary-dark); }
.constructor-advice .adv-row { margin-bottom: 0.35rem; }
.constructor-advice .adv-source {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Export toolbar */
.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn-export {
  padding: 8px 14px;
  background: white;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-export:hover { background: var(--primary); color: white; }
.export-hint { font-size: 0.78rem; color: var(--text-muted); }
.export-howto { font-size: 0.78rem; font-weight: 600; color: var(--primary); text-decoration: none; }
.export-howto:hover { text-decoration: underline; }

.print-only { display: none; }
.print-header {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #1e3a5f;
  font-size: 0.9rem;
}
.print-header span { display: block; margin-top: 0.25rem; color: #475569; font-size: 0.8rem; }

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: white; color: #000; }
  header {
    background: none !important;
    color: #000 !important;
    padding: 0 0 0.75rem 0;
    text-align: left;
    border-bottom: 1px solid #cbd5e1;
  }
  header h1 { font-size: 1.2rem; }
  header p, .gd-brand-mark { display: none; }
  .container { max-width: 100%; margin: 0; padding: 0; }
  .results { display: block !important; }
  .result-section, .gland-card, .oring-card {
    box-shadow: none !important;
    break-inside: avoid;
  }
  .vd-visual { border: 1px solid #94a3b8; }
  .vd-visual svg { max-height: 280px; }
  .expert-box { border-width: 1px; }
  a[href]::after { content: ""; }
}


/* Materiaal / compound selector */
.material-card {
  margin-top: 0.6rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text);
}
.material-card.ok { border-left: 4px solid #10b981; }
.material-card.warning { border-left: 4px solid #f59e0b; }
.material-card .mat-name { font-weight: 700; color: var(--primary-dark); margin-bottom: 0.35rem; }
.material-card .mat-row { margin-bottom: 0.2rem; }
.material-card .mat-warn {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: #fffbeb;
  border-radius: 6px;
  color: #92400e;
  font-size: 0.78rem;
}
.oring-material-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.oring-material-line .dim-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.oring-material-line .dim-value {
  font-weight: 700;
  color: var(--primary-dark);
}


/* === O-ring calculator review 2026-10 (classes only used by /oring/ and /nl/oring/) === */
.diam-input-row { display: flex; gap: 8px; align-items: stretch; }
.diam-input-row input { flex: 1 1 auto; min-width: 0; }
.unit-toggle-inline { align-self: center; }
.unit-toggle-inline button { padding: 8px 14px; font-size: 0.9rem; }
.vd-row.vd-row-2 { grid-template-columns: 1fr 1fr; }
.vd-select { width: 100%; padding: 8px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.95rem; background: #fff; }
.vd-select-unit { width: auto; }
.vd-optional { font-weight: 400; color: #64748b; text-transform: none; }
.pressure-row { display: flex; gap: 8px; align-items: center; }
.pressure-row input { flex: 1 1 auto; min-width: 0; padding: 8px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.95rem; }
.oring-calc .vd-field { margin-bottom: 12px; }
input[aria-invalid="true"] { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15); }
.oring-tols { margin-top: 0.5rem; font-size: 0.78rem; color: var(--text-muted); text-align: center; }
.oring-fit { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.fit-chip { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; border: 1px solid; }
.fit-chip small { opacity: 0.8; }
.st-ok.fit-chip { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.st-warn.fit-chip { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.input-role { font-size: 0.82rem; color: var(--text); margin-bottom: 0.75rem; }
.gland-grid.gland-list { grid-template-columns: 1fr; gap: 0; }
.gland-list .gland-row { align-items: flex-start; gap: 12px; }
.gland-list .gland-label { flex: 1 1 55%; }
.gland-list .gland-row.row-key .gland-label { color: var(--text); font-weight: 600; }
.gland-list .gland-row.st-warn .gland-value { color: #b45309; }
.gland-note { font-size: 0.72rem; color: var(--text-muted); text-align: right; }
.warn-box { display: none; margin-top: 0.85rem; padding: 0.6rem 0.9rem; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; color: #92400e; font-size: 0.82rem; }
.warn-box.show { display: block; }
.warn-box ul, .error-box ul { margin: 0.35rem 0 0 1.1rem; }
.err-export { margin-top: 0.4rem; font-weight: 600; }
.disclaimer { margin-top: 0.75rem; font-size: 0.75rem; color: var(--text-muted); }
.note-box > div + div { margin-top: 0.35rem; }
.btn-export:disabled, .btn-export[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; background: #fff; color: var(--primary); }
.oring-calc .export-bar { margin-top: 0; }
.vd-visual-scroll { width: 100%; }

@media (max-width: 600px) {
  .vd-row.vd-row-2 { grid-template-columns: 1fr; }
  .oring-calc header { padding: 1rem; }
  .oring-calc .container { margin-top: 1rem; }
  .oring-calc .mode-btn { padding: 10px 6px; }
  .oring-calc .mode-btn .mode-desc { display: none; }
  .vd-diameter input { font-size: 1.25rem; }
  /* readable drawing: keep the text size, scroll sideways instead of shrinking */
  .vd-visual { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .vd-visual-scroll { min-width: 600px; }
  .vd-visual-scroll:has(> svg:empty) { min-width: 0; }
  .gland-list .gland-row { flex-direction: column; gap: 2px; }
  .gland-list .gland-value-wrap { align-items: flex-start; text-align: left; }
  .gland-note { text-align: left; }
  .oring-dims { grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem; }
  .oring-dim { padding: 0.5rem 0.25rem; }
  .oring-dim .dim-value { font-size: 0.95rem; }
  .export-bar { flex-direction: column; align-items: stretch; }
  .export-bar .btn-export { width: 100%; }
}
@media print {
  .oring-calc .vd-visual-scroll { min-width: 0; }
  .warn-box.show { border-width: 1px; }
}

/* === O-ring calculator: inline field errors (message directly under the faulty input) === */
.field-err { display: flex; gap: 0.3rem; align-items: flex-start; margin-top: 4px; color: #b91c1c; font-size: 0.8rem; font-weight: 600; line-height: 1.3; font-style: normal; }
.field-err[hidden] { display: none; }
.field-err::before { content: "⚠" / ""; flex: 0 0 auto; }
.oring-calc input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25); }
.err-summary { font-weight: 600; }
