:root {
  --sage: #1f3a5f; --sage-2: #4f46a5; --sage-soft: #e6e9f2;
  --sand: #f4f5f7; --ink: #1f2933; --mute: #66707a; --line: #e3e6ea;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --ok: #15803d;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--sand); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px 24px; }
h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0; }
.sub { color: var(--mute); font-size: 14px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b { font-weight: 700; }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; }
.card { background: #fff; border-radius: var(--r); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.stack > * + * { margin-top: 10px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.logo { font-size: 13px; font-weight: 700; color: var(--sage-2); letter-spacing: .08em; text-transform: uppercase; }

button, .btn { font: inherit; border: 0; cursor: pointer; border-radius: 14px; padding: 12px 14px; font-weight: 700; background: var(--sage-soft); color: var(--sage); text-align: center; text-decoration: none; display: inline-block; }
button:active, .btn:active, .press:active { transform: scale(.97); }
.btn-main { background: var(--sage); color: #fff; }
.btn-ghost { background: transparent; color: var(--mute); }
.btn-bad { background: #fee2e2; color: var(--bad); }
.btn-block { width: 100%; display: block; }
.fab { position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 20; background: var(--sage); color: #fff; border-radius: 22px; padding: 16px 20px; font-size: 16px; box-shadow: 0 8px 24px rgba(63,90,76,.35); }

input, select, textarea { font: inherit; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--sage-2); }
label.f { display: block; font-size: 13px; font-weight: 700; color: var(--mute); margin: 12px 0 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.nav button { flex: 1; max-width: 150px; background: none; color: var(--mute); padding: 6px 2px; font-size: 11px; border-radius: 12px; }
.nav button span { display: block; font-size: 22px; line-height: 1.2; }
.nav button.on { color: var(--sage); background: var(--sage-soft); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--sage-soft); color: var(--sage); white-space: nowrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.pill { flex-shrink: 0; padding: 8px 14px; border-radius: 99px; background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; }
.pill.on { background: var(--sage); color: #fff; }

.exp { display: flex; gap: 12px; align-items: center; width: 100%; background: #fff; border-radius: var(--r); padding: 12px; text-align: left; font-weight: 400; color: var(--ink); }
.exp .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; overflow: hidden; background: var(--sage-soft); }
.exp .ic img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.bar { height: 8px; border-radius: 99px; background: #eef0ec; overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.amount { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.month { display: flex; justify-content: space-between; margin: 20px 4px 8px; font-size: 13px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: #eef0ec; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { background: transparent; color: var(--mute); padding: 10px 6px; font-size: 14px; }
.seg button.on { background: #fff; color: var(--sage); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.catgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.catbtn { background: #fff; border: 2px solid var(--line); color: var(--ink); padding: 10px 4px; font-size: 12px; font-weight: 700; line-height: 1.2; }
.catbtn span { display: block; font-size: 22px; margin-bottom: 2px; }
.catbtn.on { border-color: var(--sage); background: var(--sage-soft); }

.line { display: grid; grid-template-columns: 1fr 54px 86px; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line input { padding: 8px 10px; }
.line .price { text-align: right; font-variant-numeric: tabular-nums; }
.line .qty { text-align: center; padding: 8px 4px; }
.line select { grid-column: 1 / 3; padding: 7px 10px; font-size: 14px; }
.line .del { grid-column: 3 / 4; padding: 7px; background: #f4f4f2; color: var(--mute); font-size: 13px; }

.notice { border-radius: 14px; padding: 10px 12px; font-size: 14px; background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: #dcfce7; color: var(--ok); }

.rx { border-radius: 22px; padding: 14px; background: linear-gradient(135deg, var(--sage), var(--sage-2)); color: #fff; }
.rx .sub { color: rgba(255,255,255,.75); }
.rx button, .rx label.btn { background: rgba(255,255,255,.16); color: #fff; }
.rx .go { background: #f0c27b; color: #3b2a10; }
.rx .strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.rx .strip img { height: 80px; width: 56px; object-fit: cover; object-position: top; border-radius: 8px; }
.rx .prog { height: 6px; border-radius: 99px; background: rgba(255,255,255,.2); margin-top: 10px; overflow: hidden; }
.rx .prog i { display: block; height: 100%; background: #f0c27b; transition: width .3s; }

.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(20,30,25,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto; background: var(--sand); border-radius: 24px 24px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: 90vw; }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery button { padding: 0; overflow: hidden; background: #fff; text-align: left; font-weight: 400; color: var(--ink); }
.gallery .im { height: 150px; background: #eee; overflow: hidden; }
.gallery .im img { width: 100%; object-fit: cover; object-position: top; }
.gallery .tx { padding: 8px 10px; }

.months { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 10px; }
.months div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 10px; color: var(--mute); }
.months i { display: block; width: 100%; background: var(--sage-2); border-radius: 4px 4px 0 0; min-height: 2px; }
.months .cur i { background: var(--sage); }

.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.login .lotus { font-size: 64px; }

/* ---------- Mes dépenses : espaces, logos, fiche société ---------- */
.spacebar { margin-bottom: 14px; }
.spaces { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #fff; padding: 5px; border-radius: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.spaces .sp { padding: 9px 4px; font-size: 13px; background: transparent; color: var(--mute); border-radius: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-img { display: inline-flex; align-items: center; background: #fff; border-radius: 10px; padding: 4px 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.brand-img img { display: block; width: auto; max-width: 200px; }
.brand-name { font-weight: 800; letter-spacing: -.01em; }
.hero { border-radius: 22px; padding: 18px 16px; margin-bottom: 14px; color: #fff; background: linear-gradient(135deg, var(--sage), var(--sage-2)); }
.logo-slot .logo-box { height: 110px; display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 14px; background: #fff; padding: 10px; }
.logo-slot .logo-box img { max-height: 90px; max-width: 100%; object-fit: contain; }
.logo-text { font-size: 26px; font-weight: 800; letter-spacing: -.02em; text-align: center; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.cmp th, table.cmp td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.cmp th { cursor: pointer; }
table.cmp .cur { background: var(--sage-soft); }
.cmp-logo { height: 34px; display: flex; align-items: center; }
.cmp-logo img { max-height: 30px; max-width: 120px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.timeline { position: relative; padding-left: 16px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline .tl { position: relative; padding: 4px 0 10px; }
.timeline .tl > i { position: absolute; left: -23px; top: 8px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.login-page main { max-width: 420px; }
.login-hero { padding: 26px 18px; border-radius: 26px; color: #fff; background: linear-gradient(135deg, #1f3a5f, #4f46a5 55%, #b3121f); }
.login-hero h1 { color: #fff; margin-top: 8px; }
.login-hero p { opacity: .85; }
.login-mark { font-size: 46px; }
a.btn .g { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 900; margin-right: 6px; }
#google { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.notice { text-align: left; }

/* ---------- Confort sur natel ---------- */
html { -webkit-text-size-adjust: 100%; }
button, .btn, a, label, summary, .press { touch-action: manipulation; }
.sheet-body { max-height: 94dvh; overscroll-behavior: contain; }
.sheet-body::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 9px; background: #cfd4da; margin: -6px auto 12px; }
.spacebar { position: sticky; top: 0; z-index: 25; margin: calc(-14px - env(safe-area-inset-top)) -16px 14px; padding: calc(10px + env(safe-area-inset-top)) 16px 8px; background: rgba(244,245,247,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.fab { box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.toast { box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (max-width: 899px) { input, select, textarea { font-size: 16px !important; } } /* pas de zoom automatique sur iPhone */
@media (hover: hover) { button:hover, .btn:hover { filter: brightness(.96); } .exp:hover, .card.press:hover, .gallery button:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); } }
:focus-visible { outline: 3px solid var(--sage-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Installation */
.install-banner { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--sage-soft); border-radius: 18px; padding: 10px 10px 10px 14px; margin-bottom: 12px; }
.step-n { flex-shrink: 0; width: 30px; height: 30px; border-radius: 99px; background: var(--sage); color: #fff; display: grid; place-items: center; font-weight: 800; }
.kbd { display: inline-block; border: 1.5px solid var(--sage); border-radius: 6px; padding: 0 6px; color: var(--sage); }
.ios-arrow { text-align: center; font-size: 34px; line-height: 1; color: var(--sage); margin-top: 14px; animation: bob 1s ease-in-out infinite; }
.ios-arrow .tiny { font-weight: 700; margin-top: 2px; }
@keyframes bob { 50% { transform: translateY(8px); } }

/* Glisser-déposer (ordinateur) */
body.dropping::after { content: "📥 Dépose ici tes tickets ou factures (photos, PDF)"; position: fixed; inset: 12px; z-index: 80; display: grid; place-items: center; border: 3px dashed var(--sage); border-radius: 24px; background: rgba(255,255,255,.9); color: var(--sage); font-size: 22px; font-weight: 800; pointer-events: none; }

/* ---------- Ordinateur et tablette en paysage : menu à gauche, panneaux à droite ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 232px; }
  main { max-width: 920px; padding: 20px 32px 48px; }
  .nav { top: 0; right: auto; width: 232px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 24px 14px; border-top: 0; border-right: 1px solid var(--line); background: #fff; }
  .nav::before { content: "💼 SinaïApp"; display: block; font-weight: 800; font-size: 18px; color: var(--ink); padding: 0 12px 18px; }
  .nav button { flex: none; max-width: none; display: flex; align-items: center; gap: 12px; padding: 11px 12px; font-size: 15px; text-align: left; }
  .nav button span { font-size: 20px; }
  .spacebar { margin: -20px -32px 18px; padding: 14px 32px 10px; }
  .spaces { max-width: 520px; }
  .fab { right: 32px; bottom: 28px; }
  .toast { bottom: 28px; left: calc(50% + 116px); }
  .sheet { justify-content: flex-end; align-items: stretch; }
  .sheet-body { max-width: 600px; max-height: none; height: 100%; border-radius: 22px 0 0 22px; padding: 26px 28px 32px; animation: side .2s ease-out; }
  .sheet-body::before { display: none; }
  @keyframes side { from { transform: translateX(40px); opacity: .5; } to { transform: none; opacity: 1; } }
  .gallery { grid-template-columns: repeat(4, 1fr); }
  .hero { padding: 24px 26px; }
  .stack > .exp + .exp { margin-top: 8px; }
  .login-page { padding-left: 0; }
  .login-page main { max-width: 420px; }
}
@media (min-width: 1300px) { .gallery { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 899px) { main { padding-bottom: 110px; } .fab { padding: 14px 18px; } }
