/* ---------------------------------------------------------------------------
   Equity — design system.
   Coquille d'application : barre latérale + zone de contenu.
   Thème clair par défaut, thème sombre suivant la préférence système.
   --------------------------------------------------------------------------- */

:root {
    /* Surfaces & texte */
    --bg:           #f5f6f9;
    --surface:      #ffffff;
    --surface-2:    #fafbfd;
    --border:       #e7e9f0;
    --border-2:     #d9dde7;
    --text:         #0d1424;
    --text-2:       #5b6478;
    --text-3:       #8d95a8;

    /* Marque */
    --brand:        #4f46e5;
    --brand-ink:    #ffffff;
    --brand-soft:   rgba(79, 70, 229, .10);

    /* Sémantique */
    --danger:       #e11d48;
    --danger-soft:  rgba(225, 29, 72, .10);
    --success:      #059669;
    --success-soft: rgba(5, 150, 105, .11);
    --warn:         #b45309;
    --warn-soft:    rgba(217, 119, 6, .13);

    /* Géométrie */
    --r-sm: 7px;
    --r:    11px;
    --r-lg: 16px;
    --sh-1: 0 1px 2px rgba(13, 20, 36, .04), 0 1px 3px rgba(13, 20, 36, .06);
    --sh-2: 0 2px 4px rgba(13, 20, 36, .04), 0 12px 28px -14px rgba(13, 20, 36, .22);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0a0c11;
        --surface:      #12151d;
        --surface-2:    #171b24;
        --border:       #222734;
        --border-2:     #2e3442;
        --text:         #e8ebf2;
        --text-2:       #99a2b5;
        --text-3:       #6d768a;

        --brand:        #7c78f0;
        --brand-ink:    #0a0c11;
        --brand-soft:   rgba(124, 120, 240, .15);

        --danger:       #fb7185;
        --danger-soft:  rgba(251, 113, 133, .13);
        --success:      #34d399;
        --success-soft: rgba(52, 211, 153, .13);
        --warn:         #fbbf24;
        --warn-soft:    rgba(251, 191, 36, .13);

        --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
        --sh-2: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 28px -14px rgba(0, 0, 0, .8);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); }

/* Garde-fou : un SVG inline sans width/height s'affiche en 300×150 px par
   défaut. On borne toutes les icônes ici, les règles suivantes affinent. */
svg { width: 17px; height: 17px; flex: none; }

/* ===========================================================================
   Coquille : barre latérale + contenu
   =========================================================================== */

.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }

.side {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.side__in { display: flex; align-items: center; gap: 1rem; padding: .6rem .9rem; }

.brand {
    display: flex; align-items: center; gap: .55rem;
    font-weight: 700; font-size: 1.02rem; letter-spacing: -.02em;
    color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand__mark {
    width: 28px; height: 28px; border-radius: 8px; flex: none;
    background: linear-gradient(140deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #ec4899));
    display: grid; place-items: center; color: #fff;
}
.brand__mark svg { width: 16px; height: 16px; }

.nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
    display: flex; align-items: center; gap: .55rem; white-space: nowrap;
    padding: .5rem .7rem; border-radius: var(--r-sm);
    color: var(--text-2); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.is-active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; }

.side__foot { display: flex; align-items: center; gap: .6rem; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    background: var(--brand-soft); color: var(--brand);
    display: grid; place-items: center; font-weight: 700; font-size: .82rem;
}
.side__who { display: none; min-width: 0; }
.side__who b { display: block; font-size: .87rem; font-weight: 600; }
.side__who span {
    display: block; font-size: .75rem; color: var(--text-3);
    overflow: hidden; text-overflow: ellipsis;
}

@media (min-width: 900px) {
    .shell { grid-template-columns: 252px 1fr; }
    .side { border-bottom: 0; border-right: 1px solid var(--border); height: 100vh; }
    .side__in {
        flex-direction: column; align-items: stretch;
        height: 100%; padding: 1.15rem .85rem; gap: 1.4rem;
    }
    .brand { padding: 0 .4rem; font-size: 1.08rem; }
    .nav { flex-direction: column; overflow: visible; flex: 1; }
    .side__foot { border-top: 1px solid var(--border); padding-top: .85rem; }
    .side__who { display: block; flex: 1; }
}

.content { min-width: 0; }
.content__in { max-width: 1080px; margin: 0 auto; padding: 1.7rem 1.15rem 4rem; }
@media (min-width: 900px) { .content__in { padding: 2.1rem 2rem 4.5rem; } }

/* ===========================================================================
   Titres de page
   =========================================================================== */

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; margin: 0; }
.page-head p { color: var(--text-2); margin: .35rem 0 0; font-size: .93rem; max-width: 62ch; }

/* ===========================================================================
   Cartes
   =========================================================================== */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-bottom: 1.15rem;
}
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.05rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card__head h2 { margin: 0; font-size: .98rem; font-weight: 650; letter-spacing: -.01em; }
.card__head p { margin: .15rem 0 0; font-size: .84rem; color: var(--text-2); }
.card__body { padding: 1.25rem; }
.card__body > :first-child { margin-top: 0; }
.card__body > :last-child { margin-bottom: 0; }
.card--flush .card__body { padding: 0; }

