:root {
  --primary: #0d6efd;
  --green: #198754;
  --green-dark: #146c43;
  --blue-dark: #0a4f8a;
  --sidebar-bg: linear-gradient(180deg, #0a2e5c 0%, #0d6e3a 100%);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.1);
  --header-h: 64px;
  --sidebar-w: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', sans-serif; background: #f0f4f8; overflow-x: hidden; }

/* SPLASH */
#splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0a2e5c 0%, #0d6e3a 50%, #0a2e5c 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 1.2s ease, visibility 1.2s ease;
}
#splash-screen.fade-out { opacity: 0; visibility: hidden; }
.splash-logo { width: 180px; height: 180px; animation: splashPulse 2s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255,255,255,0.4)); }
.splash-title { color: white; font-size: 2.5rem; font-weight: 800; letter-spacing: 4px; margin-top: 20px; text-shadow: 0 2px 20px rgba(0,0,0,0.5); }
.splash-subtitle { color: rgba(255,255,255,0.8); font-size: 1rem; margin-top: 8px; letter-spacing: 2px; }
.splash-loader { margin-top: 40px; width: 200px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; overflow: hidden; }
.splash-loader-bar { height: 100%; background: linear-gradient(90deg, #00ff88, #00ccff); border-radius: 2px; animation: loadBar 2.5s ease forwards; }
@keyframes loadBar { from { width: 0; } to { width: 100%; } }
@keyframes splashPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* AUTH */
#auth-screen {
  position: fixed; inset: 0; z-index: 8888;
  background: linear-gradient(135deg, #0a2e5c 0%, #0d6e3a 100%);
  display: flex; align-items: center; justify-content: center;
}
#auth-screen.hidden { display: none; }
.auth-card { background: white; border-radius: 20px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideUp 0.5s ease; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo img { width: 100px; height: 100px; }
.auth-logo h2 { font-size: 1.8rem; font-weight: 800; color: #0a2e5c; margin-top: 10px; }
.auth-logo p { color: #666; font-size: 0.85rem; }
.auth-input { border: 2px solid #e0e0e0; border-radius: 10px; padding: 12px 16px; font-size: 1rem; width: 100%; transition: border-color 0.3s; }
.auth-input:focus { border-color: #0d6efd; outline: none; box-shadow: 0 0 0 3px rgba(13,110,253,0.15); }
.btn-login { background: linear-gradient(135deg, #0a2e5c, #0d6e3a); color: white; border: none; border-radius: 10px; padding: 14px; font-size: 1.1rem; font-weight: 600; width: 100%; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }

/* APP */
#app { display: none; }
#app.visible { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.top-header { position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); background: linear-gradient(90deg, #0a2e5c, #0d6e3a); display: flex; align-items: center; padding: 0 20px; z-index: 1000; box-shadow: 0 2px 15px rgba(0,0,0,0.3); }
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo img { width: 42px; height: 42px; }
.header-logo span { color: white; font-size: 1.3rem; font-weight: 700; letter-spacing: 1px; }
.header-logo small { color: rgba(255,255,255,0.7); font-size: 0.65rem; display: block; }
.header-menu-btn { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; padding: 8px; border-radius: 8px; transition: background 0.2s; }
.header-menu-btn:hover { background: rgba(255,255,255,0.15); }
.header-user { margin-left: auto; display: flex; align-items: center; gap: 10px; color: white; }
.header-user .avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #00ccff, #00ff88); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; color: #0a2e5c; }
.header-date { font-size: 0.75rem; color: rgba(255,255,255,0.7); text-align: right; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: var(--header-h); width: var(--sidebar-w); height: calc(100vh - var(--header-h)); background: var(--sidebar-bg); overflow-y: auto; overflow-x: hidden; transition: transform 0.3s ease; z-index: 999; padding-bottom: 20px; }
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.nav-section { padding: 16px 16px 8px; }
.nav-section-title { color: rgba(255,255,255,0.45); font-size: 0.65rem; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; padding: 0 8px 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 10px; color: rgba(255,255,255,0.75); cursor: pointer; transition: all 0.2s; margin-bottom: 3px; font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-item.active { background: rgba(255,255,255,0.2); color: white; font-weight: 600; }
.nav-item.active .nav-icon { color: #00ff88; }
.nav-icon { width: 20px; text-align: center; font-size: 1rem; }
.nav-badge { margin-left: auto; background: #00ff88; color: #0a2e5c; font-size: 0.65rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; }

/* Main content */
.main-content { margin-left: var(--sidebar-w); margin-top: var(--header-h); padding: 24px; min-height: calc(100vh - var(--header-h)); transition: margin-left 0.3s; }
.main-content.expanded { margin-left: 0; }

/* Pages */
.page-section { display: none; }
.page-section.active { display: block; }

/* Cards */
.stat-card { background: white; border-radius: 16px; padding: 20px; box-shadow: var(--card-shadow); position: relative; overflow: hidden; }
.stat-card .icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; margin-bottom: 12px; }
.stat-card h3 { font-size: 1.8rem; font-weight: 700; margin: 0; }
.stat-card p { color: #666; font-size: 0.8rem; margin: 4px 0 0; }
.stat-card .trend { position: absolute; top: 16px; right: 16px; font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.trend-up { background: #d1f4e4; color: #198754; }
.trend-down { background: #fde8e8; color: #dc3545; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { background: linear-gradient(135deg, #0a2e5c, #0d6e3a); color: white; padding: 12px 14px; text-align: left; font-weight: 600; font-size: 0.78rem; letter-spacing: 0.5px; }
.data-table th:first-child { border-radius: 8px 0 0 0; }
.data-table th:last-child { border-radius: 0 8px 0 0; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table tr:hover td { background: #f8fffe; }
.data-table tr:last-child td { border-bottom: none; }

/* Buttons */
.btn-add { background: linear-gradient(135deg, #198754, #0d6efd); color: white; border: none; border-radius: 10px; padding: 10px 20px; font-size: 0.875rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform 0.2s, box-shadow 0.2s; text-decoration: none; }
.btn-add:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.2); color: white; }
.btn-sm { padding: 5px 10px; border-radius: 7px; border: none; cursor: pointer; font-size: 0.75rem; font-weight: 500; }
.btn-edit { background: #fff3cd; color: #856404; }
.btn-edit:hover { background: #ffc107; color: white; }
.btn-view { background: #d1ecf1; color: #0c5460; }
.btn-view:hover { background: #17a2b8; color: white; }
.btn-delete { background: #f8d7da; color: #721c24; }
.btn-delete:hover { background: #dc3545; color: white; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; background: white; padding: 16px; border-radius: 12px; box-shadow: var(--card-shadow); margin-bottom: 20px; }
.search-input { flex: 1; min-width: 200px; padding: 9px 14px 9px 36px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 0.875rem; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23999'%3E%3Cpath d='M10 2a8 8 0 105.293 14.707l4 4 1.414-1.414-4-4A8 8 0 0010 2zm0 2a6 6 0 110 12A6 6 0 0110 4z'/%3E%3C/svg%3E") no-repeat 10px center / 16px; transition: border-color 0.2s; }
.search-input:focus { border-color: #0d6efd; outline: none; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: white; border-radius: 16px; width: 100%; max-width: 700px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: modalIn 0.3s ease; }
@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { background: linear-gradient(135deg, #0a2e5c, #0d6e3a); color: white; padding: 18px 24px; border-radius: 16px 16px 0 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h5 { margin: 0; font-weight: 600; font-size: 1.1rem; }
.modal-close { background: none; border: none; color: white; font-size: 1.4rem; cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; }
.form-label { font-weight: 500; font-size: 0.85rem; color: #444; margin-bottom: 5px; }
.form-control, .form-select { border: 2px solid #e0e0e0; border-radius: 8px; padding: 9px 12px; font-size: 0.875rem; transition: border-color 0.2s; width: 100%; }
.form-control:focus, .form-select:focus { border-color: #0d6efd; outline: none; box-shadow: 0 0 0 3px rgba(13,110,253,0.1); }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: #0a2e5c; }
.page-title span { color: #198754; }

/* KPI */
.kpi-card { background: white; border-radius: 14px; padding: 18px; box-shadow: var(--card-shadow); border-left: 4px solid; transition: transform 0.2s; }
.kpi-card:hover { transform: translateY(-3px); }
.kpi-value { font-size: 1.6rem; font-weight: 800; }
.kpi-label { font-size: 0.78rem; color: #666; margin-top: 4px; }
.kpi-desc { font-size: 0.72rem; color: #999; margin-top: 2px; }

/* KPI Tab buttons */
.kpi-tab-btn { flex: 1; padding: 12px 8px; border: none; background: none; cursor: pointer; font-size: 0.8rem; font-weight: 500; color: #666; border-bottom: 3px solid transparent; transition: all 0.2s; font-family: inherit; }
.kpi-tab-btn.active-tab, .kpi-tab-btn:hover { color: #0a2e5c; font-weight: 600; border-bottom-color: #0a2e5c; }

/* Chart */
.chart-wrapper { background: white; border-radius: 16px; padding: 20px; box-shadow: var(--card-shadow); }

/* Tags */
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.tag-entretien { background: #d1f4e4; color: #0a5c2a; }
.tag-reparation { background: #fde8e8; color: #8b1a1a; }
.tag-ok { background: #d1ecf1; color: #0c5460; }

/* Doc cards */
.doc-card { background: white; border-radius: 14px; padding: 20px; box-shadow: var(--card-shadow); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; text-align: center; }
.doc-card:hover { transform: translateY(-5px); box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.doc-card .doc-icon { font-size: 2.5rem; margin-bottom: 12px; }
.doc-card h6 { font-size: 0.85rem; font-weight: 600; color: #0a2e5c; margin: 0; }
.doc-card p { font-size: 0.72rem; color: #999; margin: 4px 0 0; }

/* Pagination */
.page-btn { padding: 6px 12px; border: 1px solid #dee2e6; border-radius: 6px; background: white; cursor: pointer; font-size: 0.8rem; }
.page-btn:hover, .page-btn.active { background: #0a2e5c; color: white; border-color: #0a2e5c; }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Alert */
.custom-alert { position: fixed; top: 80px; right: 20px; z-index: 9000; padding: 14px 20px; border-radius: 12px; font-size: 0.875rem; font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,0.2); animation: slideRight 0.3s ease; max-width: 320px; }
@keyframes slideRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.alert-success { background: #d1f4e4; color: #0a5c2a; border: 1px solid #a3e4c1; }
.alert-error { background: #fde8e8; color: #8b1a1a; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* AI Card */
.ai-card { background: linear-gradient(135deg, #0a2e5c, #0d6e3a); color: white; border-radius: 16px; padding: 24px; }
.ai-result { background: rgba(255,255,255,0.1); border-radius: 12px; padding: 16px; margin-top: 16px; white-space: pre-wrap; font-size: 0.85rem; max-height: 300px; overflow-y: auto; font-family: 'Courier New', monospace; }

/* Responsive */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-title { font-size: 1.2rem; }
  .stat-card h3 { font-size: 1.3rem; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #0d6efd55; border-radius: 3px; }

@media print {
  .sidebar, .top-header, .toolbar, .btn-add, .btn-sm { display: none !important; }
  .main-content { margin: 0; padding: 0; }
}
