:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e0d6;
  --soft: #f5efe7;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-soft: #f4e4d8;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 8px 24px rgba(28, 25, 23, .06);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --panel: #201c19;
    --ink: #f5efe7;
    --muted: #a8a29e;
    --line: #37302b;
    --soft: #2a2420;
    --accent: #e07a4c;
    --accent-ink: #1c1917;
    --accent-soft: #3d2a20;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #facc15;
    --warn-soft: #3a3110;
    --bad: #f87171;
    --bad-soft: #3b1515;
    --info: #93c5fd;
    --info-soft: #172a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 13px; }
[hidden] { display: none !important; }

/* --- Authentification --- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: var(--bg); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { font: 600 40px/1.15 var(--serif); margin: 0 0 16px; max-width: 14ch; }
.auth-side p { color: #d6d3d1; max-width: 42ch; margin: 0; }
.auth-side ul { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; color: #e7e5e4; }
.auth-side li::before { content: "—"; color: var(--accent); margin-right: 10px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font: 600 28px/1.2 var(--serif); margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); margin: 0 0 28px; }
.switch { margin-top: 20px; color: var(--muted); font-size: 14px; text-align: center; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; }

.logo { font: 700 20px var(--serif); letter-spacing: .01em; display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font: 700 15px var(--serif); }
.auth-side .logo { color: var(--bg); }

/* --- Formulaires --- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--accent); color: var(--accent-ink); transition: filter .15s, background .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.block { width: 100%; padding: 12px 16px; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); filter: none; }
.btn.danger { background: var(--panel); color: var(--bad); border-color: var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.alert { border-radius: 10px; padding: 11px 14px; font-size: 14px; margin-bottom: 16px; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* --- Application --- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { padding: 0 10px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.side-foot .who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font: 600 22px var(--serif); margin: 0; }
.shop-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.content { padding: 28px 32px 64px; max-width: 1120px; }

.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.4fr 1fr; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 4px; }
.card .desc { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.card + .card { margin-top: 16px; }
.section-gap { margin-top: 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font: 600 30px/1.2 var(--serif); margin-top: 6px; }
.kpi .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.meter { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; margin-top: 12px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); width: 0; transition: width .4s; }
.meter.high > i { background: var(--warn); }
.meter.full > i { background: var(--bad); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.chart .bar i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 3px; opacity: .85; }
.chart .bar i.zero { background: var(--line); opacity: 1; }
.chart .bar span { font-size: 10.5px; color: var(--muted); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 12px; margin-top: 1px; }
.steps li.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.steps strong { display: block; font-size: 14px; }
.steps span { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.succeeded { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.processing { background: var(--info-soft); color: var(--info); }
.badge.queued { background: var(--warn-soft); color: var(--warn); }
.badge.plan { background: var(--accent-soft); color: var(--accent); }
.badge.plan::before { display: none; }

.keybox { display: flex; gap: 8px; align-items: center; }
.keybox code { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre.code { margin: 0; padding: 14px 16px; border-radius: 12px; background: #1c1917; color: #f5efe7; overflow-x: auto; font: 13px/1.6 var(--mono); }
.code-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.code-head span { font-size: 13px; font-weight: 600; }

.origins { display: grid; gap: 8px; margin-bottom: 12px; }
.origin { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--mono); font-size: 13px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.plan { display: flex; flex-direction: column; }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan h3 { font: 600 20px var(--serif); margin: 0; }
.plan .price { font: 600 32px var(--serif); margin: 12px 0 2px; }
.plan .price small { font: 400 14px var(--sans); color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; display: grid; gap: 8px; font-size: 14px; flex: 1; }
.plan li::before { content: "✓"; color: var(--accent); font-weight: 700; margin-right: 8px; }

.modal-back { position: fixed; inset: 0; background: rgba(28, 25, 23, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 16px; padding: 24px; width: 100%; max-width: 520px; box-shadow: 0 24px 64px rgba(0, 0, 0, .3); }
.modal h2 { font: 600 22px var(--serif); margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mt { margin-top: 12px; }
.loading { padding: 64px; text-align: center; color: var(--muted); }

@media (max-width: 960px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .plans { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; gap: 12px; }
  .sidebar .logo span:last-child, .side-foot { display: none; }
  .nav { grid-auto-flow: column; }
  .nav a span { display: none; }
  .topbar { padding: 14px 16px; position: static; }
  .content { padding: 20px 16px 48px; }
  .grid.kpis { grid-template-columns: 1fr 1fr; }
}
.forgot { margin: -6px 0 16px; text-align: right; font-size: 13px; }
.alert.row-between { display: flex; }
.periods { display: grid; gap: 8px; }
.period { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.period:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.period input { accent-color: var(--accent); }
.period > span:nth-child(2) { flex: 1; }
.period-price { font-weight: 600; }
.plan-actions { display: grid; gap: 8px; }
.small { font-size: 12px; }

/* --- Articles et liens d'essayage --- */
.btn.wa { background: #0f7a5c; color: #fff; }
a.btn { text-decoration: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; min-height: 150px; margin-bottom: 16px; padding: 16px; border: 2px dashed var(--line); border-radius: 14px; background: var(--soft); color: var(--muted); font-size: 13.5px; cursor: pointer; text-align: center; }
.photo-pick strong { color: var(--ink); font-size: 15px; }
.photo-pick.filled { border-style: solid; background: var(--panel); padding: 10px; }
.photo-pick img { max-height: 240px; max-width: 100%; border-radius: 10px; object-fit: contain; }
.photo-pick.filled span { color: var(--accent); font-weight: 600; margin-top: 6px; }
.articles { display: grid; gap: 12px; }
.article { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.article.paused { opacity: .75; }
.article-thumb { width: 84px; height: 112px; border-radius: 10px; object-fit: cover; background: var(--soft); flex: none; }
.article-main { min-width: 0; flex: 1; display: grid; gap: 6px; align-content: start; }
.article-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.article-title strong { overflow-wrap: anywhere; }
.article-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.article-stats strong { color: var(--ink); }
.article-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.plans { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.nav a .short { display: none; }
.modal .actions { flex-wrap: wrap; }

@media (max-width: 760px) {
  /* Sur téléphone, la navigation devient une barre d'onglets en bas d'écran, comme une application. */
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; background: var(--panel); border-bottom: 0; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); overflow: visible; }
  .sidebar .logo { display: none; }
  .nav { display: flex; width: 100%; }
  .nav a { flex: 1; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; text-align: center; }
  .nav a .long { display: none; }
  .nav a .short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav svg { width: 20px; height: 20px; }
  .content { padding-bottom: 104px; }
  .toast { bottom: 84px; max-width: calc(100vw - 32px); text-align: center; }
  .inline-form { flex-wrap: wrap; }
  .keybox { flex-wrap: wrap; }
  .keybox code { flex-basis: 100%; }
  .row-between { flex-wrap: wrap; }
  .article-thumb { width: 72px; height: 96px; }
  .btn.small { padding: 8px 12px; }
}
