:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafb;
  --border: #e3e8ec;
  --border-strong: #cfd7de;
  --text: #16212b;
  --muted: #5d6b78;
  --faint: #8b97a3;
  --primary: #155e75;
  --primary-hover: #0e4a5d;
  --primary-soft: #e3f1f5;
  --side: #10222c;
  --side-text: #b8c7d1;
  --side-active: #1d3a48;
  --green: #137a4b;
  --green-soft: #e3f4ec;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #a15c07;
  --amber-soft: #fff4e0;
  --blue-soft: #e8f0fe;
  --blue: #1f4fb5;
  --violet-soft: #f1ebfd;
  --violet: #6433b9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 34, 44, .06), 0 1px 1px rgba(16, 34, 44, .04);
  --shadow-lg: 0 20px 50px rgba(16, 34, 44, .25);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.ico { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; font-weight: 600; font-size: 15px; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: #1f7a96; display: grid; place-items: center; font-weight: 700; }
.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge-count { margin-left: auto; background: #b42318; color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.side-foot button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244,246,248,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); padding: 12px 28px; display: flex; gap: 14px; align-items: center; }
.search { position: relative; flex: 1; max-width: 560px; }
.search input, .search input[type=search] { width: 100%; padding: 9px 12px 9px 36px; border-radius: 9px; border: 1px solid var(--border-strong); background: #fff; font: inherit; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.alert .value { color: var(--red); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--panel-2); white-space: nowrap; }
tbody tr:hover { background: #fafcfd; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
tfoot td { font-weight: 600; background: var(--panel-2); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; background: #eef1f4; color: #3c4a56; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.teal { background: var(--primary-soft); color: var(--primary); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--red); border-color: #f1c4bf; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f4; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; padding: 5px; border-radius: 6px; cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; vertical-align: middle; }
.icon-btn:hover { background: #eef1f4; color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); }

label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
label.field > span .req { color: var(--red); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(21,94,117,.35); outline-offset: 1px; border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--faint); margin-top: 3px; }
.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 500; border-right: 1px solid var(--border-strong); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--primary); color: #fff; }
.seg label.debit:has(input:checked) { background: var(--red); }
.seg label.credit:has(input:checked) { background: var(--green); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.filters label.field { min-width: 140px; }
.filters input, .filters select { padding: 6px 9px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: #eef1f4; color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

/* ---------- Info lists ---------- */
dl.info { display: grid; grid-template-columns: 170px 1fr; gap: 9px 14px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13px; }
dl.info dd { margin: 0; min-width: 0; word-break: break-word; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.secret { font-family: var(--mono); letter-spacing: .08em; }

/* ---------- Comptes ---------- */
.compte { margin-bottom: 18px; }
.compte-head { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bank-avatar { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; flex: none; }
.compte-solde { margin-left: auto; text-align: right; }
.compte-solde .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.compte-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.compte-grid > div { padding: 14px 18px; }
.compte-grid > div + div { border-left: 1px solid var(--border); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sc-list { list-style: none; margin: 0; padding: 0; }
.sc-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.sc-list li:last-child { border-bottom: 0; }
.iban-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.iban-card.ferme { opacity: .6; }
.iban-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.iban-line .mono { font-size: 13.5px; font-weight: 600; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: #eef1f4; font-size: 14px; }
.timeline .body { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.timeline li.done .body { text-decoration: line-through; color: var(--faint); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 24, 32, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 100; overflow-y: auto; animation: fade .12s ease-out; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--panel-2); border-radius: 0 0 12px 12px; }
.modal .error { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.viewer { width: 100%; height: 72vh; border: 0; background: #f0f2f4; }
.viewer-img { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #10222c; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; max-width: 380px; }
.toast.err { background: var(--red); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #10222c 0%, #155e75 100%); }
.login { background: #fff; border-radius: 14px; padding: 30px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login h1 { margin-bottom: 4px; }
.login .stack { margin-top: 20px; }

/* ---------- Divers ---------- */
.alert-box { padding: 10px 14px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); font-size: 13px; }
.alert-box.info { background: var(--primary-soft); color: var(--primary); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.search-group h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

@media (max-width: 1000px) {
  .compte-grid { grid-template-columns: 1fr; }
  .compte-grid > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
.grid > *, .stack > * { min-width: 0; }
@media print {
  .sidebar, .topbar, .btn, .icon-btn, .tabs { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}
.badge.grey { background: #e6e9ed; color: #4a5561; }
.badge.dark { background: #3c4a56; color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-weight: 500; font-size: 13px; cursor: pointer; }
.chip:hover { text-decoration: none; background: var(--panel-2); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip .n { background: rgba(0,0,0,.07); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.chip.active .n { background: rgba(255,255,255,.2); }
.chip .dotc { width: 8px; height: 8px; border-radius: 50%; }
.form-section { grid-column: 1 / -1; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-top: 8px; }
.form-section:first-child { margin-top: 0; }
.prefill { grid-column: 1 / -1; background: var(--primary-soft); border-radius: 8px; padding: 10px 12px; }
.prefill select { background: #fff; }
.status-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hist li .body { white-space: pre-wrap; }
.bank-avatar.sm { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.sc-card { display: flex; flex-direction: column; }
.sc-card.ferme { opacity: .6; }
.sc-head { display: flex; gap: 12px; padding: 14px 16px 10px; align-items: flex-start; }
.sc-solde { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-iban { padding: 10px 16px; margin: 0 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.sc-iban .mono { font-size: 14px; font-weight: 600; }
.sc-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; margin-top: auto; }
@media (max-width: 760px) { .sc-grid { grid-template-columns: 1fr; } }
.qr-box { width: 200px; margin: 0 auto; background: #fff; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.center { text-align: center; }
#update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 300; background: var(--primary); color: #fff; padding: 10px 16px; text-align: center; font-weight: 500; box-shadow: var(--shadow-lg); }
#update-banner .btn { margin-left: 10px; }
.chip.file-chip { padding: 3px 9px; font-size: 12px; gap: 4px; border-radius: 6px; }
.chip.file-chip .ico { width: 13px; height: 13px; }
.chip.file-chip .icon-btn { padding: 1px; }
.chip.file-chip a { color: var(--text); }
.clickable-rib { cursor: pointer; transition: border-color .12s, background .12s; }
.clickable-rib:hover { border-color: var(--primary); background: var(--primary-soft); }
.rib-hint { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--primary); font-weight: 500; opacity: .75; }
.clickable-rib:hover .rib-hint { opacity: 1; }
.rib-hint .ico { width: 13px; height: 13px; }

/* =====================================================================
   Mobile
   ===================================================================== */
.m-header, .m-tabs, .m-list, .m-search, .m-filter-btn, .m-total { display: none; }
* { -webkit-tap-highlight-color: transparent; }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .layout { display: block; }
  .sidebar, .topbar { display: none; }
  .d-only { display: none !important; }
  .main { overflow-x: clip; min-width: 0; }
  .grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
  .table-wrap table { min-width: 0; }
  .card td { white-space: normal; }
  .card td.nowrap, .card td .nowrap { white-space: nowrap; }
  .card td .bank-avatar { width: 32px; height: 32px; font-size: 12px; }
  .content { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }

  /* En-tête */
  .m-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--side); color: #fff; }
  .m-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; user-select: none; }
  .m-brand .brand-logo { width: 32px; height: 32px; }
  .m-icon { background: transparent; border: 0; color: inherit; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; }
  .m-icon:active { background: rgba(255,255,255,.12); }
  .m-icon .ico { width: 22px; height: 22px; }
  .m-search:not(.hidden) { display: flex; gap: 6px; align-items: center; position: sticky; top: 0; z-index: 31; padding: calc(8px + env(safe-area-inset-top)) 10px 8px 14px; background: var(--side); }
  .m-search input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 0; font-size: 16px; }
  .m-search .m-icon { color: #fff; }

  /* Barre d'onglets en bas */
  .m-tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .m-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 0;
    font-size: 11px; font-weight: 500; color: var(--muted); background: none; border: 0; font-family: inherit; text-decoration: none !important; }
  .m-tab .ico { width: 23px; height: 23px; }
  .m-tab.active { color: var(--primary); }
  .m-add { align-self: center; justify-self: center; width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: #fff;
    box-shadow: 0 6px 16px rgba(21,94,117,.4); margin-top: -22px; }
  .m-add .ico { width: 28px; height: 28px; }
  .m-add:active { transform: scale(.94); }
  .m-dot { position: absolute; top: 0; right: calc(50% - 22px); background: var(--red); color: #fff; font-style: normal; font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
  .m-dot.static { position: static; margin-left: auto; }

  /* Titres de page */
  h1 { font-size: 21px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head .sub { font-size: 13px; }
  .page-head > .btn.primary, .page-head .row > .btn.primary { display: none; } /* remplacé par le bouton + du bas */
  .crumbs { margin-bottom: 2px; }

  /* Pastilles de statut : défilement horizontal */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; padding: 8px 13px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 19px; }

  /* Cartes / listes */
  .card { border-radius: 14px; }
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .m-list { display: block; }
  .m-total { display: block; padding: 10px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
  .m-card, .m-row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--border);
    background: #fff; color: var(--text); text-align: left; font: inherit; text-decoration: none !important; }
  .m-card.col { flex-direction: column; align-items: stretch; gap: 4px; }
  .m-list > :last-child { border-bottom: 0; border-radius: 0 0 14px 14px; }
  .m-card:active, .m-row:active { background: var(--panel-2); }
  .m-main { flex: 1; min-width: 0; }
  .m-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  .m-row .m-title { white-space: nowrap; }
  .m-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
  .m-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
  .m-right { text-align: right; flex: none; font-weight: 600; }
  .m-amount { font-size: 15px; font-variant-numeric: tabular-nums; }
  .m-check { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 11px; margin-right: 5px; vertical-align: 1px; }
  .m-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
  .m-actions .icon-btn { margin-left: auto; }
  .list-plain li { padding: 12px 14px; flex-wrap: wrap; }
  table td, table th { padding: 10px; }

  /* Filtres repliables */
  .filters { padding: 10px 14px; gap: 8px; align-items: center; }
  .filters label.field { min-width: 0; flex: 1 1 100%; }
  .filters label.field > span { display: none; }
  .filters .m-collapsible { display: none; }
  .filters.open .m-collapsible { display: block; }
  .filters.open label.field > span { display: block; }
  .m-filter-btn { display: inline-flex; flex: none; }
  .filters > label.field:has(input[type=search]) { flex: 1 1 0; }
  .filters .grow { display: none; }
  .filters > .btn:not(.m-filter-btn) { display: none; }

  /* Onglets d'un compte */
  .tabs { margin: 0 -14px 14px; padding: 0 8px; scrollbar-width: none; position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 20; background: var(--bg); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 11px 10px; }
  .page-head .row.wrap { width: 100%; }
  .page-head .row.wrap .btn { flex: 1; justify-content: center; padding: 9px 8px; font-size: 13px; }
  .bank-avatar { width: 36px; height: 36px; }

  /* Sous-comptes */
  .sc-grid { grid-template-columns: 1fr; }
  .sc-iban { margin: 0 14px; }
  .sc-iban .mono { font-size: 13px; }
  .rib-hint span { display: none; }

  /* Formulaires / fenêtres : plein écran, boutons toujours visibles */
  input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
    font-size: 16px; padding: 11px 12px; border-radius: 10px; }
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 7px 11px; }
  .icon-btn { padding: 9px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  dl.info { grid-template-columns: 1fr; gap: 2px 0; }
  dl.info dt { font-size: 12px; margin-top: 6px; }
  dl.info dd { margin-bottom: 4px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 94dvh; display: flex; flex-direction: column; animation: slideup .2s ease-out; }
  .modal-head { padding: 14px 16px; }
  .modal-head h2 { font-size: 16px; }
  .modal-body { overflow-y: auto; padding: 14px 16px; flex: 1; }
  .modal-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .modal-foot .checkbox { flex-basis: 100%; }
  .modal-foot .grow { display: none; }
  .modal-foot { flex-wrap: wrap; }
  .seg { display: flex; width: 100%; }
  .seg label { flex: 1; text-align: center; padding: 11px 6px; }
  .viewer { height: 65dvh; }

  #toasts { left: 14px; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; text-align: center; }
  .login { padding: 24px 20px; border-radius: 18px; }
}

/* Feuille d'actions */
.sheet-backdrop { align-items: flex-end !important; padding: 0 !important; }
.sheet { width: 100%; max-width: 520px; margin: 0 auto; background: #fff; border-radius: 18px 18px 0 0; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); animation: slideup .2s ease-out; }
.sheet-title { text-align: center; font-size: 13px; color: var(--muted); padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 12px; border: 0; background: none; font: inherit; font-size: 16px; color: var(--text); border-radius: 10px; text-align: left; }
.sheet-item:active, .sheet-item:hover { background: var(--panel-2); }
.sheet-item .ico { width: 20px; height: 20px; color: var(--primary); }
.sheet-item.danger, .sheet-item.danger .ico { color: var(--red); }
.sheet-item.cancel { justify-content: center; font-weight: 600; margin-top: 6px; background: var(--panel-2); }
.sheet .m-dot { background: var(--red); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; margin-left: auto; }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 760px) {
  .filters > label.field:has(input[type=search]) { order: -2; }
  .filters > .m-filter-btn { order: -1; }
  .page-head .sub { display: none; }
  .page-head > div > .sub.status-line, .page-head .status-line { display: flex; }
}
/* Tableau de bord */
.month-nav { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 4px 6px; }
.month-nav strong { min-width: 140px; text-align: center; text-transform: capitalize; }
.month-nav .icon-btn { font-size: 20px; line-height: 1; width: 32px; height: 32px; }
.month-nav .icon-btn:disabled { opacity: .3; cursor: default; }
.kpis.big { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.big .value { font-size: 25px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.in { border-top: 3px solid var(--green); }
.kpi.out { border-top: 3px solid var(--red); }
.kpi.warn { border-top: 3px solid var(--amber); }
.dash-table td { vertical-align: top; }
.comment-cell { white-space: pre-wrap; cursor: text; border-radius: 6px; padding: 4px 6px; margin: -4px -6px; min-height: 22px; font-size: 13.5px; }
.comment-cell[data-act]:hover { background: var(--primary-soft); }
.comment-cell textarea { width: 100%; font-size: 14px; }
.comment-box { display: flex; gap: 10px; align-items: flex-start; background: #fffbea; border: 1px solid #f3e3a6; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.comment-box .comment-ico { font-size: 16px; line-height: 22px; }
.comment-box .comment-cell { margin: 0; padding: 0 4px; }
@media (max-width: 1100px) { .kpis.big { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .kpis.big .value { font-size: 19px; }
  .month-nav { width: 100%; justify-content: space-between; }
  .page-head:has(.month-nav) { flex-direction: column; align-items: stretch; }
  .m-card .comment-cell { margin: 8px 0 0; padding: 8px 10px; background: #fffbea; border: 1px solid #f3e3a6; }
}
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-row .chip { font-size: 13px; }
.month-nav { flex-wrap: wrap; }
@media (max-width: 760px) { .month-nav .btn.sm { padding: 6px 10px; } }
