/* Rufus Pay — interface d'administration */
:root {
  --bg: #F3F5F9;
  --card: #FFFFFF;
  --ink: #0B1B3A;
  --text: #1C2437;
  --muted: #667085;
  --line: #E3E7EF;
  --line-2: #EEF1F6;
  --brand: #0B1B3A;
  --accent: #2C75FF;
  --accent-ink: #1B5BD8;
  --pos: #0E7A43;
  --neg: #B4233D;
  --warn-bg: #FFF6E5;
  --warn-ink: #8A5300;
  --ok-bg: #E8F6EE;
  --ko-bg: #FDECEF;
  --wait-bg: #EAF1FF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.05rem; }
.h2 { font-size: 1.05rem; margin: 1.6rem 0 .7rem; }
.h3 { font-size: .95rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--line-2); padding: .05em .35em; border-radius: 5px; }
small, .small { font-size: .84rem; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.ok-text { color: var(--pos); }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mt { margin-top: 1.2rem; }
[hidden] { display: none !important; }

/* ---------- en-tête */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: #fff; font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: #8BC6FF; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, #2C75FF, #8BC6FF); color: #fff; font-size: .95rem; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #C9D3E8; padding: 8px 12px; border-radius: 9px; white-space: nowrap; display: inline-flex; align-items: center; gap: .45rem; font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .14); color: #fff; }
.logout { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.who { color: #C9D3E8; font-size: .88rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.top .btn-link { color: #fff; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 0; }

/* ---------- éléments */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-lg { width: 14px; height: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #C5CCDA; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-sm { padding: 5px 10px; font-size: .82rem; border-radius: 8px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-ink); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(44, 117, 255, .35); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 3px; height: 40px; }
input[readonly] { background: #F8FAFC; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .86rem; font-weight: 600; color: var(--ink); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack .btn { align-self: flex-start; }

.flash { padding: 11px 14px; border-radius: 11px; margin-bottom: 12px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: #075C31; border-color: #C5E9D4; }
.flash-error { background: var(--ko-bg); color: #8E1730; border-color: #F6C9D2; }
.flash-warning { background: var(--warn-bg); color: var(--warn-ink); border-color: #F7DFAF; }
.flash a { font-weight: 600; color: inherit; text-decoration: underline; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head.pad { padding: 16px 18px 6px; }
.narrow { max-width: 520px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section, .card + .grid-2 { margin-top: 16px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs { margin: 0 0 4px; font-size: .88rem; }

.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period select { width: auto; }
.period-dates { display: inline-flex; gap: 6px; align-items: center; }
.period-dates input { width: auto; }

/* ---------- indicateurs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.3rem; color: var(--ink); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.kpi-strong { background: var(--brand); border-color: var(--brand); }
.kpi-strong .kpi-label, .kpi-strong .kpi-sub { color: #AFC0DE; }
.kpi-strong .kpi-value { color: #fff; }

.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 18px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--pc, #9AA4B8); border-radius: var(--radius); padding: 15px 16px; color: var(--text); box-shadow: var(--shadow); }
.pcard:hover { text-decoration: none; border-color: #C5CCDA; border-top-color: var(--pc, #9AA4B8); }
.pcard.is-off { opacity: .6; }
.pcard.is-warn { border-top-color: #E0A200; background: #FFFCF4; }
.pcard-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 10px; color: var(--ink); }
.pcard dl { margin: 0; display: grid; gap: 6px; }
.pcard dl > div { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.pcard dt { color: var(--muted); }
.pcard dd { margin: 0; font-weight: 600; text-align: right; }
.pcard-bal { border-top: 1px dashed var(--line); padding-top: 7px; margin-top: 2px; }
.pcard-bal dd { color: var(--ink); }
.pcard-warn { margin: 10px 0 0; font-size: .8rem; color: var(--warn-ink); }
.tag { font-size: .72rem; font-weight: 600; background: var(--line-2); color: var(--muted); padding: 2px 7px; border-radius: 99px; }
.chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .86rem; white-space: nowrap; }
.chip-warn { background: var(--warn-bg); color: var(--warn-ink); padding: 2px 8px; border-radius: 99px; font-weight: 600; font-size: .78rem; }

.st { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.st-ok { background: var(--ok-bg); color: var(--pos); }
.st-ko { background: var(--ko-bg); color: var(--neg); }
.st-wait { background: var(--wait-bg); color: var(--accent-ink); }
.fw { font-weight: 600; }
.fw-sent { color: var(--pos); }
.fw-failed, .fw-rejected { color: var(--neg); }
.fw-retry, .fw-pending, .fw-processing { color: var(--warn-ink); }
.fw-skipped { color: var(--muted); }

/* ---------- tableaux */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover { background: #FAFBFE; }
.table tr[data-href] { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .clip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tfoot td { background: #FAFBFD; font-weight: 600; border-top: 1px solid var(--line); }
.journal .opening td { background: #FAFBFD; color: var(--muted); }
.empty-row { padding: 18px; margin: 0; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters label { flex: 1 1 140px; }
.filters label.grow { flex: 3 1 240px; }
.filters-actions { display: flex; gap: 12px; align-items: center; padding-bottom: 2px; }

/* ---------- graphique, flux */
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart .lbl { font-size: 13px; fill: var(--muted); text-anchor: middle; }
.chart .val { font-size: 11px; fill: var(--ink); text-anchor: middle; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; margin-top: 8px; }
.legend > span { display: inline-flex; align-items: center; gap: .4rem; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed a { display: flex; align-items: center; gap: 10px; padding: 9px 2px; color: var(--text); }
.feed a:hover { text-decoration: none; background: #FAFBFE; }
.feed-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.feed-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.feed-side small { color: var(--muted); font-size: .76rem; }
.feed li.muted { padding: 10px 0; }

/* ---------- détail */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.kv { display: inline-block; background: var(--line-2); border-radius: 7px; padding: 2px 8px; margin: 0 6px 6px 0; font-size: .84rem; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.events li { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; display: grid; gap: 3px; font-size: .9rem; }
.events form { margin-top: 4px; }

/* ---------- écritures */
.entry-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0 16px; }
.entry-form label { flex: 1 1 120px; }
.entry-form label.grow { flex: 2 1 220px; }
.entry-form .w-cur { width: 72px; }
.entry-form label:has(.w-cur) { flex: 0 0 80px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: .9rem; }
.entries-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.entries li.is-cancelled { opacity: .55; }
.entries li.is-cancelled .entries-main > span, .entries li.is-cancelled .nowrap { text-decoration: line-through; }

/* ---------- paramètres */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.choices { border: 0; padding: 0; margin: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.choices legend { font-size: .86rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; padding: 0; }
.choice { flex-direction: row; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 11px; padding: 9px 13px; cursor: pointer; font-weight: 500; }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); }
.choice:has(input:checked) { border-color: var(--accent); background: #F3F7FF; }
.copy-field { margin-bottom: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: var(--mono); font-size: .84rem; }
.code { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: 10px; font: .8rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.balances { list-style: none; margin: 0; padding: 0; }
.balances li { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line-2); font-size: .92rem; }
.rules { margin: 0 0 8px; padding-left: 1.2rem; }
.pdetails summary { cursor: pointer; display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; list-style: none; }
.pdetails summary::-webkit-details-marker { display: none; }
.pdetails summary::before { content: "▸"; color: var(--muted); }
.pdetails[open] summary::before { content: "▾"; }
.pdetails[open] summary { margin-bottom: 14px; }
.pform-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pform-grid .span-2 { grid-column: span 2; }
.pform-foot { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.pform-foot .btn { margin-left: auto; }
.months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* ---------- invité */
body.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #1C3A78 0%, transparent 60%), var(--brand); }
.guest-card { background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.guest-card .brand { color: var(--ink); margin-bottom: 18px; }
.guest-card .brand b { color: var(--accent); }
.brand-lg { font-size: 1.25rem; }
.guest-card h1 { font-size: 1.35rem; }
.empty { text-align: center; padding: 40px 10px; }
.empty h1 { justify-content: center; }

/* ---------- mobile */
@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .pform-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .who { display: none; }
}
@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; padding-bottom: 6px; }
  .nav { order: 3; flex-basis: 100%; }
  .logout { margin-left: auto; }
  .kpis { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.15rem; }
  .pform-grid { grid-template-columns: 1fr; }
  .pform-grid .span-2 { grid-column: auto; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: 9px 10px; }
  h1 { font-size: 1.35rem; }
  .period-dates { flex-wrap: wrap; }
}

/* ---------- double authentification, retraits */
.steps { padding-left: 1.2rem; margin: 0 0 12px; font-size: .92rem; display: grid; gap: 4px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; margin: 8px 0 12px; }
.qr svg { width: 220px; height: 220px; max-width: 100%; }
.key { font-size: 1.05rem; letter-spacing: .08em; background: var(--line-2); padding: 10px; border-radius: 10px; word-break: break-all; }
.code-input { font: 600 1.4rem/1 var(--mono); letter-spacing: .3em; text-align: center; }
.recovery { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.recovery li { background: var(--line-2); border-radius: 9px; padding: 8px 10px; text-align: center; font-size: 1rem; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #F20D42; color: #fff; font-size: .72rem; font-weight: 700; margin-left: 4px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi-accent { border-color: #C9DBFF; background: #F5F9FF; }
.kpi-accent .kpi-value { color: var(--accent-ink); }
.ws { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.ws-requested { background: var(--warn-bg); color: var(--warn-ink); }
.ws-processing { background: var(--wait-bg); color: var(--accent-ink); }
.ws-paid { background: var(--ok-bg); color: var(--pos); }
.ws-rejected, .ws-cancelled, .ws-failed { background: var(--ko-bg); color: var(--neg); }
.ws-pending { background: var(--warn-bg); color: var(--warn-ink); }
.ws-approved { background: var(--ok-bg); color: var(--pos); }
.ws-archived { background: var(--line-2); color: var(--muted); }
.decision { display: grid; gap: 14px; }
.decision form { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.decision h3 { margin: 0; font-size: .95rem; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row > label { flex: 1 1 160px; }
.form-row .code-input { font-size: 1.1rem; letter-spacing: .2em; max-width: 170px; }
.method-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
[data-method-panel][hidden] { display: none !important; }
.hint-box { background: #F5F9FF; border: 1px solid #C9DBFF; border-radius: 11px; padding: 10px 12px; font-size: .88rem; color: #1B3B7A; }

.pad-x { padding: 0 18px 10px; }
.feed-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; }
