@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Karla:wght@400;500;600;700&display=swap');

:root {
    --vert-foret: #1F3B2E;
    --vert-sauge: #6E8C74;
    --ivoire: #FAF8F2;
    --ivoire-fonce: #F0EBDE;
    --ocre: #B8874B;
    --ocre-clair: #E4C79A;
    --charbon: #23281F;
    --brique: #A64B3F;
    --ligne: #DCD5C4;
    --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ivoire);
    color: var(--charbon);
    font-family: 'Karla', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    margin: 0 0 0.4em 0;
    line-height: 1.15;
    color: var(--vert-foret);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

a { color: var(--vert-foret); }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---- Barre latérale ---- */
.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--vert-foret);
    color: var(--ivoire);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
}

.sidebar .marque {
    font-family: 'Fraunces', serif;
    font-size: 1.3rem;
    color: var(--ivoire);
    margin-bottom: 4px;
}

.sidebar .marque span {
    display: block;
    font-family: 'Karla', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    color: var(--ocre-clair);
    margin-top: 2px;
}

.sidebar nav {
    margin-top: 34px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.sidebar nav a {
    color: var(--ivoire);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    border-left: 2px solid transparent;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.06);
}

.sidebar nav a.actif {
    border-left: 2px solid var(--ocre);
    background: rgba(255,255,255,0.08);
    font-weight: 600;
}

.nav-titre {
    margin: 14px 0 2px;
    padding: 0 12px;
    font-family: 'Karla', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ocre-clair);
    opacity: 0.75;
}

.nav-titre:first-of-type { margin-top: 8px; }

.sidebar .pied {
    font-size: 0.82rem;
    color: var(--vert-sauge);
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 14px;
}

.sidebar .pied a { color: var(--ocre-clair); }

/* ---- Recherche globale (barre latérale) ---- */
.recherche-globale { margin-top: 16px; }
.recherche-globale input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.08);
    color: var(--ivoire);
    font-family: 'Karla', sans-serif;
    font-size: 0.88rem;
}
.recherche-globale input::placeholder { color: rgba(250,248,242,0.55); }
.recherche-globale input:focus {
    outline: none;
    border-color: var(--ocre);
    background: rgba(255,255,255,0.12);
}

/* ---- Bouton hamburger (mobile uniquement) ---- */
.sidebar-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 34px;
    height: 34px;
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--ivoire);
}

/* ---- Contenu principal ---- */
.contenu {
    flex-grow: 1;
    min-width: 0;
    padding: 36px 44px;
    max-width: 1000px;
}

.entete-page {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 10px;
}

.sous-titre {
    color: var(--vert-sauge);
    margin-bottom: 28px;
    font-size: 0.98rem;
}

/* ---- Boutons ---- */
.btn {
    display: inline-block;
    background: var(--vert-foret);
    color: var(--ivoire);
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-family: 'Karla', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: #16291f; }

.btn-ocre { background: var(--ocre); color: var(--charbon); }
.btn-ocre:hover { background: #a3763d; }

.btn-discret {
    background: none;
    color: var(--vert-foret);
    border: 1px solid var(--ligne);
}
.btn-discret:hover { border-color: var(--vert-foret); }

.btn-danger { background: var(--brique); }
.btn-danger:hover { background: #8a3c31; }

.btn-petit { padding: 5px 12px; font-size: 0.82rem; }

/* ---- Sections structurées par lignes, pas par cartes flottantes ---- */
.bloc {
    border-top: 1px solid var(--ligne);
    padding: 22px 0;
}

.bloc:first-child { border-top: none; padding-top: 0; }

/* ---- Bandeau de statistiques ---- */
.stats {
    display: flex;
    gap: 0;
    border: 1px solid var(--ligne);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 30px;
}

.stats .stat {
    flex: 1;
    padding: 18px 20px;
    border-right: 1px solid var(--ligne);
}
.stats .stat:last-child { border-right: none; }

.stats .valeur {
    font-family: 'Fraunces', serif;
    font-size: 2rem;
    color: var(--vert-foret);
    display: block;
}

.stats .libelle {
    font-size: 0.85rem;
    color: var(--vert-sauge);
}

/* ---- Tableaux ---- */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Agenda (calendrier mensuel) ---- */
.agenda-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.agenda-grille {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 6px;
    min-width: 780px;
}
.agenda-entete-jour {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--vert-sauge);
    padding-bottom: 4px;
    text-transform: uppercase;
}
.agenda-case {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 86px;
    padding: 6px 8px;
    border: 1px solid var(--ligne);
    border-radius: var(--radius);
    background: var(--ivoire);
}
.agenda-case-vide { border: none; background: transparent; }
.agenda-numero-lien { text-decoration: none; display: block; }
.agenda-numero { font-weight: 700; font-size: 0.9rem; color: var(--charbon); }
.agenda-numero-lien:hover .agenda-numero { color: var(--ocre); }
.agenda-aujourdhui { border-color: var(--ocre); border-width: 2px; }
.agenda-selectionne { background: var(--ivoire-fonce); box-shadow: inset 0 0 0 2px var(--vert-foret); }
.agenda-apercu {
    display: block;
    font-size: 0.72rem;
    color: var(--vert-foret);
    background: var(--ivoire-fonce);
    border-radius: 4px;
    padding: 1px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}
.agenda-apercu:hover { background: var(--vert-foret); color: var(--ivoire); }
.agenda-plus { color: var(--vert-sauge); background: none; padding: 0; }
.agenda-plus:hover { background: none; color: var(--ocre); }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--vert-sauge);
    border-bottom: 1px solid var(--ligne);
    padding: 8px 10px;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--ligne);
    font-size: 0.94rem;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

