/* Thème clair : chaque couleur de texte fait au moins 4,5:1 sur son fond (WCAG AA). */
:root{
  --bg:#fff6f9; --surface:#ffffff; --border:#ecc3d4; --text:#3c2432; --muted:#7a5262;
  --accent:#b8235a; --accent-soft:#ffe3ee; --accent-ink:#ffffff;
  --pos:#1f7a51; --pos-bg:#e4f5ec;
  --neg:#c0362d; --neg-bg:#fdecea;
  --info-bg:#ffe3ee; --info-ink:#a3245c;
  --wait-bg:#fdf1db; --wait-ink:#7a5a14;
  --page-grad:linear-gradient(160deg,#ffe3ef 0%,#fde7f7 45%,#f3e4ff 100%); --pattern:url('/pauline-light.svg');
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#201118; --surface:#2b1620; --border:#4a2534; --text:#fbe9f0; --muted:#c79cae;
    --accent:#ff7bab; --accent-soft:#4a2534; --accent-ink:#2b0a17;
    --pos:#5bd499; --pos-bg:#143126;
    --neg:#ff8a80; --neg-bg:#3a1b17;
    --info-bg:#4a2534; --info-ink:#ffaccb;
    --wait-bg:#3a2e17; --wait-ink:#e3bf6f;
    --page-grad:linear-gradient(160deg,#2a0f1d 0%,#24101f 50%,#1d1127 100%); --pattern:url('/pauline-dark.svg');
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg:#201118; --surface:#2b1620; --border:#4a2534; --text:#fbe9f0; --muted:#c79cae;
  --accent:#ff7bab; --accent-soft:#4a2534; --accent-ink:#2b0a17;
  --pos:#5bd499; --pos-bg:#143126;
  --neg:#ff8a80; --neg-bg:#3a1b17;
  --info-bg:#4a2534; --info-ink:#ffaccb;
  --wait-bg:#3a2e17; --wait-ink:#e3bf6f;
  --page-grad:linear-gradient(160deg,#2a0f1d 0%,#24101f 50%,#1d1127 100%); --pattern:url('/pauline-dark.svg');
  color-scheme: dark;
}
*{box-sizing:border-box}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
body{
  margin:0; background:var(--bg) var(--page-grad) fixed; color:var(--text);
  font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;
  font-size:14px; min-height:100vh; min-height:100dvh;
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
  /* Colonne pleine hauteur : le bandeau (.site-footer) reste collé en bas de
     l'écran même quand la page est courte. */
  display:flex; flex-direction:column;
}
#app{flex:1 0 auto}
/* Fond « Pauline » en diagonale. Calque fixe plus grand que l'écran, tourné ;
   le motif glisse quand on scrolle (--scroll-y, mis à jour par app.js). */
body::before{
  content:""; position:fixed; z-index:-1; pointer-events:none;
  top:-50%; left:-50%; width:200%; height:200%;
  background-image:var(--pattern); background-size:280px 120px;
  background-position:0 calc(var(--scroll-y, 0) * 0.6px);
  transform:rotate(-28deg);
}
@media (prefers-reduced-motion: reduce){ body::before{background-position:0 0} }

/* Interrupteur thème sombre on/off, toujours visible en bas à droite. */
.theme-switch{
  position:fixed; right:16px; bottom:calc(16px + env(safe-area-inset-bottom,0px)); z-index:50;
  display:flex; align-items:center; gap:8px; padding:6px 8px 6px 12px;
  border-radius:999px; border:1px solid var(--border); background:var(--surface);
  color:var(--text); font:inherit; font-size:12.5px; font-weight:600; cursor:pointer;
  box-shadow:0 4px 14px rgba(184,35,90,.22);
}
.theme-switch:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
.ts-track{position:relative; width:52px; height:28px; border-radius:999px; background:var(--accent-soft); border:1px solid var(--border); transition:background .2s}
.ts-knob{position:absolute; top:2px; left:2px; width:22px; height:22px; border-radius:50%; background:var(--accent); display:flex; align-items:center; justify-content:center; font-size:13px; line-height:1; transition:transform .2s}
.theme-switch[aria-checked="true"] .ts-track{background:var(--accent)}
.theme-switch[aria-checked="true"] .ts-knob{transform:translateX(24px); background:var(--accent-ink)}
@media (prefers-reduced-motion: reduce){ .ts-track, .ts-knob{transition:none} }
.display{font-family:Fraunces,serif; font-weight:600}
[hidden]{display:none !important}

.login-screen{flex:1 0 auto; display:flex; align-items:center; justify-content:center; padding:24px}

/* Bandeau de bas de page, sur tous les écrans (connexion comprise). Marge à
   droite pour ne pas passer sous l'interrupteur de thème fixé en bas. */
.site-footer{
  background:var(--surface); border-top:1px solid var(--border); color:var(--muted);
  text-align:center; font-size:12.5px; line-height:1.5;
  padding:16px 190px calc(16px + env(safe-area-inset-bottom,0px));
  margin-top:auto; flex-shrink:0;
}
.site-footer strong{color:var(--accent); font-weight:700}
@media(max-width:600px){ .site-footer{padding:14px 16px calc(70px + env(safe-area-inset-bottom,0px))} }
.login-card{background:var(--surface); border:1px solid var(--border); border-radius:20px; padding:28px; width:100%; max-width:340px}
.login-brand{display:flex; align-items:center; gap:8px; font-size:19px; margin-bottom:18px; justify-content:center}
.login-brand svg{width:20px; height:20px; color:var(--accent)}
.login-error{background:var(--neg-bg); color:var(--neg); font-size:13px; padding:9px 12px; border-radius:10px; margin-bottom:12px; display:none}
.login-error.show{display:block}
.setup-warning{font-size:12.5px; background:var(--wait-bg); color:var(--wait-ink); border-radius:10px; padding:9px 12px; margin:0 0 14px; line-height:1.45}
.setup-intro{font-size:13px; color:var(--muted); margin:0 0 14px; line-height:1.45}

.topbar{position:sticky; top:0; z-index:20; background:var(--surface); border-bottom:1px solid var(--border); padding:0 16px; padding-top:env(safe-area-inset-top,0px); display:flex; align-items:center; height:54px}
.brand{display:flex; align-items:center; gap:8px; font-size:16px}
.brand svg{width:18px; height:18px; color:var(--accent)}
.topbar-right{margin-left:auto; display:flex; align-items:center; gap:10px; min-width:0}
@media(max-width:600px){
  .topbar{padding:0 12px; gap:8px}
  .brand{font-size:15px; white-space:nowrap; min-width:0; overflow:hidden; text-overflow:ellipsis}
  .brand svg{flex-shrink:0}
  .who{display:none}
  .topbar-right{gap:6px; flex-shrink:0}
  .view-as{max-width:100px}
  .logout-btn{padding:6px 8px}
}
.who{font-size:12.5px; color:var(--muted)}
.logout-btn{background:none; border:1px solid var(--border); border-radius:8px; padding:6px 10px; font:inherit; font-size:12px; color:var(--muted); font-weight:600}
.view-as{background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:6px 8px; font:inherit; font-size:12px; color:var(--text); font-weight:600; max-width:150px}
.view-banner{background:var(--wait-bg); color:var(--wait-ink); font-size:13px; font-weight:600; text-align:center; padding:8px 16px}
.sr-only{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

.tabbar{display:flex; gap:4px; padding:10px 12px; background:var(--surface); border-bottom:1px solid var(--border); position:sticky; top:54px; z-index:19; overflow-x:auto}
.tab{padding:7px 14px; border-radius:20px; border:1px solid transparent; background:none; color:var(--muted); font:inherit; font-weight:600; font-size:13px; white-space:nowrap}
.tab.active{background:var(--accent-soft); color:var(--accent); border-color:var(--accent-soft)}

main{max-width:760px; margin:0 auto; padding:16px}
.page-title{font-size:20px; margin:4px 0 14px}

.card{background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:16px; margin-bottom:12px}
.kpis{display:grid; grid-template-columns:repeat(2,1fr); gap:10px; margin-bottom:12px}
@media(min-width:520px){ .kpis{grid-template-columns:repeat(5,1fr)} }
.kpi{background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:12px 14px}
.kpi .label{font-size:12px; color:var(--muted); margin-bottom:4px}
.kpi .value{font-size:20px; font-weight:700; font-variant-numeric:tabular-nums}

.section-label{font-size:12.5px; font-weight:600; color:var(--muted); margin:0 0 10px}
.chart-head{display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:10px; margin-bottom:12px}
.seg{display:inline-flex; background:var(--bg); border:1px solid var(--border); border-radius:20px; padding:2px}
.seg-btn{padding:5px 11px; border-radius:18px; border:none; background:none; color:var(--muted); font:inherit; font-weight:600; font-size:12px}
.seg-btn.active{background:var(--accent); color:var(--accent-ink)}

.chart-area{position:relative}
.hover-zone{fill:transparent; cursor:pointer}
.chart-cursor{opacity:0; transition:opacity .15s ease; pointer-events:none}
.chart-cursor.show{opacity:1}
#cursor-line, #cursor-dot{transition:transform .12s ease-out}
.chart-tooltip{position:absolute; pointer-events:none; background:var(--text); color:var(--surface); padding:6px 10px; border-radius:8px; font-size:12px; font-weight:600; white-space:nowrap; transform:translate(-50%,-120%); opacity:0; transition:opacity .12s ease, transform .12s ease-out; z-index:5}
.chart-tooltip.show{opacity:1}
.chart-tooltip .tt-sub{font-weight:400; opacity:.75; font-size:11px}
svg .axis-label{fill:var(--muted); font-size:10.5px; font-family:Inter,sans-serif}
svg .bar-pos{fill:var(--pos); transition:opacity .15s ease}
svg .bar-neg{fill:var(--neg); transition:opacity .15s ease}

button:focus-visible, a:focus-visible, [tabindex]:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:4px}
svg .hover-zone:focus-visible{outline:2px solid var(--accent)}

/* Pense-bête : carte opaque avec bord rose à gauche, pour ressortir sur le fond rose. */
.sticky-note{background:var(--surface); border-color:var(--border); border-left:4px solid var(--accent); position:relative; box-shadow:0 2px 10px rgba(184,35,90,.10)}
.sticky-note::before{content:"📌"; position:absolute; top:-10px; left:16px; font-size:16px; transform:rotate(-12deg)}
.note-area{width:100%; min-height:72px; border:1px solid var(--border); border-radius:10px; background:var(--bg); resize:vertical; font:inherit; font-size:13.5px; color:var(--text); padding:9px 10px; line-height:1.5}
.note-area:focus{outline:2px solid var(--accent); outline-offset:1px}
.note-area::placeholder{color:var(--muted)}
.note-saved{font-size:11px; color:var(--muted); text-align:right; margin-top:4px; height:14px}

.row-head{display:grid; grid-template-columns:40px 1.5fr .75fr .7fr 60px; gap:8px; padding:0 2px 8px; border-bottom:1px solid var(--border)}
.row-head span{font-size:11px; color:var(--muted); font-weight:600}
.trow{display:grid; grid-template-columns:40px 1.5fr .75fr .7fr 60px; gap:8px; align-items:center; padding:12px 2px; border-bottom:1px solid var(--border)}
.trow:last-child{border-bottom:none}
.thumb{width:40px; height:40px; border-radius:10px; object-fit:cover; background:var(--accent-soft); border:1px solid var(--border)}
.thumb-ph{width:40px; height:40px; border-radius:10px; background:var(--accent-soft); display:flex; align-items:center; justify-content:center; color:var(--accent); font-size:14px}
.tname{font-weight:600; font-size:13.5px}
.tsub{font-size:12px; color:var(--muted); margin-top:2px}
.tby{font-size:11px; color:var(--muted); margin-top:2px; font-style:italic}
.tnum{font-variant-numeric:tabular-nums; font-size:13.5px}

.badge{display:inline-block; font-size:11.5px; font-weight:600; padding:3px 9px; border-radius:20px}
.badge.en_vente{background:var(--wait-bg); color:var(--wait-ink)}
.badge.vendu{background:var(--info-bg); color:var(--info-ink)}
.badge.expedie{background:var(--info-bg); color:var(--info-ink)}
.badge.livre{background:var(--pos-bg); color:var(--pos)}

.track-link{display:inline-flex; align-items:center; gap:4px; font-size:12px; color:var(--accent); text-decoration:none; margin-top:6px; font-weight:600}
.track-link svg{width:11px; height:11px}
.del, .edit{background:none; border:1px solid var(--border); border-radius:8px; color:var(--muted); width:26px; height:26px; font-size:14px; line-height:1}
.empty{text-align:center; padding:40px 16px; color:var(--muted); font-size:13.5px}

.field{margin-bottom:12px}
.field label{display:block; font-size:12.5px; font-weight:600; margin-bottom:5px}
.field input, .field select{width:100%; padding:9px 10px; border-radius:10px; border:1px solid var(--border); background:var(--bg); color:var(--text); font:inherit; font-size:14px}
.field input:focus, .field select:focus{outline:2px solid var(--accent); outline-offset:1px}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:10px}
.help-card{border-left:4px solid var(--accent)}
.help-card summary{cursor:pointer; font-weight:700; font-size:14px; list-style-position:inside}
.help-card summary:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}
.help-steps{margin:12px 0 8px; padding-left:20px; font-size:13.5px; line-height:1.55}
.help-steps li{margin-bottom:6px}
.help-tips{margin:0; padding-left:20px; font-size:12.5px; line-height:1.5; color:var(--muted)}
.help-tips li{margin-bottom:4px}
.help-tips strong{color:var(--text)}
.desc-layout{display:grid; gap:12px}
@media(min-width:860px){ .desc-layout{grid-template-columns:1fr 1fr; align-items:start} .desc-out{position:sticky; top:120px} }
.chips{display:flex; flex-wrap:wrap; gap:6px}
.chip{padding:6px 12px; border-radius:999px; border:1px solid var(--border); background:var(--bg); color:var(--text); font:inherit; font-size:12.5px; font-weight:600; cursor:pointer}
.chip[aria-pressed="true"]{background:var(--accent); border-color:var(--accent); color:var(--accent-ink)}
.chip:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
.field-hint{font-size:11.5px; color:var(--muted); margin-top:4px}
.field textarea{width:100%; min-height:70px; padding:9px 10px; border-radius:10px; border:1px solid var(--border); background:var(--bg); color:var(--text); font:inherit; font-size:14px; resize:vertical}
.field textarea:focus{outline:2px solid var(--accent); outline-offset:1px}
.desc-source{display:flex; gap:10px; align-items:center}
.desc-source img{width:56px; height:56px; border-radius:10px; object-fit:cover; flex-shrink:0; border:1px solid var(--border)}
.out-block{margin-bottom:14px}
.out-head{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px}
.out-head .section-label{margin:0}
.out-text{white-space:pre-wrap; word-break:break-word; background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:10px 12px; font-size:13.5px; line-height:1.55; margin:0; font-family:inherit}
.out-count{font-size:11.5px; color:var(--muted)}
.out-count.over{color:var(--neg); font-weight:700}
.btn-copy{padding:5px 10px; border-radius:9px; border:1px solid var(--accent); background:none; color:var(--accent); font:inherit; font-weight:700; font-size:12px}
.btn-copy.done{background:var(--accent); color:var(--accent-ink)}
.check-line{display:flex; align-items:center; gap:8px; font-size:13px; margin:4px 0}
.stock-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:12px; align-items:start}
.stock-card{background:var(--surface); border:1px solid var(--border); border-radius:16px; overflow:hidden; display:flex; flex-direction:column}
.stock-photo{position:relative}
.stock-photo .stock-img, .stock-photo .stock-img-ph{aspect-ratio:16/10}
.bilan{display:grid; grid-template-columns:repeat(3,1fr); gap:6px; background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:8px}
.bilan div{display:flex; flex-direction:column; gap:1px}
.bilan span{font-size:10.5px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.02em}
.bilan strong{font-size:13.5px}
.bilan .bilan-wide{grid-column:span 3; flex-direction:row; justify-content:space-between; align-items:baseline; border-top:1px solid var(--border); padding-top:6px}
.var-row, .piece-row{border:1px solid var(--border); border-radius:10px; padding:8px; display:flex; flex-direction:column; gap:6px}
.var-nums, .piece-inputs{display:grid; grid-template-columns:1fr 1fr; gap:6px}
.var-nums label, .piece-inputs label{font-size:11px; font-weight:600; color:var(--muted); display:flex; flex-direction:column; gap:2px; margin:0}
.var-actions{display:flex; gap:6px; flex-wrap:wrap}
.var-actions .btn-secondary, .var-actions .btn-danger{padding:6px 10px; font-size:12px}
.var-meta{font-size:11.5px; color:var(--muted)}
.piece-row{border-color:var(--wait-ink); border-style:dashed}
.piece-name{font-size:13px; font-weight:600}
.var-add summary, details.card > summary{cursor:pointer; font-size:12.5px; font-weight:700; color:var(--accent)}
.var-add[open] summary{margin-bottom:6px}
details.card[open] > summary{margin-bottom:12px}
.stock-badges{position:absolute; top:8px; left:8px; right:8px; display:flex; flex-wrap:wrap; gap:4px}
.stock-badges .badge{box-shadow:0 1px 4px rgba(0,0,0,.15)}
.badge.stock-out{background:var(--neg-bg); color:var(--neg)}
.stock-img{width:100%; aspect-ratio:1/1; object-fit:cover; display:block; background:var(--bg)}
.stock-img-ph{width:100%; aspect-ratio:1/1; display:flex; align-items:center; justify-content:center; font-size:32px; background:var(--bg)}
.stock-body{padding:10px 12px 12px; display:flex; flex-direction:column; gap:8px; flex:1}
.stock-body input{width:100%; padding:7px 9px; border-radius:9px; border:1px solid var(--border); background:var(--bg); color:var(--text); font:inherit; font-size:13px}
.stock-body label{font-size:11.5px; font-weight:600; color:var(--muted); display:block; margin-bottom:3px}
.stock-row{display:grid; grid-template-columns:1fr 1fr; gap:8px}
.stock-actions{display:flex; gap:6px; flex-wrap:wrap; margin-top:auto}
.stock-actions .btn-secondary, .stock-actions .btn-danger{padding:6px 10px; font-size:12px}
.btn-sell{padding:6px 10px; border-radius:10px; border:none; background:var(--accent); color:var(--accent-ink); font:inherit; font-weight:700; font-size:12px}
.btn-sell:disabled{opacity:.5}
.stock-head{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:12px}
.stock-head .page-title{margin:0}
.acct{border-top:1px solid var(--border); padding:14px 0 4px}
.acct:first-of-type{border-top:none; padding-top:0}
.acct-head{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px}
.acct-name{font-weight:700; font-size:14px; word-break:break-all}
.acct-meta{font-size:12px; color:var(--muted)}
.acct-info{display:grid; grid-template-columns:max-content 1fr; gap:6px 12px; margin:0 0 12px; font-size:13px}
.acct-info dt{color:var(--muted); font-weight:600}
.acct-info dd{margin:0; word-break:break-all}
.pw-cell{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.pw-value{font-family:ui-monospace,Consolas,monospace; font-size:13px; background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:2px 8px}
.pw-cell .btn-secondary{padding:4px 10px; font-size:12px}
.badge.role-superadmin{background:var(--accent); color:var(--accent-ink)}
.badge.role-admin{background:var(--info-bg); color:var(--info-ink)}
.badge.role-user{background:var(--wait-bg); color:var(--wait-ink)}
.badge.setup{background:var(--neg-bg); color:var(--neg)}
.inline-form{display:flex; gap:8px; margin-bottom:8px}
.inline-form input, .inline-form select{flex:1; min-width:0; padding:8px 10px; border-radius:10px; border:1px solid var(--border); background:var(--bg); color:var(--text); font:inherit; font-size:13px}
.inline-form .btn-secondary{white-space:nowrap}
.btn-danger{padding:8px 14px; border-radius:10px; border:1px solid var(--neg); background:none; color:var(--neg); font:inherit; font-weight:600; font-size:13px}
.acct-actions{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px}
.check-row{display:flex; align-items:center; gap:8px; font-size:13px; margin-bottom:12px}
.btn-primary{width:100%; padding:11px; border:none; border-radius:10px; margin-top:4px; background:var(--accent); color:var(--accent-ink); font:inherit; font-weight:700; font-size:14px}
.btn-primary[disabled]{opacity:.6}
.photo-row{display:flex; align-items:center; gap:12px}
.photo-preview{width:64px; height:64px; border-radius:14px; object-fit:cover; background:var(--accent-soft); border:1px solid var(--border); flex-shrink:0}
.photo-preview-ph{width:64px; height:64px; border-radius:14px; background:var(--accent-soft); display:flex; align-items:center; justify-content:center; color:var(--accent); font-size:20px; flex-shrink:0}
.form-actions{display:flex; gap:8px; align-items:center}
.btn-secondary{padding:8px 14px; border-radius:10px; border:1px solid var(--border); background:var(--surface); color:var(--text); font:inherit; font-weight:600; font-size:13px}

.avatar-btn{background:none; border:none; padding:0; border-radius:50%; line-height:0}
.avatar-ph{width:32px; height:32px; border-radius:50%; background:var(--accent-soft); display:flex; align-items:center; justify-content:center; font-size:15px; border:1px solid var(--border)}
.avatar-img{width:32px; height:32px; border-radius:50%; object-fit:cover; border:1px solid var(--border); display:block}

.log-row{display:flex; align-items:center; gap:12px; padding:11px 2px; border-bottom:1px solid var(--border)}
.log-row:last-child{border-bottom:none}
.log-icon{width:34px; height:34px; border-radius:50%; background:var(--accent-soft); display:flex; align-items:center; justify-content:center; font-size:15px; flex-shrink:0}
.log-label{font-size:13.5px; font-weight:600}
.log-time{font-size:12px; color:var(--muted); margin-top:1px}

/* Classes utilitaires (on évite les style="" inline pour rester compatible CSP strict) */
.amt-pos{color:var(--pos)}
.amt-neg{color:var(--neg)}
.amt-muted{color:var(--muted)}

.m0{margin:0}
.mb8{margin-bottom:8px}
.flex-gap{display:flex; gap:6px}
.text-right{text-align:right}
