/* Créapilote : l'application. Couleurs et polices de la marque. */
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage.woff") format("woff"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("/fonts/publicsans.woff") format("woff"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plexmono-500.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plexmono-600.woff") format("woff"); font-weight: 600; font-display: swap; }

:root {
  --brand: #1C6A44;
  --brand-hover: #155236;
  --lime: #C8F169;
  --ink: #13201A;
  --bg: #EEF2EC;
  --card: #FFFFFF;
  --soft: #F5F8F4;
  --muted: #55655B;
  --line: #D8E0D5;
  --accent: #1C6A44;
  --accent-soft: #E2F2E7;
  --late: #B42318;
  --late-bg: #FDECEA;
  --wait: #7A5200;
  --wait-bg: #FFF3D1;
  --gain: #1C6A44;
  --loss: #B42318;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(19, 32, 26, 0.05), 0 6px 18px rgba(19, 32, 26, 0.06);
  --tabbar-h: 66px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E7EFE9;
    --bg: #0E1712;
    --card: #15211A;
    --soft: #1A2920;
    --muted: #9BB0A3;
    --line: #2A3B31;
    --accent: #8ED6A8;
    --accent-soft: #1D3A29;
    --late: #FF9D90;
    --late-bg: #3B1F1B;
    --wait: #F1C96E;
    --wait-bg: #382E14;
    --gain: #8ED6A8;
    --loss: #FF9D90;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.5; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.num { font-variant-numeric: tabular-nums; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; border-radius: 6px; }

/* ---------- Structure ---------- */
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand-accent { color: var(--accent); }
.plan-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.85rem; text-decoration: none; white-space: nowrap; }
.plan-pill.warn { background: var(--wait-bg); color: var(--wait); }
.main { padding: 18px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); max-width: 1040px; margin: 0 auto; }
.sidebar { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar svg, .sidebar svg { width: 24px; height: 24px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .topbar { display: none; }
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--card); }
  .sidebar .brand { padding: 4px 8px 18px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 600; }
  .sidebar nav a:hover { background: var(--soft); }
  .sidebar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .sidebar .side-foot { margin-top: auto; display: grid; gap: 10px; padding: 8px; }
  .main { padding: 32px 36px 64px; }
}

/* ---------- Éléments ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.stack { display: grid; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; background: var(--brand); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-hover); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); }
.btn-lime { background: var(--lime); color: #13201A; }
.btn-lime:hover { background: #b7e152; }
.btn-danger { background: transparent; color: var(--late); border-color: color-mix(in srgb, var(--late) 40%, transparent); }
.btn-danger:hover { background: var(--late-bg); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 0.92rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-family: var(--font-mono); font-weight: 600; font-size: 0.78rem; white-space: nowrap; background: var(--soft); color: var(--muted); }
.chip.late { background: var(--late-bg); color: var(--late); }
.chip.pending { background: var(--wait-bg); color: var(--wait); }
.chip.published { background: var(--accent-soft); color: var(--accent); }
.chip.fiable { background: var(--accent-soft); color: var(--accent); }
.chip.a-surveiller { background: var(--late-bg); color: var(--late); }
.chip.nouveau { background: var(--soft); color: var(--muted); }

.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; margin-bottom: 18px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); }
.banner.warn { background: var(--wait-bg); }
.banner strong { font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi dt { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.kpi dd { margin: 4px 0 0; font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi.wide { grid-column: 1 / -1; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi.wide { grid-column: auto; } }

.list { display: grid; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-title { font-weight: 700; overflow-wrap: anywhere; }
.item-title a { color: inherit; text-decoration: none; }
.item-sub { color: var(--muted); font-size: 0.92rem; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
a.item { color: inherit; text-decoration: none; }
a.item:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.mini-stats div { background: var(--soft); border-radius: 12px; padding: 8px 10px; }
.mini-stats dt { font-size: 0.76rem; color: var(--muted); font-weight: 600; }
.mini-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; text-transform: uppercase; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg a { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 0.92rem; cursor: pointer; text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.empty { text-align: center; padding: 28px 18px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); display: grid; gap: 10px; justify-items: center; }
.empty p { max-width: 42ch; }

.steps { counter-reset: s; display: grid; gap: 8px; list-style: none; padding: 0; margin: 12px 0 0; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--soft); }
.steps li::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-weight: 800; flex: none; }
.steps li.done::before { content: "✓"; background: var(--brand); color: #fff; border-color: var(--brand); }
.steps li.done span { text-decoration: line-through; color: var(--muted); }
.steps a { margin-left: auto; font-weight: 700; white-space: nowrap; }

.ticket { display: grid; gap: 0; margin: 0; }
.ticket div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.ticket div:last-child { border-bottom: 0; }
.ticket dt { color: var(--muted); }
.ticket dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.ticket .total dt { color: var(--ink); font-weight: 700; }
.ticket .total dd { font-family: var(--font-display); font-size: 1.3rem; }
.verdict { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--soft); }

.brief { white-space: pre-wrap; font-size: 0.97rem; line-height: 1.55; background: var(--soft); border-radius: 12px; padding: 14px; margin: 0; font-family: var(--font-body); overflow-wrap: anywhere; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; }
.hint { color: var(--muted); font-size: 0.86rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1rem;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--lime) 70%, transparent); outline-offset: 0; border-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.two { display: grid; gap: 14px; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }
.form-error { color: var(--late); background: var(--late-bg); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 0.93rem; }
.form-error:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.danger-zone { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Fenêtres ---------- */
dialog.sheet { width: min(560px, 100%); max-height: min(92vh, 900px); margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--ink); box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2); }
dialog.sheet::backdrop { background: rgba(10, 20, 14, 0.45); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 22px; } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; background: var(--card); border-bottom: 1px solid var(--line); z-index: 1; }
.sheet-body { padding: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 100; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); }
.toast.error { background: var(--late); color: #fff; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 48px; }
.auth-card { width: min(440px, 100%); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .lede { color: var(--muted); margin-bottom: 20px; }
.auth-foot { margin-top: 18px; text-align: center; display: grid; gap: 8px; }

.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.plain { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.plain-card { max-width: 440px; background: var(--card); border-radius: var(--radius); padding: 28px; display: grid; gap: 14px; }
.more-list { display: grid; gap: 8px; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; text-align: left; cursor: pointer; }
.more-list svg { width: 22px; height: 22px; color: var(--accent); }
.legal-links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.88rem; }
.legal-links a { color: var(--muted); }
[hidden] { display: none !important; }
.paywall { max-width: 560px; }
.brief-card .item-top { align-items: center; }
details.archived { margin-top: 18px; }
details.archived summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 6px 0; }
details.archived .list { margin-top: 10px; }
.notes { white-space: pre-wrap; }

/* Photos des produits */
.thumb { width: 52px; height: 52px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 22px; height: 22px; }
.thumb.sm { width: 40px; height: 40px; border-radius: 10px; }
.thumb.sm svg { width: 18px; height: 18px; }
.thumb.lg { width: 88px; height: 88px; border-radius: 16px; }
.thumb.xl { width: 112px; height: 112px; border-radius: 18px; }
.thumb.lg svg, .thumb.xl svg { width: 32px; height: 32px; }
.photo-pick { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.file-btn { cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.head-with-photo { display: flex; align-items: center; gap: 16px; min-width: 0; }
