:root {
    --navy: #16213e;
    --navy-700: #1f3864;
    --blue: #2f6fed;
    --blue-light: #eaf1fe;
    --success: #16a34a;
    --success-bg: #e7f6ec;
    --warning: #b45309;
    --warning-bg: #fef3e0;
    --danger: #dc2626;
    --danger-bg: #fde8e8;
    --neutral: #56617a;
    --neutral-bg: #eef1f6;
    --bg: #f3f5fa;
    --surface: #ffffff;
    --border: #e4e8f0;
    --text: #1c2536;
    --text-muted: #6b7386;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.06);
    --shadow-md: 0 4px 16px rgba(20, 30, 60, 0.08);
    --shadow-lg: 0 12px 32px rgba(20, 30, 60, 0.14);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); }

/* --- Mise en page : barre latérale + contenu --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 244px;
    background: linear-gradient(180deg, var(--navy) 0%, #101a33 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 40;
    /* Seule la liste des entrées défile : le bloc utilisateur reste visible. */
    overflow: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    font-size: 1rem;
    color: #fff;
    text-decoration: none;
    padding: 1.15rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.sidebar-brand::before {
    content: "";
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #ffd166;
    box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.2);
    flex: 0 0 auto;
}

.sidebar-nav { flex: 1; padding: 0.7rem 0.6rem; overflow-y: auto; }
.nav-section {
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.38);
    padding: 0.9rem 0.7rem 0.35rem;
}
.sidebar-nav a,
.sidebar-foot a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.76);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-nav a svg,
.sidebar-foot a svg { width: 18px; height: 18px; stroke: currentColor; flex: 0 0 auto; }
.sidebar-nav a:hover,
.sidebar-foot a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #ffd166;
}

.sidebar-foot {
    padding: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}
.sidebar-user span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-user strong { font-size: 0.88rem; font-weight: 700; }
.sidebar-user small { font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 18, 34, 0.55);
    z-index: 35;
}

.app { min-height: 100vh; }
body.has-sidebar .app { margin-left: 244px; }

