:root {
  /* Identité "joaillerie" : saphir, or, argent, rubis, émeraude */
  --bleu: #1B3A8C;          /* saphir */
  --bleu-fonce: #11265E;    /* saphir nuit */
  --bleu-clair: #E1E7F6;
  --bleu-pale: #F0F3FA;
  --or: #C8972F;            /* or jaune */
  --or-vif: #E2B54A;        /* or éclairé */
  --or-fonce: #A67A1B;
  --or-clair: #F6EAC9;
  --or-pale: #FCF7EA;
  --or-texte: #6B4A0B;
  --or-degrade: linear-gradient(135deg, #E9C463 0%, #C8972F 55%, #A67A1B 100%);
  --rubis: #B0233C;
  --rubis-clair: #FBE3E8;
  --rubis-bord: #F0B4C0;
  --rubis-texte: #861A2E;
  --emeraude: #0E7A5A;
  --emeraude-clair: #DDF2E9;
  --emeraude-bord: #A9DBC6;
  --emeraude-texte: #0A5A42;
  --argent: #C3C9D4;
  --argent-degrade: linear-gradient(180deg, #FFFFFF 0%, #F1F3F7 100%);
  --texte: #141B33;
  --texte-2: #3B4258;
  --gris: #586078;
  --bord: #DDE1E9;
  --bord-fort: #C3C9D4;
  --fond: #F3F4F7;
  --blanc: #FFFFFF;
  --rayon: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: var(--bleu); }
a:hover { color: var(--bleu-fonce); }
h1 { font-size: 28px; margin: 0; font-weight: 800; }
h2 { font-size: 18px; margin: 0; font-weight: 700; }
h3 { font-size: 15px; margin: 0; font-weight: 700; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: var(--texte); }
img { max-width: 100%; }

/* structure */
.shell { display: flex; min-height: 100vh; }
.side { width: 240px; flex: none; background: linear-gradient(180deg, #1B3A8C 0%, #11265E 100%); border-right: 3px solid var(--or); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(160deg, #2D53B8 0%, #11265E 100%); border: 1.5px solid var(--or-vif); box-shadow: 0 2px 8px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; flex: none; }
.brand-name { font-weight: 800; font-size: 21px; }
.brand-sub { font-size: 12px; color: #E9C463; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #fff; text-decoration: none; font-weight: 600; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.on { background: #fff; color: var(--bleu); font-weight: 700; box-shadow: inset 4px 0 0 var(--or); }
.nav a .pill { margin-left: auto; background: var(--or-vif); color: #2B1D03; border-radius: 999px; font-size: 12px; font-weight: 800; padding: 1px 8px; }
.nav a.on .pill { background: var(--rubis); color: #fff; }
.side-foot { margin-top: auto; padding: 14px 8px 0; font-size: 13px; color: #DCE4FF; border-top: 1px solid rgba(226,181,74,.45); }
.side-foot button { background: none; border: none; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; display: flex; flex-direction: column; gap: 20px; }
.topline { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.sub { color: var(--gris); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > * { min-width: 0; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grow { flex: 1 1 300px; }
.grow2 { flex: 2 1 420px; }

/* cartes */
.card { background: var(--blanc); border: 1px solid var(--bord); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.bleu { background: linear-gradient(135deg, #1B3A8C 0%, #11265E 100%); box-shadow: inset 0 -3px 0 var(--or); color: #fff; border: none; }
.card.bleu .sub { color: #DCE4FF; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.kpis { display: flex; flex-wrap: wrap; gap: 14px; }
.kpi { flex: 1 1 170px; background: var(--argent-degrade); border: 1px solid var(--bord); border-top: 3px solid var(--or); border-radius: 16px; padding: 16px 18px; }
.kpi .l { font-size: 13px; color: var(--gris); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 4px; }
.kpi .s { font-size: 13px; color: var(--gris); }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.tile { flex: 1 1 150px; background: #fff; color: var(--texte); border-radius: 12px; padding: 12px 14px; }
.tile .l { font-size: 13px; color: var(--gris); font-weight: 600; }
.tile .v { font-size: 21px; font-weight: 800; }
.tile.rachat { background: var(--or-clair); }
.tile.rachat .l { color: var(--or-texte); }

/* alertes */
.alert { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--rubis-clair); border: 1px solid var(--rubis-bord); color: var(--rubis-texte); border-radius: 14px; padding: 12px 16px; }
.alert .t { flex: 1 1 240px; min-width: 0; }
.alert b { display: block; }
.alert.info { background: var(--bleu-pale); border-color: #C9D3EE; color: var(--bleu-fonce); }
.alert.ok { background: var(--emeraude-clair); border-color: var(--emeraude-bord); color: var(--emeraude-texte); }
.alert svg { flex: none; }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 11px; border: 1.5px solid var(--or-fonce); background: var(--or-degrade); color: #2B1D03; font-weight: 700; box-shadow: inset 0 1px 0 rgba(255,255,255,.45); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--or-fonce); color: #fff; }
.btn.bleu { background: var(--bleu); border-color: var(--bleu); color: #fff; box-shadow: none; }
.btn.bleu:hover { background: var(--bleu-fonce); }
.btn.ghost { background: #fff; color: var(--bleu); border-color: var(--bleu); box-shadow: none; }
.btn.ghost:hover { background: var(--bleu-pale); color: var(--bleu); }
.btn.light { background: #fff; color: var(--bleu); border-color: var(--bord-fort); box-shadow: none; }
.btn.light:hover { background: var(--bleu-pale); color: var(--bleu); }
.btn.danger { background: #fff; color: var(--rubis); border-color: var(--rubis-bord); box-shadow: none; }
.btn.danger:hover { background: var(--rubis); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.big { min-height: 54px; font-size: 16px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link { background: none; border: none; color: var(--bleu); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }

/* chips et badges */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--bord-fort); background: #fff; color: var(--texte-2); font-weight: 700; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-weight: 700; font-size: 12.5px; white-space: nowrap; background: #EEF0F5; color: var(--texte-2); }
.badge.bleu { background: var(--bleu-clair); color: var(--bleu); }
.badge.or { background: var(--or-clair); color: var(--or-texte); }
.badge.rubis { background: var(--rubis-clair); color: var(--rubis-texte); }
.badge.emeraude { background: var(--emeraude-clair); color: var(--emeraude-texte); }
.badge.plein { background: var(--bleu); color: #fff; }
.retard { color: var(--rubis); font-weight: 800; font-size: 13px; }

/* formulaires */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .lab { font-size: 13px; font-weight: 700; }
.input, .field input, .field select, .field textarea { min-height: 46px; width: 100%; padding: 0 13px; border-radius: 10px; border: 1.5px solid var(--bord-fort); background: #fff; }
.field textarea { padding: 10px 13px; min-height: 80px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid #EBD08A; border-color: var(--or-fonce); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hint { font-size: 13px; color: var(--gris); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--or-fonce); }
.search { position: relative; }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--bord-fort); border-radius: 12px; box-shadow: 0 10px 30px rgba(20,33,61,.12); max-height: 280px; overflow-y: auto; }
.suggest button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border: none; background: #fff; cursor: pointer; border-bottom: 1px solid var(--bord); }
.suggest button:hover { background: var(--bleu-pale); }

/* listes */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--fond); text-align: left; border: 2px solid transparent; width: 100%; color: var(--texte); text-decoration: none; }
button.item, a.item { cursor: pointer; }
button.item:hover, a.item:hover { border-color: var(--bord-fort); color: var(--texte); }
.item.on { border-color: var(--bleu); background: #fff; }
.item .t { flex: 1 1 auto; min-width: 0; }
.item .t b { display: block; }
.item .t span { font-size: 13px; color: var(--gris); }
.thumb { width: 52px; height: 52px; flex: none; border-radius: 12px; background: linear-gradient(135deg, #EEF1F6 0%, #DCE1EA 100%); color: var(--or-fonce); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.lines { display: flex; flex-direction: column; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--bord); }
.line:last-child { border-bottom: none; }
.line .k { color: var(--gris); }
.line .v { font-weight: 700; text-align: right; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.total .v { font-size: 28px; font-weight: 800; color: var(--bleu); }
.empty { padding: 18px; border-radius: 12px; border: 1.5px dashed var(--bord-fort); color: var(--gris); text-align: center; background: #fff; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fact { background: var(--fond); border-radius: 12px; padding: 10px 13px; }
.fact .l { font-size: 12px; color: var(--gris); font-weight: 600; }
.fact .v { font-weight: 700; }
table.tab { width: 100%; border-collapse: collapse; font-size: 14px; }
.tab th { text-align: left; font-size: 12.5px; color: var(--gris); font-weight: 700; padding: 8px 10px; border-bottom: 1.5px solid var(--bord); }
.tab td { padding: 10px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
.tab td.n, .tab th.n { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* bijoux */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.bcard { background: #fff; border: 1px solid var(--bord); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: var(--texte); }
.bcard:hover { border-color: var(--or); color: var(--texte); box-shadow: 0 6px 18px rgba(166,122,27,.18); }
.bcard .ph { height: 140px; background: linear-gradient(135deg, #EEF1F6 0%, #DCE1EA 100%); color: var(--or-fonce); display: flex; align-items: center; justify-content: center; }
.bcard .ph img { width: 100%; height: 100%; object-fit: cover; }
.bcard .bd { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.bcard .px { font-weight: 800; color: var(--bleu); font-size: 17px; }
.photo-big { height: 300px; border-radius: 18px; background: linear-gradient(135deg, #EEF1F6 0%, #DCE1EA 100%); color: var(--or-fonce); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.photo-big img { width: 100%; height: 100%; object-fit: cover; }
.photos { display: flex; flex-wrap: wrap; gap: 12px; }
.photo { flex: 0 1 170px; display: flex; flex-direction: column; gap: 5px; margin: 0; }
.photo .box { height: 150px; border-radius: 12px; background: var(--bleu-clair); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--bleu); }
.photo .box img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo figcaption { font-size: 12.5px; color: var(--gris); }
.addphoto { flex: 0 1 150px; min-height: 150px; border-radius: 12px; border: 2px dashed var(--bord-fort); background: #fff; color: var(--bleu); font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px; text-align: center; }
.addphoto img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; }

/* étapes */
.steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.step { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--gris); }
.step .d { width: 28px; height: 28px; border-radius: 999px; background: #EEF0F5; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.step.done { color: var(--bleu); }
.step.done .d { background: var(--bleu); color: #fff; box-shadow: 0 0 0 2px var(--or-vif); }
.step.cur { font-weight: 800; }
.step .sep { width: 22px; height: 2px; background: var(--bord-fort); }

/* WhatsApp */
.wa { border-radius: 16px; background: var(--emeraude-clair); border: 1px solid var(--emeraude-bord); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.wa .msg { background: #fff; border-radius: 12px; padding: 12px 14px; white-space: pre-line; font-size: 14px; }

/* paiement */
.payline { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 8px; align-items: end; }
.iconbtn { width: 44px; height: 46px; border-radius: 10px; border: 1.5px solid var(--bord-fort); background: #fff; color: var(--rubis); cursor: pointer; font-size: 20px; font-weight: 700; }

/* modale */
dialog#modal { border: none; border-radius: 20px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px rgba(20,33,61,.3); color: var(--texte); }
dialog#modal::backdrop { background: rgba(20,33,61,.45); }
#modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.close { width: 40px; height: 40px; border-radius: 10px; border: none; background: var(--fond); cursor: pointer; font-size: 22px; color: var(--texte-2); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: var(--texte); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--rubis); }

/* connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 20% 15%, #2A4FB0 0%, #1B3A8C 40%, #0D1E4C 100%); }
.login .card { border-top: 4px solid var(--or); }
.login .card { width: min(420px, 100%); padding: 28px; gap: 16px; }

/* inventaire */
.inv-item.ok { background: var(--bleu-pale); border-color: var(--bleu); }
.progress { height: 12px; border-radius: 999px; background: var(--bleu-clair); overflow: hidden; }
.progress div { height: 100%; background: var(--bleu); border-radius: 999px; }

.toggle { width: 56px; height: 32px; flex: none; border-radius: 999px; border: none; padding: 3px; cursor: pointer; display: flex; background: var(--bord-fort); justify-content: flex-start; }
.toggle span { width: 26px; height: 26px; border-radius: 999px; background: #fff; display: block; }
.toggle[aria-pressed="true"] { background: var(--bleu); justify-content: flex-end; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub, .side-foot { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { white-space: nowrap; min-height: 40px; }
  .main { padding: 18px 14px 50px; }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payline { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; }
  .payline .ref { grid-column: 1 / 3; }
}
@media (max-width: 520px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 23px; }
}
@media print {
  .side, .no-print { display: none !important; }
}
