:root {
  --bg: #F4F9FB;
  --surface: #FFFFFF;
  --ink: #12303D;
  --muted: #5E7784;
  --line: #D6E4EA;
  --pool: #0E6F95;
  --pool-deep: #0B4B66;
  --pool-soft: #E3F1F7;
  --pool-rule: rgba(14, 111, 149, 0.16);
  --focus: #F0A93B;
  --note-bg: #FFF6E3;
  --note-ink: #7A5A16;
}

html, body { margin: 0; }

body {
  width: 380px;
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

button, input, select { font-family: inherit; }

/* ---------- En-tête : le bassin ---------- */

.top {
  background: var(--pool-deep);
  color: #fff;
  padding: 12px 16px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { width: 30px; height: 30px; flex: none; }

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand span {
  display: block;
  font-size: 12px;
  opacity: 0.78;
}

.basin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 9px 0 7px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  cursor: text;
}

.basin > span:first-child { font-size: 13px; }

.basin-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.basin input {
  width: 84px;
  padding: 2px 4px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  text-align: right;
  color: #fff;
  background: transparent;
  border: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

.basin input::placeholder { color: rgba(255, 255, 255, 0.4); }

.basin input:focus {
  outline: none;
  border-bottom-color: var(--focus);
}

.basin em {
  font-style: normal;
  font-size: 13px;
  opacity: 0.85;
}

/* ---------- Onglets ---------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: var(--pool-deep);
}

.tabs button {
  flex: 1;
  padding: 9px 2px 10px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border: 0;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}

.tabs button:hover { color: #fff; }

.tabs button[aria-selected="true"] {
  color: var(--pool-deep);
  background: var(--bg);
}

.tabs button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* ---------- Contenu ---------- */

main {
  padding: 12px 16px 6px;
  max-height: 420px;
  overflow: auto;
}

section[hidden], .sub[hidden], .field[hidden] { display: none; }

.field {
  display: grid;
  grid-template-columns: 1fr 124px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.field label {
  font-size: 13px;
  line-height: 1.3;
}

.field label small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.in {
  display: flex;
  align-items: center;
  height: 33px;
  padding: 0 8px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.in:focus-within {
  border-color: var(--pool);
  box-shadow: 0 0 0 2px rgba(14, 111, 149, 0.18);
}

.in input, .in select {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.in input { text-align: right; }

.in select { padding-right: 0; cursor: pointer; }

.in i {
  flex: none;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  padding-left: 2px;
}

.field:has(select) { grid-template-columns: auto 1fr; }

.field.pair { grid-template-columns: 1fr 96px 96px; }

.in .pre {
  padding-left: 8px;
  font-size: 11px;
  color: var(--muted);
}

.in .pre + input { padding-left: 4px; }

/* Sélecteur de produit (traitement) */

.seg {
  display: inline-flex;
  padding: 3px;
  margin-bottom: 12px;
  background: #E4EDF1;
  border-radius: 999px;
}

.seg button {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  color: var(--pool-deep);
  background: #fff;
  box-shadow: 0 1px 2px rgba(11, 75, 102, 0.18);
}

.seg button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- Résultat ---------- */

.result {
  margin-top: 10px;
  padding: 10px 14px 11px;
  background: var(--pool-soft);
  border-radius: 12px;
}

.result:empty { display: none; }

.result .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.result .big {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--pool-deep);
  font-variant-numeric: tabular-nums;
}

.result .big small {
  font-size: 14px;
  font-weight: 600;
  margin-left: 2px;
  letter-spacing: 0;
}

.result .rows { margin-top: 8px; }

.result .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  border-top: 1px solid var(--pool-rule);
}

.result .row span { flex: 0 1 auto; color: var(--muted); }

.result .row b {
  flex: 1 0 auto;
  max-width: 62%;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result .ok { font-size: 15px; font-weight: 600; color: var(--pool-deep); }

.result .empty { font-size: 13px; }

.result .empty p { margin: 0 0 10px; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--pool);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover { background: var(--pool-deep); }

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn.done {
  color: var(--pool-deep);
  background: transparent;
  border: 1px solid var(--pool);
  cursor: default;
}

.result .action { margin-top: 10px; }

.note {
  margin-top: 9px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--note-ink);
  background: var(--note-bg);
  border-radius: 8px;
}

/* ---------- Liens vers les guides ---------- */

.links {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.links a {
  color: var(--pool);
  text-decoration: none;
  border-bottom: 1px solid rgba(14, 111, 149, 0.35);
}

.links a:hover { border-bottom-color: var(--pool); }

.links a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 10px;
  font-size: 12px;
  border-top: 1px solid var(--line);
}

footer a {
  color: var(--pool);
  font-weight: 600;
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

footer a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color 120ms ease; }
}
