:root {
  --bg: #eef1f4; --surface: #fff; --ink: #13202b; --muted: #5b6b7a; --line: #d8dee4;
  --accent: #0b6e6e; --accent-ink: #fff; --warn: #b45309; --danger: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1317; --surface: #151d23; --ink: #e6edf2; --muted: #8a9aa8; --line: #26323b;
    --accent: #3cc4b4; --accent-ink: #06201d; --warn: #f0b429; --danger: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1317; --surface: #151d23; --ink: #e6edf2; --muted: #8a9aa8; --line: #26323b;
  --accent: #3cc4b4; --accent-ink: #06201d; --warn: #f0b429; --danger: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5;
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
.muted, .lede { color: var(--muted); }
button, input { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; padding: .35rem .7rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input { width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }

.auth { max-width: 24rem; margin: 12vh auto 0; padding: 0 1.25rem; }
.auth form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.auth label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.alert { padding: .7rem .9rem; border: 1px solid var(--danger); border-radius: 8px; color: var(--danger); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.topbar-end { display: flex; align-items: center; gap: .75rem; }
.topbar-end form { margin: 0; }
.who { color: var(--muted); font-size: .9rem; }
.page { max-width: 60rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.summary { margin-bottom: 2rem; }
.figure { font-size: clamp(2.4rem, 8vw, 4rem); font-weight: 700; letter-spacing: -.03em; margin: 0; font-variant-numeric: tabular-nums; }
.figure-label { margin: 0; color: var(--muted); }
.empty { padding: 2rem; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface); }

.subs { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.subs th, .subs td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
.subs th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.subs tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paused { opacity: .6; }
.tag { font-size: .75rem; padding: .1rem .45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.countdown { margin-left: .4rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.countdown.soon { color: var(--warn); font-weight: 700; }
@media (max-width: 40rem) { .subs th:nth-child(2), .subs td:nth-child(2), .subs th:nth-child(4), .subs td:nth-child(4) { display: none; } }
@media (prefers-reduced-motion: no-preference) { button { transition: filter .15s; } button:hover { filter: brightness(1.08); } }

/* ---- Étape 2 : abonnements ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .85rem; }
a { color: var(--accent); }
.btn, .btn-sm { display: inline-block; text-decoration: none; border-radius: 8px; font-weight: 600; }
.btn { padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink); }
.btn-sm { padding: .3rem .65rem; border: 1px solid var(--line); color: var(--ink); font-weight: 500; font-size: .85rem; background: transparent; }
button.sm { padding: .3rem .65rem; font-size: .85rem; }
button.danger { color: var(--danger); }
.summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 14rem; width: auto; }
select, textarea { padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 0; margin: 0; overflow: hidden; background: var(--surface); }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; width: 0; }
.seg span { display: block; padding: .5rem .85rem; cursor: pointer; font-size: .9rem; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--cat, var(--line)); border-radius: 12px; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.card header { display: flex; gap: .7rem; align-items: center; margin-bottom: .5rem; }
.card h3 { margin: 0; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.card p { margin: 0; }
.card.is-paused { opacity: .65; }
.price { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.due { margin-top: .6rem !important; display: flex; align-items: center; gap: .5rem; }
.avatar { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 10px; display: grid; place-items: center; font-weight: 700;
  background: color-mix(in srgb, var(--cat, var(--muted)) 18%, var(--surface)); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--cat, var(--muted)) 45%, var(--surface)); }
.avatar.sm { width: 1.75rem; height: 1.75rem; border-radius: 7px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; padding-top: .8rem; }
.actions form, .row-actions form { margin: 0; }
.countdown { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--muted) 14%, transparent); font-variant-numeric: tabular-nums; margin-left: 0; }
.countdown.soon { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); font-weight: 700; }

.table-wrap { overflow-x: auto; }
.subs th a { color: inherit; text-decoration: none; }
.subs th[aria-sort="ascending"] a::after { content: " ▲"; font-size: .7em; }
.subs th[aria-sort="descending"] a::after { content: " ▼"; font-size: .7em; }
.name-cell { display: inline-flex; align-items: center; gap: .6rem; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; align-items: center; }
.subs .countdown { margin-left: .4rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; max-width: 40rem; margin-top: 1.25rem; }
.form-grid label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
.custom-cycle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.custom-cycle[hidden] { display: none; }
.form-actions { display: flex; gap: .6rem; align-items: center; }
@media (max-width: 40rem) { .form-grid { grid-template-columns: 1fr; } }

.nowrap { white-space: nowrap; }
.toolbar select { flex: 0 1 auto; max-width: 11.5rem; font-size: .9rem; }
.row-cell { width: 1%; white-space: nowrap; }
@media (max-width: 40rem) {
  .toolbar select { flex: 1 1 8rem; max-width: none; }
  .subs th:nth-child(2), .subs td:nth-child(2), .subs th:nth-child(4), .subs td:nth-child(4) { display: none; }
}
.page { max-width: 72rem; }
.subs .btn-sm, .subs button.sm { padding: .25rem .5rem; font-size: .8rem; }
.subs th, .subs td { padding: .7rem .8rem; }
button.ghost { white-space: nowrap; }
@media (max-width: 30rem) { .who { display: none; } }
