/* Cockpit Micka : mobile d'abord, gros boutons, clair et sombre. */
:root {
    --bg: #F6F1E9;
    --surface: #FFFFFF;
    --ink: #1C1714;
    --muted: #6E6259;
    --line: #E4DACD;
    --accent: #B3201A;
    --accent-ink: #FFFFFF;
    --gold: #C9861F;
    --ok: #2E7D4F;
    --radius: 14px;
    --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0E0B0A;
        --surface: #1A1513;
        --ink: #F3EADB;
        --muted: #A89A8C;
        --line: #2E2622;
        --accent: #D2362D;
        --gold: #E8A33D;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ─── Barre du haut ─── */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: .75rem;
    padding: calc(.75rem + env(safe-area-inset-top)) 16px .75rem;
    background: #0E0B0A; color: #F3EADB;
}
.brand { font-weight: 700; }
.page-title { color: #C9BBAA; font-size: .95rem; }

.page { max-width: 720px; margin: 0 auto; padding: 16px; }

/* ─── Menu du bas ─── */
.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: .75rem; color: var(--muted); text-decoration: none;
}
.bottomnav a span { font-size: 1.35rem; }
.bottomnav a.active { color: var(--accent); font-weight: 600; }
.bottomnav a.soon { opacity: .4; }

/* ─── Cartes, tuiles, listes ─── */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.hello { margin: 8px 0 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.tile {
    display: flex; flex-direction: column; gap: 4px; min-height: 110px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.tile-icon { font-size: 1.6rem; }
.tile small { color: var(--muted); font-size: .8rem; }
.tile.soon { opacity: .6; }
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 10px 0; border-top: 1px solid var(--line);
}

/* ─── Boutons et formulaires ─── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 48px; padding: 0 18px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-small { min-height: 38px; padding: 0 12px; font-size: .875rem; }
.btn-ghost { background: transparent; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=password], input[type=text], input[type=number], input[type=date], select {
    width: 100%; min-height: 48px; padding: 0 14px; font: inherit;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
form .btn-primary { margin-top: 16px; }

.flash { background: #E6F3EA; color: #1F5A37; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.error { background: #FBE7E5; color: #8E1C16; border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
@media (prefers-color-scheme: dark) {
    .flash { background: #173523; color: #BFE8CD; }
    .error { background: #3A1512; color: #F6C3BE; }
}

/* ─── Connexion ─── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
    width: 100%; max-width: 380px; text-align: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 20px;
}
.login-card form { text-align: left; }

/* ─── Menus et listes cliquables (étape 1) ─── */
.menu { list-style: none; margin: 0 0 16px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a, .list-links a {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    color: var(--ink); text-decoration: none; min-height: 56px;
}
.menu a > span:nth-child(2), .list-links a > span:first-child { flex: 1; display: flex; flex-direction: column; }
.menu small, .list-links small { font-size: .8rem; }
.menu-icon { font-size: 1.4rem; }
.chevron { color: var(--muted); font-size: 1.4rem; }
.list-links { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 16px; }
.list-links li { padding: 0; }
.list-links li:first-child { border-top: 0; }
.list-links li.group {
    padding: 10px 16px 6px; font-size: .75rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--gold); background: var(--bg);
}
.list-links li.archived a { opacity: .5; }
.back { margin: 0 0 8px; }
.back a { text-decoration: none; font-weight: 600; }

/* ─── Formulaires ─── */
.form .field { margin-bottom: 4px; }
.form .field small { display: block; margin-top: 4px; }
.form .has-error input, .form .has-error select { border-color: var(--accent); }
.field-error { color: var(--accent); font-weight: 600; }
textarea {
    width: 100%; padding: 12px 14px; font: inherit; resize: vertical;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
label.check { display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 8px 0 0; font-weight: 600; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.archive-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }

/* ─── Argent (étape 2) ─── */
.pos { color: var(--ok); }
.neg { color: var(--accent); }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.month-nav strong { font-size: 1.15rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; }
.stat small { display: block; color: var(--muted); font-size: .75rem; }
.stat strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.details summary { cursor: pointer; font-weight: 600; }
table.mini { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
table.mini td { padding: 6px 0; border-top: 1px solid var(--line); }
table.mini td + td { text-align: right; white-space: nowrap; padding-left: 8px; }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.btn-big { min-height: 56px; font-size: 1.05rem; }
.btn-in { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-out { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-wide { width: 100%; margin-top: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chip { flex: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .85rem; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-sep { flex: none; width: 1px; background: var(--line); }
.empty { text-align: center; padding: 24px 0; }
.ledger .amount { text-align: right; font-weight: 700; white-space: nowrap; display: flex; flex-direction: column; }
.links-row { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: center; margin: 20px 0; }
.links-row a { text-decoration: none; font-weight: 600; }
.note { background: var(--surface); border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.block { display: block; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.seg { display: flex; align-items: center; justify-content: center; min-height: 48px; margin: 0; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg-in:has(input:checked) { border-color: var(--ok); background: var(--ok); color: #fff; }
.seg-out:has(input:checked) { border-color: var(--accent); background: var(--accent); color: #fff; }
.input-big { font-size: 1.6rem !important; font-weight: 700; min-height: 60px !important; }
fieldset.field { border: 0; padding: 0; margin: 12px 0 0; }
fieldset legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
[hidden] { display: none !important; }
input[type=file] { width: 100%; padding: 10px 0; font: inherit; }
.justif { margin: 0 0 8px; }
a.tile { color: var(--ink); text-decoration: none; }
.repeat { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; }
input[type=month] {
    width: 100%; min-height: 48px; padding: 0 14px; font: inherit;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}

/* ─── Écran Marché (étape 4) ─── */
.m-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.m-bar small { display: block; color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-bar strong { font-size: 1.25rem; white-space: nowrap; }
.m-bar > div { min-width: 0; }
.m-sync { border: 0; border-radius: 999px; padding: 8px 10px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.m-sync.ok { background: #E6F3EA; color: #1F5A37; }
.m-sync.attente { background: #FFF1D6; color: #7A4B00; }
@media (prefers-color-scheme: dark) {
    .m-sync.ok { background: #173523; color: #BFE8CD; }
    .m-sync.attente { background: #3A2A0E; color: #F4D08F; }
}
.m-onglets .seg { background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; }
.m-onglets .seg.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.m-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
@media (min-width: 560px) { .m-grille { grid-template-columns: repeat(4, 1fr); } }
.m-produit {
    display: flex; flex-direction: column; justify-content: space-between; gap: 2px; min-height: 84px; padding: 8px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
    font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.m-produit:active { transform: scale(.97); background: var(--line); }
.m-produit small { color: var(--muted); font-size: .7rem; }
.m-produit span { font-size: .85rem; font-weight: 600; line-height: 1.15; }
.m-produit b { color: var(--accent); font-size: .9rem; }
.m-produit.libre { border-style: dashed; }
.m-vide { grid-column: 1 / -1; }
.m-libre { margin-bottom: 12px; }
.m-libre summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.m-libre-form { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; }
.m-ventes { margin-top: 8px; }
.m-ventes li { align-items: flex-start; }
.m-annulee { opacity: .5; text-decoration: line-through; }

/* Panneau du client, fixé au-dessus du menu */
body.m-avec-panier { padding-bottom: calc(var(--nav-h) + 230px + env(safe-area-inset-bottom)); }
.m-panier {
    position: fixed; left: 0; right: 0; z-index: 9;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    max-width: 720px; margin: 0 auto; padding: 8px 12px 10px;
    background: var(--surface); border-top: 2px solid var(--accent); box-shadow: 0 -6px 18px rgba(0,0,0,.12);
}
.m-lignes { list-style: none; margin: 0; padding: 0; max-height: 28vh; overflow-y: auto; }
.m-lignes li { display: grid; grid-template-columns: 1fr auto 76px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.m-l-nom { font-size: .9rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-qte { display: inline-flex; align-items: center; gap: 6px; }
.m-qte button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 1.2rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.m-qte b { min-width: 1.4em; text-align: center; }
input.m-prix { min-height: 36px !important; padding: 0 8px !important; text-align: right; font-weight: 600; }
.m-total-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-top: 8px; }
.m-total small { display: block; color: var(--muted); font-size: .75rem; }
.m-total strong { font-size: 1.5rem; white-space: nowrap; }
.m-pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.m-pay-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
    border: 0; border-radius: 12px; background: var(--ok); color: #fff; font: inherit; font-size: 1.2rem; cursor: pointer; touch-action: manipulation;
}
.m-pay-btn span { font-size: .72rem; font-weight: 700; }
.m-pay-btn.on { outline: 3px solid var(--gold); outline-offset: 1px; }
.m-pay-btn:disabled { background: var(--line); color: var(--muted); cursor: default; }
.m-especes { padding: 8px 0 0; }
.m-recu { display: grid; grid-template-columns: auto 110px 1fr; gap: 8px; align-items: center; }
.m-recu label { margin: 0; }
.m-recu input { min-height: 44px; font-weight: 700; text-align: right; }
.m-rendu { font-weight: 700; color: var(--ok); }
.m-rendu.neg { color: var(--accent); }
.m-billets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.m-billets .chip { cursor: pointer; font: inherit; font-size: .85rem; }
.m-especes .btn-primary { margin-top: 0; min-height: 48px; }
.m-toast {
    position: fixed; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); z-index: 20; max-width: 520px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #0E0B0A; color: #F3EADB; border-radius: 12px; padding: 12px 14px; box-shadow: 0 6px 18px rgba(0,0,0,.25); font-weight: 600;
}
.m-toast button { border: 0; background: transparent; color: var(--gold); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 8px; }

/* Boutique : fenêtre du prix (écran Ventes) */
.m-produit.a-prix b { color: var(--gold); }
.m-sheet-fond { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.m-sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.m-sheet h2 { margin-bottom: 2px; }
.m-sheet-champs { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.m-sheet-champs label { margin-top: 8px; }
.m-sheet .m-qte { min-height: 60px; }
.m-prix-total { font-weight: 700; min-height: 1.4em; margin: 10px 0 0; }
.m-pay.quatre { grid-template-columns: repeat(4, 1fr); }
.m-pay.quatre .m-pay-btn span { font-size: .66rem; }
