/* Flat black — thème sombre neutre. La profondeur vient de la luminosité des
   surfaces (fond < panneau < surface élevée), jamais de dégradés ni de teinte
   bleue. L'accent est monochrome (blanc cassé) : boutons principaux et onglets
   actifs sont « inversés » (fond clair, texte noir). Les couleurs vert/jaune/
   rouge restent réservées à l'information (couverture, alertes). L'impression
   A4 a son propre style clair : ce thème ne concerne que l'écran. */

:root {
    color-scheme: dark;

    --bg: #0d0d0d;             /* fond de page */
    --panel: #171717;          /* panneaux, cartes */
    --raised: #242424;         /* surfaces élevées : en-têtes, hover, boutons */
    --field: #131313;          /* champs de saisie */
    --border: #2a2a2a;
    --border-strong: #3d3d3d;

    --text: #f2f2f2;
    --muted: #9a9a9a;

    --accent: #f2f2f2;         /* accent monochrome : blanc cassé */
    --accent-strong: #ffffff;
    --on-accent: #000000;      /* texte posé sur l'accent (fond clair) */
    --danger: #ff6b6b;

    --ok-bg: #16301f;
    --ok-text: #5fd08d;
    --warn-bg: #322610;
    --warn-text: #f0b45c;
    --err-bg: #3a1c1e;
    --err-text: #ff8a8a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

h1 { font-size: 1.5rem; margin: 1.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

.muted { color: var(--muted); }

code {
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.9em;
}

/* ---- Barre du haut ---- */
.topbar {
    background: #17181b;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-height: 54px;
}
.brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}
.topbar nav {
    display: flex;
    gap: 0.3rem;
    flex: 1;
}
.topbar nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}
.topbar nav a:hover { background: var(--raised); color: var(--text); }
.topbar nav a.active { background: var(--raised); color: var(--text); font-weight: 600; }
.logout-form { margin: 0; }
.btn-link {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
}
.btn-link:hover { background: var(--raised); color: var(--text); }

/* ---- Contenu ---- */
.content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* ---- Sous-navigation (2e niveau) ---- */
.subnav {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin: 1rem 0 0.2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}
.subnav a {
    text-decoration: none;
    color: var(--muted);
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.92rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.subnav a:hover { background: var(--raised); color: var(--text); }
.subnav a.active { background: var(--raised); color: var(--text); font-weight: 600; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}

.cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.5rem;
}
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem 1.4rem;
    min-width: 160px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: border-color 0.15s, background 0.15s;
}
.card:hover { border-color: var(--accent); background: var(--raised); color: var(--text); }
.card-title { font-weight: 600; }
.card-number { font-size: 2rem; font-weight: 700; color: var(--accent); }

/* ---- Tableau de bord (accueil) ---- */
.dash-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.2rem;
}
.dash-head h1 { margin: 0; }
.dash-date {
    color: var(--muted);
    font-size: 0.9rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
}
.dash-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8rem;
    margin: 1.2rem 0 0.4rem;
}
.dash-stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-top: 3px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
}
.dash-stat .n { display: block; font-size: 2rem; font-weight: 800; line-height: 1.05; }
.dash-stat .l { color: var(--muted); font-size: 0.8rem; }
/* Accent sémantique par tuile (haut coloré + chiffre coloré). */
.dash-present { border-top-color: var(--ok-text); }
.dash-present .n { color: var(--ok-text); }
.dash-avenir  { border-top-color: var(--accent); }
.dash-pause   { border-top-color: var(--warn-text); }
.dash-pause .n { color: var(--warn-text); }
.dash-termine { border-top-color: var(--muted); }
.dash-termine .n { color: var(--muted); }
.dash-absent  { border-top-color: var(--err-text); }
.dash-absent .n { color: var(--err-text); }
.dash-note { font-size: 0.85rem; margin: 0.7rem 0 0; }
.dash-absents {
    margin: 0.9rem 0 0;
    padding: 0.6rem 0.9rem;
    background: var(--err-bg);
    border-radius: 8px;
    color: var(--err-text);
}
.dash-absents strong { color: var(--err-text); }
.dash-empty {
    text-align: center;
    padding: 1.8rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
}
.dash-empty-title { font-weight: 600; font-size: 1.05rem; margin-bottom: 0.3rem; }
/* Disposition 2 colonnes : Planning du jour (large) | Informations importantes. */
.dash-cols {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.2rem;
    align-items: stretch;
}
.dash-cols .panel { margin-bottom: 0; }
@media (max-width: 900px) {
    .dash-cols { grid-template-columns: 1fr; }
}
.status {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}
.status-present { background: var(--ok-bg); color: var(--ok-text); }
.status-avenir  { background: var(--raised); color: var(--text); border: 1px solid var(--border-strong); }
.status-pause   { background: var(--warn-bg); color: var(--warn-text); }
.status-termine { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.status-absent  { background: var(--err-bg); color: var(--err-text); }
tr.row-now td { background: rgba(255, 255, 255, 0.05); }
tr.row-next td { box-shadow: inset 3px 0 0 var(--accent); }
.team-tag { color: var(--muted); }
.cover-block { margin-bottom: 1rem; }
.cover-block:last-child { margin-bottom: 0; }
.cover-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.3rem; }
.cover-list { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.9rem; }
.cover-list li { margin: 0.15rem 0; }
.cover-list li.cover-good { color: var(--ok-text); }
.cover-list li.cover-bad { color: var(--err-text); font-weight: 600; }

