:root {
  --sidebar-bg: #ffffff;
  --page-bg: #fbfcfe;
  --border: #e5eaf1;
  --text: #1e293b;
  --text-strong: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #0f2a4a;
  --active-bg: #eef2f7;
  --card-bg: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  color: var(--text);
  background: var(--page-bg);
  font-size: 15px;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
}

.brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}
/* Logo complet (nom compris) sur la page de connexion */
.brand-logo-full {
  height: 92px;
  width: auto;
  object-fit: contain;
}

.brand-name { font-size: 17px; font-weight: 700; color: var(--text-strong); }

.workspace {
  padding: 10px 8px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
}
.workspace strong { color: var(--text); font-weight: 600; }

.nav-section {
  margin-top: 14px;
  padding: 0 8px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
}
.nav-item:hover { background: var(--active-bg); }
.nav-item.active { background: var(--active-bg); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; stroke: var(--text-muted); flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Main ---------- */
.main { flex: 1; padding: 40px 48px; min-width: 0; }

.page-title { font-size: 30px; font-weight: 700; color: var(--text-strong); margin: 0 0 6px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 32px; font-size: 15.5px; }
.page-subtitle strong { color: var(--text); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  max-width: 1120px;
}

.card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: #c7d2e0; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06); }
.card h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--text-strong); }
.card p { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.5; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
}
.login-box {
  width: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
}
.login-box .brand { justify-content: center; padding-bottom: 24px; }
.login-box label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 16px;
}
.login-box input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #1a3d66; }
.errorlist { color: #b91c1c; font-size: 13.5px; padding-left: 18px; }

.logout-form button {
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Page header & buttons ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-header .page-title { margin-bottom: 4px; font-size: 26px; }
.page-header .page-subtitle { margin-bottom: 0; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--active-bg); }
.btn.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.btn-accent:hover { background: #1a3d66; }
.btn.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn.btn-danger:hover { background: #fef2f2; }

/* ---------- Tables ---------- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f8fafc; }
table.data a { color: var(--accent); font-weight: 600; text-decoration: none; }
table.data a:hover { text-decoration: underline; }
.table-empty { padding: 36px; text-align: center; color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters select, .filters input[type="text"] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff; font-family: inherit;
}

/* ---------- Forms ---------- */
.form-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; max-width: 720px; }
.form-field { margin-bottom: 18px; }
.form-field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14.5px; font-family: inherit; background: #fff;
}
.form-field input[type="checkbox"] { width: auto; }
.form-field .help { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.form-field .errorlist { margin: 4px 0 0; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 20px; max-width: 1120px; }
.messages li { padding: 11px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; }
.messages li.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.messages li.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; max-width: 1120px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.panel h2 { font-size: 16px; margin: 0 0 16px; color: var(--text-strong); }
.dl { margin: 0; }
.dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.dl div:last-child { border-bottom: none; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; font-weight: 600; text-align: right; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 8px; margin-top: 18px; font-size: 14px; align-items: center; }
.pagination a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; max-width: 1120px; margin-bottom: 24px; }
.stat-tile { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-tile .value { font-size: 24px; font-weight: 700; color: var(--text-strong); }
.stat-tile .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-tile.alert .value { color: #b91c1c; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; max-width: 1120px; margin-bottom: 24px; }

.vbars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; }
.vbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.vbar .fill { background: #35618f; border-radius: 3px 3px 0 0; min-height: 2px; transition: background 0.15s; }
.vbar:hover .fill { background: #0f2a4a; }
.vbar .peak-label { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.vbar-labels { display: flex; gap: 6px; margin-top: 6px; }
.vbar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--text-faint); }

.hbar-row { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; }
.hbar-row .hlabel { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-row .track { background: var(--active-bg); border-radius: 4px; height: 14px; }
.hbar-row .track .fill { background: #35618f; height: 100%; border-radius: 4px; min-width: 2px; }
.hbar-row .hvalue { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
