:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-hover: #f7f8fa;
  --border: #e3e8ee;
  --border-strong: #d5dbe1;
  --text: #1a1f36;
  --text-2: #414552;
  --muted: #687385;
  --faint: #8792a2;
  --accent: #635bff;
  --accent-hover: #5851ea;
  --accent-soft: #f2f1ff;
  --green: #05690d; --green-bg: #d7f7c2;
  --red: #b3093c; --red-bg: #ffe7f2;
  --amber: #a82c00; --amber-bg: #fcedb9;
  --blue: #0055bc; --blue-bg: #cff5f6;
  --grey: #545969; --grey-bg: #ebeef1;
  --radius: 8px;
  --shadow: 0 0 0 1px rgba(64,68,82,.08), 0 2px 5px rgba(64,68,82,.08);
  --shadow-lg: 0 0 0 1px rgba(64,68,82,.06), 0 15px 35px rgba(48,49,61,.12), 0 5px 15px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/20px var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ── Boutons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 6px; border: 0;
  background: #fff; box-shadow: var(--shadow); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--text-2); }
.btn:hover { color: var(--text); background: var(--bg-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.12), 0 0 0 1px var(--accent); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--red); }
.btn-ghost { box-shadow: none; background: transparent; }
.btn-ghost:hover { background: var(--grey-bg); }
.icon-btn { width: 28px; padding: 0; justify-content: center; }

