:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a2233;
  --text-muted: #6b7280;
  --border: #e5e9f0;
  --primary: #2E7DF6;
  --primary-dark: #1B5FD1;
  --primary-light: #E9F1FE;
  --success: #16a34a;
  --success-light: #e8f8ee;
  --danger: #dc2626;
  --danger-light: #fdecea;
  --warning: #d97706;
  --warning-light: #fef4e5;
  --info: #2563eb;
  --info-light: #e9f0fe;
  --sidebar-bg: #0F1B45;
  --sidebar-text: #b9c5e8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

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

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.2; color: #fff; }
.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.sidebar-overlay.visible { display: block; }

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.topbar-left { display: flex; align-items: center; gap: 14px; }

.sidebar-nav { display: flex; flex-direction: column; padding: 16px 10px; gap: 4px; flex: 1; }
.sidebar-nav a {
  color: var(--sidebar-text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.user-name { color: #fff; font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: var(--sidebar-text); }
.logout-link { font-size: 13px; color: #f6a05f; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-date { color: var(--text-muted); font-size: 14px; }

.content-area { padding: 28px 32px; flex: 1; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; }
.flash-success { background: var(--success-light); color: var(--success); }
.flash-danger { background: var(--danger-light); color: var(--danger); }
.flash-warning { background: var(--warning-light); color: var(--warning); }
.flash-info { background: var(--info-light); color: var(--info); }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* Tablette et mobile : sidebar en tiroir hors-écran, menu hamburger */
@media (max-width: 900px) {
  .hamburger { display: flex; }
  .sidebar-close { display: block; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .content-area { padding: 20px 16px; }
  .topbar { padding: 14px 16px; }
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  th, td { padding: 10px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.card-value { font-size: 26px; font-weight: 700; margin: 0; }
.card-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-header h2 { font-size: 16px; margin: 0; }
.panel-body { padding: 20px; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; background: #fafbfc; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: #eef0f3; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: none;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #e2e5eb; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px;
  padding: 4px 8px; line-height: 1; border-radius: 6px;
}
.password-toggle:hover { background: #eef0f3; }

.confirm-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(9, 16, 48, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.confirm-overlay.visible { opacity: 1; pointer-events: all; }
.confirm-box {
  background: var(--surface); border-radius: 16px; padding: 32px 28px;
  width: 400px; max-width: 100%; text-align: center;
  border-top: 4px solid var(--primary);
  box-shadow: 0 24px 60px rgba(9, 16, 48, 0.45);
  transform: translateY(12px); transition: transform .2s ease;
}
.confirm-overlay.visible .confirm-box { transform: translateY(0); }
.confirm-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 12px; }
.confirm-title { margin: 0 0 10px; font-size: 18px; color: var(--text); }
.confirm-message { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.confirm-detail { margin: 0 0 4px; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.confirm-actions .btn { min-width: 110px; justify-content: center; }

.progress { background: #eef0f3; border-radius: 999px; height: 10px; overflow: hidden; }
.progress-bar { background: var(--primary); height: 100%; border-radius: 999px; }

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #16256b 55%, var(--primary) 130%);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 40px; width: 380px; max-width: 90vw;
  box-shadow: 0 24px 60px rgba(9, 16, 48, 0.45);
  border-top: 4px solid var(--primary);
}
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-logo { display: block; max-width: 240px; width: 100%; height: auto; margin: 0 auto 4px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.login-demo { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }

.actions-row { display: flex; gap: 8px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