/* --- Barre supérieure --- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 1.4rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-brand { display: none; font-weight: 800; color: var(--navy-700); text-decoration: none; }
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--navy-700);
    padding: 0.4rem;
    border-radius: 8px;
    box-shadow: none;
    cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: currentColor; display: block; }

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 440px;
    margin: 0;
}
.topbar-search svg {
    position: absolute;
    left: 0.7rem; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    stroke: var(--text-muted);
    pointer-events: none;
}
.topbar-search input {
    width: 100%;
    padding: 0.5rem 0.8rem 0.5rem 2.2rem;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.88rem;
}
.topbar-search input:focus { background: var(--surface); }

/* --- Layout --- */
.content { max-width: 1180px; margin: 0 auto; padding: 1.8rem 1.4rem 3rem; }
h1 { color: var(--navy-700); font-size: 1.55rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { color: var(--navy-700); font-size: 1.05rem; font-weight: 700; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

/* --- Terrain : itinéraire, contact, photos --- */
.link-map {
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    margin-left: 0.4rem;
}
.link-map::before { content: "➜ "; }

.field-contact {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.field-contact .actions-row { margin-top: 0; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.9rem;
}
.photo-item {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.photo-item img {
    display: block;
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: var(--neutral-bg);
}
.photo-item figcaption {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
}
.photo-item figcaption small { font-size: 0.72rem; }
.photo-delete { padding: 0.3rem 0.5rem; font-size: 0.75rem; align-self: flex-start; }

/* --- Layout --- */
.content { max-width: 1100px; margin: 0 auto; padding: 1.8rem 1.2rem 3rem; }
h1 { color: var(--navy-700); font-size: 1.55rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { color: var(--navy-700); font-size: 1.05rem; font-weight: 700; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

/* --- Forms --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); gap: 0.35rem; }
input, select, textarea, button {
    font: inherit;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}
button {
    background: var(--blue);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 0.7rem 1.1rem;
    grid-column: 1 / -1;
    justify-self: start;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--navy-700); }
button:active { transform: translateY(1px); }

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; min-width: 700px; }
.table th, .table td {
    text-align: left;
    padding: 0.7rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.table th {
    color: var(--text-muted);
    background: transparent;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
}
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: #f8faff; }
.actions-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.inline-form select { min-width: 120px; }

/* --- Login --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 20% 20%, #24345f 0%, var(--navy) 55%, #0d1526 100%);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    padding: 1rem;
}
.login-box {
    background: var(--surface);
    padding: 2.2rem;
    border-radius: 18px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}
.login-box h1 {
    margin: 0 0 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.login-box h1::before {
    content: "⚡";
    font-size: 1.3rem;
}
.login-sub { color: var(--text-muted); margin-top: 0; margin-bottom: 1.4rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.9rem; }
.login-box button { width: 100%; padding: 0.75rem; }
.error {
    color: var(--danger);
    background: var(--danger-bg);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.success {
    color: var(--success);
    background: var(--success-bg);
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.btn-secondary {
    background: var(--surface);
    color: var(--blue);
    border: 1px solid var(--blue);
    box-shadow: none;
}
.btn-secondary:hover { background: var(--blue-light); }
a.btn-secondary {
    display: inline-block;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.signature-pad {
    display: block;
    width: 100%;
    max-width: 600px;
    height: 180px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #fbfcfe;
    touch-action: none;
}
.signature-actions { margin-top: 0.4rem; }
.signature-actions button { grid-column: auto; }

/* --- Dashboard --- */
.muted { color: var(--text-muted); font-weight: 500; }

.stat-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 1.9rem; font-weight: 800; color: var(--navy-700); letter-spacing: -0.02em; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-top: 0.15rem; }

.stat-row-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .stat-row-4 { grid-template-columns: repeat(4, 1fr); } }

/* --- Badges (statuts) --- */
.badge, .status-chip, .intervention-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    background: var(--neutral-bg);
    color: var(--neutral);
    white-space: nowrap;
    line-height: 1.3;
}
.badge::before, .status-chip::before, .intervention-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}
.badge-success, .status-chip.status-a_facturer, .status-chip.status-facture,
.intervention-status.status-a_facturer, .intervention-status.status-facture {
    background: var(--success-bg); color: var(--success);
}
.badge-warning, .status-chip.status-en_cours, .intervention-status.status-en_cours {
    background: var(--warning-bg); color: var(--warning);
}
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--blue-light); color: var(--blue); }

.status-breakdown { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.intervention-list { display: flex; flex-direction: column; gap: 0.7rem; }
.intervention-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.9rem;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.intervention-item:hover { box-shadow: var(--shadow-sm); border-color: #d3dcf0; }
.intervention-time {
    font-weight: 700;
    color: var(--navy-700);
    white-space: nowrap;
    font-size: 0.88rem;
    background: var(--blue-light);
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-sm);
}
.intervention-main { flex: 1; min-width: 0; }
.intervention-client { font-weight: 700; color: var(--text); }
.intervention-address, .intervention-employee { font-size: 0.83rem; color: var(--text-muted); }
.intervention-cerfa-link {
    font-size: 0.8rem;
    color: var(--blue);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    white-space: nowrap;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.intervention-cerfa-link:hover { background: var(--blue-light); border-color: var(--blue); }
.intervention-cerfa-link.is-done {
    background: var(--success-bg);
    color: var(--success);
    border-color: transparent;
}
.intervention-cerfa-link.is-done:hover { border-color: var(--success); }
a.badge { text-decoration: none; }
a.badge:hover { filter: brightness(0.95); }

.password-callout { border: 2px solid var(--warning); background: var(--warning-bg); }
.temp-password {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--navy-700);
    background: var(--surface);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    user-select: all;
}
.intervention-links { display: flex; flex-direction: column; gap: 0.3rem; }
.actions-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.8rem; }
.actions-row form { margin: 0; }
.actions-row button { padding: 0.6rem 1rem; }

.btn-block {
    display: block;
    text-align: center;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease;
}
.btn-block:hover { background: var(--navy-700); }

