:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --primary: #1f6feb;
    --primary-hover: #388bfd;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --info: #58a6ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 600; }
.sidebar-logo svg { width: 22px; height: 22px; color: var(--primary); }

.sidebar-nav { flex: 1; padding: 4px 8px; overflow-y: auto; }
.nav-section { margin-bottom: 6px; }
.nav-section-title { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; padding: 2px 8px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 5px; color: var(--text-secondary); transition: all 0.15s; font-size: 0.8rem; }
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer { padding: 8px 10px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 26px; height: 26px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.75rem; }
.user-details { flex: 1; }
.user-name { font-weight: 500; font-size: 0.7rem; }
.user-role { font-size: 0.65rem; color: var(--text-muted); }

.main-content { flex: 1; margin-left: 240px; padding: 20px 28px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 2px; }
.page-subtitle { color: var(--text-secondary); font-size: 0.85rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; font-weight: 500; font-size: 0.8rem;
    border: none; cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.9rem; font-weight: 600; }
.card-body { padding: 16px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.table th { font-weight: 600; color: var(--text-secondary); font-size: 0.75rem; text-transform: uppercase; background: var(--bg-tertiary); }
.table tbody tr:hover { background: var(--bg-tertiary); }

.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 0.7rem; font-weight: 500; }
.badge-success { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.badge-warning { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.badge-danger { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.badge-info { background: rgba(88, 166, 255, 0.2); color: var(--info); }
.badge-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-purple { background: rgba(163, 113, 247, 0.2); color: #a371f7; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); font-size: 0.8rem; }
.form-control {
    width: 100%; padding: 8px 12px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); font-size: 0.85rem;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.filters-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1; min-width: 180px; }
.search-input svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-input .form-control { padding-left: 36px; }
.filter-select { width: auto; min-width: 140px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: rgba(31, 111, 235, 0.2); color: var(--primary); }
.stat-icon.green { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.stat-icon.yellow { background: rgba(210, 153, 34, 0.2); color: var(--warning); }
.stat-icon.red { background: rgba(248, 81, 73, 0.2); color: var(--danger); }
.stat-icon.purple { background: rgba(163, 113, 247, 0.2); color: #a371f7; }
.stat-value { font-size: 1.5rem; font-weight: 600; }
.stat-label { color: var(--text-secondary); font-size: 0.8rem; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.85rem; }
.detail-label { color: var(--text-secondary); }
.detail-value { font-weight: 500; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ''; position: absolute; left: -15px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline-item.entrée::before, .timeline-item.entry::before { background: var(--success); }
.timeline-item.affectation::before { background: var(--info); }
.timeline-item.retour::before { background: var(--warning); }
.timeline-item.transfert::before { background: #a371f7; }
.timeline-date { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 3px; }
.timeline-type { font-weight: 600; margin-bottom: 3px; font-size: 0.85rem; }
.timeline-details { font-size: 0.8rem; color: var(--text-secondary); }

.empty-state { text-align: center; padding: 50px 20px; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 14px; font-size: 1rem; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); }
.login-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 360px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo svg { width: 42px; height: 42px; color: var(--primary); margin-bottom: 14px; }
.login-logo h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-logo p { color: var(--text-secondary); font-size: 0.85rem; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 0.85rem; }
.alert-success { background: rgba(63, 185, 80, 0.15); border: 1px solid var(--success); color: var(--success); }
.alert-danger { background: rgba(248, 81, 73, 0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-warning { background: rgba(210, 153, 34, 0.15); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background: rgba(88, 166, 255, 0.15); border: 1px solid var(--info); color: var(--info); }

/* Modal de confirmation */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}
.modal-icon.danger { background: rgba(248, 81, 73, 0.15); color: var(--danger); }
.modal-icon.warning { background: rgba(210, 153, 34, 0.15); color: var(--warning); }
.modal-icon svg { width: 20px; height: 20px; }

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
}

.modal-message {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.5;
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn { min-width: 90px; }

@media (max-width: 1024px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; padding: 16px 20px; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}

