/* Wattpro Heures — carnet de chantier : utilitaire, contrasté, grandes zones tactiles.
   Bleu plan pour les actions, jaune sécurité uniquement pour les alertes, rouge pour les dépassements. */
:root {
  --bg: #eef0ec; --surface: #ffffff; --sunk: #e4e7e1; --ink: #1b211e; --muted: #56615b; --line: #d3d8d1;
  --accent: #1f4fbf; --accent-ink: #ffffff; --accent-soft: #e3eafb;
  --ok: #2d7a4c; --ok-soft: #dcefe3; --warn: #8a5f00; --warn-fill: #e0a400; --warn-soft: #fbefc4;
  --crit: #bf3328; --crit-soft: #f8dedb;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px; --tap: 44px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614; --surface: #1a1f1c; --sunk: #232925; --ink: #e7ebe6; --muted: #a2ada6; --line: #313934;
    --accent: #86a8ff; --accent-ink: #0e1530; --accent-soft: #1f2a47;
    --ok: #6cc790; --ok-soft: #173325; --warn: #e8b931; --warn-fill: #e8b931; --warn-soft: #3a3013;
    --crit: #ff7f73; --crit-soft: #3d1c19;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font); min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
a { color: var(--accent); text-underline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num, td.num, .figures dd, .kpi-value { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.neg { color: var(--crit); }
.pos { color: var(--ok); }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1160px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main.wrap { padding-top: 16px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

/* En-tête */
header.top {
  position: sticky; top: 0; z-index: 10; background: var(--surface);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 6px; }
.brand {
  font-weight: 800; font-size: 1.3rem; letter-spacing: .02em; text-transform: uppercase; line-height: 1;
  color: var(--ink); text-decoration: none;
}
.brand small { display: block; font-size: .72rem; font-weight: 500; letter-spacing: .04em; text-transform: none; color: var(--muted); margin-top: 3px; }
.brand-lg { font-size: 1.6rem; margin-bottom: 16px; color: var(--accent); }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); text-align: right; flex-wrap: wrap; justify-content: flex-end; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; display: flex; align-items: center; min-height: var(--tap); padding: 0 12px;
  color: var(--muted); font-weight: 600; font-size: .95rem; text-decoration: none; border-bottom: 3px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { color: var(--ink); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card.narrow { max-width: 460px; width: 100%; margin-left: auto; margin-right: auto; }
.page-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-title h1 { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .95rem var(--font); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--crit); border-color: var(--crit-soft); }
.btn-danger:hover { border-color: var(--crit); }
.btn-sm { min-height: 36px; padding: 0 10px; font-size: .85rem; }
@media (pointer: coarse) { .btn-sm { min-height: var(--tap); } }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; min-height: var(--tap); padding: 0 4px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; min-width: 0; }
input, select, textarea {
  font: 400 1rem var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-height: var(--tap); width: 100%; max-width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
input[type="file"] { padding: 8px; }
textarea { min-height: 120px; }
input:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--crit); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; min-height: var(--tap); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.grid-form .span-2, .grid-form .span-3, .grid-form .span-4 { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .grid-form.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-form.cols-4 .span-2 { grid-column: span 2; }
  .grid-form.cols-4 .span-3 { grid-column: span 3; }
}
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 4px; padding: 0; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented legend { grid-column: 1 / -1; }
.segmented label {
  flex-direction: row; align-items: center; gap: 8px; min-height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-weight: 500; cursor: pointer;
}
.segmented label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.total-box {
  display: flex; flex-direction: column; justify-content: center; min-height: var(--tap);
  padding: 4px 12px; border-radius: 8px; background: var(--sunk);
}
.total-box output { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.total-box output.bad { color: var(--crit); font-size: .95rem; }
.code-input { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters label { flex: 1 1 160px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.calc-result { font-size: 1.05rem; }

/* Messages */
.flash { border-radius: 8px; padding: 10px 14px; border: 1px solid; font-weight: 500; }
.flash p:last-child { margin-bottom: 0; }
.flash-ok { background: var(--ok-soft); border-color: var(--ok); }
.flash-info { background: var(--accent-soft); border-color: var(--accent); }
.flash-error { background: var(--crit-soft); border-color: var(--crit); }
.notice { background: var(--warn-soft); border-left: 4px solid var(--warn-fill); padding: 10px 14px; border-radius: 6px; margin: 0; }
.error-list { color: var(--crit); padding-left: 20px; }
pre.debug, pre.code { white-space: pre-wrap; word-break: break-word; background: var(--sunk); padding: 10px; border-radius: 6px; font: .82rem/1.45 var(--mono); overflow-x: auto; }
.temp-pw { border: 2px solid var(--accent); }
.temp-pw .token { font-size: .95rem; }

/* KPI */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.15; }
.kpi-warn { border-color: var(--warn-fill); background: var(--warn-soft); }

/* Projets */
.project-list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .project-list { grid-template-columns: 1fr 1fr; } }
.project-card { display: flex; flex-direction: column; gap: 8px; border-left-width: 5px; }
.project-card.lvl-ok { border-left-color: var(--ok); }
.project-card.lvl-warn { border-left-color: var(--warn-fill); }
.project-card.lvl-over { border-left-color: var(--crit); }
.project-card.lvl-none { border-left-color: var(--line); }
.pc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.pc-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.pc-title:hover { text-decoration: underline; }
.progress { display: block; width: 100%; height: 12px; margin: 4px 0; overflow: visible; }
.progress .track { fill: var(--sunk); }
.progress .fill { fill: var(--ok); }
.progress.lvl-warn .fill { fill: var(--warn-fill); }
.progress.lvl-over .fill { fill: var(--crit); }
.progress .mark { stroke: var(--ink); stroke-width: .6; vector-effect: non-scaling-stroke; }
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 4px 0 0; }
@media (min-width: 560px) { .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.figures div { min-width: 0; }
.figures dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.figures dd { margin: 0; font-weight: 700; font-size: 1.02rem; }
.figures-lg dd { font-size: 1.25rem; }
.figures small { font-weight: 500; color: var(--muted); }

/* Pastilles */
.chip, .tag {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700;
  border: 1px solid var(--line); background: var(--sunk); color: var(--ink); white-space: nowrap; line-height: 1.6;
}
.chip-ok, .tag-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip-warn, .tag-warn { background: var(--warn-soft); border-color: var(--warn-fill); color: var(--warn); }
.chip-over, .tag-crit { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
.chip-none { color: var(--muted); }
.tag-btn { cursor: pointer; font-family: var(--font); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.delta { font-weight: 700; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.filter-tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr.total td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; }
tr.subtotal td { font-weight: 700; color: var(--muted); }
tr.unvalidated td:first-child { box-shadow: inset 4px 0 0 var(--warn-fill); }
tr.missing td { background: var(--crit-soft); color: var(--crit); font-weight: 600; }
tr.empty td { color: var(--muted); }
tr.inactive td { color: var(--muted); }
.summary-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv li:last-child { border-bottom: 0; }

/* Saisie employé */
.week-group { margin-bottom: 16px; }
.week-head { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 2px solid var(--ink); }
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.entry-main { min-width: 0; flex: 1 1 0; }
.entry-title { font-weight: 600; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.entry-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.entry-actions { display: flex; gap: 8px; flex-basis: 100%; justify-content: flex-end; }
.entry-side .num { font-size: 1.1rem; }

/* Semaine */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav .btn { min-width: var(--tap); font-size: 1.3rem; padding: 0 12px; }
.week-label { display: flex; flex-direction: column; align-items: center; min-width: 220px; flex: 1 1 auto; text-align: center; }

/* Connexion */
.login { display: flex; flex-direction: column; gap: 16px; padding-top: 4vh; }
.help summary { cursor: pointer; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }
.row-actions { margin-top: 8px; }
details summary { cursor: pointer; }
.center-page main { margin: 10vh auto; }

/* Registre du temps de travail */
.register-table th, .register-table td { padding: 6px 6px; }
.register-table tr.week-row th { background: var(--sunk); color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .9rem; padding-top: 10px; }
.register-table tr.rest-row td { color: var(--muted); }
.register-table tr.alert-row td { border-bottom-style: dashed; padding-top: 2px; }
.register-table tr.alert-row .tag { margin: 2px 2px 2px 0; }
.register-table tr.week-alerts td { border-bottom: 2px solid var(--line); }
.alerts { margin: 0; padding-left: 20px; color: var(--warn); font-size: .88rem; }
.alerts li { margin: 2px 0; }
.diff { list-style: none; margin: 0; padding: 0; }
.diff li { margin: 2px 0; }
.diff del { color: var(--crit); }
.diff ins { color: var(--ok); text-decoration: none; font-weight: 600; }
.print-head, .screen-hidden { display: none; }
.print-view .print-head { display: block; }
.print-view main.wrap { max-width: 1100px; }
.print-company { font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.print-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin: 8px 0; }
.print-meta div { display: flex; gap: 6px; }
.print-meta dt { font-weight: 600; color: var(--muted); }
.print-meta dd { margin: 0; }
.print-mention { font-size: .85rem; font-style: italic; }

@media print {
  header.top, .btn, .btn-row, .filters, .week-nav .btn, form, .screen-only, .page-title, .foot { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card { border: 0; padding: 0; }
  .print-head, .screen-hidden { display: block !important; }
  .register { break-before: page; }
  .register:first-of-type { break-before: auto; }
  .register-table tr { break-inside: avoid; }
  .register-table thead { display: table-header-group; }
  .tag { border-color: #000; color: #000; background: none; }
  .table-wrap { overflow: visible; }
  main.wrap { padding: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
}
