*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Poppins', system-ui, sans-serif;
    color: #222;
    background: #f5f5f8;
    font-size: 15px;
}

h1 { font-size: 1.6rem; margin: 0 0 16px; color: var(--primary); }
h2 { font-size: 1.2rem; margin: 28px 0 12px; color: var(--primary); }
a { color: var(--primary); }
.muted { color: #6b6b7b; font-size: 14px; }

/* ---- Layout back-office ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    background: var(--primary);
    color: #fff;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
    color: #fff;
    text-decoration: none;
    padding: 10px 22px;
    border-left: 4px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.1); }
.sidebar nav a.active { border-left-color: var(--accent); background: rgba(255,255,255,.15); font-weight: 600; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 22px 20px; font-weight: 600; font-size: 16px; }
.brand .logo { max-height: 36px; max-width: 120px; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 1px solid #e6e6ee;
}

.content { padding: 28px; }

/* ---- Guest (connexion) ---- */
body.guest { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--primary); }
.guest-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    margin: 16px;
    padding: 32px 28px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.guest-brand { color: var(--primary); padding: 0 0 16px; }

/* ---- Formulaires ---- */
form label { display: block; margin: 12px 0 4px; font-size: 14px; font-weight: 500; }
input, select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #cfcfdb;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
input[type="color"] { width: 80px; height: 40px; padding: 2px; }
input[type="file"] { padding: 6px; }
fieldset { border: 1px solid #e0e0ea; border-radius: 8px; padding: 12px 18px 6px; margin: 0 0 18px; background: #fff; }
legend { font-weight: 600; color: var(--primary); padding: 0 6px; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; max-width: 920px; }
.grid-form > label { margin-top: 12px; }
.grid-form fieldset label { margin: 10px 0 4px; }
.grid-form .form-actions, .grid-form fieldset { grid-column: 1 / -1; }
.form-actions { margin-top: 14px; }

.btn-primary {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 18px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn-small {
    padding: 5px 10px;
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.btn-link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 0; }

.logo-preview { max-height: 60px; }

/* ---- Messages ---- */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; }
.flash-success { background: #e7f7ec; color: #17603a; }
.flash-error { background: #fde8e8; color: #8a1c1c; }

/* ---- Tableaux et cartes ---- */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #eee; font-size: 14px; }
.table th { background: #f0eef7; color: var(--primary); }
.table form { margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    border-top: 4px solid var(--accent);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.card.wide { max-width: 720px; }
.card-label { font-size: 13px; color: #6b6b7b; }
.card-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }

@media (max-width: 760px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; padding: 12px 0; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 8px 12px; font-size: 13px; }
    .sidebar nav a.active { border-bottom-color: var(--accent); }
    .content { padding: 16px; }
}

/* ---- Flotte ---- */
.thumb { width: 56px; height: 40px; object-fit: cover; border-radius: 4px; }
.car-photo { max-width: 220px; border-radius: 8px; }

/* ---- Calendrier et petites cartes ---- */
.card-value.small { font-size: 1.1rem; }
.cal-wrap { overflow-x: auto; background: #fff; border-radius: 8px; }
.cal { border-collapse: collapse; font-size: 13px; }
.cal th, .cal td { border: 1px solid #eee; padding: 6px 8px; min-width: 64px; text-align: center; }
.cal td.busy { background: var(--accent); color: #fff; }
.cal td.busy a { color: #fff; text-decoration: none; }
.cal th:first-child { text-align: left; white-space: nowrap; }

/* ---- Contrats et signatures ---- */
.card textarea, .card select, .card input { margin-bottom: 4px; }
.sig-card { gap: 8px; }
.sig-canvas { width: 100%; max-width: 360px; height: 140px; border: 1px dashed #aaa; border-radius: 6px; background: #fff; touch-action: none; }
.sig-img { max-width: 100%; max-height: 120px; border: 1px solid #eee; background: #fff; border-radius: 6px; }
.sig-form { margin: 0; }

/* ---- Alertes ---- */
.alert-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.alert { padding: 12px 16px; border-radius: 8px; border-left: 4px solid #999; background: #fff; }
.alert a { color: inherit; text-decoration: none; }
.alert-danger { border-left-color: #c0392b; background: #fdecea; }
.alert-warning { border-left-color: #e67e22; background: #fff4e5; }
.alert-info { border-left-color: #2980b9; background: #eaf3fb; }
