/* ─────────────────────────────────────────────────────────────────────────────
   Sarments — design system « Vigne »
   Vert vigne pour l'action, raisin pour les accents, neutres chauds, aplats sobres.
   Titres & texte : Manrope · Chiffres : JetBrains Mono (tabulaires)
   ───────────────────────────────────────────────────────────────────────────── */
:root {
    --ink-950: #0E1A13;
    --ink-900: #17241C;
    --ink-800: #263329;
    --ink-700: #3A473D;
    --ink-600: #546157;
    --ink-500: #6E7A71;
    --ink-400: #9AA49C;
    --ink-300: #C9D0CA;
    --ink-200: #E3E8E4;
    --ink-100: #F0F3F0;
    --ink-50:  #F7F9F7;

    --accent: #2F7D4F;
    --accent-hover: #266A42;
    --accent-active: #1E5636;
    --accent-soft: #EAF5EE;
    --accent-ring: rgba(47, 125, 79, .35);
    --grape: #7A3E6B;
    --grape-soft: #F6EDF3;

    --success: #15803D; --success-soft: #F0FDF4; --success-line: #BBF7D0;
    --danger:  #B91C1C; --danger-soft:  #FEF2F2; --danger-line:  #FECACA;
    --warning: #B45309; --warning-soft: #FFFBEB; --warning-line: #FDE68A;
    --info:    #0369A1; --info-soft:    #F0F9FF; --info-line:    #BAE6FD;

    --bg: var(--ink-50);
    --surface: #FFFFFF;
    --line: var(--ink-200);
    --text: var(--ink-900);
    --text-2: var(--ink-600);
    --text-3: var(--ink-500);

    --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
    --shadow-1: 0 1px 2px rgba(23, 36, 28, .06);
    --shadow-2: 0 6px 18px rgba(23, 36, 28, .08);
    --shadow-3: 0 18px 44px rgba(23, 36, 28, .18);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --sidebar-w: 248px;
    --topbar-h: 60px;

    --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    --bs-body-font-family: var(--font-body);
    --bs-body-font-size: .9375rem;
    --bs-body-line-height: 1.55;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--line);
    --bs-primary: var(--accent);
    --bs-primary-rgb: 47, 125, 79;
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 47, 125, 79;
    --bs-link-hover-color: var(--accent-hover);
    --bs-border-radius: var(--r-sm);
    --bs-border-radius-lg: var(--r-md);
    --bs-secondary-color: var(--text-3);
}

/* ─── Base ─────────────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { font-weight: 800; color: var(--ink-900); letter-spacing: -.02em; }
[v-cloak] { display: none !important; }
a { text-decoration: none; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.text-muted { color: var(--text-3) !important; }
.small-caps { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.min-w-0 { min-width: 0; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

/* ─── Boutons ──────────────────────────────────────────────────────────────── */
.btn { font-weight: 700; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
.btn i { font-size: 1.05em; line-height: 1; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover); --bs-btn-active-bg: var(--accent-active); --bs-btn-active-border-color: var(--accent-active); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent-active); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--ink-100); color: var(--text); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-soft { background: var(--ink-100); color: var(--ink-800); border: 1px solid var(--line); }
.btn-soft:hover { background: var(--ink-200); }