/* --- Cases à cocher (équipe) --- */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.checkbox-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.45rem 0.9rem 0.45rem 0.7rem;
    cursor: pointer;
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.checkbox-item:hover { border-color: var(--emp, var(--blue)); }
.checkbox-item input { width: 1.05rem; height: 1.05rem; accent-color: var(--emp, var(--blue)); margin: 0; }
.checkbox-item:has(input:checked) {
    background: color-mix(in srgb, var(--emp, #2f6fed) 12%, white);
    border-color: var(--emp, var(--blue));
    color: var(--emp, var(--blue));
}

/* --- Contrôles de conformité --- */
.check-list { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
.check-item {
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    background: var(--surface);
}
.check-item.is-ko { border-left-color: var(--danger); background: #fffafa; }
.check-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; }
.check-item p { margin: 0.2rem 0 0; font-size: 0.9rem; }
.check-problems { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; }
.check-problems li { margin-bottom: 0.2rem; }
.audit-meta { font-size: 0.8rem; color: var(--text-muted); max-width: 26rem; }

/* --- Choix du mode (facturation) --- */
.mode-choices { display: flex; flex-direction: column; gap: 0.7rem; }
.mode-choice {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
    cursor: pointer;
    background: var(--surface);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.mode-choice:hover { border-color: var(--blue); }
.mode-choice input { margin: 0.15rem 0 0; width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }
.mode-choice span { display: flex; flex-direction: column; gap: 0.15rem; }
.mode-choice strong { color: var(--text); font-weight: 700; }
.mode-choice small { color: var(--text-muted); font-weight: 500; line-height: 1.4; }
.mode-choice:has(input:checked) { border-color: var(--blue); background: var(--blue-light); }
.mode-choice:has(input:checked) strong { color: var(--blue); }

/* --- Totaux de facture --- */
.invoice-totals {
    margin-top: 1.2rem;
    margin-left: auto;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.invoice-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.92rem;
    color: var(--text-muted);
}
.invoice-totals strong { color: var(--text); }
.invoice-totals .grand {
    border-top: 2px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.2rem;
    font-size: 1.1rem;
    color: var(--navy-700);
}
.invoice-totals .grand strong { color: var(--navy-700); font-weight: 800; }

.required-mark {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#lines-table input { width: 100%; }
#lines-table td { vertical-align: middle; }
.remove-line { padding: 0.35rem 0.6rem; }

/* --- Alerte --- */
.warning {
    color: var(--warning);
    background: var(--warning-bg);
    border-left: 4px solid var(--warning);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* --- Bascule Liste / Calendrier --- */
.view-switch {
    display: inline-flex;
    background: var(--neutral-bg);
    border-radius: 999px;
    padding: 0.25rem;
    margin-bottom: 1.2rem;
    gap: 0.25rem;
}
.view-switch a {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.88rem;
}
.view-switch a.active { background: var(--surface); color: var(--navy-700); box-shadow: var(--shadow-sm); }

/* --- Calendrier --- */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}
.cal-modes { display: inline-flex; background: var(--neutral-bg); border-radius: 999px; padding: 0.25rem; gap: 0.25rem; }
.cal-modes a {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}
.cal-modes a.active { background: var(--surface); color: var(--navy-700); box-shadow: var(--shadow-sm); }

.cal-nav { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.cal-title { flex: 1; text-align: center; color: var(--navy-700); font-size: 1.05rem; }

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.cal-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cal-col.is-today { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.15); }
.cal-col-head {
    padding: 0.45rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #fafbfe;
}
.cal-col-head a { color: inherit; text-decoration: none; }
.cal-col-head strong { color: var(--navy-700); font-size: 0.95rem; }
.cal-col-body { padding: 0.4rem; display: flex; flex-direction: column; gap: 0.35rem; }

.cal-entry {
    border-left: 3px solid var(--neutral);
    background: var(--neutral-bg);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
}
.cal-entry-time { font-weight: 700; color: var(--navy-700); }
.cal-entry-client { font-weight: 600; }
.cal-entry-client a { color: inherit; text-decoration: none; }
.cal-entry-client a:hover { text-decoration: underline; }
.cal-entry-meta { color: var(--text-muted); font-size: 0.74rem; }
.cal-entry.is-conflict { outline: 2px solid var(--danger); outline-offset: -2px; }

.cal-day-list { display: flex; flex-direction: column; gap: 0.6rem; }
.cal-day-list .cal-entry { font-size: 0.9rem; padding: 0.7rem 0.8rem; }

.cal-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}
.cal-month-head {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.3rem 0;
}
.cal-month-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 92px;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.cal-month-cell.is-today { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.15); }
.cal-month-cell.is-outside { background: #fafbfd; opacity: 0.6; }
.cal-month-day { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.cal-month-day a { color: inherit; text-decoration: none; }

.cal-chip {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.18rem 0.35rem;
    border-radius: 4px;
    text-decoration: none;
    background: var(--neutral-bg);
    color: var(--neutral);
    border-left: 3px solid var(--neutral);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-chip.is-conflict { outline: 1.5px solid var(--danger); }

/* Couleurs d'équipe : la bande de gauche est découpée par salarié affecté */
.cal-entry {
    border-left: none;
    position: relative;
    padding-left: 0.75rem;
    background: color-mix(in srgb, var(--tint, #56617a) 8%, white);
    color: var(--tint, #56617a);
}
.cal-entry::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 6px 0 0 6px;
    background: var(--stripe, #56617a);
}
.cal-entry .cal-entry-client, .cal-entry .cal-entry-time { color: inherit; }

.cal-chip {
    border-left: none;
    padding-left: 0.5rem;
    background-color: color-mix(in srgb, var(--tint, #56617a) 10%, white);
    background-image: var(--stripe, none);
    background-size: 3px 100%;
    background-repeat: no-repeat;
    background-position: left center;
    color: var(--tint, #56617a);
}

/* Pastille colorée devant chaque nom de salarié */
.team-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    margin-right: 0.5rem;
    white-space: nowrap;
}
.team-dot i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
.cal-entry-team { display: flex; flex-wrap: wrap; gap: 0.1rem; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.15rem; }
.cal-entry-team .team-dot { color: var(--text-muted); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.cal-legend-item {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    border-left: 4px solid var(--emp);
    background: color-mix(in srgb, var(--emp) 10%, white);
    color: var(--emp);
}

@media (max-width: 800px) {
    .cal-week { grid-template-columns: 1fr; }
    .cal-col { min-height: 0; }
    .cal-col-head { text-align: left; padding-left: 0.7rem; }
    .cal-month { gap: 0.2rem; }
    .cal-month-cell { min-height: 62px; padding: 0.2rem; }
    .cal-month-head { font-size: 0.65rem; }
    .cal-chip { font-size: 0.6rem; }
    .cal-title { flex-basis: 100%; order: -1; margin-bottom: 0.4rem; }
}

/* --- Barre du bas (mobile) --- */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 30;
    box-shadow: 0 -2px 10px rgba(20, 30, 60, 0.06);
}
.bottom-nav a,
.bottom-more {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.2rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
}
.bottom-nav svg { width: 21px; height: 21px; stroke: currentColor; }
.bottom-nav a.active { color: var(--blue); }

/* --- Sous 1000 px : la barre latérale devient un panneau coulissant --- */
@media (max-width: 1000px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
        width: min(280px, 82vw);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.has-sidebar .app { margin-left: 0; }

    .nav-toggle { display: block; }
    .topbar-brand { display: block; }
    .topbar-search { max-width: none; }
}

@media (min-width: 1001px) {
    .sidebar-overlay { display: none !important; }
}

/* --- Mobile breakpoint --- */
@media (max-width: 640px) {
    .content { padding: 1.2rem 1rem 5.5rem; }
    .topbar { padding: 0.6rem 0.9rem; gap: 0.6rem; }
    .topbar-brand { font-size: 0.95rem; }

    .bottom-nav { display: flex; }

    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table { min-width: 0; }
    .table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 0.8rem;
        padding: 0.5rem 0.7rem;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    .table td {
        border-bottom: none;
        padding: 0.4rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.6rem;
        text-align: right;
    }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
    }
    .table td.actions-cell { display: block; }
    .table td.actions-cell::before { display: block; margin-bottom: 0.4rem; }
    .table td.actions-cell {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.4rem;
    }
    .table td.actions-cell::before { flex-basis: 100%; text-align: left; }
    .actions-cell form { margin: 0; }
    .actions-cell .btn-secondary, .actions-cell button { width: auto; }

    .intervention-item { flex-wrap: wrap; }
    .intervention-main { flex-basis: 100%; order: 1; }
    .intervention-time { order: 0; }
    .intervention-status { order: 2; }
    .intervention-links { order: 3; flex-direction: row; margin-left: auto; }
}
