:root {
  --orange: #ff7900;
  --orange-dark: #cc6100;
  --ink: #111827;
  --muted: #6b7280;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e5e7eb;
  --ok: #2e7d32;
  --ok-bg: #e6f4ea;
  --bad: #c62828;
  --bad-bg: #fde8e8;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 .15rem; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
h3 { font-size: .8rem; margin: 0 0 .4rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.sr { position: absolute; left: -9999px; }

/* Barre du haut */
.topbar { background: #000; color: #fff; }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.brand-mark { color: var(--orange); }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { color: #d1d5db; text-decoration: none; padding: .4rem .75rem; border-radius: 8px; }
.topbar nav a:hover { color: #fff; background: #1f2937; }
.topbar nav a.on { color: #000; background: var(--orange); font-weight: 600; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 1rem 2rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
form.inline { margin: 0; }

/* Boutons et champs */
.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #cbd0d8; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #000; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: #fff; }
input, select, textarea {
  font: inherit; padding: .5rem .65rem; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; color: var(--ink); max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid rgba(255, 121, 0, .35); border-color: var(--orange); }
textarea { width: 100%; resize: vertical; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--orange); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 2.1rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.kpi-value.kpi-date { font-size: 1.6rem; padding-top: .35rem; }
.kpi-sub { font-size: .85rem; }
.ok, .ok-text { color: var(--ok); }
.bad, .bad-text { color: var(--bad); }

.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.note { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: var(--radius); padding: .9rem 1.1rem; }
.note p { margin: 0; }
.note .cause { margin-top: .5rem; color: var(--bad); }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .6rem .7rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
.grid tbody tr:hover { background: #fafafa; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; }
.pill { display: inline-block; min-width: 2.6rem; text-align: center; padding: .15rem .55rem; border-radius: 999px; font-weight: 700; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.chart-box { position: relative; height: 320px; }

/* Formulaires */
.form-top { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.field { min-width: 0; }
.total-box { margin-left: auto; text-align: right; }
.total-box .kpi-value { display: block; }
.form-grid input[type=number] { width: 7rem; }
.form-grid input[type=date] { width: 11rem; }
.form-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.25rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

.alert { background: var(--bad-bg); color: #7f1d1d; border: 1px solid #f5b5b5; border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.info { background: #fff4e5; color: #7a3e00; border: 1px solid #ffd7a8; border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; }
.empty { text-align: center; padding: 4rem 1rem; }

/* Connexion */
.login-body { display: grid; place-items: center; min-height: 100vh; background: #000; }
.login-card { background: #fff; width: min(92vw, 380px); padding: 2rem; border-radius: 16px; }
.login-card .brand-mark { font-size: 1.8rem; }
.login-card h1 { font-size: 1.25rem; margin-bottom: .25rem; }
.login-card form { display: grid; gap: .6rem; margin-top: 1rem; }
.login-card input { width: 100%; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .notes, .charts, .form-notes { grid-template-columns: 1fr; }
  .total-box { margin-left: 0; text-align: left; }
}

@media print {
  .topbar, .no-print, .foot { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .wrap { max-width: none; padding: 0; }
  .card, .kpi, .note { break-inside: avoid; }
  .charts { grid-template-columns: 1fr; }
  .chart-box { height: 260px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