/* ===========================================================================
   Les deux compteurs de dette
   =========================================================================== */

.stats { display: grid; gap: 1.1rem; grid-template-columns: 1fr; margin-bottom: 1.15rem; }
@media (min-width: 760px) { .stats { grid-template-columns: 1fr 1fr; } }

.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-1);
    padding: 1.3rem 1.35rem; position: relative; overflow: hidden;
}
/* Filet de couleur en haut de carte : le sens se lit d'un coup d'œil. */
.stat::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: var(--text-3);
}
.stat--out::before { background: var(--danger); }
.stat--in::before  { background: var(--success); }

.stat__label {
    display: flex; align-items: center; gap: .45rem;
    color: var(--text-2); font-size: .86rem; font-weight: 500; margin-bottom: .5rem;
}
.stat__value {
    font-size: 2.3rem; font-weight: 700; letter-spacing: -.045em; line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.stat--out .stat__value { color: var(--danger); }
.stat--in  .stat__value { color: var(--success); }
.stat--zero .stat__value { color: var(--text-3); }

/* Détail du calcul : doit se lire comme une opération, pas comme trois
   statistiques indépendantes. D'où les signes et la ligne de total. */
.stat__break {
    margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border);
    display: grid; gap: .4rem;
}
.stat__break .cap {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3); font-weight: 650; margin-bottom: .1rem;
}
.brk {
    display: grid; grid-template-columns: 1ch 1fr auto; gap: .55rem;
    align-items: baseline; font-size: .83rem; color: var(--text-2);
}
.brk__sign { color: var(--text-3); font-weight: 700; text-align: center; }
.brk__val {
    font-weight: 600; color: var(--text);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.brk--zero { opacity: .5; }
.brk--total {
    border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .5rem;
    color: var(--text); font-weight: 650; font-size: .88rem;
}
.brk--total .brk__sign { color: var(--text); }

/* Bandeau de conclusion : répond « qui doit quoi, au final » avant même que
   l'œil descende sur les deux compteurs. Sans lui, deux montants identiques
   de part et d'autre se lisent comme « on se doit encore de l'argent ». */
.hero {
    display: flex; align-items: center; gap: 1.05rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--sh-1);
    padding: 1.35rem 1.4rem; margin-bottom: 1.15rem;
    position: relative; overflow: hidden;
}
.hero::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: var(--text-3);
}
.hero--quits::before { background: var(--success); }
.hero--in::before    { background: var(--success); }
.hero--out::before   { background: var(--danger); }

.hero__icon {
    width: 46px; height: 46px; border-radius: 13px; flex: none;
    display: grid; place-items: center;
    background: var(--bg); color: var(--text-2);
}
.hero__icon svg { width: 23px; height: 23px; }
.hero--quits .hero__icon { background: var(--success-soft); color: var(--success); }
.hero--in    .hero__icon { background: var(--success-soft); color: var(--success); }
.hero--out   .hero__icon { background: var(--danger-soft);  color: var(--danger); }

.hero__txt { min-width: 0; }
.hero__txt h2 {
    margin: 0; font-size: 1.22rem; font-weight: 700; letter-spacing: -.025em;
}
.hero--quits .hero__txt h2 { color: var(--success); }
.hero__txt p { margin: .25rem 0 0; color: var(--text-2); font-size: .89rem; }

.stats-cap {
    display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
    margin: 1.6rem 0 .75rem;
}
.stats-cap h3 {
    margin: 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-3); font-weight: 650;
}
.stats-cap span { font-size: .84rem; color: var(--text-2); }


/* ===========================================================================
   Tableaux
   =========================================================================== */

.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
thead th {
    text-align: left; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-3); font-weight: 650;
    padding: .7rem 1.25rem; background: var(--surface-2);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: .8rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.act, th.act { text-align: right; width: 1%; white-space: nowrap; }
