/* Gestion K.A.T.E.C. — thème du site vitrine : gravier / bitume / rouge signal, Barlow */
:root {
  --gravier: #efede8; --gravier-2: #e3e0d9; --bitume: #17191c; --bitume-2: #2b2e33; --gris: #6b6e74;
  --rouge: #d0261c; --rouge-2: #b11f16; --blanc: #fff; --ok: #2f7d4f; --warn: #b8860b; --late: #d0261c;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif; --body: "Barlow", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--body); font-size: 1rem; line-height: 1.45; color: var(--bitume); background: var(--gravier); }
a { color: var(--bitume); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.05; }
h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
h2 { font-size: 1.4rem; margin-bottom: .75rem; }
h3 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--gris); }
.small { font-size: .9rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--rouge); outline-offset: 2px; }

/* Structure : barre latérale + contenu */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--bitume); color: var(--gravier); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem; text-decoration: none; color: var(--gravier); font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: .9; border-bottom: 1px solid var(--bitume-2); }
.brand small { display: block; font-family: var(--body); font-weight: 500; font-size: .75rem; letter-spacing: .1em; color: var(--gris); margin-top: .2rem; }
.chev { width: 30px; height: 30px; flex: none; background: repeating-linear-gradient(135deg, var(--rouge) 0 7px, var(--blanc) 7px 14px); border: 2px solid var(--gravier); }
.side nav { display: flex; flex-direction: column; padding: .6rem 0; flex: 1; }
.side nav a { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.1rem; color: var(--gravier); text-decoration: none; font-weight: 500; border-left: 4px solid transparent; }
.side nav a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side nav a:hover { background: var(--bitume-2); }
.side nav a.active { border-left-color: var(--rouge); background: var(--bitume-2); }
.side-user { padding: 1rem 1.1rem; border-top: 1px solid var(--bitume-2); display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .95rem; }
.side-user small { display: block; color: var(--gris); font-size: .8rem; }
.side-user .link { color: var(--gravier); }
.main { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 4rem; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
.card { background: var(--blanc); padding: 1.25rem; margin-bottom: 1.25rem; border-top: 3px solid var(--bitume); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.flash { padding: .75rem 1rem; margin-bottom: 1rem; border-left: 4px solid var(--ok); background: var(--blanc); }
.flash.error { border-left-color: var(--rouge); }

/* Boutons */
.btn { display: inline-block; font-family: var(--display); font-weight: 700; font-size: 1.1rem; padding: .55rem 1.1rem; background: var(--rouge); color: var(--blanc); border: 2px solid var(--rouge); text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--rouge-2); border-color: var(--rouge-2); }
.btn.ghost { background: transparent; color: var(--bitume); border-color: var(--bitume); }
.btn.ghost:hover { background: var(--gravier-2); }
.btn.small { font-size: .95rem; padding: .35rem .75rem; }
.btn.big { font-size: 1.4rem; padding: .9rem 1.5rem; width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--bitume); text-decoration: underline; cursor: pointer; }
.link.danger, .danger { color: var(--rouge); }
.x { background: none; border: 0; color: var(--gris); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 .3rem; }
.x:hover { color: var(--rouge); }
.inline { display: inline; }
.danger-zone { margin-top: 2rem; }

