/* Gestion Viti v2 — palette de la v1 (Pacôme), pensée pour le téléphone au vignoble :
   grosses zones tactiles (48 px mini), fort contraste en plein soleil, polices système (marche hors réseau). */
:root {
  --bg: #F2F1EE; --surface: #FFFFFF; --sunk: #E9E7E2; --ink: #211D1F; --muted: #645C60; --line: #DCD8D2;
  --wine: #6D1F2F; --wine-soft: #F1DDE4; --vine: #3D6A48; --vine-soft: #DCE8DE;
  --crit: #B23A32; --crit-soft: #F6DEDB; --warn: #9A6514; --warn-soft: #F5E8D2;
  --display: Georgia, "Times New Roman", serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 12px; --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151214; --surface: #1D191B; --sunk: #272225; --ink: #ECE7E9; --muted: #A59CA0; --line: #352F32;
    --wine: #D9809B; --wine-soft: #43232F; --vine: #86B791; --vine-soft: #253A2B;
    --crit: #E8776E; --crit-soft: #3F2220; --warn: #E0AD5C; --warn-soft: #3D2E16;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151214; --surface: #1D191B; --sunk: #272225; --ink: #ECE7E9; --muted: #A59CA0; --line: #352F32;
  --wine: #D9809B; --wine-soft: #43232F; --vine: #86B791; --vine-soft: #253A2B;
  --crit: #E8776E; --crit-soft: #3F2220; --warn: #E0AD5C; --warn-soft: #3D2E16;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--wine); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .grow { flex: 1; } .end { justify-content: flex-end; }
.stack > * + * { margin-top: .75rem; }

/* ---------- squelette */
.app { max-width: 1100px; margin: 0 auto; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.app.large { padding-bottom: 2rem; }
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .5rem 1rem; display: flex; align-items: center; gap: .6rem; min-height: 56px; }
.top .logo { width: 32px; height: 32px; flex: none; }
.top .titre { font-family: var(--display); font-size: 1.1rem; line-height: 1.1; }
.top .titre small { display: block; font: .75rem var(--body); color: var(--muted); }
main { padding: 1rem; }

/* barre d'onglets en bas (téléphone) */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; color: var(--muted); text-decoration: none; font-size: .75rem; }
.tabs a .ico { font-size: 1.45rem; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--wine); font-weight: 600; }
/* menu latéral (ordinateur, manager) */
.side { display: none; }
@media (min-width: 900px) {
  .app.large { display: grid; grid-template-columns: 220px 1fr; max-width: 1280px; padding-bottom: 0; }
  .app.large .top { grid-column: 1 / -1; }
  .app.large .tabs { display: none; }
  .app.large .side { display: block; padding: 1rem .5rem; border-right: 1px solid var(--line); min-height: calc(100vh - 56px); position: sticky; top: 56px; align-self: start; }
  .side a { display: flex; gap: .6rem; align-items: center; padding: .55rem .75rem; border-radius: 10px; color: var(--ink); text-decoration: none; }
  .side a[aria-current="page"] { background: var(--wine-soft); color: var(--wine); font-weight: 600; }
  .side .grp { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem .75rem .25rem; }
}

/* ---------- composants */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; }
.card + .card { margin-top: .75rem; }
.card.alert { border-color: var(--crit); background: var(--crit-soft); }
.card.warn { border-color: var(--warn); background: var(--warn-soft); }
.card.ok { border-color: var(--vine); background: var(--vine-soft); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list > .item { display: flex; gap: .75rem; align-items: center; padding: .75rem 1rem; min-height: var(--tap);
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; }
.list > .item:last-child { border-bottom: 0; }
.list > .item:active { background: var(--sunk); }
.item .t { font-weight: 500; } .item .s { font-size: .85rem; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: 0 1.1rem;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.pri { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn.ok { background: var(--vine); border-color: var(--vine); color: #fff; }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.big { width: 100%; min-height: 64px; font-size: 1.1rem; }
.btn.sm { min-height: 36px; padding: 0 .75rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
:root[data-theme="dark"] .btn.pri, :root[data-theme="dark"] .btn.ok { color: #151214; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri, :root:not([data-theme="light"]) .btn.ok { color: #151214; } }

/* grosses tuiles du salarié */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 110px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--ink); font-weight: 500; cursor: pointer; }
.tile .ico { font-size: 2rem; }
.tile.pri { background: var(--wine); color: #fff; border-color: var(--wine); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { min-height: 44px; padding: 0 1rem; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
:root[data-theme="dark"] .chip[aria-pressed="true"] { color: #151214; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.wine { background: var(--wine-soft); color: var(--wine); } .pill.ok { background: var(--vine-soft); color: var(--vine); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.crit { background: var(--crit-soft); color: var(--crit); }

/* formulaires */
.form { display: grid; gap: 1rem; }
.f { display: grid; gap: .3rem; }
.f > span { font-size: .9rem; color: var(--muted); }
.f input, .f select, .f textarea { width: 100%; min-height: var(--tap); padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.f textarea { min-height: 96px; resize: vertical; }
.f input[type=checkbox] { width: 28px; min-height: 28px; height: 28px; }
.f .req::after { content: " *"; color: var(--crit); }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper button { width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1.5rem; cursor: pointer; }
.stepper output { min-width: 4.5rem; text-align: center; font-size: 1.6rem; font-family: var(--display); }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: .75rem 1rem 1rem; margin: 0; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .9rem; }

/* tableau (manager, ordinateur) */
.tw { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; background: var(--sunk); }
tr.clic { cursor: pointer; } tr.clic:hover td { background: var(--sunk); }

/* indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .75rem 1rem; text-decoration: none; color: inherit; }
.kpi b { display: block; font: 1.8rem var(--display); line-height: 1.1; }
.kpi.alert { border-color: var(--crit); } .kpi.alert b { color: var(--crit); }
.kpi.warn b { color: var(--warn); }

/* feu tricolore maladie */
.feu { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.feu i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: var(--line); }
.feu.nul i { background: var(--vine); } .feu.faible i { background: #8BAA4A; } .feu.moyen i { background: var(--warn); } .feu.fort i { background: var(--crit); }

/* bandeau d'état de synchro */
.sync { font-size: .78rem; padding: .25rem .6rem; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; cursor: pointer; border: 0; }
.sync.off { background: var(--warn-soft); color: var(--warn); } .sync.err { background: var(--crit-soft); color: var(--crit); }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; max-width: 90vw; box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.login { max-width: 420px; margin: 8vh auto; padding: 1rem; }
.login .logo { width: 64px; height: 64px; display: block; margin: 0 auto 1rem; }
.photos { display: flex; gap: .5rem; flex-wrap: wrap; }
.photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.carte { height: 60vh; min-height: 320px; border-radius: var(--r); border: 1px solid var(--line); }
.grille-sem { display: grid; grid-template-columns: 140px repeat(7, minmax(110px, 1fr)); min-width: 920px; }
.grille-sem > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: .35rem; min-height: 54px; font-size: .85rem; }
.grille-sem .h { background: var(--sunk); font-weight: 600; font-size: .8rem; min-height: 0; }
.grille-sem .case { cursor: pointer; } .grille-sem .case:hover { background: var(--sunk); }
.aff { display: block; background: var(--wine-soft); color: var(--wine); border-radius: 6px; padding: .15rem .35rem; margin-bottom: .2rem; font-size: .78rem; }
.aff.fait { background: var(--vine-soft); color: var(--vine); text-decoration: line-through; }
