/* Sarbacan /app — neutral styles of sprint 02 (no brand yet: the art direction comes later).
   No external font, no inline style: everything the pages need is here (CSP style-src 'self'). */

:root {
    --ink: #18181b;
    --ink-2: #3f3f46;
    --muted: #52525b;
    --line: #d4d4d8;
    --line-2: #e4e4e7;
    --bg: #f4f4f5;
    --card: #ffffff;
    --action: #1d4ed8;
    --action-dark: #1e3a8a;
    --warn-bg: #fef3c7;
    --warn-line: #b45309;
    --warn-ink: #78350f;
    --alert-bg: #fee2e2;
    --alert-line: #b91c1c;
    --alert-ink: #7f1d1d;
    --ok-bg: #dcfce7;
    --ok-line: #15803d;
    --ok-ink: #14532d;
    --radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--action); }
a:hover { color: var(--action-dark); }
h1 { margin: 0; font-size: 1.75rem; font-weight: 600; line-height: 1.25; }
h2 { margin: 0 0 12px; font-size: 1.0625rem; font-weight: 600; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 8px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-left, .topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.topbar-right a, .link-button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; font-size: 0.875rem; font-weight: 500; }
.brand { font-size: 1.125rem; font-weight: 700; color: var(--ink); text-decoration: none; margin-right: 8px; }
.brand-large { font-size: 1.375rem; margin: 0 0 24px; }
.crumb { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.crumb:hover { background: var(--bg); color: var(--ink); }
.crumb-sep { color: var(--muted); }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.link-button { border: 0; background: none; color: var(--action); font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: underline; }
.link-button:hover { color: var(--action-dark); }

/* Shell */
.shell { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }
.sidebar { flex: 1 1 200px; max-width: 240px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.nav-link { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--line-2); font-weight: 600; }
.nav-soon { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 0 12px; font-size: 0.875rem; color: var(--muted); }
.nav-title { margin: 8px 12px 4px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 0.75rem; font-weight: 600; color: var(--muted); }
@media (max-width: 720px) {
    .sidebar { max-width: none; flex-direction: row; flex-wrap: wrap; }
    .nav-soon, .nav-title { display: none; }
}

/* Blocks */
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head p { margin: 0; }
.panel { padding: 20px 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.notice { margin: 0; padding: 12px 16px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); font-size: 0.9375rem; }
.notice-error { background: var(--alert-bg); border-color: var(--alert-line); color: var(--alert-ink); }
.badge { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.75rem; font-weight: 600; color: var(--ink-2); vertical-align: middle; }
.badge-muted { color: var(--muted); }
.badge-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.plain-list { margin: 0; padding-left: 20px; }
.role-legend { margin: 16px 0 0; padding-left: 20px; font-size: 0.875rem; color: var(--ink-2); }

/* Cards (organizations, sites) */
.card-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-link { color: var(--ink); text-decoration: none; }
.card-link:hover { border-color: var(--action); color: var(--ink); }
.card-link:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
.card-title { font-size: 1.0625rem; font-weight: 600; }
.card-meta { font-size: 0.875rem; color: var(--muted); }
.card-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 0.875rem; color: var(--ink-2); }