/* ── Champs ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 500; font-size: 13px; color: var(--text-2); }
.input { height: 32px; padding: 0 10px; border-radius: 6px; border: 0; box-shadow: var(--shadow); background: #fff; outline: none; width: 100%; }
.input:focus { box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px rgba(99,91,255,.18); }
.hint { font-size: 12px; color: var(--muted); }

/* ── En-tête ── */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 32px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; flex: none; }
.topbar .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on { color: var(--green); }
.live.on .dot { background: #1ea672; box-shadow: 0 0 0 0 rgba(30,166,114,.5); animation: pulse 2s infinite; }
.live.off .dot { background: #e5a500; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30,166,114,.45); } 70% { box-shadow: 0 0 0 7px rgba(30,166,114,0); } 100% { box-shadow: 0 0 0 0 rgba(30,166,114,0); } }
.user { color: var(--muted); font-size: 13px; }
.demo-banner { background: var(--amber-bg); color: var(--amber); text-align: center; font-size: 12px; font-weight: 500; padding: 4px; }

/* ── Page ── */
main { max-width: 1440px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { font-size: 24px; line-height: 32px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
.segmented { display: inline-flex; padding: 2px; background: var(--grey-bg); border-radius: 7px; }
.segmented button { border: 0; background: transparent; height: 26px; padding: 0 12px; border-radius: 5px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ── KPI ── */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 28px; }
.kpi { padding: 16px 20px; border-left: 1px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 22px; line-height: 30px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .bullet { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ── Comptes ── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head .totals { font-size: 13px; color: var(--muted); }
.section-head .totals b { color: var(--text); font-weight: 600; }
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 32px; }
.acc { text-align: left; border: 0; background: #fff; box-shadow: var(--shadow); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: box-shadow .15s; min-width: 0; }
.acc:hover { box-shadow: var(--shadow-lg); }
.acc.selected { box-shadow: 0 0 0 2px var(--accent); }
.acc-top { display: flex; align-items: center; gap: 8px; }
.acc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.acc-bal { font-size: 18px; line-height: 26px; font-weight: 600; margin-top: 8px; letter-spacing: -.01em; }
.acc-meta { font-size: 12px; line-height: 18px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-err { font-size: 12px; color: var(--red); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.sdot.ok { background: #1ea672; } .sdot.error { background: #df1b41; } .sdot.paused { background: var(--faint); }
.sdot.pending, .sdot.late { background: #e5a500; }
.acc-add { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--accent); font-weight: 500; box-shadow: none; border: 1px dashed var(--border-strong); min-height: 96px; }
.acc-add:hover { box-shadow: none; background: var(--accent-soft); }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.tag-test { background: var(--amber-bg); color: var(--amber); }
.tag-late { background: var(--amber-bg); color: var(--amber); margin-left: 6px; cursor: help; }
.nowrap { white-space: nowrap; }
.tag-live { background: var(--grey-bg); color: var(--grey); }
.tag-warn { background: var(--red-bg); color: var(--red); }

/* ── Barre d'outils / onglets ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.tabs { display: flex; gap: 20px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 0 9px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-size: 12px; color: var(--faint); font-weight: 500; }
.tab.active .count { color: var(--accent); }
.search { width: 280px; height: 30px; margin-bottom: 6px; padding-left: 30px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23687385' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center; }

/* ── Tableau ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 4px; }
tbody tr { cursor: pointer; transition: background-color .6s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.flash { background: #efeeff; transition: none; }
td.amount { font-weight: 600; text-align: right; width: 1%; }
th.amount { text-align: right; }
td.amount .cur { color: var(--faint); font-weight: 500; font-size: 12px; margin-left: 6px; }
.client-email { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.client-name { font-size: 12px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.reason { color: var(--text-2); max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.card-cell { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.brand-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 20px; padding: 0 4px; border-radius: 4px; border: 1px solid var(--border); font-size: 10px; font-weight: 700; letter-spacing: .03em; color: var(--text-2); background: #fff; }
.date { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 56px 0; }
.more { display: flex; justify-content: center; padding: 16px; }

/* ── Pastilles de statut ── */
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::after { content: ""; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.grey { background: var(--grey-bg); color: var(--grey); }
.pill .ic { font-size: 11px; line-height: 1; }

/* ── Tiroir détail ── */
.overlay { position: fixed; inset: 0; background: rgba(26,31,54,.24); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .15s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: #fff; z-index: 50; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.drawer-head .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-amount { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; display: flex; align-items: center; gap: 12px; }
.drawer-body { padding: 8px 24px 32px; overflow-y: auto; flex: 1; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 12px 0 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.drawer h3 { font-size: 14px; font-weight: 600; margin: 24px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tdot { width: 9px; height: 9px; border-radius: 50%; margin: 5px 0 0 3px; background: var(--faint); }
.timeline .tdot.succeeded { background: #1ea672; } .timeline .tdot.failed { background: #df1b41; } .timeline .tdot.pending { background: #e5a500; }
.timeline .t-title { font-weight: 500; }
.timeline .t-sub { font-size: 12px; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-top: 12px; }
.alert.red { background: var(--red-bg); color: var(--red); }
.alert.amber { background: var(--amber-bg); color: var(--amber); }
.alert.green { background: var(--green-bg); color: var(--green); }

/* ── Modale comptes ── */
.modal { position: fixed; z-index: 60; top: 64px; left: 50%; transform: translate(-50%, 8px); width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 96px);
  background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; }
.acc-list { list-style: none; margin: 0; padding: 0; }
.acc-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.acc-list .info { flex: 1; min-width: 0; }
.acc-list .title { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.acc-list .sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-list .actions { display: flex; gap: 6px; flex: none; }
.acc-list .inline-form { display: flex; gap: 6px; margin-top: 8px; }
.add-form { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; align-items: end; margin-top: 20px; padding: 16px; background: var(--bg-subtle); border-radius: var(--radius); }
.form-msg { margin-top: 10px; }

/* ── Toast ── */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: #fff; padding: 9px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow-lg); }
.toast.error { background: #df1b41; }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background:
  radial-gradient(1200px 600px at 10% -10%, #ece9ff 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e3f4ff 0, transparent 60%), var(--bg-subtle); }
.login-card { width: 380px; max-width: calc(100vw - 32px); background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 32px; }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.login-card .btn-primary { height: 36px; justify-content: center; font-size: 14px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi:nth-child(4) { border-left: 0; } .kpi:nth-child(n+4) { border-top: 1px solid var(--border); } }
@media (max-width: 720px) {
  main { padding: 20px 16px 48px; } .topbar { padding: 0 16px; } .user { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; } .kpi { border-left: 0; border-top: 1px solid var(--border); } .kpi:first-child, .kpi:nth-child(2) { border-top: 0; }
  .search { width: 100%; } .toolbar { flex-direction: column; align-items: stretch; }
  .add-form { grid-template-columns: 1fr; }
}

.bullet.green { background: #1ea672; } .bullet.red { background: #df1b41; } .bullet.amber { background: #e5a500; }
.btn-tall { height: 32px; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt24 { margin-top: 24px; }

.input::placeholder { color: var(--faint); }

/* ── Profil ── */
.modal-sm { width: min(480px, calc(100vw - 32px)); }
.user { font-weight: 500; }
.sub-title { font-size: 14px; font-weight: 600; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#pw-msg .alert { margin-top: 0; }

/* ── Navigation ── */
.nav { display: flex; gap: 4px; margin-left: 24px; }
.nav a { color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--text); background: var(--bg-hover); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

/* ── Bot Telegram ── */
.head-actions { display: flex; align-items: center; gap: 12px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.setting-label { font-weight: 600; margin-bottom: 8px; }
.setting-value { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.cap-input { max-width: 120px; flex: none !important; text-align: right; }
.mb16 { margin-bottom: 16px; } .mt32 { margin-top: 32px; }
.empty.small { padding: 24px 0; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
tbody tr.static { cursor: default; }
tbody tr.static:hover { background: transparent; }
.bot-table td { vertical-align: top; padding-top: 14px; padding-bottom: 14px; }
.bot-table .acc-name { font-weight: 600; }
.link-cell { display: flex; align-items: center; gap: 8px; }
.link-url { color: var(--text-2); font-size: 12px; }
.link-form { min-width: 320px; }
.switch { position: relative; width: 34px; height: 20px; border-radius: 10px; border: 0; background: var(--border-strong); cursor: pointer; padding: 0; transition: background .15s; }
.switch span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on span { transform: translateX(14px); }
.gauge-cell { min-width: 200px; }
.gauge { display: flex; height: 6px; border-radius: 3px; background: var(--grey-bg); overflow: hidden; margin-top: 6px; }
.gauge .g-paid { background: #1ea672; }
.gauge .g-prov { background: #9bd9bd; }
.gauge.full .g-paid { background: #e5a500; }
.gauge-text { font-size: 12px; color: var(--muted); margin-top: 6px; }
.gauge-text b { color: var(--text); font-weight: 600; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } .nav { margin-left: 8px; } }

.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; vertical-align: 1px; }
.alert.row-between { display: flex; }
.red-text { color: var(--red); font-weight: 500; }
.small { font-size: 12px; font-weight: 400; }

/* Encaissements par jour (onglet Bot) */
.mb8 { margin-bottom: 8px; }
.section-head:has(.segmented) { align-items: center; }
.hist-table { width: auto; min-width: 640px; }
.hist-table .hday { min-width: 180px; }
.hist-table th, .hist-table td { padding: 8px 16px; }
.hist-table th.amount, .hist-table td.amount { min-width: 96px; }
.hist-table tbody td, .hist-table .hday { font-weight: 400; }
.hist-table .htoday td { background: var(--bg-subtle); }
.hist-table .hz { color: var(--faint); }
.hist-table .hempty td { color: var(--faint); }
.hist-table .hfull { color: var(--amber); }
.hfull-legend { color: var(--amber); font-weight: 600; }
.hist-table .htot { border-left: 1px solid var(--border); }
.hist-table tbody .hsum td { font-weight: 600; background: var(--bg-subtle); border-bottom: 1px solid var(--border-strong); }

/* Logo */
.logo-edit { display: flex; align-items: center; gap: 20px; padding-top: 16px; }
.logo-preview { width: 72px; height: 72px; object-fit: contain; border-radius: 14px; border: 1px solid var(--border); padding: 6px; background: var(--bg-subtle); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.toast.warn { border-left: 3px solid var(--amber); }
