/* Palette "terrain robuste" — identique à la maquette validée et à l'app mobile. */
:root {
  --background: #FBF8F3;
  --surface: #FFFFFF;
  --border: #E7E1D6;
  --ink: #1C1A17;
  --muted: #847C6E;
  --muted-strong: #5C564C;
  --anthracite: #26221D;
  --anthracite-border: #3A342C;
  --accent: #E8630A;
  --accent-text: #FFFFFF;
  --inactive: #8B8578;

  --status-valide-bg: #E7F5EC;
  --status-valide-fg: #1F8A4C;
  --status-attente-bg: #FDEFE0;
  --status-attente-fg: #B5590A;
  --status-brouillon-bg: #EFECE6;
  --status-brouillon-fg: #6B655B;
  --status-refuse-bg: #FBE7E7;
  --status-refuse-fg: #C23B3B;

  --dispo-bg: #E7F5EC;
  --dispo-fg: #1F8A4C;
  --absent-bg: #FBE7E7;
  --absent-fg: #C23B3B;
  --chantier-bg: #EAF0F8;
  --chantier-fg: #2A5B8C;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

#root { min-height: 100vh; min-height: 100dvh; }

/* ---------- Boot screen ---------- */
.boot-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: var(--anthracite);
}
.spinner-wrap { display: flex; justify-content: center; padding: 40px 0; }
.spinner, .boot-screen .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner-wrap .spinner { border-color: var(--border); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  background: var(--anthracite);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-inner { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; }
.login-title { font-size: 26px; font-weight: 900; color: #fff; text-align: center; }
.login-subtitle { font-size: 14px; color: #B7AFA0; text-align: center; margin-top: 6px; }
.login-card { background: var(--background); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 12px; }
.field-input {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 13px 14px;
  font-size: 15px; color: var(--ink); background: #fff; width: 100%; min-height: 48px;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.login-error { color: var(--status-refuse-fg); font-size: 13px; margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 16px; min-height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; width: 100%; transition: opacity .15s;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.6; pointer-events: none; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--dark { background: var(--anthracite); color: #fff; }
.btn--success { background: var(--status-valide-fg); color: #fff; }
.btn--outline-danger { background: transparent; color: var(--status-refuse-fg); border: 1.5px solid var(--status-refuse-fg); }
.btn--small { padding: 10px 14px; min-height: 44px; font-size: 13px; width: auto; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-row > .btn { flex: 1; }
.btn .spinner { width: 18px; height: 18px; border-width: 2px; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  background: var(--anthracite); color: #fff; padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.app-header__title { font-size: 16px; font-weight: 800; }
.app-header__logout { background: none; border: none; color: var(--accent); font-weight: 700; font-size: 13px; padding: 10px 4px; }

.app-content { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 32px; max-width: 640px; margin: 0 auto; width: 100%; }

.tab-bar {
  display: flex; background: var(--anthracite); border-top: 1px solid var(--anthracite-border);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky; bottom: 0; z-index: 5;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--inactive);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 10px; font-size: 10.5px; font-weight: 700;
}
.tab-btn svg { stroke: var(--inactive); }
.tab-btn--active { color: var(--accent); }
.tab-btn--active svg { stroke: var(--accent); }

/* ---------- Cards / lists ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--10 { gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.card--row { flex-direction: row; align-items: center; gap: 12px; padding: 14px; }
.card-title { font-weight: 800; font-size: 15px; color: var(--ink); }
.card-sub { font-size: 12.5px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 6px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-text { color: var(--muted-strong); font-size: 13px; }
.divider { height: 1px; background: var(--border); }

.avatar {
  background: var(--anthracite); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}

.badge {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge--valide, .badge--dispo { background: var(--status-valide-bg); color: var(--status-valide-fg); }
.badge--attente { background: var(--status-attente-bg); color: var(--status-attente-fg); }
.badge--refuse, .badge--absent { background: var(--status-refuse-bg); color: var(--status-refuse-fg); }
.badge--brouillon { background: var(--status-brouillon-bg); color: var(--status-brouillon-fg); }
.badge--chantier { background: var(--chantier-bg); color: var(--chantier-fg); }

.empty-state {
  color: var(--muted); font-size: 13.5px; text-align: center; padding: 40px 20px;
}

/* ---------- Day strip ---------- */
.days-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.day-pill {
  width: 44px; flex-shrink: 0; padding: 8px 0; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
.day-pill__label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--ink); }
.day-pill__num { font-size: 15px; font-weight: 800; color: var(--ink); }
.day-pill--selected { background: var(--accent); border-color: var(--accent); }
.day-pill--selected .day-pill__label, .day-pill--selected .day-pill__num { color: #fff; }
.day-dot { width: 4px; height: 4px; border-radius: 2px; background: var(--accent); position: absolute; bottom: 4px; }

/* ---------- Chips ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 20px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.chip--selected { background: var(--anthracite); border-color: var(--anthracite); color: #fff; }

/* ---------- KPI ---------- */
.kpi-row { display: flex; gap: 10px; margin-bottom: 18px; }
.kpi { flex: 1; border: 1px solid; border-radius: 14px; padding: 12px; }
.kpi-value { font-size: 22px; font-weight: 900; }
.kpi-label { font-size: 11.5px; font-weight: 600; margin-top: 4px; }

/* ---------- Today card (ouvrier) ---------- */
.today-card { background: var(--anthracite); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.today-title { color: #fff; font-weight: 800; font-size: 16px; }
.today-meta { color: #D8D2C6; font-size: 13px; }
.today-divider { height: 1px; background: var(--anthracite-border); }
.today-chef { color: #B7AFA0; font-size: 12.5px; }
.itineraire-btn { background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 9px 14px; font-weight: 700; font-size: 12.5px; }

/* ---------- Forms ---------- */
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
textarea.field-input { min-height: 80px; resize: vertical; }
.two-col { display: flex; gap: 12px; }
.two-col > * { flex: 1; }

/* ---------- Confirmation screen ---------- */
.confirmation { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 60px 24px; text-align: center; }
.confirmation-icon { width: 64px; height: 64px; border-radius: 32px; background: var(--status-valide-bg); display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--status-valide-fg); }
.confirmation-title { font-weight: 800; font-size: 17px; color: var(--ink); }
.confirmation-text { color: var(--muted); font-size: 14px; line-height: 20px; }
.confirmation .btn { max-width: 260px; }

/* ---------- Section titles ---------- */
.section-title { font-weight: 800; font-size: 14px; color: var(--anthracite); margin-bottom: 10px; }

/* ---------- Calendrier ---------- */
.calendar-row { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.calendar-row-title { font-weight: 700; font-size: 13px; color: var(--ink); }
.calendar-row-sub { font-size: 11.5px; color: var(--muted); }
.calendar-row-date { font-size: 11.5px; color: var(--muted-strong); font-weight: 600; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 50; padding: 0 16px; }
.toast {
  background: var(--anthracite); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: 420px; text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--status-refuse-fg); }
.toast--success { background: var(--status-valide-fg); }

/* ---------- Misc ---------- */
.hint { font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 700; font-size: 13px; padding: 4px; }

@media (min-width: 720px) {
  .app-content { padding: 24px; }
}