/* ---- Formulaires ---- */
label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}
input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--field);
    color: var(--text);
}
input::placeholder { color: #6a6a6a; }
input:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    border-color: var(--accent);
}
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 150px; }
.form-row .field-narrow { flex: 0 0 150px; min-width: 150px; }
.form-row .field-submit { flex: 0 0 auto; display: flex; gap: 0.5rem; }

/* ---- Boutons ---- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--raised);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--on-accent);
}
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }

/* ---- Tableaux ---- */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 0.4rem 0.6rem;
    border-bottom: 2px solid var(--border-strong);
}
.table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
.table tbody tr:hover { background: var(--raised); }
.row-inactive td { color: #6a6a6a; }
.badge-off {
    background: var(--raised);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.8rem;
}
.col-actions { width: 1%; white-space: nowrap; }
.inline-form { display: inline; }

/* ---- Messages flash ---- */
.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg); color: var(--ok-text); border-color: #1d4a30; }
.flash-error { background: var(--err-bg); color: var(--err-text); border-color: #5c2b2e; }

/* ---- Planning : onglets et barre de semaine ---- */
.tabs {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 1rem;
}
.tabs a {
    padding: 0.45rem 1.2rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border-strong);
    background: var(--panel);
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tabs a:hover { border-color: var(--accent); color: var(--accent-strong); }
.tabs a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.week-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.week-label { font-size: 1.05rem; }
.week-jump { margin: 0; }

/* ---- Planning : grille ---- */
.grid-wrap { overflow-x: auto; padding: 0.6rem; }
.grid-wrap::-webkit-scrollbar { height: 10px; }
.grid-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
.grid-wrap::-webkit-scrollbar-track { background: transparent; }
.grid {
    width: 100%;
    border-collapse: collapse;
}
.grid th, .grid td {
    border: 1px solid var(--border);
}
.grid thead th {
    background: var(--raised);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.45rem 0.5rem;
}
.grid .col-emp {
    text-align: left;
    padding: 0.4rem 0.6rem;
    white-space: nowrap;
    min-width: 120px;
}
.emp-contract {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--muted);
}
td.cell {
    min-width: 92px;
    height: 52px;
    vertical-align: top;
    padding: 3px 6px;
    cursor: pointer;
}
td.cell:hover { background: var(--raised); }
td.cell-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.plage { font-size: 0.85rem; white-space: nowrap; }
.cell-total { font-size: 0.72rem; color: var(--muted); }
/* Absence : hachures très sombres — le pendant écran de la case noircie sur papier */
td.cell-absence {
    background: repeating-linear-gradient(45deg,
        #0a0a0a, #0a0a0a 7px, #161616 7px, #161616 14px);
}
td.cell-absence:hover {
    background: repeating-linear-gradient(45deg,
        #111, #111 7px, #1d1d1d 7px, #1d1d1d 14px);
}
.cell-abs {
    color: #6a6a6a;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 0.5rem;
    text-align: center;
}
td.cell-warn { box-shadow: inset 0 0 0 2px var(--danger); }
.cell-week-total {
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
    padding: 0.3rem 0.5rem;
}
.cell-delta { text-align: center; padding: 0.3rem 0.4rem; }
.delta {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}
.delta-over { background: var(--err-bg); color: var(--err-text); }
.delta-under { background: var(--warn-bg); color: var(--warn-text); }
.delta-ok { background: var(--ok-bg); color: var(--ok-text); }
.row-count td {
    text-align: center;
    font-weight: 700;
    background: var(--raised);
    padding: 0.35rem;
}

/* ---- Planning : règles d'équipe et couverture ---- */
.rules-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
}
.rules-text { color: var(--muted); font-size: 0.88rem; }
.rules-buttons { display: flex; gap: 0.5rem; flex: 0 0 auto; }
.row-cover td {
    text-align: center;
    font-size: 0.82rem;
    padding: 0.3rem;
}
.row-cover td.cover-green { background: var(--ok-bg); color: var(--ok-text); font-weight: 700; cursor: help; }
.row-cover td.cover-yellow { background: var(--warn-bg); color: var(--warn-text); font-weight: 700; cursor: help; }
.row-cover td.cover-red { background: var(--err-bg); color: var(--err-text); font-weight: 700; cursor: help; }
.row-cover td.cover-empty { background: var(--panel); color: #5b6478; }
.legend { margin-top: 0.8rem; }
.legend-warn {
    border: 2px solid var(--danger);
    border-radius: 4px;
    padding: 0 0.3rem;
}

/* ---- Planning : éditeur de journée ---- */
.editor {
    position: absolute;
    z-index: 50;
    background: var(--raised);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    width: 320px;
}
.editor-title { font-weight: 700; margin-bottom: 0.5rem; }
.check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.check input { width: auto; accent-color: var(--accent); }
.ed-times {
    border: none;
    padding: 0;
    margin: 0 0 0.5rem;
}
.ed-times:disabled { opacity: 0.45; }
.ed-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.35rem 0;
}
.ed-row > span:first-child {
    width: 86px;
    font-size: 0.85rem;
    font-weight: 600;
}
.ed-sep { color: var(--muted); }
.ed-row input[type="time"] { flex: 1; padding: 0.3rem 0.4rem; }
.editor-error {
    background: var(--err-bg);
    color: var(--err-text);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.editor-actions { display: flex; gap: 0.5rem; }

/* ---- Page de connexion ---- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem 2.2rem;
    width: 100%;
    max-width: 380px;
}
.login-card .brand {
    display: block;
    text-align: center;
    color: var(--text);
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}
.login-card h2 {
    text-align: center;
    font-size: 1rem;
    color: var(--muted);
    font-weight: 600;
}
.login-card label { margin-top: 1rem; }
.login-card .btn-block { margin-top: 1.4rem; }
.login-alt { text-align: center; margin: 0.9rem 0 0; font-size: 0.9rem; }

/* ---- Congés payés ---- */
.cp-table thead th { white-space: nowrap; }
.cp-week-date {
    display: block;
    font-weight: 400;
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}
td.cp-cell {
    min-width: 56px;
    height: 34px;
    text-align: center;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}
td.cp-cell:hover { background: var(--raised); }
td.cp-cell.cp-set { background: var(--warn-bg); color: var(--warn-text); font-weight: 700; }
.cp-team-row th {
    background: var(--raised);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.cp-days-list { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.5rem; }
.cp-days-list .check { margin-bottom: 0.15rem; font-weight: 400; }

/* ---- Aperçu par tranches de 15 minutes ---- */
.tl-day { padding: 0.9rem 1.1rem; }
.tl-day h2 { margin-bottom: 0.6rem; }
.tl-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 3px 0;
}
.tl-name {
    flex: 0 0 110px;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-name-abs { color: #6a6a6a; text-decoration: line-through; }
.tl-count-label { font-weight: 700; }
.tl-scale { position: relative; flex: 1; height: 16px; }
.tl-hour {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--muted);
}
.tl-track {
    position: relative;
    flex: 1;
    height: 18px;
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.tl-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; }
.tl-abs {
    position: absolute;
    left: 8px;
    top: 0;
    font-size: 0.7rem;
    color: #6a6a6a;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 18px;
}
.tl-counts {
    display: flex;
    flex: 1;
    height: 14px;
    gap: 1px;
    border-radius: 4px;
    overflow: hidden;
}
.tl-seg { flex: 1; cursor: help; }
.tl-n0 { background: #242424; }
.tl-n1 { background: #8a3c3c; }
.tl-n2 { background: #8a6d2f; }
.tl-n3 { background: #2f6b46; }
.tl-n4 { background: #57d189; }

/* ---- Page Employés : binômes et options ---- */
.check-plain { font-weight: 400; margin: 0.55rem 0 0; }
.pairs-title { font-size: 0.95rem; margin: 1.2rem 0 0.4rem; }
.pairs-list {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0.8rem;
}
.pairs-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

/* ---- Onglet Commandes : cadencier (accordéon fournisseurs) ---- */
.cad-title { margin-top: 1.5rem; }
details.supplier {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.6rem;
    overflow: hidden;
}
details.supplier[open] { border-color: var(--border-strong); }
details.supplier > summary {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
details.supplier > summary::-webkit-details-marker { display: none; }
details.supplier > summary::before {
    content: "▸";
    color: var(--muted);
    transition: transform 0.15s ease;
}
details.supplier[open] > summary::before { transform: rotate(90deg); }
details.supplier > summary:hover { background: var(--raised); }
.sup-name { font-weight: 700; }
.sup-cat {
    font-size: 0.78rem;
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.05rem 0.55rem;
    color: var(--muted);
}
.sup-meta { color: var(--muted); font-size: 0.9rem; }
.sup-count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.supplier-body { padding: 0.2rem 1rem 1rem; }
.supplier-delete { margin-top: 0.6rem; display: block; }

/* ---- Page Sécurité (double authentification) ---- */
.setup-steps li { margin: 0.45rem 0; }
.totp-secret {
    display: inline-block;
    background: var(--field);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    margin-top: 0.2rem;
    user-select: all;
    color: var(--text);
}
