/* Acheteo - GLAPSYS */
:root {
  --green: #BCC63F; --green-d: #9DA62E; --green-l: #F3F5DA;
  --black: #000; --ink: #15170F; --muted: #6B6E60; --line: #E3E5D8;
  --bg: #F7F8F2; --card: #FFF; --red: #C8402F; --orange: #D98A1E; --blue: #2F6FC8;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

/* En-tête */
header.top { position: sticky; top: 0; z-index: 20; background: var(--black); color: #fff; padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; letter-spacing: .5px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--green); }
.brand svg { width: 26px; height: 26px; }
.company-pick { margin-left: auto; background: #1E2016; border: 1px solid #33362A; color: #fff; border-radius: 10px; padding: 6px 10px; max-width: 55vw; font-size: 14px; }
.company-name { margin-left: auto; font-size: 14px; color: #CFD2C2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }

/* Navigation bas (mobile) / latérale (ordinateur) */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-b); }
nav.tabs button { flex: 1; background: none; border: 0; padding: 9px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); cursor: pointer; position: relative; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.active { color: var(--black); font-weight: 600; }
nav.tabs button.active svg { color: var(--green-d); }
nav.tabs .dot { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--orange); color: #fff; border-radius: 9px; font-size: 10.5px; min-width: 17px; height: 17px; padding: 0 4px; line-height: 17px; font-weight: 700; }
@media (min-width: 900px) {
  nav.tabs { top: 58px; bottom: 0; right: auto; width: 92px; flex-direction: column; justify-content: flex-start; padding-top: 16px; border-top: 0; border-right: 1px solid var(--line); }
  nav.tabs button { flex: 0; padding: 14px 4px; }
  main { padding-left: 116px; max-width: none; padding-right: 32px; }
  header.top { padding-left: 24px; height: 58px; }
}

/* Cartes et éléments */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer; background: #ECEEE3; color: var(--ink); text-decoration: none; min-height: 46px; }
.btn.primary { background: var(--green); color: var(--black); }
.btn.dark { background: var(--black); color: #fff; }
.btn.danger { background: #FBE7E4; color: var(--red); }
.btn.ghost { background: none; color: var(--muted); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input.i, select.i, textarea.i { width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 12px; background: #fff; font-size: 16px; min-height: 46px; }
input.i:focus, select.i:focus, textarea.i:focus { outline: none; border-color: var(--green-d); box-shadow: 0 0 0 3px var(--green-l); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Accueil : gros bouton photo */
.capture { display: flex; flex-direction: column; align-items: center; padding: 26px 0 18px; }
.shoot { width: min(64vw, 230px); height: min(64vw, 230px); border-radius: 50%; border: 0; background: var(--green); color: var(--black); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: 17px; box-shadow: 0 0 0 10px var(--green-l), 0 10px 30px rgba(120,130,20,.35); transition: transform .12s; }
.shoot:active { transform: scale(.96); }
.shoot svg { width: 72px; height: 72px; }
.quickbtn { margin-top: 22px; background: #fff; border: 2px solid var(--black); color: var(--black); min-width: min(64vw, 230px); }
.capture #pickbtn { margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: #fff; border-radius: 12px; padding: 12px; box-shadow: var(--shadow); text-align: center; }
.stat b { display: block; font-size: clamp(15px, 4.6vw, 20px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { font-size: 12px; color: var(--muted); }
@media (min-width: 900px) { .home { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; } }

/* Liste de tickets */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; border: 0; width: 100%; text-align: left; }
.item .thumb { width: 46px; height: 46px; border-radius: 9px; background: #EEF0E4 center/cover no-repeat; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.item .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: #EEF0E4; color: var(--muted); white-space: nowrap; }
.chip.processing { background: #E6EEFA; color: var(--blue); }
.chip.to_confirm, .chip.manual { background: #FCEFD9; color: #9A5D07; }
.chip.validated { background: var(--green-l); color: #5E6512; }
.chip.error { background: #FBE7E4; color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Écran de confirmation */
.confirm { display: grid; gap: 14px; }
@media (min-width: 900px) { .confirm { grid-template-columns: minmax(280px, 42%) 1fr; align-items: start; } .confirm .photo { position: sticky; top: 76px; } }
.photo { background: #1A1C14; border-radius: var(--radius); overflow: hidden; display: flex; justify-content: center; min-height: 120px; }
.photo img { max-width: 100%; max-height: 34vh; object-fit: contain; cursor: zoom-in; display: block; }
@media (min-width: 900px) { .photo img { max-height: calc(100vh - 110px); } }
.photo iframe { width: 100%; height: 60vh; border: 0; background: #fff; }
.warn { background: #FCEFD9; color: #7A4A05; border-radius: 11px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.err { background: #FBE7E4; color: var(--red); border-radius: 11px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.ok { background: var(--green-l); color: #4F5510; border-radius: 11px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1.5px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 13px; font-size: 14px; cursor: pointer; }
.pill.on { background: var(--black); color: #fff; border-color: var(--black); }
table.vat { width: 100%; border-collapse: collapse; }
table.vat th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: right; padding: 0 4px 4px; }
table.vat th:first-child { text-align: left; }
table.vat td { padding: 3px 3px; }
table.vat input { min-height: 42px; padding: 8px; }
table.vat td.rate { width: 82px; }
table.vat td.del { width: 34px; }
.iconbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.sticky-actions { position: sticky; bottom: calc(66px + var(--safe-b)); z-index: 5; display: flex; gap: 10px; padding: 12px 0 2px; background: linear-gradient(transparent, var(--bg) 30%); }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }
.sticky-actions .btn.primary { flex: 1; font-size: 17px; min-height: 54px; }
details.lines summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.total-line { display: flex; justify-content: space-between; font-weight: 700; padding: 8px 4px 0; border-top: 1px solid var(--line); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* Zoom photo */
.zoom { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.zoom img { width: 100%; max-width: 1400px; }
.zoom .close { position: fixed; top: calc(12px + var(--safe-t)); right: 12px; background: #fff; border: 0; border-radius: 50%; width: 42px; height: 42px; font-size: 20px; cursor: pointer; }

/* Toast et feuilles */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); background: var(--black); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; font-weight: 500; box-shadow: 0 8px 26px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }
.toast.good { background: #3D4410; }
.toast.bad { background: var(--red); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; border-radius: 20px 20px 0 0; padding: 22px 20px calc(22px + var(--safe-b)); width: 100%; max-width: 520px; }
@media (min-width: 600px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }

/* Connexion */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--black); }
.login .box { background: #fff; border-radius: 20px; padding: 28px 22px; width: 100%; max-width: 400px; }
.login .logo { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.login .logo b { color: var(--green-d); }
.login .logo svg { width: 40px; height: 40px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Tableaux réglages */
.setrow { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #D5D8C8; border-radius: 30px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green-d); }
.switch input:checked + span::before { transform: translateX(20px); }
.seg { display: flex; background: #ECEEE3; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 9px 6px; font-size: 14px; cursor: pointer; font-weight: 500; }
.seg button.on { background: #fff; box-shadow: var(--shadow); font-weight: 700; }
.progress { height: 8px; background: #ECEEE3; border-radius: 8px; overflow: hidden; }
.progress div { height: 100%; background: var(--green-d); }
.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
.upload-bar { position: fixed; top: calc(58px + var(--safe-t)); left: 0; right: 0; height: 3px; z-index: 30; }
.upload-bar div { height: 100%; background: var(--green); transition: width .2s; }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.exp-grid .btn { flex-direction: column; min-height: 84px; gap: 4px; }
.exp-grid .btn small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; }
.scroll-x { overflow-x: auto; }

/* Achat sans ticket */
.sheet-bg.full .sheet { max-width: 420px; }
@media (max-width: 599px) { .sheet-bg.full .sheet { border-radius: 20px 20px 0 0; padding-top: 16px; } }
.q-amount { text-align: center; font-size: clamp(40px, 13vw, 54px); font-weight: 800; margin: 10px 0 6px; font-variant-numeric: tabular-nums; letter-spacing: -1px; white-space: nowrap; overflow: hidden; }
.q-amount small { font-size: .45em; color: var(--muted); font-weight: 700; letter-spacing: 0; }
.q-opts { margin-bottom: 10px; }
.q-opts .pills { justify-content: flex-start; }
.q-more { margin-top: 8px; flex-wrap: wrap; position: relative; }
.linkbtn { background: none; border: 0; color: var(--ink); font-weight: 600; cursor: pointer; padding: 6px 2px; font-size: 14px; }
.q-date { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pad button { border: 0; background: #F0F2E6; border-radius: 14px; height: clamp(50px, 8.5vh, 64px); font-size: 26px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.pad button:active { background: var(--green-l); transform: scale(.97); }
.q-save { min-height: 58px; font-size: 18px; }