.t-main { font-weight: 600; }
.t-sub  { color: var(--text-3); font-size: .82rem; margin-top: .12rem; }
.muted  { color: var(--text-2); }

/* ===========================================================================
   Progression & échéancier compact
   =========================================================================== */

.progress {
    height: 6px; border-radius: 99px; background: var(--border);
    overflow: hidden; min-width: 90px;
}
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--success); }

/* Bandeau de segments : une case par échéance, lisible d'un coup d'œil. */
.strip { display: flex; gap: 3px; flex-wrap: wrap; }
.strip i {
    width: 26px; height: 7px; border-radius: 99px; background: var(--border-2);
    display: block; font-style: normal;
}
.strip i.is-paid { background: var(--success); }
.strip i.is-late { background: var(--danger); }

/* ===========================================================================
   Pastilles
   =========================================================================== */

.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .74rem; font-weight: 650; padding: .22rem .55rem;
    border-radius: 99px; background: var(--bg); color: var(--text-2);
    border: 1px solid var(--border); white-space: nowrap; line-height: 1.35;
}
.badge--ok   { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--late { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge--soon { background: var(--warn-soft);    color: var(--warn);    border-color: transparent; }
.badge--info { background: var(--brand-soft);   color: var(--brand);   border-color: transparent; }

/* ===========================================================================
   Formulaires
   =========================================================================== */

.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 660px) {
    .grid--2 { grid-template-columns: 1fr 1fr; }
    .grid--3 { grid-template-columns: repeat(3, 1fr); }
}

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label { font-size: .84rem; font-weight: 600; }
.hint { font-size: .78rem; color: var(--text-3); }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border-2); border-radius: var(--r-sm);
    padding: .55rem .7rem; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 62px; }

/* Champ montant : le symbole € vit dans le champ, pas dans le libellé. */
.money { position: relative; }
.money input { padding-right: 2rem; text-align: right; font-variant-numeric: tabular-nums; }
.money::after {
    content: "€"; position: absolute; right: .7rem; top: 50%; transform: translateY(-50%);
    color: var(--text-3); font-size: .9rem; pointer-events: none;
}

.form-actions {
    display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
    padding-top: 1.15rem; margin-top: 1.15rem; border-top: 1px solid var(--border);
}

/* ===========================================================================
   Boutons
   =========================================================================== */

.btn {
    font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; border-radius: var(--r-sm);
    padding: .55rem 1rem; background: var(--brand); color: var(--brand-ink);
    text-decoration: none; display: inline-flex; align-items: center; gap: .45rem;
    line-height: 1.4; transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(.95); }
.btn svg { width: 15px; height: 15px; }

.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn--ghost:hover { background: var(--bg); filter: none; }
.btn--sm { padding: .34rem .65rem; font-size: .83rem; }
.btn--danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn--danger:hover { background: var(--danger-soft); filter: none; }
.btn--ok { background: var(--success); color: #fff; }
.btn--block { width: 100%; justify-content: center; }

/* ===========================================================================
   Messages & états vides
   =========================================================================== */

.flash {
    display: flex; align-items: flex-start; gap: .6rem;
    padding: .8rem 1rem; border-radius: var(--r); margin-bottom: 1.1rem;
    font-size: .9rem; background: var(--success-soft); color: var(--success);
}
.flash--error { background: var(--danger-soft); color: var(--danger); }

.note {
    display: flex; align-items: flex-start; gap: .55rem;
    background: var(--brand-soft); color: var(--text-2);
    border-radius: var(--r); padding: .7rem .9rem; font-size: .86rem;
}
.note svg { width: 16px; height: 16px; flex: none; margin-top: .12rem; color: var(--brand); }

.empty { text-align: center; padding: 2.6rem 1.25rem; color: var(--text-2); }
.empty svg { width: 30px; height: 30px; color: var(--text-3); margin-bottom: .6rem; }
.empty p { margin: 0; font-size: .92rem; }

/* ===========================================================================
   Connexion
   =========================================================================== */

.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(900px 460px at 50% -12%, var(--brand-soft), transparent 70%),
        var(--bg);
}
.auth__box { width: 100%; max-width: 384px; }
.auth__head { text-align: center; margin-bottom: 1.5rem; }
.auth__head .brand { justify-content: center; font-size: 1.3rem; }
.auth__head p { color: var(--text-2); margin: .5rem 0 0; font-size: .92rem; }
.auth .card { box-shadow: var(--sh-2); margin: 0; }
