/* Notes de frais - feuille de style (téléphone d'abord, mode sombre automatique) */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --row-advance: #eceef2; /* lignes d'avance : gris clair */
  --text: #171a26;
  --muted: #6b7183;
  --border: #e4e6ee;
  --accent: #3554d1;
  --accent-2: #6a3fd1;
  --accent-text: #ffffff;
  --accent-soft: #eaeefc;
  --danger: #c23a2b;
  --danger-soft: #fdeceb;
  --success: #12805c;
  --success-soft: #e3f5ee;
  --warning: #8a5a00;
  --warning-soft: #fff4dc;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 4px 16px rgba(20, 24, 40, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --surface-2: #1f2330;
    --row-advance: #272b37;
    --text: #eceef4;
    --muted: #9aa0b2;
    --border: #2a2f3d;
    --accent: #7b93ff;
    --accent-2: #a585ff;
    --accent-text: #0d1020;
    --accent-soft: #232a45;
    --danger: #ff8a7d;
    --danger-soft: #3a1e1b;
    --success: #5fd3a5;
    --success-soft: #14302a;
    --warning: #f3c060;
    --warning-soft: #352a12;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .25rem 0 1rem; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-size: .9em; background: var(--accent-soft); padding: .05em .3em; border-radius: 4px; }
