/* ==========================================================================
   Re Members — design system "Material"
   Inspiré des apps Google (Gmail / Drive / Calendar) : bleu #1A73E8,
   surfaces neutres, cartes arrondies, rail de navigation avec pastille active.
   ========================================================================== */

:root {
    --bg: #f8fafd;
    --bg-elevated: #ffffff;
    --bg-sunken: #f1f3f4;
    --border: #dadce0;
    --text: #202124;
    --text-muted: #5f6368;
    --text-faint: #80868b;

    --accent: #1a73e8;
    --accent-strong: #1a73e8;
    --accent-soft: #e8f0fe;
    --on-accent: #ffffff;

    --success: #188038;
    --success-bg: #e6f4ea;
    --warning: #b06000;
    --warning-bg: #fef7e0;

    /* alias historiques (utilisés par les vues JS) */
    --teal-500: var(--success);
    --teal-600: var(--success);
    --rust-500: #d93025;
    --rust-600: #b3261e;
    --ink-800: #323232;

    --shadow-1: 0 1px 2px 0 rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-2: 0 1px 3px 0 rgba(60,64,67,.30), 0 4px 8px 3px rgba(60,64,67,.15);

    --font-ui: "Roboto", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #202124;
        --bg-elevated: #2d2e30;
        --bg-sunken: #35363a;
        --border: #3c4043;
        --text: #e8eaed;
        --text-muted: #9aa0a6;
        --text-faint: #80868b;
        --accent: #8ab4f8;
        --accent-soft: rgba(138,180,248,.16);
        --on-accent: #0b3a75;
        --success: #81c995;
        --success-bg: rgba(129,201,149,.14);
        --warning: #fdd663;
        --warning-bg: rgba(253,214,99,.14);
        --teal-500: var(--success); --teal-600: var(--success);
        --rust-500: #f28b82; --rust-600: #f28b82; --ink-800: #323232;
        --shadow-1: 0 1px 2px 0 rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.35);
        --shadow-2: 0 1px 3px 0 rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.35);
    }
}
:root[data-theme="dark"] {
    --bg: #202124; --bg-elevated: #2d2e30; --bg-sunken: #35363a; --border: #3c4043;
    --text: #e8eaed; --text-muted: #9aa0a6; --text-faint: #80868b;
    --accent: #8ab4f8; --accent-soft: rgba(138,180,248,.16); --on-accent: #0b3a75;
    --teal-500: #81c995; --teal-600: #81c995; --rust-500: #f28b82; --rust-600: #f28b82; --ink-800: #323232;
    --success: #81c995; --success-bg: rgba(129,201,149,.14);
    --warning: #fdd663; --warning-bg: rgba(253,214,99,.14);
    --shadow-1: 0 1px 2px 0 rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.35);
    --shadow-2: 0 1px 3px 0 rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
    --bg: #f8fafd; --bg-elevated: #ffffff; --bg-sunken: #f1f3f4; --border: #dadce0;
    --text: #202124; --text-muted: #5f6368; --text-faint: #80868b;
    --accent: #1a73e8; --accent-soft: #e8f0fe; --on-accent: #ffffff;
    --success: #188038; --success-bg: #e6f4ea;
    --warning: #b06000; --warning-bg: #fef7e0;
    --teal-500: #188038; --teal-600: #188038; --rust-500: #d93025; --rust-600: #b3261e; --ink-800: #323232;
    --shadow-1: 0 1px 2px 0 rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-2: 0 1px 3px 0 rgba(60,64,67,.30), 0 4px 8px 3px rgba(60,64,67,.15);
}

html { color-scheme: light dark; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
}

* { border-color: var(--border); }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); }
.bg-elevated { background: var(--bg-elevated); }
.bg-sunken { background: var(--bg-sunken); }
.border-default { border-color: var(--border); }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgb(from var(--text-faint) r g b / 35%); border-radius: 9999px; }

.tab-view { animation: fade-in .16s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
    .tab-view { animation: none; }
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Structure ---------- */

.app-sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
}

.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

/* ---------- Navigation (rail façon Gmail / Drive) ---------- */

.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .9rem;
    border-radius: 22px;
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background-color .12s ease, color .12s ease;
    width: 100%;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--bg-sunken); color: var(--text); }
.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-item-mobile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .2rem;
    padding: .5rem 0;
    color: var(--text-faint);
    font-size: .62rem;
    font-weight: 500;
    flex: 1;
}
.nav-item-mobile.active { color: var(--accent); font-weight: 600; }

/* ---------- Cartes ---------- */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-1);
}

.stub {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow-1);
}
.stub-label {
    font-size: .68rem;
    font-weight: 500;
    color: var(--text-muted);
}
.stub-value {
    font-variant-numeric: tabular-nums;
    font-size: 1.65rem;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -.01em;
}
.stub-sub { font-size: .74rem; color: var(--text-muted); }

/* ---------- Boutons / champs ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border-radius: 999px;
    padding: .55rem 1.2rem;
    font-size: .84rem;
    font-weight: 500;
    transition: filter .12s ease, background-color .12s ease, box-shadow .12s ease;
    white-space: nowrap;
}
.btn:active { filter: brightness(.96); }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover { box-shadow: var(--shadow-2); }
.btn-secondary { background: var(--bg-elevated); color: var(--accent); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-sunken); }
.btn-ghost { color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { color: #d93025; }
.btn-danger:hover { background: rgba(217,48,37,.08); }

.field-label {
    display: block; font-size: .72rem; font-weight: 500;
    color: var(--text-muted); margin-bottom: .3rem;
}
.field {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .7rem;
    color: var(--text);
    font-size: .88rem;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- Badges de statut ---------- */

.badge { display: inline-flex; align-items: center; padding: .18rem .65rem; border-radius: 999px; font-size: .72rem; font-weight: 500; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------- Tableau ---------- */

.ledger-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.ledger-table thead th {
    text-align: left; font-size: .68rem; font-weight: 500;
    color: var(--text-muted); padding: 0 1rem .6rem; border-bottom: 1px solid var(--border);
}
.ledger-table tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.ledger-table tbody tr:last-child td { border-bottom: none; }
.ledger-table tbody tr:hover { background: var(--bg-sunken); }
.ledger-num { font-variant-numeric: tabular-nums; }

/* ---------- Jauge circulaire (progression 507h) ---------- */

.gauge-track { stroke: var(--border); }
.gauge-value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); }
.gauge-tick { stroke: var(--text-faint); }

/* ---------- FAB (bouton d'action flottant) ---------- */

.fab {
    position: fixed;
    right: 1.5rem; bottom: 1.5rem;
    width: 56px; height: 56px;
    border-radius: 16px;
    background: var(--accent);
    color: var(--on-accent);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-2);
    z-index: 30;
    transition: transform .15s ease, box-shadow .15s ease;
}
.fab:hover { transform: translateY(-1px); }
.fab:active { transform: translateY(0) scale(.96); }
@media (max-width: 1023px) {
    .fab { bottom: calc(1.5rem + env(safe-area-inset-bottom) + 56px); }
}

/* ---------- Divers ---------- */

.section-label {
    font-size: .68rem; font-weight: 500; color: var(--text-muted);
}

#toast {
    font-family: var(--font-ui);
}

.skeleton {
    background: linear-gradient(90deg, rgb(from var(--text-faint) r g b / 12%) 25%, rgb(from var(--text-faint) r g b / 22%) 37%, rgb(from var(--text-faint) r g b / 12%) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