/* ─── Formulaires ──────────────────────────────────────────────────────────── */
.form-label { font-weight: 700; font-size: .85rem; color: var(--ink-700); margin-bottom: .3rem; }
.form-control, .form-select { border-color: var(--ink-300); border-radius: var(--r-sm); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.form-control-color { width: 3rem; }

/* ─── Coquille : barre latérale + topbar ───────────────────────────────────── */
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
    background: var(--ink-950); color: #C8D3CB; display: flex; flex-direction: column;
    transition: transform .25s var(--ease);
}
.app-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; color: #fff; }
.app-brand:hover { color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-org { font-size: .75rem; color: #8FA196; }
.app-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; }
.app-nav-section { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #6F8476; padding: 1rem .6rem .4rem; }
.app-nav-list { list-style: none; margin: 0; padding: 0; }
.app-nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: var(--r-sm);
    color: #C8D3CB; font-weight: 600; font-size: .92rem;
}
.app-nav-item i { font-size: 1.15rem; opacity: .85; }
.app-nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-nav-item.active { background: rgba(47, 125, 79, .28); color: #fff; box-shadow: inset 3px 0 0 #6CC28F; }
.app-nav-badge { margin-left: auto; background: #6CC28F; color: var(--ink-950); font-size: .7rem; font-weight: 800; padding: .05rem .45rem; border-radius: 99px; }
.app-sidebar-foot { padding: .9rem 1.1rem; font-size: .75rem; color: #6F8476; border-top: 1px solid rgba(255, 255, 255, .06); }

.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
    padding: 0 1.5rem; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.app-burger { display: none; }
.app-breadcrumb .breadcrumb { margin: 0; font-size: .9rem; }
.app-breadcrumb .breadcrumb-item.active { font-weight: 700; color: var(--text); }
.app-content { padding: 1.5rem; flex: 1; width: 100%; max-width: 1320px; }
.user-menu-btn { display: flex; align-items: center; gap: .6rem; background: none; border: 0; padding: .25rem .4rem; border-radius: var(--r-sm); }
.user-menu-btn:hover { background: var(--ink-100); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grape); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.user-name { font-weight: 700; font-size: .88rem; line-height: 1.2; }
.user-role { font-size: .75rem; color: var(--text-3); }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-3); }
    .app-sidebar.open { transform: none; }
    .app-main { margin-left: 0; }
    .app-burger { display: inline-flex; }
    .app-topbar { padding: 0 1rem; }
    .app-content { padding: 1rem; }
}

/* ─── En-tête de page ─────────────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.55rem; margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--text-2); }

/* ─── Cartes & tuiles ──────────────────────────────────────────────────────── */
.card-x { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.card-x-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.card-x-head h2, .card-x-head h3 { font-size: 1rem; margin: 0; }
.card-x-body { padding: 1.1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem 1.1rem; height: 100%; }
.kpi-label { font-size: .78rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; margin-top: .25rem; }
.kpi-sub { font-size: .82rem; color: var(--text-2); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-2); }
.empty i { font-size: 2.2rem; color: var(--ink-400); display: block; margin-bottom: .5rem; }

/* ─── Tableaux ─────────────────────────────────────────────────────────────── */
.table-x { width: 100%; margin: 0; --bs-table-bg: transparent; }
.table-x th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 800; background: var(--ink-50); border-bottom: 1px solid var(--line); padding: .65rem .9rem; white-space: nowrap; }
.table-x td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: var(--ink-50); }
.table-x .actions { white-space: nowrap; text-align: right; }
.row-muted td { color: var(--text-3); }

/* ─── Pastilles ────────────────────────────────────────────────────────────── */
.status, .role { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-planifiee { color: var(--info); background: var(--info-soft); }
.status-ouverte { color: var(--success); background: var(--success-soft); }
.status-ouverte::before { animation: pulse 1.6s infinite; }
.status-cloturee { color: var(--ink-700); background: var(--ink-100); }
.status-archivee { color: var(--ink-500); background: var(--ink-100); }
.status-inactif { color: var(--ink-500); background: var(--ink-100); }
.status-partiel { color: var(--warning); background: var(--warning-soft); }
.status-retard { color: var(--danger); background: var(--danger-soft); }
.status-brouillon { color: var(--info); background: var(--info-soft); }
.status-ouvert { color: var(--success); background: var(--success-soft); }
.status-cloture { color: var(--ink-700); background: var(--ink-100); }
.status-annule { color: var(--danger); background: var(--danger-soft); }
.progress-x { height: 8px; background: var(--ink-100); border-radius: 99px; overflow: hidden; }
.progress-x > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.02em; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.role { background: var(--ink-100); color: var(--ink-700); }
.role-admin { background: var(--grape-soft); color: var(--grape); }
.role-protocole { background: var(--accent-soft); color: var(--accent-active); }
.role-tresorier { background: var(--warning-soft); color: var(--warning); }
.role-chef_departement { background: var(--info-soft); color: var(--info); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .08); }
.type-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; }

