/* MargePilot — feuille de style unique (design tokens hérités de la maquette) */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6;
  --series-1-track: #cde2fb;
  --series-2: #1baf7a;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { margin:0; padding:0; box-sizing:border-box; }
body { background:var(--page); color:var(--ink); font-size:14px; line-height:1.45; }
a { color:var(--accent); }

/* ---------- Barre supérieure ---------- */
.topbar { display:flex; align-items:center; gap:14px; background:var(--surface-1); border-bottom:1px solid var(--grid); padding:10px 24px; position:sticky; top:0; z-index:20; }
.logo { display:flex; align-items:center; gap:8px; font-weight:700; font-size:16px; }
.logo-mark { width:26px; height:26px; border-radius:7px; background:var(--accent); display:inline-flex; align-items:center; justify-content:center; }
.nav { display:flex; gap:4px; margin-left:18px; flex-wrap:wrap; }
.nav a { text-decoration:none; color:var(--ink-2); padding:7px 13px; border-radius:8px; font-weight:500; }
.nav a:hover { background:#f0efec; }
.nav a.active { background:#e8f0fb; color:#1c5cab; font-weight:600; }
.nav-link { text-decoration:none; color:var(--ink-2); padding:7px 13px; font-weight:500; }
.spacer { flex:1; }
.whoami { color:var(--muted); font-size:12.5px; }
.btn-primary { display:inline-block; background:var(--accent); color:#fff; border:none; font:inherit; font-weight:600; padding:9px 18px; border-radius:8px; cursor:pointer; text-decoration:none; }
.btn-primary:hover { background:#256abf; }
.btn-ghost { background:transparent; border:1px solid var(--border); color:var(--ink-2); font:inherit; font-weight:500; padding:7px 14px; border-radius:8px; cursor:pointer; text-decoration:none; display:inline-block; }
.btn-ghost:hover { background:#f0efec; }
.btn-danger { background:transparent; border:1px solid var(--critical); color:var(--critical); font:inherit; font-weight:500; padding:7px 14px; border-radius:8px; cursor:pointer; }

.banner { padding:9px 24px; font-size:13px; }
.banner.info { background:#e8f0fb; color:#1c5cab; }
.banner.lock { background:#f9dcdc; color:#a11f1f; }
.banner a { font-weight:600; }

main { max-width:1120px; margin:0 auto; padding:24px; }
h1.page-title { font-size:20px; font-weight:700; margin-bottom:2px; }
.page-sub { color:var(--ink-2); margin-bottom:20px; font-size:13px; }

/* ---------- Tuiles & cartes ---------- */
.tiles { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:22px; }
.tile { background:var(--surface-1); border:1px solid var(--border); border-radius:12px; padding:14px 16px; }
.tile .label { color:var(--ink-2); font-size:12.5px; margin-bottom:6px; }
.tile .value { font-size:26px; font-weight:600; letter-spacing:-0.01em; }
.tile .delta { font-size:12px; margin-top:4px; font-weight:600; }
.delta.up-good { color:var(--good-text); }
.delta.down-bad { color:var(--critical); }
.delta.neutral { color:var(--muted); font-weight:500; }
.card { background:var(--surface-1); border:1px solid var(--border); border-radius:12px; padding:18px; margin-bottom:20px; }
.card h2 { font-size:14.5px; font-weight:650; margin-bottom:2px; }
.card .card-sub { color:var(--muted); font-size:12px; margin-bottom:14px; }
.two-col { display:grid; grid-template-columns:1fr 340px; gap:20px; align-items:start; }

/* ---------- Tableaux ---------- */
table.chantiers { width:100%; border-collapse:collapse; }
table.chantiers th { text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:0.04em; color:var(--muted); font-weight:600; padding:8px 10px; border-bottom:1px solid var(--grid); }
table.chantiers td { padding:11px 10px; border-bottom:1px solid var(--grid); vertical-align:middle; }
table.chantiers td:first-child { min-width:190px; }
table.chantiers td:nth-child(2), table.chantiers td:nth-child(3) { white-space:nowrap; }
table.chantiers tr:last-child td { border-bottom:none; }
tr.row-link { cursor:pointer; }
tr.row-link:hover td { background:#f4f6f9; }
.ch-name { font-weight:600; }
.ch-name a { color:inherit; text-decoration:none; }
.ch-name a:hover { text-decoration:underline; }
.ch-client { color:var(--muted); font-size:12px; }
.num { font-variant-numeric:tabular-nums; text-align:right; }

table.dep { width:100%; border-collapse:collapse; font-size:13px; }
table.dep th { text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:0.04em; color:var(--muted); padding:6px 8px; border-bottom:1px solid var(--grid); }
table.dep td { padding:8px; border-bottom:1px solid var(--grid); }
table.dep tr:last-child td { border-bottom:none; }

/* ---------- Meter / badges / alertes ---------- */
.meter-wrap { display:flex; align-items:center; gap:8px; }
.meter { width:100px; height:8px; border-radius:4px; overflow:hidden; background:var(--series-1-track); flex:none; }
.meter.warn { background:#fdeccc; } .meter.crit { background:#f6d2d2; }
.meter > i { display:block; height:100%; background:var(--series-1); border-radius:0 4px 4px 0; }
.meter.warn > i { background:var(--warning); } .meter.crit > i { background:var(--critical); }
.meter-val { font-variant-numeric:tabular-nums; font-weight:600; min-width:52px; white-space:nowrap; }
.badge { display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:600; padding:3px 8px; border-radius:999px; white-space:nowrap; }
.badge.ok { background:#e2f4e2; color:#006300; }
.badge.derive { background:#fdeccc; color:#7a5200; }
.badge.crit { background:#f9dcdc; color:#a11f1f; }
.alert { display:flex; gap:10px; padding:10px 12px; border-bottom:1px solid var(--grid); border-left:3px solid transparent; }
.alert:last-child { border-bottom:none; }
.alert .ic { flex:none; }
.alert p { font-size:13px; color:var(--ink-2); }
.alert-critique { border-left-color:var(--critical); }
.alert-serieux { border-left-color:#e8890c; }
.alert-attention { border-left-color:#d4a900; }
a.alert-link { text-decoration:none; color:inherit; align-items:center; transition:background .12s; }
a.alert-link:hover { background:var(--grid); border-radius:0 8px 8px 0; }
a.alert-link .chev { margin-left:auto; flex:none; color:var(--muted); font-weight:700; opacity:0; transition:opacity .12s; }
a.alert-link:hover .chev { opacity:1; }
html { scroll-behavior:smooth; }
:target { scroll-margin-top:20px; animation:cible-flash 1.6s ease-out; }
@keyframes cible-flash { 0% { box-shadow:0 0 0 3px var(--critical); } 100% { box-shadow:0 0 0 3px transparent; } }

/* ---------- Graphiques ---------- */
.legend { display:flex; gap:16px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
.legend .key { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--ink-2); }
.key .swatch { width:10px; height:10px; border-radius:3px; }
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.axis-label { font-size:11px; fill:var(--muted); }
.val-label { font-size:11px; fill:var(--ink-2); font-weight:600; font-variant-numeric:tabular-nums; }

/* ---------- Formulaires ---------- */
.field { margin-bottom:12px; }
.field label { display:block; font-size:12px; font-weight:600; color:var(--ink-2); margin-bottom:4px; }
.field input, .field select { width:100%; padding:9px 10px; border:1px solid var(--baseline); border-radius:8px; font:inherit; background:#fff; }
.form-narrow { max-width:420px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.form-error { background:#f9dcdc; color:#a11f1f; border-radius:8px; padding:9px 12px; font-size:13px; margin-bottom:12px; }
.form-ok { background:#e2f4e2; color:#006300; border-radius:8px; padding:9px 12px; font-size:13px; margin-bottom:12px; }
.inline-form { display:flex; gap:8px; align-items:flex-end; flex-wrap:wrap; }
.inline-form .field { margin-bottom:0; }

/* ---------- Détail chantier ---------- */
.kv { display:flex; gap:22px; margin-top:8px; flex-wrap:wrap; }
.kv div span { display:block; }
.kv .k { font-size:11.5px; color:var(--muted); }
.kv .v { font-weight:650; font-variant-numeric:tabular-nums; }
.back { color:var(--accent); font-weight:600; text-decoration:none; display:inline-block; margin-bottom:10px; }

/* ---------- Marketing ---------- */
.mkt { max-width:1000px; }
.hero { text-align:center; padding:56px 16px 40px; }
.hero h1 { font-size:38px; line-height:1.15; letter-spacing:-0.01em; max-width:720px; margin:0 auto 14px; }
.hero p.lead { font-size:17px; color:var(--ink-2); max-width:620px; margin:0 auto 26px; }
.hero .cta-note { color:var(--muted); font-size:12.5px; margin-top:10px; }
.features { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin:30px 0 50px; }
.feature { background:var(--surface-1); border:1px solid var(--border); border-radius:12px; padding:18px; }
.feature .emoji { font-size:22px; }
.feature h3 { font-size:14.5px; margin:8px 0 4px; }
.feature p { font-size:13px; color:var(--ink-2); }
.pricing { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin:24px 0 40px; }
.plan { background:var(--surface-1); border:1px solid var(--border); border-radius:14px; padding:22px; position:relative; }
.plan.featured { border:2px solid var(--accent); }
.plan .tag { position:absolute; top:-11px; left:50%; transform:translateX(-50%); background:var(--accent); color:#fff; font-size:11px; font-weight:700; padding:3px 10px; border-radius:999px; }
.plan h3 { font-size:15px; }
.plan .price { font-size:30px; font-weight:700; margin:8px 0 2px; }
.plan .price small { font-size:13px; font-weight:500; color:var(--muted); }
.plan ul { list-style:none; margin:14px 0 18px; }
.plan li { padding:4px 0; font-size:13px; color:var(--ink-2); }
.plan li::before { content:"✓ "; color:var(--good-text); font-weight:700; }
.section-title { text-align:center; font-size:24px; margin:40px 0 6px; }
.section-sub { text-align:center; color:var(--ink-2); margin-bottom:24px; }
.footer { border-top:1px solid var(--grid); margin-top:40px; padding:22px 24px; color:var(--muted); font-size:12.5px; display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; }
.footer a { color:var(--muted); }

.auth-box { max-width:400px; margin:48px auto; background:var(--surface-1); border:1px solid var(--border); border-radius:14px; padding:26px; }
.auth-box h1 { font-size:19px; margin-bottom:16px; }
.auth-alt { text-align:center; font-size:13px; color:var(--ink-2); margin-top:14px; }

@media (max-width:900px) {
  .tiles, .features, .pricing { grid-template-columns:repeat(2,1fr); }
  .two-col { grid-template-columns:1fr; }
  .hero h1 { font-size:28px; }
}
@media (max-width:560px) {
  .tiles, .features, .pricing, .form-grid { grid-template-columns:1fr; }
}
@media print {
  .topbar, .banner, .no-print { display:none !important; }
  body { background:#fff; }
  .card { border:none; padding:0; }
}
