/* AGENDA CADB — styles communs (charte pwa.ca-db.fr : bleu #004289, DM Sans) */
:root {
    --primary: #004289; --primary-dark: #002855; --primary-light: #E0F2FE;
    --bg: #F1F5F9; --surface: #fff; --text: #1E293B; --text-muted: #64748B; --border: #E2E8F0;
    --ok: #16A34A; --ok-bg: #DCFCE7; --ko: #DC2626; --ko-bg: #FEE2E2; --warn: #D97706; --warn-bg: #FEF3C7;
    --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; -webkit-text-size-adjust: 100%; }
a { color: var(--primary); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* barre du haut (webapp et admin) */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + var(--safe-top));
    background: linear-gradient(135deg, #004289 0%, #002855 100%); color: #fff; box-shadow: 0 4px 16px rgba(0,40,85,.25); position: sticky; top: 0; z-index: 50; }
.topbar h1 { font-size: 1.05rem; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .pill { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: #fff; font-size: .85rem; font-weight: 600;
    padding: 7px 12px; border-radius: 100px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); white-space: nowrap; cursor: pointer; }
.topbar .pill:active { transform: scale(.95); }
.topbar .pill.active { background: #fff; color: var(--primary); }
.topbar .icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12); color: #fff;
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* navigation basse de la webapp */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; background: #fff; border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom); box-shadow: 0 -4px 20px rgba(0,0,0,.06); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 7px; text-decoration: none; color: var(--text-muted); font-size: .68rem; font-weight: 700; }
.tabbar a.active { color: var(--primary); }
.tabbar svg { width: 22px; height: 22px; }
.tabbar .badge { position: absolute; margin-left: 22px; margin-top: -4px; background: var(--ko); color: #fff; font-size: .6rem; border-radius: 10px; padding: 1px 5px; }

/* conteneurs */
.page { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(90px + var(--safe-bottom)); }
.page.large { max-width: 1400px; padding-bottom: 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: 0 4px 14px rgba(15,40,80,.06); margin-bottom: 14px; }
.card h2 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 12px; }
.muted { color: var(--text-muted); }
.empty { text-align: center; color: var(--text-muted); padding: 34px 0; font-weight: 500; }
.chip { display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #F1F5F9; color: #334155; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.ko { background: var(--ko-bg); color: var(--ko); } .chip.warn { background: var(--warn-bg); color: var(--warn); }

/* formulaires */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: #334155; margin-bottom: 5px; }
.input, .select, textarea.input { width: 100%; padding: 11px 12px; border: 1px solid #CBD5E1; border-radius: 10px; background: #fff; color: var(--text); font-size: .95rem; }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,66,137,.12); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 10px; padding: 11px 16px; font-weight: 700; font-size: .9rem; cursor: pointer; background: var(--primary); color: #fff; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #EFF6FF; color: var(--primary); } .btn.danger { background: var(--ko-bg); color: var(--ko); } .btn.ok { background: var(--ok-bg); color: var(--ok); }
.btn.block { width: 100%; } .btn.sm { padding: 6px 10px; font-size: .78rem; border-radius: 8px; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: .88rem; font-weight: 600; margin-bottom: 14px; }
.alert.ko { background: var(--ko-bg); color: #991B1B; } .alert.ok { background: var(--ok-bg); color: #166534; } .alert.warn { background: var(--warn-bg); color: #92400E; }

/* toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translate(-50%, -160%); background: #0F172A; color: #fff; padding: 11px 20px; border-radius: 14px;
    font-weight: 700; font-size: .88rem; box-shadow: 0 10px 24px rgba(0,0,0,.2); z-index: 300; transition: transform .35s cubic-bezier(.175,.885,.32,1.275); text-align: center; max-width: 92vw; }
.toast.visible { transform: translate(-50%, calc(var(--safe-top) + 6px)); }
.toast.ok { background: #10B981; } .toast.ko { background: #EF4444; }
.toast small { display: block; font-weight: 500; opacity: .9; font-size: .76rem; margin-top: 2px; }

/* modales */
.voile { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.voile.ouvert { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 22px 22px 18px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.modal .sub { color: var(--text-muted); font-size: .85rem; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }

/* feuille basse (légende) */
.backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .28s; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 160; background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -6px 40px rgba(0,0,0,.18);
    transform: translateY(101%); transition: transform .34s cubic-bezier(.32,.72,0,1); max-height: 80vh; display: flex; flex-direction: column; padding-bottom: calc(var(--safe-bottom) + 12px); }
.sheet.show { transform: translateY(0); }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; transform: translate(-50%, 101%); width: 420px; border-radius: 20px; bottom: 24px; } .sheet.show { transform: translate(-50%, 0); } }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 4px; flex: none; }
.sheet .head { display: flex; align-items: flex-start; gap: 12px; padding: 8px 20px 12px; flex: none; }
.sheet .head .t { font-size: 1.15rem; font-weight: 700; } .sheet .head .s { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.sheet .close { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; border: none; background: #F1F5F9; color: var(--text-muted); cursor: pointer; }
.sheet .body { overflow-y: auto; padding: 0 20px 8px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: .9rem; padding: 10px 0; border-bottom: 1px solid #F1F5F9; }
.legend-item:last-child { border-bottom: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* cartes de quotas (solde, bilan) */
.quota-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.quota-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px; box-shadow: 0 4px 14px rgba(15,40,80,.06); }
.quota-card .qt { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quota-card .qn { font-size: 1.25rem; font-weight: 800; line-height: 1; }
.quota-card .qn .sep { color: var(--text-muted); font-weight: 400; margin: 0 3px; } .quota-card .qn .tot { color: var(--text-muted); font-size: .95rem; } .quota-card .qn .j { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.quota-card .qd { font-size: .68rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }
.quota-bar { height: 6px; background: #F1F5F9; border-radius: 3px; margin-top: 8px; overflow: hidden; display: flex; }
.quota-bar i { display: block; height: 100%; background: var(--qc, var(--primary)); } .quota-bar i.att { opacity: .35; } .quota-bar i.over { background: var(--ko); }
.quota-card .qr { font-size: .64rem; margin-top: 6px; font-weight: 700; white-space: nowrap; }
.quota-card .qr.positive { color: var(--qc, var(--ok)); } .quota-card .qr.overflow { color: var(--ko); } .quota-card .qr.neutral { color: var(--text-muted); }
