:root {
  --navy:        #1B3A6B;
  --navy-dark:   #122A52;
  --navy-light:  #2A4E8C;
  --gold:        #C9A84C;
  --gold-light:  #F5EDD0;
  --gold-dark:   #A8862E;
  --white:       #ffffff;
  --bg:          #F0F4F8;
  --card-bg:     #ffffff;
  --text:        #1a2332;
  --text-muted:  #5a6a7e;
  --border:      #dde3ed;
  --success:     #16a34a;
  --success-bg:  #dcfce7;
  --warning:     #d97706;
  --warning-bg:  #fef3c7;
  --danger:      #dc2626;
  --danger-bg:   #fee2e2;
  --shadow:      0 2px 12px rgba(27,58,107,0.10);
  --shadow-lg:   0 4px 24px rgba(27,58,107,0.15);
  --radius:      12px;
  --radius-sm:   8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Topbar ── */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--white);
}

.topbar-logo {
  height: 36px;
  width: auto;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.topbar-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  margin-top: -2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-company {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

/* ── Navigation ── */
.sidenav {
  background: var(--navy-dark);
  width: 220px;
  min-height: calc(100vh - 64px);
  padding: 20px 0;
  flex-shrink: 0;
}

.sidenav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidenav a:hover {
  color: var(--white);
  background: rgba(255,255,255,0.07);
  border-left-color: var(--gold);
}

.sidenav a.active {
  color: var(--white);
  background: rgba(201,168,76,0.15);
  border-left-color: var(--gold);
}

.sidenav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.main-content {
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

@media (max-width: 768px) {
  .sidenav { display: none; }
  .main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-subtitle { display: none; }
}

/* ── Page title ── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--gold-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border-left: 4px solid var(--navy);
}

.kpi-card.gold  { border-left-color: var(--gold); }
.kpi-card.green { border-left-color: var(--success); }
.kpi-card.red   { border-left-color: var(--danger); }

.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--navy); margin: 4px 0 2px; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); }

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.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: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F8FAFF; }

/* ── Badges statut ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red    { background: var(--danger-bg);  color: var(--danger); }
.badge-gray   { background: #F3F4F6; color: #6B7280; }
.badge-blue   { background: #EEF2FF; color: #4338CA; }
.badge-gold   { background: var(--gold-light); color: var(--gold-dark); }

/* ── Boutons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: var(--navy-light); color: var(--white); }

.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover { background: var(--gold-dark); color: var(--white); }

.btn-success {
  background: var(--success);
  color: var(--white);
}
.btn-success:hover { background: #15803d; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #FCA5A5;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Formulaires ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
  font-family: inherit;
}

.form-control:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27,58,107,0.08); }

textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Alert / Flash ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: var(--success-bg); color: var(--success); border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info    { background: #EEF2FF; color: #4338CA; border-left: 4px solid #4338CA; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo img { height: 56px; }

.login-brand-name {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.login-tagline {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 24px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

/* ── Hab detail row ── */
.hab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

@media (max-width: 600px) {
  .hab-row { grid-template-columns: 1fr 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
}

/* ── Mobile nav toggle ── */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: block; }
  .sidenav {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    width: 240px;
    height: calc(100vh - 64px);
    z-index: 200;
    box-shadow: 4px 0 16px rgba(0,0,0,0.2);
  }
  .sidenav.open { display: block; }
}

/* ── Footer ── */
.page-footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,0.55);
  text-align: center;
  padding: 16px;
  font-size: 12px;
  margin-top: auto;
}

.page-footer a { color: var(--gold); text-decoration: none; }
