/* AgriOne — feuille de style. Utilitaire haut contraste, pensé cabine. */
:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --ink: #15140F;
  --muted: #5A5850;
  --faint: #A8A49A;
  --line: #D6D2C8;
  --green: #167A3B;
  --green-dark: #0F5A2A;
  --green-tint: #DDEFE2;
  --green-text: #0F5A2A;
  --amber: #B8690A;
  --amber-tint: #FBEBD0;
  --amber-text: #7A4A05;
  --red: #B4251A;
  --red-tint: #F8DAD6;
  --red-text: #7E1A12;
  --on-accent: #FFFFFF;
  --shadow: 0 6px 24px rgba(21, 20, 15, 0.18);
  --radius: 10px;
  --nav-h: 76px;
  color-scheme: light;
}
:root[data-theme="nuit"] {
  --bg: #12130F;
  --surface: #1C1D18;
  --ink: #F2EFE6;
  --muted: #B9B4A6;
  --faint: #6F6B60;
  --line: #34352E;
  --green: #2E9B55;
  --green-dark: #4ADE80;
  --green-tint: #17301F;
  --green-text: #9BE3B3;
  --amber: #E0A030;
  --amber-tint: #3A2A0C;
  --amber-text: #F2C46B;
  --red: #E0473A;
  --red-tint: #3E1512;
  --red-text: #F5A39B;
  --on-accent: #FFFFFF;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-size="grand"] { font-size: 112%; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: var(--green); }
a:hover { color: var(--green-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Shell ---------- */
#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); }
.top {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 8px 16px;
}
.top .eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.top h1 { margin: 2px 0 0 0; font-size: 22px; font-weight: 900; line-height: 1.1; letter-spacing: -0.01em; text-wrap: balance; }
.top .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.body { flex-grow: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 24px 16px; display: flex; flex-direction: column; gap: 12px; }
.body > * { flex-shrink: 0; }
.nav {
  flex-shrink: 0; display: flex; flex-direction: row;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 2px solid var(--ink); background: var(--surface);
}
.nav a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  position: relative;
}
.nav a.on { color: var(--green); }
.nav a .dot { position: absolute; top: 12px; right: calc(50% - 22px); width: 10px; height: 10px; border-radius: 999px; background: var(--red); border: 2px solid var(--surface); }
.nav svg { width: 26px; height: 26px; }

/* ---------- Primitives ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--green-tint); color: var(--green-text); }
.pill.warn { background: var(--amber-tint); color: var(--amber-text); }
.pill.no { background: var(--red-tint); color: var(--red-text); }
.pill.neutral { background: var(--line); color: var(--ink); }
.pill .d { width: 8px; height: 8px; border-radius: 999px; background: currentColor; }

.label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.label.mt { margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: 500; }
.big { font-size: 34px; font-weight: 900; line-height: 1.05; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex-grow: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.card.strong { border: 2px solid var(--ink); }
.card.ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.card.ink .muted { color: var(--line); }
.card.green { background: var(--green); color: var(--on-accent); border-color: var(--green); }
.card.green .muted { color: var(--green-tint); }
.card.red { background: var(--red); color: var(--on-accent); border-color: var(--red); }
.card.amber { background: var(--amber-tint); color: var(--amber-text); border-color: var(--amber-tint); }
.card.warnline { border-left: 6px solid var(--amber); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.item { display: flex; flex-direction: row; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.item:last-child { border-bottom: 0; }
.item .t { font-size: 15px; font-weight: 700; }
.item .s { font-size: 13px; font-weight: 500; color: var(--muted); }
.item .dot { width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0; }
.item .dot.ok { background: var(--green); } .item .dot.warn { background: var(--amber); } .item .dot.no { background: var(--red); } .item .dot.neutral { background: var(--faint); }
.item.sel { background: var(--green-tint); }
.item .datebox { width: 44px; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.item .datebox b { font-size: 20px; font-weight: 900; line-height: 1; }
.item .datebox span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.chev { color: var(--faint); flex-shrink: 0; }

/* Buttons: 56 px minimum, 72 px pour les actions cabine */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 18px; border-radius: var(--radius); font-size: 16px; font-weight: 700; border: 2px solid var(--ink); background: var(--surface); color: var(--ink); text-decoration: none; width: 100%; }
.btn.primary { background: var(--green); color: var(--on-accent); border-color: var(--green); }
.btn.ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.danger { background: var(--red); color: var(--on-accent); border-color: var(--red); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.xl { min-height: 72px; font-size: 18px; justify-content: flex-start; }
.btn.xl .lead { flex-shrink: 0; }
.btn.xl .txt { flex-grow: 1; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.btn.xl .txt small { font-size: 13px; font-weight: 500; color: var(--muted); }
.btn.primary.xl .txt small, .btn.ink.xl .txt small { color: inherit; opacity: 0.8; }
.btn.sm { min-height: 44px; font-size: 14px; padding: 0 14px; width: auto; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 26px; height: 26px; flex-shrink: 0; }
.btn.sm svg { width: 20px; height: 20px; }
.btnrow { display: flex; flex-direction: row; gap: 10px; }
.btnrow .btn { flex: 1 1 0; }

.chips { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 15px; font-weight: 700; border: 2px solid var(--ink); background: var(--surface); color: var(--ink); white-space: nowrap; flex-shrink: 0; }
.chip.on { background: var(--ink); color: var(--bg); }
.chip.ok { border-color: var(--green); }
.chip.ok.on { background: var(--green); border-color: var(--green); color: var(--on-accent); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.field input, .field select, .field textarea { min-height: 56px; padding: 10px 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 17px; font-weight: 700; width: 100%; }
.field textarea { min-height: 80px; font-weight: 500; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; }
.field .hint { font-size: 12px; font-weight: 500; color: var(--muted); }
.field.bad input, .field.bad select { border-color: var(--red); }
.inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 4px; font-weight: 700; }
.check input { width: 28px; height: 28px; accent-color: var(--green); }
.kv { display: flex; flex-direction: row; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { width: 100px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.kv .v { flex-grow: 1; font-size: 16px; font-weight: 700; min-width: 0; }
.kv .v small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.kv.warn { background: var(--amber-tint); }
.kv.warn .k { color: var(--amber-text); }
.kv .ok { color: var(--green); flex-shrink: 0; }
.kv .bad { color: var(--amber); flex-shrink: 0; }

/* Mic */
.micwrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 4px 0; }
.mic { position: relative; width: 128px; height: 128px; border-radius: 999px; border: 4px solid var(--ink); background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; }
.mic svg { width: 56px; height: 56px; }
.mic.listening { background: var(--red); }
.mic.done { background: var(--ink); }
.mic .ring { position: absolute; inset: -4px; border-radius: 999px; border: 4px solid var(--green); animation: ring 1.1s ease-out infinite; }
.mic .ring.r2 { animation-delay: 0.45s; }
@keyframes ring { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.6); opacity: 0; } }
.transcript { padding: 12px 14px; background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius); font-style: italic; font-size: 16px; min-height: 52px; }
.transcript.empty { color: var(--faint); border-color: var(--line); font-style: normal; }

/* Weather status block */
.status { display: flex; flex-direction: column; gap: 4px; padding: 20px; border-radius: 12px; }
.status.ok { background: var(--green); color: #fff; }
.status.warn { background: #F2B84B; color: #15140F; }
.status.no { background: var(--red); color: #fff; }
.status.neutral { background: var(--line); color: var(--ink); }
.status .word { font-size: 56px; font-weight: 900; line-height: 1; letter-spacing: -0.02em; }
.status .why { font-size: 16px; font-weight: 700; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tile .v { font-size: 26px; font-weight: 900; line-height: 1.1; }
.tile .v small { font-size: 13px; font-weight: 700; color: var(--muted); }
.hour { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 60px; border-radius: 8px; border: 3px solid transparent; font-weight: 900; font-size: 14px; }
.hour.ok { background: var(--green); color: #fff; } .hour.warn { background: #F2B84B; color: #15140F; } .hour.no { background: var(--red); color: #fff; }
.hour.sel { border-color: var(--ink); }
.hour small { font-size: 10px; font-weight: 700; }

/* Map (schéma) */
.map { background: #EDE9DF; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
:root[data-theme="nuit"] .map { background: #23241E; }
.map svg { display: block; width: 100%; height: auto; }
.map .lbl { font-family: inherit; font-size: 12px; font-weight: 900; fill: var(--ink); pointer-events: none; }
.map .ha { font-size: 10px; font-weight: 700; fill: var(--muted); pointer-events: none; }
.map polygon { cursor: pointer; }

/* Chantier en cours */
.timer { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.blink { animation: blink 1.2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Sheet & toast */
.sheet-bg { position: fixed; inset: 0; background: rgba(21, 20, 15, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 900; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); max-width: 528px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 14px 16px; border-radius: var(--radius); font-weight: 700; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); z-index: 60; }
.toast.ok svg { color: #4ADE80; }
.toast.bad { background: var(--red); color: #fff; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 700; }
.banner.demo { background: var(--amber-tint); color: var(--amber-text); }
.banner.offline { background: var(--line); color: var(--ink); }
.banner .btn { width: auto; }

/* Onboarding */
.onb h1 { font-size: 28px; font-weight: 900; line-height: 1.1; margin: 0; text-wrap: balance; }
.preview { display: flex; flex-direction: column; gap: 6px; }
.preview .p { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.preview .p::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--green); flex-shrink: 0; }

/* Tables (papiers / argent) */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 900; }

/* Print */
.printonly { display: none; }
@media print {
  #app { display: none !important; }
  .printonly { display: block !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .printonly h1 { font-size: 18pt; margin: 0 0 4pt 0; }
  .printonly h2 { font-size: 13pt; margin: 14pt 0 6pt 0; border-bottom: 1px solid #000; }
  .printonly table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .printonly th, .printonly td { border: 1px solid #000; padding: 3pt 4pt; text-align: left; white-space: normal; }
  .printonly .sig { margin-top: 24pt; display: flex; justify-content: space-between; }
}

/* Très grand texte et mode simplifié */
:root[data-size="tres-grand"] { font-size: 130%; }
:root[data-size="tres-grand"] .nav a { font-size: 12px; }
:root[data-size="tres-grand"] .btn.xl { min-height: 84px; }
:root[data-gloves="1"] .btn { min-height: 72px; font-size: 18px; }
:root[data-gloves="1"] .btn.xl { min-height: 96px; font-size: 22px; }
:root[data-gloves="1"] .item { min-height: 76px; }
:root[data-gloves="1"] .chip { min-height: 56px; font-size: 17px; }
:root[data-gloves="1"] .check input { width: 36px; height: 36px; }
.toast .btn { width: auto; }