/* Health */
.health { padding: 16px 20px; border-radius: var(--radius); border: 2px solid var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.health h2 { margin-bottom: 6px; }
.health p { margin: 0; }
.health-warning { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.health-alert { border-color: var(--alert-line); background: var(--alert-bg); color: var(--alert-ink); }
.health-items { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.health-item { display: flex; flex-direction: column; gap: 2px; padding-left: 12px; border-left: 4px solid var(--warn-line); }
.health-item-alert { border-left-color: var(--alert-line); }
.health-item .hint { font-size: 0.8125rem; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi-label { font-size: 0.8125rem; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 1.875rem; font-weight: 700; line-height: 1.1; }
.kpi-hint { font-size: 0.8125rem; color: var(--ink-2); }

/* Weekly chart (SVG: sizes are attributes, colours are here). On a phone it scrolls rather than shrinking its labels. */
.chart-wrap { overflow-x: auto; direction: rtl; } /* starts scrolled on the latest weeks */
.chart { display: block; direction: ltr; width: 100%; min-width: 480px; max-width: 640px; height: auto; margin-right: auto; } /* left-aligned on wide screens despite the rtl wrapper */
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-bar { fill: #71717a; }
.chart-bar-current { fill: #a1a1aa; }
.chart-value { font-size: 13px; font-weight: 700; fill: var(--ink); }
.chart-label { font-size: 12px; fill: var(--muted); }

/* Funnel */
.funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.funnel li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "rate rate"; align-items: baseline; gap: 2px 16px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.funnel li:last-child { border-bottom: 0; }
.funnel-label { grid-area: label; font-weight: 500; }
.funnel-value { grid-area: value; font-size: 1.5rem; font-weight: 700; text-align: right; }
.funnel-rate { grid-area: rate; font-size: 0.875rem; color: var(--ink-2); }
@media (min-width: 640px) {
    .funnel li { grid-template-columns: minmax(160px, 1fr) minmax(80px, auto) minmax(140px, 1fr); grid-template-areas: "label value rate"; gap: 8px 16px; }
}

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
thead th { color: var(--ink-2); font-weight: 600; border-bottom-color: var(--line); white-space: nowrap; }
tbody th { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-flag { background: var(--warn-bg); }
td.actions { white-space: nowrap; }
td.actions .inline-form + .inline-form { margin-left: 4px; }

/* Help */
.help summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.help dl { margin: 12px 0 0; display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 8px 24px; font-size: 0.875rem; }
.help dt { font-weight: 600; }
.help dd { margin: 0; color: var(--ink-2); }
@media (max-width: 560px) { .help dl { grid-template-columns: 1fr; } }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; margin: 0 0 16px; }
.panel .form:not(.form-inline) { max-width: 560px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-inline .field { flex: 1 1 220px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.875rem; font-weight: 600; }
input[type="email"], input[type="text"], input[type="password"], select {
    min-height: 44px; padding: 0 12px; border: 1px solid #a1a1aa; border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; font-size: 1rem; width: 100%;
}
select { width: auto; min-width: 150px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--alert-line); }
.field-hint { margin: 0; font-size: 0.8125rem; color: var(--muted); }
.field-error { margin: 0; font-size: 0.875rem; font-weight: 500; color: var(--alert-line); }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 1px solid #a1a1aa; border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; font-size: 0.9375rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--bg); color: var(--ink); }
.button-primary { background: var(--action); border-color: var(--action); color: #ffffff; }
.button-primary:hover { background: var(--action-dark); border-color: var(--action-dark); color: #ffffff; }
.button-small { min-height: 36px; padding: 0 12px; font-size: 0.8125rem; }
.button-danger { color: var(--alert-line); border-color: var(--alert-line); }
.button-danger:hover { background: var(--alert-bg); color: var(--alert-ink); }
.button-block { width: 100%; }

/* Sign-in pages */
.guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.guest-card { width: 100%; max-width: 420px; padding: 32px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.guest-card h1 { margin-bottom: 16px; font-size: 1.5rem; }
.guest-card .notice { margin-bottom: 16px; }
.guest-link { margin: 8px 0 0; font-size: 0.9375rem; text-align: center; }

/* Médiathèque (sprint 03) */
.back { margin: 0; font-size: 0.9375rem; }
.back a { display: inline-flex; align-items: center; min-height: 44px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 0; }
.empty { margin: 0; color: var(--ink-2); }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
input[type="file"] { min-height: 44px; padding: 8px; border: 1px dashed #a1a1aa; border-radius: 6px; background: var(--bg); font: inherit; font-size: 0.9375rem; width: 100%; }
input[type="file"]:hover { border-color: var(--action); }
.media-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.media-item { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.media-item:last-child { border-bottom: 0; }
.media-type { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border: 1px solid var(--alert-line); border-radius: 6px; background: var(--alert-bg); color: var(--alert-ink); font-size: 0.75rem; font-weight: 700; }
.media-type-image { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.media-body { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.media-title { font-weight: 600; overflow-wrap: anywhere; }
.media-meta { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.media-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; }
.media-preview { display: block; max-width: 100%; height: auto; max-height: 480px; object-fit: contain; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); }
.trash summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.trash summary + p { margin-top: 8px; }
td.wrap { overflow-wrap: anywhere; min-width: 160px; }
@media (max-width: 560px) {
    .media-actions { width: 100%; padding-left: 68px; }
}

/* Administration (sprint 03) */
.badge-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.site-sender { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; border-top: 1px solid var(--line-2); }
.site-sender:first-of-type { border-top: 0; }
.site-sender-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.site-sender .form { margin: 0; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; }
.checkbox input { width: 20px; height: 20px; margin: 0; }

/* Sites, abonnés, formulaires (sprint 03b) */
.wrap { overflow-wrap: anywhere; }
.kpi-link { color: var(--ink); text-decoration: none; }
.kpi-link:hover { border-color: var(--action); color: var(--ink); }
.kpi-link:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
.filters { margin-bottom: 16px; }
.form-inline .field-narrow { flex: 0 1 180px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.status-active { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.status-pending { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.status-unsubscribed { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { display: flex; flex-direction: column; gap: 2px; padding-left: 14px; border-left: 3px solid var(--line); }
.checklist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.checklist li { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 6px; border: 1px solid var(--line); }
.checklist .check-ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.checklist .check-todo { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.snippet { margin: 8px 0 12px; padding: 12px 14px; overflow-x: auto; background: var(--ink); color: #f4f4f5; border-radius: 6px; font-size: 0.8125rem; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.snippet code { background: none; padding: 0; color: inherit; font-size: inherit; }
.form-card .panel-head { justify-content: flex-start; }
.form-preview { margin: 12px 0 8px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 6px; background: var(--bg); }
.form-preview p { margin: 0 0 6px; }
.form-preview-title { font-weight: 700; }
.subhead { margin: 16px 0 8px; font-size: 0.9375rem; font-weight: 600; }
.display-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.display-card.is-off { opacity: 0.75; }
.display-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.facts { margin: 0; display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 4px 16px; font-size: 0.875rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }
.kpis-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpis-compact .kpi { padding: 12px 14px; }
.kpis-compact .kpi-value { font-size: 1.5rem; }
.col-email { min-width: 13rem; }
