:root {
  color-scheme: light;
  --bl-navy: #1c3140;
  --bl-blue: #009fe3;
  --bl-blue-dark: #00648f;
  --bl-bg: #f3f7fa;
  --bl-card: #fff;
  --bl-border: #d5e1ea;
  --bl-text: #1f2933;
  --bl-muted: #526372;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--bl-text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bl-bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--bl-blue-dark); }
:focus-visible { outline: 3px solid var(--bl-blue-dark); outline-offset: 3px; }

.container { max-width: 1152px; margin: 0 auto; padding: 32px 24px 24px; }
.header {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(26px, 5vw, 54px);
  border-radius: 18px;
  background: var(--bl-navy);
  color: #fff;
  margin-bottom: 22px;
}
.brand-tag { display: flex; align-items: center; gap: 8px; color: #b9e7f8; font-size: .69rem; font-weight: 700; letter-spacing: .11em; }
.brand-tag > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #72d3f9; }
.brand-divider { opacity: .65; }
h1 { font-family: Georgia, serif; font-weight: 400; font-size: clamp(2.25rem, 6.5vw, 4.5rem); letter-spacing: -.035em; line-height: .99; margin: 20px 0 15px; }
.subtitle { color: #d5e4ec; max-width: 32rem; margin: 0; line-height: 1.55; font-size: .98rem; }
.lab-illustration { position: absolute; inset: 50% 5% auto auto; transform: translateY(-50%); color: #73ceed; z-index: -1; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
form { display: grid; gap: 18px; }
.card { background: var(--bl-card); border: 1px solid var(--bl-border); border-radius: 16px; padding: clamp(16px, 2.7vw, 25px); }
h2 { display: flex; align-items: center; gap: 10px; font-size: 1.03rem; color: var(--bl-navy); margin: 0 0 16px; }
.step { color: var(--bl-blue-dark); background: #e6f4fb; border-radius: 7px; padding: 5px 7px; font-size: .73rem; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: block; min-width: 0; color: var(--bl-navy); font-size: .82rem; font-weight: 700; }
.field :is(input, select) { width: 100%; min-height: 42px; margin-top: 6px; padding: 8px 10px; color: var(--bl-text); background: #fff; border: 1px solid #bacbd7; border-radius: 8px; font-size: .9rem; font-weight: 400; }
.field :is(input, select):focus { border-color: var(--bl-blue-dark); }
.field :is(input, select)[aria-invalid="true"] { border-color: #a52222; }
.hint { margin: 5px 0 0; color: var(--bl-muted); font-size: .77rem; line-height: 1.45; font-weight: 400; }
.solution-options { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bl-border); }
.solution-options summary { color: var(--bl-blue-dark); cursor: pointer; font-size: .84rem; font-weight: 700; }
.solution-options .grid-2 { margin-top: 12px; }
.section-intro { margin: -5px 0 14px; font-size: .88rem; color: var(--bl-muted); line-height: 1.5; }
.oil-list { display: grid; gap: 9px; }
.oil-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(90px, .85fr) minmax(62px, .75fr) minmax(65px, auto) 34px; gap: 8px; align-items: end; padding: 11px; border: 1px solid #e1ebf1; border-radius: 10px; background: #f8fbfd; }
.custom-fields { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
.mass-badge, .sap-badge { min-height: 42px; margin-top: 6px; display: grid; place-items: center; padding: 0 5px; color: var(--bl-navy); background: #e6f4fb; border-radius: 8px; text-align: center; overflow-wrap: anywhere; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sap-badge { background: #e6eef5; }
.ingredient-note { grid-column: 1 / -1; margin-top: 0; color: #5c4709; }
.mix-balance { margin: 10px 0 0; font-size: .81rem; font-weight: 700; color: var(--bl-navy); font-variant-numeric: tabular-nums; }
.mix-balance[data-state="complete"] { color: #166247; }
.mix-balance[data-state="excess"] { color: #991b1b; }
.remove-btn { height: 42px; color: var(--bl-navy); background: #fff; border: 1px solid #bacbd7; border-radius: 8px; font-size: 1.2rem; }
.remove-btn:hover:not(:disabled) { background: #fce9e9; }
.remove-btn:disabled { opacity: .45; cursor: not-allowed; }
.oil-hint { margin-top: 9px; }
.sap-reference { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bl-border); }
.sap-reference summary { color: var(--bl-blue-dark); cursor: pointer; font-size: .84rem; font-weight: 700; }
.sap-table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; font-size: .78rem; font-variant-numeric: tabular-nums; }
.sap-table caption { margin: 14px 0 5px; text-align: left; color: var(--bl-muted); }
.sap-table th, .sap-table td { padding: 7px 5px; border-bottom: 1px solid var(--bl-border); vertical-align: top; overflow-wrap: anywhere; }
.sap-table th:first-child { width: 55%; }
.sap-table tr th a { display: block; margin-top: 4px; font-size: .74rem; font-weight: 400; }
.actions-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.btn { min-height: 42px; border: 0; border-radius: 8px; padding: 9px 13px; font-size: .87rem; font-weight: 700; }
.btn-primary { color: #fff; background: var(--bl-blue-dark); }
.btn-primary:hover { background: #004d70; }
.btn-primary span { margin-left: 4px; }
.btn-secondary { color: var(--bl-navy); background: #e6eef5; }
.btn-secondary:hover { background: #d5e2ee; }
.error-box { margin: 12px 0 0; padding: 10px 12px; background: #fef2f2; border: 1px solid #f5b5b5; color: #991b1b; border-radius: 8px; font-size: .85rem; }

.empty-result { padding: 24px 12px; text-align: center; color: var(--bl-muted); background: #f8fbfd; border: 1px dashed #bbcfdc; border-radius: 10px; }
.empty-result svg { color: var(--bl-blue-dark); }
.empty-result p { font-weight: 700; color: var(--bl-navy); margin: 6px 0; }
.empty-result span { display: block; max-width: 16rem; margin: auto; font-size: .85rem; line-height: 1.5; }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.stat-box { padding: 10px; background: #f8fbfd; border: 1px solid #dce6ee; border-radius: 10px; }
.stat-highlight { background: #ecf8ff; border-color: #a9d8ef; }
.stat-box dt { color: var(--bl-muted); font-size: .75rem; }
.stat-box dd { color: var(--bl-navy); margin: 5px 0 0; font-size: clamp(.95rem, 2vw, 1.25rem); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-settings { margin-top: 10px; }
h3 { color: var(--bl-navy); font-size: .91rem; margin: 17px 0 6px; }
.composition { list-style: none; padding: 0; margin: 0 0 13px; font-size: .86rem; }
.composition li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--bl-border); }
.composition li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.composition li span:last-child { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.result-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.print-brand { display: none; }
.copy-status:empty { margin: 0; }
.safety-note { margin-top: 14px; padding: 12px; background: #fff8e6; border: 1px solid #e6c97f; border-radius: 10px; color: #5c4709; font-size: .81rem; line-height: 1.5; }
.safety-note h3 { color: inherit; margin: 0 0 5px; }
.safety-note p { margin: 0; }
.safety-note ul { margin: 8px 0; padding-left: 18px; }
.safety-note li + li { margin-top: 5px; }
.additive-note { margin-top: 18px; }
.additive-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: 16px; }
.additive-grid section { padding-top: 10px; border-top: 1px solid var(--bl-border); }
.additive-grid h3 { margin: 0 0 5px; }
.additive-grid p { margin: 0; font-size: .84rem; line-height: 1.55; color: var(--bl-muted); }
.additive-grid p + p { margin-top: 6px; }
.footer { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-top: 20px; padding: 14px 0; border-top: 1px solid var(--bl-border); color: var(--bl-muted); font-size: .78rem; line-height: 1.5; }
.footer details { max-width: 45rem; }
.footer summary { cursor: pointer; color: var(--bl-blue-dark); }
.footer > span { font-weight: 700; letter-spacing: .1em; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 690px) {
  .lab-illustration { right: -105px; opacity: .24; }
  .additive-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 500px) {
  .container { padding: 14px 12px 20px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .oil-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(52px, .85fr) 34px; }
  .oil-select { grid-column: 1 / -1; }
}

@page { margin: 15mm; }

@media print {
  body, .stat-box, .safety-note { background: #fff; }
  .header, #formula, .additive-note, .footer, .results .step, .result-actions, .copy-status { display: none; }
  .container { max-width: none; margin: 0; padding: 0; }
  .workspace { display: block; }
  .results { border: 0; padding: 0; }
  .print-brand { display: block; margin: 0 0 6pt; font-size: 9pt; font-weight: 700; letter-spacing: .08em; }
  .results h2 { font-size: 16pt; }
  .results :is(h2, h3) { break-after: avoid; }
  .results-grid, .composition li, .safety-note li { break-inside: avoid; }
  .safety-note { color: var(--bl-text); border-color: #aaa; }
}