/* ─── Onglets ─────────────────────────────────────────────────────────────── */
.tabs-x { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs-x a { padding: .6rem .9rem; font-weight: 700; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs-x a:hover { color: var(--text); }
.tabs-x a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Barres horizontales (répartition) ───────────────────────────────────── */
.bar-row { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(60px, 1fr) 3.2rem; align-items: center; gap: .6rem; margin-bottom: .55rem; font-size: .88rem; }
.bar-track { height: 10px; background: var(--ink-100); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s var(--ease); }
.bar-row .num { text-align: right; font-weight: 700; }

/* ─── Écart avec la période précédente ────────────────────────────────────── */
.delta { display: inline-flex; align-items: center; gap: .15rem; font-weight: 800; font-size: .8rem; padding: .05rem .4rem; border-radius: 99px; }
.delta-up { color: var(--success); background: var(--success-soft); }
.delta-down { color: var(--danger); background: var(--danger-soft); }
.delta-neutre { color: var(--text-3); background: var(--ink-100); font-weight: 600; }

/* ─── Alertes & toasts ────────────────────────────────────────────────────── */
.alert { display: flex; gap: .6rem; align-items: flex-start; border-radius: var(--r-sm); }
.alert i { font-size: 1.15rem; line-height: 1.3; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.toast-item { display: flex; gap: .55rem; align-items: center; background: var(--ink-900); color: #fff; padding: .7rem 1rem; border-radius: var(--r-sm); box-shadow: var(--shadow-3); font-weight: 600; max-width: 360px; animation: toastIn .25s var(--ease); }
.toast-item.danger { background: var(--danger); }
.toast-item.success i { color: #6CC28F; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ─── Connexion ───────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background:
    radial-gradient(1200px 500px at 10% -10%, rgba(47, 125, 79, .16), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(122, 62, 107, .12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 2rem 1.75rem; }
.auth-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 1rem; }
.auth-card .brand-mark svg { width: 30px; height: 30px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: .25rem; }
.auth-card .form-control { padding: .7rem .85rem; font-size: 1rem; }

/* ─── En direct ───────────────────────────────────────────────────────────── */
.live-card { border-left: 4px solid var(--accent); }
.live-total { font-family: var(--font-mono); font-size: clamp(3rem, 8vw, 5rem); font-weight: 800; line-height: 1; letter-spacing: -.05em; color: var(--ink-900); }
.live-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .88rem; color: var(--text-2); }
.live-meta i { color: var(--accent); }
.bump { animation: bump .45s var(--ease); }
@keyframes bump { 40% { transform: scale(1.06); color: var(--accent); } }

/* ─── Application de comptage (mobile plein écran) ────────────────────────── */
.counter-body { background: var(--ink-950); color: #fff; min-height: 100vh; min-height: 100dvh; overscroll-behavior: none; }
.counter-app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: max(.75rem, env(safe-area-inset-top)) .9rem max(.9rem, env(safe-area-inset-bottom)); }
.counter-top { display: flex; align-items: center; gap: .6rem; }
.counter-top .who { font-size: .82rem; color: #9FB3A6; }
.counter-top .btn-ghost { color: #C8D3CB; }
.counter-top .btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.net { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; flex: none; font-size: .75rem; font-weight: 800; padding: .2rem .6rem; border-radius: 99px; }
.net-on { background: rgba(108, 194, 143, .16); color: #8EE0AE; }
.net-off { background: rgba(245, 158, 11, .18); color: #FCD34D; }
.counter-activity { margin-top: .9rem; }
.counter-activity .titre { font-weight: 800; font-size: 1.1rem; line-height: 1.25; }
.counter-activity .sous { font-size: .82rem; color: #9FB3A6; }
.counter-select { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14); color: #fff; border-radius: var(--r-sm); padding: .55rem .75rem; font-weight: 700; width: 100%; }
.counter-select option { color: var(--ink-900); }
.counter-totals { display: grid; grid-template-columns: 1.4fr 1fr; gap: .6rem; margin: .9rem 0; }
.counter-total { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--r-md); padding: .7rem .9rem; }
.counter-total .lbl { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #9FB3A6; }
.counter-total .val { font-family: var(--font-mono); font-weight: 800; font-size: 2.4rem; line-height: 1.05; letter-spacing: -.04em; }
.counter-total.main .val { font-size: 3rem; color: #8EE0AE; }
.counter-grid { flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; align-content: stretch; }
.counter-grid.one { grid-template-columns: 1fr; }
.tap {
    position: relative; border: 0; border-radius: var(--r-lg); color: #fff; min-height: 130px; padding: .9rem;
    display: flex; flex-direction: column; justify-content: space-between; text-align: left;
    background: var(--c, var(--accent)); box-shadow: 0 6px 0 rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .2);
    touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
    transition: transform .06s, box-shadow .06s;
}
.tap:active, .tap.pressed { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .2); }
.tap .t-lbl { font-weight: 800; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.tap .t-plus { position: absolute; right: .8rem; top: .55rem; font-size: 2.2rem; font-weight: 800; opacity: .9; line-height: 1; }
.tap .t-val { font-family: var(--font-mono); font-size: 2.3rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.tap .t-sub { font-size: .72rem; font-weight: 700; opacity: .85; }
.tap-wrap { position: relative; display: flex; }
.tap-wrap .tap { flex: 1; }
.minus {
    position: absolute; right: .55rem; bottom: .55rem; width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: rgba(0, 0, 0, .28); color: #fff; font-size: 1.4rem; font-weight: 800; display: grid; place-items: center;
}
.minus:disabled { opacity: .3; }
.counter-foot { margin-top: .8rem; display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: #9FB3A6; gap: .5rem; }
.counter-empty { flex: 1; display: grid; place-items: center; text-align: center; color: #C8D3CB; padding: 2rem 1rem; }
.counter-empty i { font-size: 3rem; color: #6CC28F; }
.counter-flash { position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); z-index: 50; background: #fff; color: var(--ink-900); font-weight: 700; padding: .55rem .9rem; border-radius: 99px; box-shadow: var(--shadow-3); font-size: .85rem; }
@media (min-height: 760px) { .tap { min-height: 160px; } }