/* Colonne d'actions fixée à droite dans les tableaux à défilement horizontal,
   pour que les boutons restent toujours accessibles sur les listes larges */
.table-scroll table td:last-child,
.table-scroll table th:last-child {
    position: sticky;
    right: 0;
    background: var(--ivoire);
    box-shadow: -6px 0 6px -6px rgba(35,40,31,0.18);
}

/* ---- Étiquettes de statut ---- */
.etiquette {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.etiquette-a_contacter { background: var(--ivoire-fonce); color: var(--charbon); }
.etiquette-contacte { background: #DCE7DC; color: var(--vert-foret); }
.etiquette-rdv_planifie { background: #EBDDBB; color: #6b501f; }
.etiquette-client { background: var(--vert-foret); color: var(--ivoire); }
.etiquette-partenaire { background: var(--ocre); color: var(--charbon); }
.etiquette-perdu { background: #EAD9D6; color: var(--brique); }

/* ---- Urgence des relances ---- */
.relance-retard { color: var(--brique); font-weight: 700; }
.relance-aujourdhui { color: var(--ocre); font-weight: 700; }

/* ---- Formulaires ---- */
.champ { margin-bottom: 18px; max-width: 440px; }

.champ label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--vert-foret);
}

.champ input,
.champ select,
.champ textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--ligne);
    border-radius: var(--radius);
    font-family: 'Karla', sans-serif;
    font-size: 0.95rem;
    background: white;
    color: var(--charbon);
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
    outline: 2px solid var(--ocre);
    outline-offset: 1px;
    border-color: var(--ocre);
}

.champ-ligne { display: flex; gap: 16px; flex-wrap: wrap; }
.champ-ligne .champ { flex: 1; min-width: 180px; }

.aide { font-size: 0.82rem; color: var(--vert-sauge); margin-top: 4px; }

.alerte {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.92rem;
}
.alerte-succes { background: #DCE7DC; color: var(--vert-foret); }
.alerte-erreur { background: #EAD9D6; color: var(--brique); }
.alerte-info { background: var(--ivoire-fonce); color: var(--charbon); }

/* ---- Fiches produit ---- */
.fiche-produit {
    border: 1px solid var(--ligne);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.fiche-produit .categorie {
    color: var(--ocre);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

/* ---- Plan d'action ---- */
.tache-jour {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-top: 1px solid var(--ligne);
}
.tache-jour:first-child { border-top: none; }
.tache-jour .jour-num {
    font-family: 'Fraunces', serif;
    font-size: 1.3rem;
    color: var(--ocre);
    width: 46px;
    flex-shrink: 0;
    text-align: right;
}
.tache-jour.fait .jour-num,
.tache-jour.fait h4 { color: var(--vert-sauge); }
.tache-jour.fait p { color: var(--vert-sauge); }

.barre-progression {
    height: 8px;
    background: var(--ivoire-fonce);
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0 24px 0;
}
.barre-progression div {
    height: 100%;
    background: var(--ocre);
}

@media (max-width: 780px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; padding: 16px 20px; }
    .menu-toggle { display: flex; }
    .sidebar nav, .sidebar .pied { display: none; }
    .sidebar.menu-ouvert nav { display: flex; margin-top: 16px; }
    .sidebar.menu-ouvert .pied { display: block; margin-top: 14px; }
    .contenu { padding: 22px 16px; }

    h1 { font-size: 1.55rem; }
    h2 { font-size: 1.25rem; }

    /* Bandeau de statistiques : 2 colonnes au lieu d'une rangée qui déborde */
    .stats {
        flex-wrap: wrap;
        margin-bottom: 22px;
    }
    .stats .stat {
        flex: 1 1 50%;
        min-width: 0;
        padding: 14px 12px;
        border-bottom: 1px solid var(--ligne);
        border-right: 1px solid var(--ligne);
    }
    .stats .stat:nth-child(2n) { border-right: none; }
    .stats .valeur { font-size: 1.5rem; }
    .stats .libelle { font-size: 0.78rem; }

    /* Tableaux : on autorise le défilement horizontal plutôt que de casser la mise en page */
    .table-scroll { margin: 0 -16px; padding: 0 16px; }
    .table-scroll table { width: auto; min-width: 100%; }
    .table-scroll td, .table-scroll th { white-space: nowrap; }
    .table-scroll td.deborde, .table-scroll th.deborde { white-space: normal; }

    /* Boutons : espacement plus confortable au doigt */
    .btn { margin: 0 6px 8px 0; }
    form .btn:last-of-type { margin-right: 0; }

    /* Formulaires : les champs prennent toute la largeur disponible */
    .champ, .champ-ligne .champ { min-width: 0; }

    /* Fiches produits et blocs : on évite les débordements de texte */
    .fiche-produit { padding: 18px 16px; }
}

@media (max-width: 420px) {
    .stats .stat { flex: 1 1 100%; border-right: none; }
    .stats .stat:last-child { border-bottom: none; }
    h1 { font-size: 1.4rem; }
}