small { font-size: .85rem; }
.muted { color: var(--muted); font-weight: 400; }
.req { color: var(--danger); font-weight: 700; }
.required-note { font-size: .85rem; color: var(--muted); margin: -.5rem 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barre du haut et onglets */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: .95rem;
}
.tabs { display: flex; gap: .25rem; }
.tab {
  display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
/* Menu du compte (en haut à droite) */
.account-menu { position: relative; }
.account-menu > summary { display: flex; align-items: center; gap: .45rem; list-style: none; cursor: pointer; padding: .2rem .3rem .2rem .2rem; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .9rem; user-select: none; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary::before { content: none; }
.account-menu > summary:hover, .account-menu[open] > summary { background: var(--surface-2); color: var(--text); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.account-menu.active .avatar { background: var(--accent); color: var(--accent-text); }
.chev { width: .4rem; height: .4rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.account-name { display: none; }
.account-pop {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 40; min-width: 210px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}
.account-who { display: flex; flex-direction: column; margin: 0 0 .3rem; padding: .5rem .65rem .6rem; border-bottom: 1px solid var(--border); }
.account-who small { color: var(--muted); }
.account-pop a, .account-pop button {
  display: block; width: 100%; padding: .6rem .65rem; border: 0; border-radius: 8px; background: none; text-align: left;
  font: inherit; font-size: .95rem; font-weight: 500; color: var(--text); text-decoration: none; cursor: pointer;
}
.account-pop a:hover, .account-pop button:hover { background: var(--surface-2); }
.account-pop a[aria-current] { color: var(--accent); font-weight: 600; }
.account-pop button { color: var(--danger); }
.account-pop form { margin: 0; }
.tab-icon svg { display: block; }

@media (max-width: 719px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .tab { flex-direction: column; justify-content: flex-end; gap: .15rem; padding: .25rem 0; font-size: .72rem; line-height: 1.15; text-align: center; border-radius: 12px; }
  .tab-label { min-height: 2.3em; display: flex; align-items: center; }
  .tab-icon { display: grid; place-items: center; height: 26px; }
  .tab.active { background: transparent; color: var(--accent); }
  .tab-add .tab-icon {
    width: 48px; height: 48px; margin-top: -1.4rem; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
    box-shadow: 0 4px 14px rgba(53, 84, 209, .35);
  }
  .tab-add .tab-icon svg { width: 26px; height: 26px; stroke-width: 2.4; }
  body.with-tabs { padding-bottom: 5.5rem; }
}

.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 1rem; }
.container.narrow, .narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.breadcrumb { margin: 0 0 .25rem; }
.breadcrumb a { text-decoration: none; font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1rem;
}
.card.subtle { background: transparent; box-shadow: none; }
.login { margin-top: 10vh; }
.grid-2 { display: grid; gap: 1rem; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 .card { margin-bottom: 0; } }

details > summary { cursor: pointer; list-style: none; color: var(--muted); font-weight: 600; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 1.1em; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary h2 { display: inline; color: var(--text); }
details[open] > summary { margin-bottom: .8rem; }

/* Messages */
.notice { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.notice ul { margin: .5rem 0 0; padding-left: 1.25rem; }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warning { background: var(--warning-soft); color: var(--warning); }

/* Navigation entre périodes */
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .25rem 0 1rem; }
.period-title { text-align: center; }
.period-title h1 { margin: 0; font-size: 1.35rem; }
.period-title .muted { font-size: .85rem; }
.nav-arrow {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%;
  font-size: 1.8rem; line-height: 1; text-decoration: none; color: var(--text);
}
a.nav-arrow { background: var(--surface); border: 1px solid var(--border); }
a.nav-arrow:hover { background: var(--accent-soft); color: var(--accent); }

/* Solde */
.hero {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem;
  padding: 1.5rem 1rem; margin-bottom: 1rem; border-radius: 22px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(53, 84, 209, .25);
  position: relative;
}
.hero-info { position: absolute; top: .7rem; right: .7rem; z-index: 5; text-align: left; }
.hero-info > summary { list-style: none; cursor: pointer; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font: italic 700 .9rem/1 Georgia, serif; color: inherit; background: rgba(255,255,255,.22); border: 1.5px solid rgba(255,255,255,.7); }
.hero-info > summary::-webkit-details-marker { display: none; }
.hero-info > summary::before { content: none; }
.hero-info > p { position: absolute; right: 0; top: calc(100% + .4rem); width: min(16rem, 70vw); margin: 0; padding: .6rem .75rem; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .82rem; font-weight: 500; line-height: 1.35; }
.hero.due { background: linear-gradient(135deg, #c23a2b, #d9573f); box-shadow: 0 10px 30px rgba(194, 58, 43, .25); }
.hero.credit { background: linear-gradient(135deg, #0f8a63, #18a77c); box-shadow: 0 10px 30px rgba(15, 138, 99, .25); }
.hero.zero { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 30px rgba(53, 84, 209, .25); }
.hero-label { font-size: .95rem; opacity: .9; font-weight: 600; }
.hero-amount { font-size: 2.6rem; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-detail { font-size: .85rem; opacity: .85; }
.hero-note { margin-top: .4rem; font-size: .8rem; background: rgba(255,255,255,.18); padding: .2rem .7rem; border-radius: 999px; }

/* Boutons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; padding: .55rem 1.2rem; border-radius: 12px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: filter .15s, transform .05s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: scale(.98); }
.button.big { min-height: 54px; font-size: 1.05rem; border-radius: 14px; }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button.secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.add-button { display: flex; width: 100%; margin-bottom: 1.25rem; background: var(--text); border-color: var(--text); color: var(--bg); }
.add-button span { font-size: 1.3rem; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.danger-text { color: var(--danger); }
.danger-zone { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--border); text-align: center; }
.export-buttons { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Liste des dépenses */
.expense-list { margin-bottom: 1rem; }
.expense-list .day { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem .25rem .4rem; }
.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.items li + li { border-top: 1px solid var(--border); }
.item { display: flex; align-items: center; gap: .8rem; padding: .75rem .9rem; color: var(--text); text-decoration: none; }
a.item:hover { background: var(--surface-2); }
.item-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; font-size: 1.25rem; background: var(--surface-2); }
.cat-resto { background: #fff1e6; } .cat-hotel { background: #efe9ff; } .cat-essence { background: #ffeaea; }
.cat-peage { background: #e8f4ff; } .cat-parking { background: #e6f0ff; } .cat-transport { background: #e7f7f0; }
.cat-divers { background: #f1f2f5; } .cat-advance { background: var(--success-soft); }
@media (prefers-color-scheme: dark) { .item-icon { background: var(--surface-2) !important; } }
.item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.item-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.is-advance .item-amount { color: var(--success); }
.clip { display: block; font-size: .8rem; font-weight: 400; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }
.badge { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; background: var(--warning-soft); color: var(--warning); white-space: nowrap; }

.by-category { margin-top: 1rem; }
.by-category dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; margin: 0; }
.by-category dl div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .75rem; }
.by-category dt { color: var(--muted); font-size: .85rem; }
.by-category dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Historique */
.period-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.period-item {
  display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.period-item:hover { border-color: var(--accent); }
.period-item .item-main small { white-space: normal; }
.period-row { display: flex; align-items: stretch; gap: .5rem; }
/* Onglets Historique / Archives */
.page-tabs { display: flex; align-items: baseline; gap: 1.4rem; margin: 0 0 1rem; }
.page-tabs a { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); text-decoration: none; font-size: 1.1rem; font-weight: 650; line-height: 1.2; padding-bottom: .25rem; border-bottom: 3px solid transparent; }
.page-tabs a h1 { margin: 0; font: inherit; color: inherit; }
.page-tabs a:hover { color: var(--text); }
.page-tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }
.archive-year { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.archive-year > summary { display: flex; align-items: baseline; gap: .7rem; padding: .85rem 1rem; cursor: pointer; list-style: none; }
.archive-year > summary::-webkit-details-marker { display: none; }
.archive-year > summary::before { content: ""; align-self: center; flex: none; width: .45rem; height: .45rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.archive-year[open] > summary::before { transform: rotate(45deg); }
.archive-year > summary strong { font-size: 1.05rem; color: var(--text); }
.archive-year > summary .muted { font-size: .85rem; margin-left: auto; }
.archive-months { display: grid; gap: .5rem; padding: 0 .6rem .6rem; }
.tab-count { font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.period-row .period-item { flex: 1; min-width: 0; }
.lock-form { display: flex; margin: 0; }
.lock-toggle {
  display: flex; align-items: center; justify-content: center; width: 52px; padding: 0; min-height: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--muted); font: inherit; text-decoration: none;
}
.lock-toggle:hover { border-color: var(--accent); color: var(--accent); }
.lock-toggle.is-locked { color: var(--success); background: var(--success-soft); border-color: transparent; }
.lock-toggle.is-locked:hover { border-color: var(--success); color: var(--success); }
.pill { padding: .25rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { background: var(--accent-soft); color: var(--accent); }
.pill.due { background: var(--danger-soft); color: var(--danger); }
.pill.credit { background: var(--success-soft); color: var(--success); }
@media (max-width: 480px) { .period-item { flex-direction: column; align-items: flex-start; gap: .4rem; } }

/* Formulaires */
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .95rem; }
label.checkbox { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
label.checkbox input { width: auto; min-height: 0; }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .8rem; min-height: 48px;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-color: var(--accent); }
input:disabled { opacity: .45; }
.stack, .form-grid { display: grid; gap: 1rem; }
.form-grid h2, .form-grid .wide { grid-column: 1 / -1; }
@media (min-width: 640px) { .form-grid:not(.single) { grid-template-columns: 1fr 1fr; } .form-grid > button { grid-column: 1 / -1; } }
.form-row { display: grid; gap: 1rem; align-items: end; }
.form-row > label > input, .form-row .amount-input.small input { height: 48px; }
input[type="date"] { display: block; min-width: 0; -webkit-appearance: none; appearance: none; }
@media (min-width: 560px) { .form-row { grid-template-columns: 1fr 1fr; } .form-row.three { grid-template-columns: 1fr 1fr 1.3fr; } .form-row .form-actions { grid-column: 1 / -1; } }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-card { padding: 1.25rem; }

.expense-form { display: grid; gap: 1.25rem; }
.photo-field {
  position: relative; flex-direction: row; align-items: center; gap: 1rem; padding: 1rem;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
}
.photo-field:hover, .photo-field:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.photo-icon { font-size: 1.8rem; }
.photo-text { display: flex; flex-direction: column; }
.photo-text small { color: var(--muted); font-weight: 400; }
.photo-field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.photo-field.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.photo-choice { display: grid; grid-template-columns: 1fr; gap: .75rem; }
.photo-choice .photo-field { padding: .85rem; gap: .7rem; }
@media (max-width: 380px) { .photo-choice { grid-template-columns: 1fr; } }
.photo-hint { margin: -.6rem 0 0; font-size: .88rem; }
.scan-status { margin: -.75rem 0 0; font-size: .9rem; color: var(--muted); min-height: 0; }
.scan-status:empty { display: none; }
.current-receipt { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: -.5rem 0 0; }

.amount-field { font-size: .95rem; display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.amount-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.amount-head > label { display: inline; }
.basis-toggle { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.basis-toggle label { position: relative; display: block; }
.basis-toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; min-height: 0; cursor: pointer; }
.basis-toggle span { display: block; padding: .1rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.basis-toggle input:checked + span { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.basis-toggle input:focus-visible + span { outline: 2px solid var(--accent); }
.basis-hint { font-weight: 400; font-size: .82rem; }
.amount-input { position: relative; display: block; }
.amount-input input { font-size: 2rem; font-weight: 700; padding: .5rem 2.5rem .5rem .9rem; min-height: 64px; font-variant-numeric: tabular-nums; }
.amount-input > span { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; color: var(--muted); }
.amount-input.small input { font-size: 1rem; font-weight: 400; min-height: 48px; }
.amount-input.small > span { font-size: 1rem; }

.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips legend { font-weight: 600; font-size: .95rem; margin-bottom: .5rem; padding: 0; }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; min-height: 0; }
.chip > span {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .92rem; cursor: pointer; user-select: none;
}
.chip-icon { font-size: 1.1rem; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip-advance input:checked + span { border-color: var(--success); background: var(--success-soft); color: var(--success); box-shadow: inset 0 0 0 1px var(--success); }
.chip input:focus-visible + span { outline: 3px solid var(--accent-soft); }
.more { border-top: 1px solid var(--border); padding-top: .9rem; }
.expense-form .form-actions .button.big { flex: 1; }

/* Page d'installation */
.checks { list-style: none; padding: 0; margin: 0; columns: 2 220px; }
.checks .ok { color: var(--success); }
.checks .ko { color: var(--danger); font-weight: 600; }

@media print {
  .topbar, form, .button, .breadcrumb, .tabs, .account-menu, .hero-info { display: none !important; }
  .card, .items { box-shadow: none; }
  .hero { color: #000; background: none; box-shadow: none; border: 1px solid #ccc; }
}
@media (min-width: 560px) { .expense-form .form-row.three { grid-template-columns: minmax(9.5rem, .8fr) 1.4fr 1fr; } }

/* Note validée (verrouillée) */
.locked-banner { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); font-weight: 600; }
.validation-card h2 { margin-top: 0; }
.unlock-form { display: grid; gap: 10px; }
.readonly-list { margin: 0; display: grid; gap: 8px; }
.readonly-list div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.readonly-list dt { color: var(--muted); }
.readonly-list dd { margin: 0; font-weight: 600; text-align: right; }
[hidden] { display: none !important; }
.lock { font-size: .85em; }

/* Liste déroulante des clients */
.combo { position: relative; }
.combo input { padding-right: 2.6rem; height: 48px; }
.combo-toggle {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 2.4rem; display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; min-height: 0; box-shadow: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.combo-toggle:hover { color: var(--accent); background: none; }
.combo-toggle svg { transition: transform .15s ease; }
.combo.open .combo-toggle svg { transform: rotate(180deg); }
.combo input:disabled ~ .combo-toggle { opacity: .45; cursor: default; }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
  max-height: 15rem; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06);
}
.combo-list li {
  padding: .65rem .75rem; border-radius: calc(var(--radius-sm) - 2px); cursor: pointer; font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
}
.combo-list li.active { background: var(--accent-soft); color: var(--accent); }
.combo-list li.current { font-weight: 600; }
.combo-list li.current::after { content: " ✓"; color: var(--accent); }
.combo-list mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* Ordre des dépenses dans une journée (poignées) */
.sortable li { display: flex; align-items: stretch; background: var(--surface); }
.sortable li > .item { flex: 1; min-width: 0; padding-left: .35rem; }
.drag-handle {
  flex: none; width: 30px; display: flex; align-items: center; justify-content: center; padding: 0 0 0 4px; min-height: 0;
  border: 0; background: none; color: var(--muted); opacity: .55; cursor: grab; touch-action: none; font: inherit;
}
.drag-handle:hover, .drag-handle:focus-visible { opacity: 1; color: var(--accent); }
.sortable.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.sortable.is-dragging .drag-handle { cursor: grabbing; }
.sortable li.dragging { position: relative; z-index: 2; background: var(--surface-2); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.sortable li.dragging .drag-handle { opacity: 1; color: var(--accent); }
.sortable.saving { opacity: .75; }
.drag-handle.is-static, .drag-handle.is-static:hover { opacity: .18; color: var(--muted); cursor: default; }

/* Œil du mot de passe */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 3rem; }
.password-eye {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 2.8rem; display: flex; align-items: center; justify-content: center;
  padding: 0; min-height: 0; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.password-eye:hover, .password-eye[aria-pressed="true"] { color: var(--accent); }

/* Éléments réservés à l'ordinateur (cachés sur téléphone) */
.list-head, .cell, .hero-breakdown, .dot { display: none; }

/* Lignes d'avance et de report : en gris, pour les distinguer des dépenses */
.item.is-advance { background: var(--row-advance); color: var(--muted); }
.item.is-advance .item-main strong { font-weight: 500; }
.is-advance .item-amount { color: var(--muted); font-weight: 600; }
.item.is-advance .item-icon { filter: grayscale(1); opacity: .7; }
a.item.is-advance:hover { background: var(--border); }
.item.is-advance .item-icon { background: var(--surface) !important; }
.sortable li:has(> .item.is-advance) { background: var(--row-advance); }

/* ---------- Ordinateur (à partir de 1024 px) ---------- */
@media (min-width: 1024px) {
  :root { --radius: 8px; --radius-sm: 6px; --shadow: none; --page: 1320px; }
  body { font-size: 15px; }
  .emoji, .tab-icon, .item-icon, .clip, .chip-icon, .photo-icon { display: none !important; }
  .item-main small { font-size: 0; line-height: 0; }
  .item-main small:not(:has(.badge)) { display: none; }
  .item-main small .badge { font-size: .7rem; line-height: 1.6; }
  .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: #9aa0b2; }
  .dot.cat-resto { background: #e8833a; } .dot.cat-hotel { background: #7c5cd6; } .dot.cat-essence { background: #d64545; }
  .dot.cat-peage { background: #2f8fd8; } .dot.cat-parking { background: #4a6cf0; } .dot.cat-transport { background: #1f9e6e; }
  .dot.cat-divers { background: #9aa0b2; } .dot.cat-advance { background: #b8bdca; }

  /* Barre du haut */
  .topbar { padding: 0 max(2rem, calc((100% - var(--page)) / 2 + 2rem)); height: 56px; gap: 2rem; }
  .brand { margin-right: 0; font-size: 1rem; }
  .brand-mark { background: var(--text); color: var(--bg); border-radius: 6px; width: 26px; height: 26px; font-size: .85rem; }
  .tabs { margin-right: auto; gap: 1.5rem; align-self: stretch; }
  .tab { border-radius: 0; padding: 0; font-size: .92rem; font-weight: 500; border-bottom: 2px solid transparent; border-top: 2px solid transparent; }
  .tab:hover { background: none; color: var(--text); }
  .tab.active { background: none; color: var(--text); border-bottom-color: var(--accent); }
  .tab-label br { display: none; }
  .account-name { display: inline; }
  .avatar { width: 28px; height: 28px; font-size: .72rem; }

  .container { max-width: 960px; padding: 2rem; }
  .container:has(.note-layout) { max-width: var(--page); }
  h1 { font-size: 1.5rem; font-weight: 650; }
  h2 { font-size: .95rem; font-weight: 650; }
  .card { padding: 1.25rem; }
  .button { min-height: 38px; padding: .45rem 1rem; border-radius: var(--radius-sm); font-size: .92rem; }
  .button.big { min-height: 42px; font-size: .95rem; border-radius: var(--radius-sm); }
  .button:active { transform: none; }
  input, select, textarea { min-height: 40px; padding: .5rem .7rem; }
  .combo input, .form-row > label > input, .form-row .amount-input.small input { height: 40px; }
  .amount-input input { font-size: 1.6rem; min-height: 54px; }
  .amount-input.small input { min-height: 40px; }
  label { font-size: .88rem; }
  .basis-toggle, .basis-toggle span { border-radius: var(--radius-sm); }
  .chip > span { border-radius: var(--radius-sm); padding: .4rem .75rem; font-size: .88rem; }
  .chip input:checked + span { box-shadow: none; }

  /* En-tête de période : titre à gauche, flèches à droite */
  .period-nav { justify-content: flex-start; gap: .4rem; margin: 0 0 1.5rem; }
  .period-title { order: -1; text-align: left; margin-right: auto; }
  .period-title h1 { font-size: 1.5rem; }
  .nav-arrow { width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 1.3rem; }
  span.nav-arrow { visibility: hidden; }

  /* Mise en page de la note : liste à gauche, résumé à droite */
  .note-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto auto auto 1fr;
    column-gap: 2rem; align-items: start;
  }
  .note-layout > .expense-list { grid-column: 1; grid-row: 1 / -1; margin: 0; }
  .note-layout > .hero, .note-layout > .add-button, .note-layout > .note-extras { grid-column: 2; }
  .note-extras .card { margin-bottom: 1rem; }
  .note-extras .export-buttons { grid-template-columns: 1fr; }
  .note-extras .export-buttons .button { justify-content: flex-start; }
  .note-extras .form-row.three { grid-template-columns: 1fr 1fr; }
  .note-extras .form-row.three > label:nth-of-type(3) { grid-column: 1 / -1; }
  .note-extras .card.subtle { border-style: dashed; }
  .by-category dl { grid-template-columns: 1fr; gap: 0; }
  .by-category dl div { display: flex; justify-content: space-between; align-items: center; background: none; border-radius: 0; padding: .45rem 0; border-bottom: 1px solid var(--border); }
  .by-category dl div:last-child { border-bottom: 0; }
  .by-category dt { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .9rem; }

  /* Solde */
  .hero, .hero.due, .hero.credit, .hero.zero {
    align-items: stretch; text-align: left; gap: .1rem; padding: 1.25rem; margin-bottom: 1rem;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none;
  }
  .hero-label { color: var(--muted); opacity: 1; font-size: .85rem; font-weight: 500; }
  .hero-amount { font-size: 2.1rem; font-weight: 700; color: var(--accent); }
  .hero.due .hero-amount { color: var(--danger); }
  .hero.credit .hero-amount { color: var(--success); }
  .hero.zero .hero-amount { color: var(--accent); }
  .hero, .hero.due, .hero.credit, .hero.zero { border-top: 3px solid var(--accent); }
  .hero.hero.due { border-top-color: var(--danger); }
  .hero.hero.credit { border-top-color: var(--success); }
  .hero-detail { display: none; }
  .hero-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
  .hero-breakdown dt { color: var(--muted); font-size: .78rem; }
  .hero-breakdown dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
  .hero-note { margin-top: .9rem; background: var(--success-soft); color: var(--success); border-radius: var(--radius-sm); padding: .45rem .7rem; }
  .hero-info > summary { color: var(--muted); background: var(--surface); border-color: var(--border); }
  .container > .hero, .container > .add-button { max-width: 420px; }
  .container > .hero .hero-detail { display: block; color: var(--muted); }

  .add-button { background: var(--accent); border-color: var(--accent); color: var(--accent-text); margin-bottom: 1rem; }
  .add-button span { font-size: 1.1rem; }

  /* Tableau des dépenses */
  .expense-list {
    --cols: minmax(0, 1fr) 7rem 6.5rem 4.5rem 6rem 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  }
  .list-head {
    display: grid; grid-template-columns: var(--cols); gap: 1rem; align-items: center;
    padding: .6rem 1rem .6rem calc(30px + .5rem); background: var(--surface-2); border-bottom: 1px solid var(--border);
    color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  }
  .num { text-align: right; }
  .expense-list .day {
    margin: 0; padding: 1rem 1rem .4rem calc(30px + .5rem); font-size: .75rem; font-weight: 600;
    letter-spacing: .05em; color: var(--muted);
  }
  .items { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; background: none; }
  .items li { display: flex; align-items: stretch; }
  .items:not(.sortable) > li { padding-left: 30px; }
  .item, .sortable li > .item {
    flex: 1; min-width: 0; display: grid; grid-template-columns: var(--cols); gap: 1rem; align-items: center;
    padding: .6rem .9rem .6rem .5rem; font-size: .92rem; column-gap: .9rem;
  }
  .item-main { flex-direction: row; align-items: center; gap: .5rem; }
  .item-main strong { font-weight: 500; }
  .item-main small { flex: none; }
  .cell { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  .cell-cat { display: flex; align-items: center; gap: .5rem; color: var(--text); }
  .cell-vat { font-variant-numeric: tabular-nums; }
  .cell-clip { display: flex; justify-content: center; color: var(--muted); }
  .item-amount { font-weight: 600; }
  .items li:hover { background: var(--surface-2); }
  a.item:hover { background: none; }
  .drag-handle { opacity: .3; }
  .items li:hover .drag-handle { opacity: .8; }
  .item.is-advance, a.item.is-advance:hover { background: none; }
  .item.is-advance .cell-cat { color: var(--muted); }
  .items li:has(> .item.is-advance) { background: var(--row-advance); }
  .empty { padding: 3rem 1rem; }

  /* Historique */
  .period-list { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .period-row + .period-row { border-top: 1px solid var(--border); }
  .period-row { gap: 0; align-items: center; }
  .period-row:hover { background: var(--surface-2); }
  .archive-year { border: 0; border-radius: 0; box-shadow: none; }
  .archive-year + .archive-year { border-top: 1px solid var(--border); }
  .archive-year > summary:hover { background: var(--surface-2); }
  .archive-months { gap: 0; padding: 0; }
  .archive-months .period-row { border-top: 1px solid var(--border); padding-left: 1.2rem; }
  .period-item { border: 0; border-radius: 0; padding: .85rem 1rem; background: none; }
  .lock-form { padding-right: .6rem; }
  .lock-toggle { width: 36px; height: 36px; border-radius: var(--radius-sm); border-color: transparent; background: none; }
  a.lock-toggle { margin-right: .6rem; }
  .lock-toggle.is-locked { background: var(--success-soft); }
  .pill { border-radius: var(--radius-sm); }

  /* Formulaire d'ajout */
  .photo-field { border-radius: var(--radius); }
}
