* { box-sizing: border-box; margin: 0; padding: 0; }

/* Body - deux modes : auth (centré) et app (plein écran) */
body { font-family: Arial, sans-serif; background: #f0f2f5; min-height: 100vh; }
body.auth-page { display: flex; justify-content: center; align-items: center; }

/* AUTH */
.auth-container { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 100%; max-width: 400px; }
.auth-container h2 { margin-bottom: 1.5rem; text-align: center; color: #333; }
.auth-container input { width: 100%; padding: 0.75rem; margin-bottom: 1rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; }
.auth-container button { width: 100%; padding: 0.75rem; background: #4f46e5; color: white; border: none; border-radius: 4px; font-size: 1rem; cursor: pointer; }
.auth-container button:hover { background: #4338ca; }
.auth-container p { text-align: center; margin-top: 1rem; }
.auth-container a { color: #4f46e5; text-decoration: none; }
.error { color: red; margin-bottom: 1rem; text-align: center; }
.success { color: green; margin-bottom: 1rem; text-align: center; }

/* LAYOUT PLEIN ECRAN */
html, body { width: 100%; height: 100%; }
.layout { display: flex; min-height: 100vh; width: 100%; }

/* SIDEBAR */
.sidebar { width: 240px; min-width: 240px; background: #1e1b4b; color: white; padding: 2rem 1rem; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .logo { font-size: 1.3rem; font-weight: bold; margin-bottom: 2rem; padding: 0 0.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar nav a { color: #a5b4fc; text-decoration: none; padding: 0.75rem 1rem; border-radius: 6px; transition: all 0.2s; }
.sidebar nav a:hover, .sidebar nav a.active { background: #4f46e5; color: white; }

/* MAIN CONTENT */
.main-content { flex: 1; min-width: 0; width: 100%; padding: 2rem; background: #f0f2f5; overflow-x: hidden; }
.main-content h1 { margin-bottom: 2rem; color: #1e1b4b; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: white; padding: 1.5rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.stat-card h3 { color: #666; font-size: 0.9rem; margin-bottom: 0.5rem; }
.stat-card .stat-number { font-size: 2rem; font-weight: bold; color: #4f46e5; }
.stat-card.warning .stat-number { color: #ef4444; }

/* TABLE */
.table-section { background: white; border-radius: 10px; padding: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f8fafc; padding: 0.75rem; text-align: left; font-size: 0.85rem; color: #666; border-bottom: 1px solid #e2e8f0; }
tbody td { padding: 0.75rem; border-bottom: 1px solid #f1f5f9; }

/* BADGES */
.badge { padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.8rem; font-weight: 500; }
.badge.payee { background: #dcfce7; color: #16a34a; }
.badge.impayee { background: #fee2e2; color: #dc2626; }
.badge.en_attente { background: #fef9c3; color: #ca8a04; }
.badge.envoyee { background: #fef9c3; color: #ca8a04; }
.badge.brouillon { background: #f1f5f9; color: #6b7280; }
.badge.annulee { background: #fee2e2; color: #dc2626; }

/* BOUTONS */
.btn-primary { background: #4f46e5; color: white; padding: 0.6rem 1.2rem; border-radius: 6px; text-decoration: none; font-size: 0.9rem; border: none; cursor: pointer; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: white; color: #4f46e5; border: 1px solid #4f46e5; padding: 0.6rem 1.2rem; border-radius: 6px; text-decoration: none; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.btn-action { padding: 0.3rem 0.6rem; border-radius: 4px; text-decoration: none; font-size: 0.9rem; }
.btn-action.view { background: #e0e7ff; }
.btn-action.print { background: #fef9c3; }
.btn-action.delete { background: #fee2e2; }

/* FORMULAIRES */
.form-card { background: white; padding: 2rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); max-width: 600px; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: #555; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.75rem; border: 1px solid #ddd; border-radius: 6px; font-size: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* FACTURE CREATION */
.invoice-lines { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.invoice-lines th { background: #f8fafc; padding: 0.6rem; text-align: left; font-size: 0.85rem; color: #666; border-bottom: 1px solid #e2e8f0; }
.invoice-lines td { padding: 0.5rem; border-bottom: 1px solid #f1f5f9; }
.invoice-lines td input { width: 100%; padding: 0.4rem; border: 1px solid #ddd; border-radius: 4px; }
.totaux { margin-top: 1.5rem; margin-left: auto; width: 300px; }
.totaux-row { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid #f1f5f9; }
.totaux-row.total-final { font-weight: bold; font-size: 1.1rem; color: #4f46e5; border-bottom: none; }

/* FILTRES */
.filtres { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filtre-btn { padding: 0.5rem 1rem; border-radius: 20px; text-decoration: none; background: white; color: #666; border: 1px solid #ddd; font-size: 0.9rem; }
.filtre-btn.active { background: #4f46e5; color: white; border-color: #4f46e5; }
.filtre-btn:hover { background: #f0f2f5; }
.actions { display: flex; gap: 0.5rem; }

/* FACTURE VIEW */
.invoice-box { background: white; padding: 3rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); max-width: 900px; margin: 0 auto; }
.invoice-header { display: flex; justify-content: space-between; margin-bottom: 2rem; }
.invoice-title { text-align: right; }
.invoice-title h1 { font-size: 2rem; color: #4f46e5; }
.invoice-from h2 { color: #1e1b4b; margin-bottom: 0.5rem; }
.invoice-from p, .invoice-client p { color: #555; margin: 0.2rem 0; }
.invoice-client { background: #f8fafc; padding: 1rem; border-radius: 6px; margin-bottom: 2rem; }
.invoice-client h3 { margin-bottom: 0.5rem; color: #666; font-size: 0.85rem; text-transform: uppercase; }
.invoice-totaux { margin-left: auto; width: 280px; margin-top: 1.5rem; }
.invoice-notes { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; color: #555; }

/* ALERTES */
.alert { padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.alert.success { background: #dcfce7; color: #16a34a; }
.alert.error { background: #fee2e2; color: #dc2626; }

/* GRIDSTACK PLEIN ECRAN */
.grid-stack { width: 100% !important; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { width: 200px; min-width: 200px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .sidebar { display: none; }
    .main-content { padding: 1rem; }
}