/* Formulaires */
.form label { display: block; font-weight: 500; margin-bottom: .8rem; font-size: .95rem; }
.form label small { font-weight: 400; }
.form input:not([type="checkbox"]), .form select, .form textarea, .filters input, .filters select, .upload input, .upload select {
  display: block; width: 100%; margin-top: .25rem; padding: .55rem .7rem; font: inherit; border: 1px solid #c9c6bf; background: var(--blanc); color: var(--bitume);
}
.form textarea { resize: vertical; }
.form .row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form .row > label { flex: 1 1 160px; }
.form .row > .grow { flex: 3 1 220px; }
.form fieldset { border: 1px solid #c9c6bf; padding: .5rem .8rem .8rem; margin: 0 0 .8rem; min-width: 0; }
.form legend { font-weight: 600; padding: 0 .3rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
label.check { display: inline-flex !important; align-items: center; gap: .4rem; font-weight: 400; }
label.check input { width: 1.1rem; height: 1.1rem; margin: 0; }
.form.mini { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.form.mini input, .form.mini select { width: auto; margin: 0; flex: 1 1 140px; padding: .4rem .5rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input { flex: 1 1 220px; margin: 0; }
.filters select { width: auto; margin: 0; }
.upload { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding: .8rem; background: var(--gravier); margin-bottom: 1rem; }
.upload select, .upload input { width: auto; margin: 0; flex: 1 1 160px; }
.hours-pick { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .5rem; }
.chip { font: inherit; font-weight: 600; padding: .5rem .9rem; border: 2px solid var(--bitume); background: var(--blanc); cursor: pointer; }
.chip.on, .chip:hover { background: var(--bitume); color: var(--blanc); }
.big-form input, .big-form select { font-size: 1.1rem; padding: .7rem .8rem; }
details.inline-edit summary { cursor: pointer; }
details.inline-edit summary.btn { list-style: none; display: inline-block; }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--gravier-2); vertical-align: top; }
.table th { font-family: var(--display); font-size: 1.05rem; font-weight: 700; border-bottom: 2px solid var(--bitume); }
.table.compact th, .table.compact td { padding: .4rem .4rem; }
.table tr.warn td { background: #fff8e1; }
.table tr.late td { background: #fdecea; }
.table tr.done td { color: var(--gris); }
.table tr.group td { font-family: var(--display); font-size: 1.05rem; background: var(--gravier); font-weight: 700; }
.table tfoot th { border: 0; }
.table.lines input, .table.lines textarea { width: 100%; padding: .4rem .5rem; font: inherit; border: 1px solid #c9c6bf; }
.table.lines textarea { margin-top: .3rem; font-size: .9rem; resize: none; overflow: hidden; }
.table.lines .qty, .table.lines .price { width: 6.5rem; text-align: right; }
.table.lines input[name="unit"] { width: 4.5rem; }
.badge { display: inline-block; font-family: var(--body); font-size: .8rem; font-weight: 600; padding: .15rem .5rem; background: var(--gravier-2); vertical-align: middle; }
.badge.s-en_cours, .badge.d-accepte { background: #dff2e5; color: var(--ok); }
.badge.s-devis, .badge.d-envoye { background: #fff3cd; color: #7a5a00; }
.badge.s-prospect, .badge.d-brouillon { background: var(--gravier-2); }
.badge.s-termine, .badge.s-receptionne { background: #e2e6ec; color: #384457; }
.badge.s-annule, .badge.d-refuse { background: #fdecea; color: var(--rouge); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--gris); }
.dl dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--gravier); padding: .75rem; margin-top: .75rem; }
.list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--gravier-2); }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { padding: .5rem 0 .5rem .8rem; border-left: 4px solid var(--warn); margin-bottom: .5rem; }
.alerts li.late { border-left-color: var(--late); }
.alerts li span { display: block; color: var(--gris); font-size: .9rem; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { padding: .4rem 0; border-bottom: 1px solid var(--gravier-2); display: flex; gap: .75rem; flex-wrap: wrap; align-items: baseline; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photos figcaption { font-size: .8rem; color: var(--gris); margin-top: .25rem; }

/* Planning : 6 colonnes */
.week { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1.25rem; }
.day { background: var(--blanc); padding: .6rem; border-top: 3px solid var(--bitume); min-height: 8rem; }
.day.today { border-top-color: var(--rouge); }
.day h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.assign { margin-bottom: .6rem; font-size: .9rem; }
.assign strong a { text-decoration: none; }
.assign ul { list-style: none; margin: .2rem 0 0; padding: 0; }
.assign li { display: flex; justify-content: space-between; align-items: center; padding: .15rem .4rem; background: var(--gravier); margin-bottom: 2px; }
.assign li.engin { background: #fff3cd; }
.week-nav .btn { font-size: .95rem; padding: .4rem .7rem; }

/* Connexion */
.login-body { display: grid; place-items: center; min-height: 100vh; margin: 0; background: var(--gravier); font-family: var(--body); }
.login { background: var(--blanc); width: min(380px, 92vw); padding: 0 2rem 2rem; }
.login .chevrons { height: 12px; background: repeating-linear-gradient(135deg, var(--rouge) 0 20px, var(--blanc) 20px 40px); margin: 0 -2rem 1.5rem; }
.login h1 { font-family: var(--display); font-size: 2.4rem; line-height: .9; margin-bottom: 1.5rem; }
.login h1 small { display: block; font-family: var(--body); font-size: .9rem; font-weight: 500; letter-spacing: .1em; color: var(--gris); margin-top: .3rem; }
.login label { display: block; font-weight: 500; margin-bottom: 1rem; }
.login input { display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem; font: inherit; border: 1px solid #c9c6bf; }
.login .btn { width: 100%; margin-top: .5rem; }

@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; align-items: stretch; z-index: 20; }
  .brand, .side-user { display: none; }
  .side nav { flex-direction: row; overflow-x: auto; padding: 0; width: 100%; }
  .side nav a { flex: 1 0 auto; flex-direction: column; gap: .2rem; font-size: .7rem; padding: .5rem .6rem; border-left: 0; border-top: 3px solid transparent; }
  .side nav a.active { border-top-color: var(--rouge); }
  .main { padding: 1rem 1rem 6rem; }
  .table { display: block; overflow-x: auto; }
  .week { grid-template-columns: 1fr; }
}

/* Planning : sélecteur de vue, mois, année */
.seg { display: inline-flex; border: 2px solid var(--bitume); }
.seg a { padding: .4rem .8rem; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1rem; }
.seg a.on { background: var(--bitume); color: var(--blanc); }
.assign.absent li { background: #fdecea; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.month-head { font-family: var(--display); font-weight: 700; padding: .3rem .4rem; }
.cell { display: block; background: var(--blanc); min-height: 6.5rem; padding: .3rem .4rem; text-decoration: none; color: inherit; border-top: 3px solid var(--gravier-2); font-size: .8rem; }
.cell:hover { border-top-color: var(--bitume); }
.cell.out { opacity: .4; }
.cell.today { border-top-color: var(--rouge); }
.cell .n { display: block; font-family: var(--display); font-weight: 700; font-size: 1rem; margin-bottom: .2rem; }
.pill { display: block; background: var(--gravier); padding: .1rem .35rem; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill small { color: var(--gris); }
.pill.abs { background: #fdecea; color: var(--rouge); }
.table-wrap { overflow-x: auto; }
.table.year td.bar { background: #dff2e5; }
.table.year td.bar-abs { background: #fdecea; }
.table.year th a { text-decoration: none; }
@media (max-width: 720px) { .month { grid-template-columns: repeat(7, minmax(0, 1fr)); } .cell { min-height: 3.5rem; font-size: .65rem; } .pill { display: none; } .cell .n { margin: 0; } }
