* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f6f8;
    color: #222;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 230px;
    background: #1f2937;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}
.sidebar h1 { font-size: 1.1rem; margin: 0 0 1.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    color: #d1d5db;
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-size: 0.95rem;
}
.sidebar nav a:hover { background: #374151; color: #fff; }
.sidebar-foot { font-size: 0.8rem; border-top: 1px solid #374151; padding-top: 0.75rem; }
.sidebar-foot a { color: #93c5fd; display: block; margin-top: 0.5rem; }

/* Main */
.main { flex: 1; padding: 0; min-width: 0; }
.main-full { display: flex; align-items: center; justify-content: center; }
.topbar {
    background: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}
.topbar h2 { margin: 0; font-size: 1.2rem; }
.content { padding: 1.5rem; }

/* Flash */
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin: 1rem 1.5rem 0; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
table th, table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid #f1f5f9; text-align: left; font-size: 0.92rem; vertical-align: middle; }
table th { background: #f9fafb; font-weight: 600; font-size: 0.85rem; color: #374151; }
table tr:last-child td { border-bottom: none; }
.row-danger { background: #fff5f5; }

/* Forms */
form.form-stack { display: flex; flex-direction: column; gap: 0.85rem; max-width: 540px; background: #fff; padding: 1.25rem; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
form.form-stack label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: #374151; }
form.form-stack .row { display: flex; gap: 1rem; }
form.form-stack .row label { flex: 1; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
    padding: 0.5rem; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.95rem; font-family: inherit; width: 100%;
}
textarea { resize: vertical; }
button, .btn {
    background: #2563eb; color: #fff; border: 0; padding: 0.55rem 1rem;
    border-radius: 4px; cursor: pointer; font-size: 0.92rem; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: #1d4ed8; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn-link { background: transparent; color: #2563eb; padding: 0.3rem 0.5rem; }
.btn-link:hover { background: transparent; text-decoration: underline; }
.btn-danger { color: #b91c1c; }
.actions-row { display: flex; gap: 0.75rem; align-items: center; margin: 0.5rem 0 1rem; }
.actions a, .actions form { margin-right: 0.4rem; }
form.inline { display: inline; }
.form-inline { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.form-inline input[type=text] { max-width: 320px; }

/* Filters */
.filters { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0 1rem; flex-wrap: wrap; background: #fff; padding: 0.75rem; border-radius: 6px; }
.filters input, .filters select { width: auto; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.card { background: #fff; padding: 1rem; border-radius: 8px; text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(0,0,0,0.05); display: flex; flex-direction: column; border-left: 4px solid #cbd5e1; }
.card:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.card-num { font-size: 1.8rem; font-weight: 700; }
.card-label { color: #6b7280; font-size: 0.85rem; }
.card-disponible { border-left-color: #10b981; }
.card-reserve { border-left-color: #f59e0b; }
.card-en_pret { border-left-color: #3b82f6; }
.card-en_nettoyage { border-left-color: #8b5cf6; }
.card-hors_service { border-left-color: #ef4444; }

/* Pills */
.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #e5e7eb; color: #374151; }
.pill-disponible { background: #d1fae5; color: #065f46; }
.pill-reserve { background: #fef3c7; color: #92400e; }
.pill-en_pret { background: #dbeafe; color: #1e40af; }
.pill-en_nettoyage { background: #ede9fe; color: #5b21b6; }
.pill-hors_service { background: #fee2e2; color: #991b1b; }
.pill-pret-reserve { background: #fef3c7; color: #92400e; }
.pill-pret-en_cours { background: #dbeafe; color: #1e40af; }
.pill-pret-retourne { background: #ede9fe; color: #5b21b6; }
.pill-pret-nettoye { background: #d1fae5; color: #065f46; }

/* Badges */
.badge { display: inline-block; background: #e5e7eb; color: #374151; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; margin-left: 0.4rem; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; margin: 0.5rem 0 1rem; border-bottom: 1px solid #e5e7eb; }
.tabs a { padding: 0.5rem 0.9rem; text-decoration: none; color: #6b7280; border-bottom: 2px solid transparent; font-size: 0.9rem; }
.tabs a.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }


/* Label avec bouton d'action inline */
.label-with-action { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; color: #374151; margin-bottom: 0.25rem; }
.btn-add-inline { font-size: 0.78rem; padding: 2px 8px; background: #2563eb; color: #fff; border: none; border-radius: 4px; cursor: pointer; line-height: 1.6; }
.btn-add-inline:hover { background: #1d4ed8; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); width: min(520px, 95vw); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem 0.75rem; border-bottom: 1px solid #e5e7eb; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #6b7280; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: #f3f4f6; color: #111; }
.modal-box .form-stack { box-shadow: none; border-radius: 0; padding: 1rem 1.25rem 1.25rem; }

/* Show grid */
.show-grid { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; background: #fff; padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.show-grid dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; }
.show-grid dt { color: #6b7280; font-size: 0.85rem; }
.show-grid dd { margin: 0; }

/* Misc */
.muted { color: #9ca3af; font-style: italic; }
.text-danger { color: #b91c1c; }
section { margin-bottom: 2rem; }
section h3 { font-size: 1rem; margin-bottom: 0.5rem; color: #374151; }
.hint { color: #6b7280; font-size: 0.85rem; }

/* Login */
.login-card {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    width: 320px;
    max-width: 90%;
}
.login-card h3 { margin: 0 0 1rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-card label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.login-card button { margin-top: 0.5rem; }
.login-card .remember-label { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: #4b5563; cursor: pointer; }
.login-card .remember-label input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }

/* Images matériel */
.img-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: 0.4rem; border: 1px solid #e5e7eb; }
.img-preview { max-width: 220px; max-height: 180px; object-fit: contain; border-radius: 6px; border: 1px solid #e5e7eb; display: block; }
.img-preview-wrap { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.5rem; }
.img-show { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; border: 1px solid #e5e7eb; display: block; margin-bottom: 1rem; }
.show-img { grid-column: 1 / -1; }

/* Checklist matériels */
fieldset { border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem 1rem; margin: 0; }
legend { font-size: 0.9rem; font-weight: 600; color: #374151; padding: 0 0.4rem; }
.checklist { display: flex; flex-direction: column; gap: 0.4rem; max-height: 260px; overflow-y: auto; padding: 0.25rem 0; }
.check-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; padding: 0.3rem 0.5rem; border-radius: 4px; }
.check-item:hover { background: #f1f5f9; }
.check-item input[type=checkbox] { width: 16px; height: 16px; flex-shrink: 0; }
.mat-list { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.mat-list li { font-size: 0.92rem; margin-bottom: 0.25rem; }
.checklist-filter-wrap { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.checklist-filter { flex: 1; padding: 0.35rem 0.6rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.88rem; }
.checklist-filter:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
.checklist-count { font-size: 0.8rem; color: #6b7280; white-space: nowrap; }
.checklist-clear { padding: 0.25rem 0.5rem; border: 1px solid #d1d5db; border-radius: 6px; background: #f9fafb; color: #6b7280; cursor: pointer; font-size: 0.85rem; line-height: 1; }
.checklist-clear:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.checklist-empty { color: #6b7280; font-size: 0.88rem; padding: 0.25rem 0.5rem; }

/* Retour partiel */
.retour-info { display: flex; flex-wrap: wrap; gap: 1.5rem; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.9rem; }
.retour-section { margin-bottom: 1rem; }
.retour-section h4 { margin: 0 0 0.6rem; font-size: 0.95rem; color: #374151; }
.check-all { font-style: italic; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.4rem; margin-bottom: 0.25rem; }
.retour-section--warning { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px; padding: 0.75rem 1rem; }

/* Import CSV */
.import-wrap { max-width: 700px; }
.import-wrap h3 { margin: 0 0 1rem; }
.import-help { border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.9rem; }
.import-help summary { cursor: pointer; font-weight: 600; color: #374151; }
.import-help p { margin: 0.75rem 0 0.5rem; }
.import-help code { background: #f1f5f9; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.85em; }
.import-form input[type=file] { padding: 0.4rem 0; }
