/* Pilotage campagne Shaunak Agri : charte (vert #0B5D4B, nuit #073B30, or #D9A441 jamais en texte sur blanc) */
:root {
  --vert: #0B5D4B; --nuit: #073B30; --or: #D9A441; --or-fonce: #9A6E1F; --petrole: #1E2B33; --cuivre: #B5652E;
  --coton: #F5F6F2; --encre: #142420; --jute: #C7A26B;
  --bg: #EEF0EA; --panel: #FFFFFF; --panel-2: #F7F8F4; --fg: #142420; --muted: #56655F; --line: #D5DBD2;
  --accent: #0B5D4B; --accent-ink: #FFFFFF; --focus: #D9A441;
  --vpale: #E3F0EC; --cpale: #F6E3D6; --opale: #FBF1DC; --calc: #F3F5F0; --input: #FBF3E2;
  --bad: #B5652E; --good: #0B5D4B;
  --f-display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --f-body: "Public Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 10px;
  --hex: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24.25' height='42'%3E%3Cpath d='M0 7L12.12 0L24.25 7L24.25 21L12.12 28L0 21Z M12.12 28V42' fill='none' stroke='%23ffffff' stroke-opacity='.07' stroke-width='1'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1613; --panel: #12211D; --panel-2: #0F1C18; --fg: #E6ECE8; --muted: #97A7A0; --line: #243630;
    --accent: #6CC7AC; --accent-ink: #07211A; --vpale: #173029; --cpale: #3A2416; --opale: #2E2614; --calc: #10201B; --input: #1C1A12;
    --bad: #E39A68; --good: #6CC7AC;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--f-display); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); margin: 4px 0 0; }
.note { color: var(--muted); font-size: 12px; font-style: italic; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.splash, .loading { padding: 48px; color: var(--muted); text-align: center; }

/* ------------------------------------------------ boutons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  font: 600 13px var(--f-body); cursor: pointer; text-decoration: none; background: var(--panel); color: var(--fg); white-space: nowrap; }
.btn.primary { background: var(--vert); color: #fff; }
.btn.primary:hover { background: var(--nuit); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { border-color: var(--line); background: var(--panel); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--vpale); color: var(--accent); font-size: 12px; font-weight: 600; }
.badge.bad { background: var(--cpale); color: var(--bad); margin-left: 6px; }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; font: 700 12px var(--f-body); cursor: pointer; }
.lang button.on { background: var(--vert); color: #fff; }

/* ------------------------------------------------ connexion */
.login { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); min-height: 100vh; }
.login-hero { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; color: #fff;
  background: linear-gradient(180deg, rgba(7,59,48,.72), rgba(7,59,48,.94)), var(--hex), url("/assets/sacs.jpg") center/cover; }
.login-logo { width: 220px; }
.login-pitch h1 { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.08; max-width: 14ch; }
.login-pitch p { max-width: 46ch; color: #D7E4DE; font-size: 16px; }
.login-pitch h1::after { content: ""; display: block; width: 64px; height: 4px; background: var(--or); margin-top: 18px; border-radius: 2px; }
.login-foot { color: #A9C2B8; font-size: 12px; }
.login-panel { display: flex; flex-direction: column; background: var(--panel); padding: 24px; }
.login-top { display: flex; justify-content: flex-end; }
.login-form { margin: auto; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-logo-sm { display: none; width: 180px; }
.login-form label, .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.field em { color: var(--bad); font-style: normal; }
input, select { font: 14px var(--f-body); color: var(--fg); background: var(--input); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--focus); outline-offset: 0; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-error { background: var(--cpale); color: var(--bad); border-left: 4px solid var(--cuivre); padding: 9px 12px; border-radius: 6px; font-size: 13px; }
.banner-warn { background: var(--opale); border-left: 4px solid var(--or); padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }

/* ------------------------------------------------ coquille */
.shell { display: flex; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; width: 248px; flex: 0 0 248px; overflow-y: auto; background: var(--nuit) var(--hex); color: #CFE0D8;
  display: flex; flex-direction: column; padding: 18px 12px; }
.brand img { width: 176px; display: block; margin: 0 8px 4px; }
.side-campagne { margin: 0 10px 14px; font-size: 12px; color: var(--or); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.nav-group { margin-bottom: 14px; }
.nav-title { font: 700 11px var(--f-body); text-transform: uppercase; letter-spacing: .08em; color: #86A79A; margin: 0 10px 4px; }
.side nav a { display: block; color: #E3EEE9; text-decoration: none; padding: 6px 10px; border-radius: 7px; font-size: 13.5px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.active { background: rgba(255,255,255,.12); border-left-color: var(--or); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; font-size: 11px; color: #6E8F82; }
.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.crumb { flex: 1; font: 700 15px var(--f-display); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.burger { display: none; border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 8px; padding: 4px 10px; font-size: 18px; cursor: pointer; }
.content { padding: 22px 24px 48px; min-width: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .search { width: 260px; max-width: 100%; }
.hint { color: var(--muted); font-size: 12px; margin-left: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------ tableaux */
.table-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.content > .table-wrap { max-height: calc(100vh - 230px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: var(--vert); color: #fff; text-align: left; font-weight: 700; padding: 8px 10px;
  border-bottom: 2px solid var(--or); white-space: nowrap; }
th.calc { background: var(--petrole); }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.calc { background: var(--calc); color: var(--muted); }
td.alert { background: var(--cuivre); color: #fff; font-weight: 700; }
td.neg { color: var(--bad); font-weight: 700; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--vpale); }
tfoot td { font-weight: 700; background: var(--vpale); position: sticky; bottom: 0; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; }

.report td { max-width: 520px; }
.report td:first-child + td { white-space: normal; min-width: 220px; }
.row-sec td { background: var(--panel-2); color: var(--accent); font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; padding-top: 12px; }
.row-tot td { font-weight: 700; background: var(--vpale); }
.row-sub td { font-style: italic; font-weight: 600; }
.row-auto td { color: var(--muted); }
.row-ok td:nth-child(4) { color: var(--good); font-weight: 700; }
.row-bad td { background: var(--cpale); }
.row-bad td:nth-child(4) { color: var(--bad); font-weight: 800; }
.row-ok td:last-child, .row-bad td:last-child { white-space: normal; min-width: 280px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis:empty { display: none; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--vert); border-radius: var(--radius); padding: 12px 14px; }
.kpi.good { border-top-color: var(--vert); }
.kpi.bad { border-top-color: var(--cuivre); }
.kpi.bad .kpi-v { color: var(--bad); }
.kpi-l { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-v { font: 800 22px var(--f-display); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tables { display: flex; flex-wrap: wrap; gap: 16px; }
.table-card { flex: 1 1 100%; min-width: 0; margin: 0; }
.table-card.half { flex: 1 1 calc(50% - 8px); min-width: min(100%, 520px); }

/* ------------------------------------------------ formulaire modal */
.modal-back { position: fixed; inset: 0; z-index: 20; background: rgba(7, 33, 26, .55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 780px; padding: 20px; border-top: 5px solid var(--vert); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 14px; margin-bottom: 12px; }
.ro { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 14px; font-size: 13px; }
.ro dt { color: var(--muted); }
.ro dd { margin: 0; font-weight: 600; }
.modal-foot { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.spacer { flex: 1; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; background: var(--vert); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 420px; }
.toast.bad { background: var(--cuivre); }

/* ------------------------------------------------ téléphone et tablette */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-logo-sm { display: block; }
  .side { position: fixed; left: 0; top: 0; z-index: 15; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 14; background: rgba(0,0,0,.4); }
  .burger { display: inline-block; }
  .top { padding: 8px 16px; gap: 8px; }
  .who { display: none; }
  .content { padding: 16px 16px 40px; }
  .table-card.half { flex-basis: 100%; }
  .hint { display: none; }
  .toolbar .search { width: 100%; }
}

@media print {
  .side, .top, .actions, .toolbar, .pager, .scrim { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; }
  .table-wrap { overflow: visible; border: 0; max-height: none !important; }
  th { position: static; }
  .card, .kpi { break-inside: avoid; }
}
