:root {
    --primary: #d32f2f;
    --primary-dark: #a02020;
    --dark: #1e293b;
    --gray: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --success: #16a34a;
    --warning: #d97706;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--dark);
}
.topbar {
    background: #2563eb;
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar a { color: white; text-decoration: none; }
.user-badge a { color: #cbd5e1; margin-left: 8px; }
.container { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.3rem; margin: 8px 0 16px; }
h1 small { font-weight: 400; color: var(--gray); font-size: 0.9rem; display: block; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: white; padding: 32px 24px; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.08); width: 90%; max-width: 360px; text-align: center; }
.login-box h1 { font-size: 1.5rem; margin-bottom: 4px; }
.subtitle { color: var(--gray); margin-bottom: 24px; }
.login-logo { width: 56px; height: 56px; margin: 4px auto 12px; display: block; }
.login-box form { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-box label { font-size: 0.85rem; color: var(--gray); margin-top: 8px; }
input, textarea {
    padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 1rem; width: 100%;
}
button { cursor: pointer; }
.btn-primary, .login-box button[type=submit] {
    background: var(--primary); color: white; border: none; padding: 14px; border-radius: 10px;
    font-size: 1rem; font-weight: 600; margin-top: 16px;
}
.btn-primary:disabled { background: #f3a3a3; }
.btn-secondary { background: white; border: 1px solid var(--border); padding: 14px; border-radius: 10px; font-size: 1rem; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* Liste véhicules */
.vehicule-list { display: grid; gap: 12px; }
.vehicule-card {
    background: white; border-radius: 14px; padding: 16px; color: var(--dark);
    box-shadow: 0 1px 4px rgba(0,0,0,.06); position: relative;
}
.vehicule-card-link { text-decoration: none; color: var(--dark); display: block; }
.vehicule-card .immat { font-size: 1.2rem; font-weight: 700; }
.vehicule-card .modele { color: var(--gray); font-size: 0.9rem; }
.vehicule-card.is-reparation { opacity: 0.7; }
.badge { display: inline-block; font-size: 0.75rem; padding: 3px 8px; border-radius: 6px; margin-top: 6px; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-location { background: #dbeafe; color: #1e40af; }

.stat-highlight { text-align: center; }
.stat-highlight-label { font-size: 0.85rem; color: var(--gray); margin-bottom: 4px; }
.stat-highlight-value { font-size: 2.4rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-highlight-sub { color: var(--gray); font-size: 0.9rem; margin-top: 4px; }
.stat-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.85rem; }
.stat-bar-row.is-today .stat-bar-label, .stat-bar-row.is-today .stat-bar-value { font-weight: 700; color: var(--dark); }
.stat-bar-label { width: 66px; flex: none; color: var(--gray); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stat-bar-track { flex: 1; background: #f1f5f9; border-radius: 6px; height: 18px; overflow: hidden; }
.stat-bar-fill { background: var(--primary); height: 100%; border-radius: 6px; }
.stat-bar-row.is-today .stat-bar-fill { background: var(--dark); }
.stat-bar-value { width: 24px; flex: none; text-align: right; font-weight: 600; }
.stat-plaques { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.stat-plaques-jour { justify-content: flex-start; margin: 0 0 14px 76px; }
.chip-plate { background: #f1f5f9; color: var(--dark); font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 6px; }
.btn-controle-vehicule {
    display: block; text-align: center; margin-top: 12px; padding: 10px; border-radius: 8px;
    background: #2563eb; color: white; text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.btn-declarer-dommage {
    display: block; text-align: center; margin-top: 8px; padding: 10px; border-radius: 8px;
    background: #fee2e2; color: #991b1b; text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.societe-badge {
    display: inline-block; background: #dbeafe; color: #1e40af; font-weight: 700; font-size: 0.85rem;
    padding: 6px 14px; border-radius: 20px; margin: 4px 0 10px;
}

/* Contrôle */
.hint { font-size: 0.85rem; color: var(--gray); margin-bottom: 12px; }
.vue-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.vue-tab {
    flex: none; background: white; border: 1px solid var(--border); padding: 8px 14px;
    border-radius: 20px; font-size: 0.85rem; white-space: nowrap;
}
.vue-tab.active { background: var(--dark); color: white; border-color: var(--dark); }
.vue-tab-check { margin-left: 4px; }
.btn-photo-obligatoire {
    width: 100%; margin-bottom: 8px; padding: 11px; border-radius: 10px; border: 2px solid var(--primary);
    background: white; font-size: 0.88rem; font-weight: 600; color: var(--primary);
}
.btn-photo-obligatoire.pris { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.vue-panel { display: none; }
.vue-panel.active { display: block; }
.silhouette-wrap { position: relative; background: white; border-radius: 14px; padding: 12px; touch-action: manipulation; }
.silhouette-svg { width: 100%; height: auto; display: block; }
.silhouette-visual { width: 100%; height: auto; display: block; border-radius: 8px; }
.silhouette-svg.flipped { transform: scaleX(-1); }
.points-overlay { position: absolute; inset: 12px; }
.point-marker {
    position: absolute; width: 26px; height: 26px; margin-left: -13px; margin-top: -13px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 0.9rem; cursor: pointer;
}
.point-marker.existant { background: var(--warning); }
.point-marker.nouveau { background: var(--primary); }

.actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg);
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
    z-index: 20;
}
.actions .btn-primary { width: 100%; max-width: 640px; margin: 0 auto; display: block; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-content { background: white; border-radius: 16px; padding: 20px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-top: 0; font-size: 1.1rem; }
.camera-zone { background: #000; border-radius: 10px; overflow: hidden; margin-bottom: 12px; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.camera-zone video, .camera-zone img { width: 100%; display: block; }
.hidden { display: none !important; }
#btn-take-photo { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: white; margin-bottom: 10px; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.modal-actions button { flex: 1; margin-top: 0; }

/* Popup info point existant */
.point-info { position: absolute; background: white; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); padding: 12px; z-index: 50; width: 220px; font-size: 0.85rem; }
.point-info img { width: 100%; border-radius: 6px; margin-bottom: 6px; }
.point-info .meta { color: var(--gray); font-size: 0.75rem; margin-top: 4px; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.admin-table th { background: #f1f5f9; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-normal { background: var(--success); }
.status-reparation { background: var(--warning); }

.admin-nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.admin-nav a {
    background: white; border: 1px solid var(--border); padding: 18px 12px; border-radius: 14px;
    text-decoration: none; color: var(--dark); font-size: 0.9rem; font-weight: 600;
    display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.05); transition: transform .1s;
}
.admin-nav a:active { transform: scale(0.97); }
.admin-nav-icon { font-size: 1.6rem; }
.notif-badge {
    position: absolute; top: 4px; right: 4px; background: #dc2626; color: white;
    font-size: 0.7rem; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.form-card { background: white; border-radius: 14px; padding: 18px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.form-card h2 { margin-top: 0; font-size: 1.05rem; }
.form-card label { display: block; font-size: 0.85rem; color: var(--gray); margin-top: 10px; margin-bottom: 4px; }
.alert-success { background: #dcfce7; color: #166534; }
.link-btn {
    background: none; border: none; color: var(--primary); text-decoration: underline;
    font-size: 0.85rem; padding: 4px 6px; cursor: pointer;
}
.chip-btn {
    display: inline-block; background: var(--bg); border: 1px solid var(--border); color: var(--dark);
    text-decoration: none; font-size: 0.8rem; font-weight: 600; padding: 8px 14px; border-radius: 20px;
}
h2 { font-size: 1.1rem; margin: 24px 0 10px; }

.photos-vehicule { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.photo-slot { background: white; border-radius: 12px; padding: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.photo-slot-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; }
.photo-slot-preview { aspect-ratio: 4/3; background: var(--bg); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.photo-slot-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot-empty { color: var(--gray); font-size: 0.75rem; }
.photo-slot-input { display: none; }
.photo-slot-btn { width: 100%; padding: 8px; font-size: 0.8rem; margin-top: 0; }

.apercu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.apercu-card { background: white; border-radius: 12px; padding: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.apercu-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.apercu-wrap { padding: 4px; }
.apercu-wrap .point-marker { width: 20px; height: 20px; margin-left: -10px; margin-top: -10px; font-size: 0.7rem; text-decoration: none; }

.apercu-details { background: white; border-radius: 12px; padding: 12px 14px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.apercu-details summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.apercu-details summary::-webkit-details-marker { display: none; }
.apercu-details summary::after { content: '▾'; margin-left: auto; color: var(--gray); }
.apercu-details[open] summary::after { content: '▴'; }
.apercu-details .apercu-grid { margin-top: 12px; }

/* Responsive mobile */
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
@media (max-width: 480px) {
    .container { padding: 12px; }
    .admin-table th, .admin-table td { padding: 8px; font-size: 0.8rem; }
    .modal-content { padding: 16px; }
    .vue-tab { padding: 7px 12px; font-size: 0.8rem; }
    .form-card { padding: 14px; }
    .topbar { padding: 10px 12px; font-size: 0.9rem; }
    .photos-vehicule { grid-template-columns: repeat(2, 1fr); }
    .admin-table input[type="text"] { width: 80px !important; font-size: 0.75rem; padding: 4px !important; }
    .link-btn { font-size: 0.75rem; padding: 2px 3px; }
}

.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
    display: flex; align-items: flex-start; gap: 12px; background: white; border-radius: 12px;
    padding: 12px 14px; text-decoration: none; color: var(--dark); box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.notif-icone { font-size: 1.3rem; flex: none; }
.notif-texte { font-size: 0.9rem; display: flex; flex-direction: column; gap: 2px; }
.notif-date { font-size: 0.75rem; color: var(--gray); }

.chauffeur-list { display: flex; flex-direction: column; gap: 10px; }
.chauffeur-card { background: white; border-radius: 14px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.chauffeur-card-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.chauffeur-card-header strong { font-size: 1rem; }
.chauffeur-identifiants { font-size: 0.85rem; color: var(--gray); }
.chauffeur-identifiants code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.chauffeur-card-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.chauffeur-inline-form { display: flex; gap: 6px; width: 100%; }
.chauffeur-inline-form input[type="text"] { flex: 1; padding: 8px; font-size: 0.85rem; }
.chauffeur-inline-form button { flex: none; }
