/* Entrepôt — feuille de style. Style de Qarto et du PIM (fonds chauds, DM Sans, coins arrondis, pilules, cartes sans trait à ombre douce,
   en-tête sur une ligne, vues en barre du bas sur téléphone) ; accent ocre propre à l'Entrepôt (le PIM a son bleu pétrole, Qarto ERP son vert). */
:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface2: #f8f7f3; --ink: #1d1e24; --muted: #5d606c; --faint: #8b8d97;
  --line: #e6e3dc; --line2: #c8c4ba; --accent: #a4501c; --accent-ink: #ffffff; --accent-soft: #f7ebe1;
  --ok: #23845a; --ok-soft: #e3f3ea; --warn: #9a6512; --warn-soft: #fbf0dc; --danger: #c0392f; --danger-soft: #fbe5e3;
  --f-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "DM Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
  --shadow: 0 1px 2px rgba(40, 32, 20, .06), 0 4px 14px rgba(40, 32, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141310; --surface: #1d1c18; --surface2: #23221e; --ink: #ecebe6; --muted: #aaa79d; --faint: #7d7a71;
    --line: #34322c; --line2: #4f4b43; --accent: #e8955f; --accent-ink: #24130a; --accent-soft: #3a2416;
    --ok: #52c58c; --ok-soft: #173327; --warn: #e5b04a; --warn-soft: #3a2e14; --danger: #ef6b60; --danger-soft: #3d1c19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.45 var(--f-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* En-tête sur une ligne : logo, vues en pilule au centre, poste à droite */
.haut {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px 14px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 6px 16px -12px rgba(40, 32, 20, .25);
}
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; flex: none; }
.onglets { display: flex; gap: 2px; background: var(--surface2); border-radius: 999px; padding: 3px; margin-inline: auto; flex: none; }
.onglets a { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.onglets a:hover { color: var(--ink); }
.onglets a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.outils { display: flex; align-items: center; gap: 8px; flex: none; }

/* Menu du rond du profil (comme Qarto et le PIM) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; width: min(290px, calc(100vw - 24px)); background: var(--surface); border-radius: 14px;
  box-shadow: 0 12px 34px rgba(40, 32, 20, .16), 0 2px 6px rgba(40, 32, 20, .08); padding: 6px; display: flex; flex-direction: column; }
.menu-pop :is(a, button) { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; text-decoration: none; border: 0;
  background: transparent; border-radius: 10px; padding: 8px 10px; cursor: pointer; color: var(--ink); font: inherit; }
.menu-pop :is(a, button):hover, .menu-pop :is(a, button):focus-visible { background: var(--accent-soft); }
.menu-pop small { color: var(--muted); font-size: 12px; }
.menu-pop form { margin: 0; }
.menu-qui { display: grid; gap: 1px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-qui small { color: var(--muted); font-size: 12.5px; }
.compte-btn { display: inline-flex; border-radius: 50%; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.compte-btn:hover .avatar, .menu.compte[open] .avatar { background: var(--accent); color: var(--accent-ink); }

@media (max-width: 760px) {
  :root { --barre-vues: calc(61px + env(safe-area-inset-bottom, 0px)); }
  body { padding-bottom: var(--barre-vues); }
  .haut { padding-block: 6px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .outils { margin-left: auto; }
  .onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; border-radius: 0; gap: 2px;
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px -8px rgba(40, 32, 20, .18); }
  .onglets a { flex: 1 1 0; min-width: 0; height: 50px; flex-direction: column; justify-content: center; gap: 3px; padding: 4px 2px; border-radius: 14px; font-size: 11px; line-height: 1.15; }
  .onglets .lbl { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .onglets .lbl[data-court] { font-size: 0; }
  .onglets .lbl[data-court]::after { content: attr(data-court); font-size: 11px; }
  .onglets a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
}

/* Champs et boutons */
select, input[type="text"], input[type="date"], input[type="search"], input[type="password"] {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 9px; min-height: 40px; color: var(--ink); width: 100%; min-width: 0;
}
:is(select, input):hover { border-color: var(--line2); }
input:focus { border-color: var(--accent); }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: var(--r); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; color: var(--ink); text-decoration: none;
}
.bouton:hover { border-color: var(--line2); background: var(--surface2); }
.bouton.principal { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bouton.principal:hover { filter: brightness(1.08); background: var(--accent); }
.bouton[disabled] { opacity: .6; cursor: progress; }

/* Mise en page */
#vue { padding: 16px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); max-width: 1440px; margin: 0 auto; }
#vue:focus { outline: none; }
h1 { font-size: 22px; margin: 4px 0 4px; line-height: 1.2; }
h2 { font-size: 16px; margin: 0 0 10px; }
.sous { color: var(--muted); margin: 0 0 16px; max-width: 75ch; }
.carte { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; min-width: 0; }

/* Page de connexion */
.connexion { max-width: 420px; margin: 0 auto; padding: max(40px, 8vh) 16px 40px; display: grid; gap: 18px; }
.connexion .marque.grande { font-size: 22px; gap: 10px; justify-self: center; }
.connexion .carte { padding: 22px; }
.connexion form { display: grid; gap: 12px; }
.connexion .champ { display: grid; gap: 4px; }
.connexion .champ > span { font-weight: 600; font-size: 13px; }
.connexion .note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.connexion .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fait { color: var(--ok); background: var(--ok-soft); border-radius: var(--r); padding: 8px 10px; font-size: 13.5px; margin: 0; }
.vide { color: var(--muted); }

/* Pastilles */
.pastille { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pastille.st-proposition { color: var(--warn); background: var(--warn-soft); }
.pastille.st-en_vigueur { color: var(--ok); background: var(--ok-soft); }
.pastille.st-retiree { color: var(--muted); background: var(--surface2); }
.pastille.moins-cher { color: var(--ok); background: var(--ok-soft); }
.pastille.habituel { color: var(--muted); background: var(--surface2); }

/* Coter un envoi : saisie à gauche, résultat à droite ; l'un sous l'autre sous 960 px */
.coter { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.saisie { position: sticky; top: 72px; display: grid; gap: 12px; }
.saisie .champ { display: grid; gap: 4px; min-width: 0; }
.saisie .champ > span { font-weight: 600; font-size: 13px; }
.saisie .champ small { color: var(--muted); font-size: 12px; }
.saisie .deux { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.saisie .case { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); cursor: pointer; }
.saisie .case input { margin-top: 3px; accent-color: var(--accent); }
.erreur { color: var(--danger); background: var(--danger-soft); border-radius: var(--r); padding: 8px 10px; font-size: 13.5px; }
.resultat { display: grid; gap: 14px; min-width: 0; scroll-margin-top: 64px; }
.resultat[aria-busy="true"] { opacity: .55; transition: opacity .15s; }

.proposition { display: grid; gap: 4px; }
.proposition .etiquette { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.proposition .ligne { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.proposition .qui { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.proposition .prix { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.proposition .motif { color: var(--muted); margin: 0; }
.proposition .gain { color: var(--ok); font-weight: 600; margin: 2px 0 0; }
.rappel { color: var(--muted); font-size: 13px; margin: 0; }
.alerte { color: var(--warn); background: var(--warn-soft); border-radius: var(--r); padding: 8px 10px; font-size: 13.5px; margin: 0; }

/* Une cotation = une ligne repliable avec le détail du calcul */
.cotations { list-style: none; margin: 0; padding: 0; }
.cotations > li { border-top: 1px solid var(--line); }
.cotations > li:first-child { border-top: 0; }
.cotations summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; padding: 11px 4px; cursor: pointer; list-style: none; border-radius: 8px; }
.cotations summary::-webkit-details-marker { display: none; }
.cotations summary:hover { background: var(--surface2); }
.cotations .nom { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.cotations .nom b { overflow-wrap: anywhere; }
.cotations .total { font-weight: 700; font-size: 16px; text-align: right; }
.cotations .ecart { color: var(--muted); font-size: 13px; text-align: right; min-width: 110px; }
.cotations .chevron { transition: transform .15s; color: var(--faint); }
.cotations details[open] .chevron { transform: rotate(90deg); }
.cotations .nom .chevron { flex: none; }
.calcul { margin: 0 4px 12px; padding: 12px 14px; background: var(--surface2); border-radius: 12px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 18px; font-size: 13.5px; }
.calcul dt { color: var(--muted); }
.calcul dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.calcul .somme { font-weight: 700; padding-top: 6px; border-top: 1px solid var(--line); }
.calcul dt.somme { color: var(--ink); }

.ecartes { list-style: none; margin: 0; padding: 0; }
.ecartes li { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; padding: 8px 4px; border-top: 1px solid var(--line); }
.ecartes li:first-child { border-top: 0; }
.ecartes .pourquoi { color: var(--muted); }

@media (max-width: 959px) {
  .coter { grid-template-columns: minmax(0, 1fr); }
  .saisie { position: static; }
}
@media (max-width: 520px) {
  .cotations summary { grid-template-columns: minmax(0, 1fr) auto; }
  .cotations .total { order: 2; }
  .cotations .ecart { order: 3; grid-column: 1 / -1; text-align: left; min-width: 0; padding-left: 16px; }
  .proposition .prix { margin-left: 0; width: 100%; }
  .calcul { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .calcul dd { margin-bottom: 6px; }
  .saisie .deux { grid-template-columns: minmax(0, 1fr); }
}

/* Grilles et carburant */
.tableau { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tableau th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 8px; border-bottom: 1px solid var(--line); }
.tableau td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.tableau tr:first-child td { border-top: 0; }
.tableau .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; max-width: 70ch; }
.defile { overflow-x: auto; }
.pile { display: grid; gap: 16px; }
@media (max-width: 720px) {
  .tableau thead { display: none; }
  .tableau, .tableau tbody, .tableau tr, .tableau td { display: block; width: 100%; }
  .tableau tr { padding: 10px 0; border-top: 1px solid var(--line); }
  .tableau tr:first-child { border-top: 0; }
  .tableau td { border: 0; padding: 2px 0; }
  .tableau td[data-l]::before { content: attr(data-l) " : "; color: var(--muted); }
}
