:root {
  --navy: #0E2148;
  --navy-soft: #16233B;
  --olive: #5E9A1E;
  --olive-deep: #3F6B12;
  --bg: #F7F8F5;
  --surface: #FFFFFF;
  --border: #E6E2D6;
  --text: #16233B;
  --text-muted: #5F6B7C;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px -8px rgba(14, 33, 72, .14);
  --shadow-lg: 0 20px 50px -20px rgba(14, 33, 72, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------------------------------------------------------------------- */
/* Topbar                                                                  */
/* ---------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; font-size: 15px; }
.topbar .brand img, .topbar .brand svg { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.topbar .brand .sub { font-weight: 500; opacity: .68; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar a.nav-link {
  color: #fff; text-decoration: none; font-size: 13.5px; opacity: .82;
  padding: 8px 12px; border-radius: 8px; transition: opacity .15s, background .15s;
}
.topbar a.nav-link:hover { opacity: 1; background: rgba(255,255,255,.08); }

/* ---------------------------------------------------------------------- */
/* Cloche de notification                                                  */
/* ---------------------------------------------------------------------- */
.bell-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.08);
  border: 0; cursor: pointer; color: #fff;
}
.bell-btn:hover { background: rgba(255,255,255,.16); }
.bell-btn svg { width: 18px; height: 18px; }
.bell-badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--olive); color: #fff; font-size: 10px; font-weight: 800;
  display: none; align-items: center; justify-content: center; line-height: 1;
  border: 2px solid var(--navy);
}
.bell-badge.show { display: flex; }

.toast {
  position: fixed; top: 18px; right: 18px; z-index: 200; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--olive);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 14px 16px;
  font-size: 13.5px; transform: translateX(120%); transition: transform .25s ease;
}
.toast.show { transform: translateX(0); }
.toast strong { display: block; margin-bottom: 2px; font-size: 13px; }

/* ---------------------------------------------------------------------- */
/* Auth screens                                                            */
/* ---------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 20% 15%, #14295a 0%, var(--navy) 45%, #0a1730 100%);
}
.auth-wrap {
  width: 100%; max-width: 400px; padding: 36px 32px; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow-lg);
}
.auth-wrap .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-wrap .logo-row img, .auth-wrap .logo-row svg { width: 34px; height: 34px; border-radius: 8px; }
.auth-wrap h1 { font-size: 21px; margin-bottom: 4px; color: var(--navy); }
.auth-wrap p.hint { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }

label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
input[type=email], input[type=password], input[type=text], input[type=date], select {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14.5px; margin-bottom: 16px; font-family: var(--font); background: var(--surface); color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px rgba(94,154,30,.15); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--navy); color: #fff; border: 0; border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 13.5px; font-weight: 700; cursor: pointer; text-decoration: none;
  font-family: var(--font); transition: transform .1s ease, opacity .15s ease;
}
button:hover, .btn:hover { opacity: .92; }
button:active, .btn:active { transform: scale(.98); }
button.green, .btn.green { background: var(--olive); }
button.danger, .btn.danger { background: #C01818; }
button.ghost, .btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--border); }
button.small, .btn.small { padding: 6px 12px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.error {
  background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C;
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}
.success-box {
  background: #F1F8E9; border: 2px solid var(--olive); color: var(--navy);
  padding: 16px; border-radius: var(--radius); margin-bottom: 24px; font-size: 13.5px;
}
.success-box .kv { margin-top: 10px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 1.9; word-break: break-all; }

/* ---------------------------------------------------------------------- */
/* Cartes / stats                                                          */
/* ---------------------------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin-bottom: 16px; color: var(--navy); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-tile .n { font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat-tile .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }

/* ---------------------------------------------------------------------- */
/* Filtres                                                                 */
/* ---------------------------------------------------------------------- */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; }
.filters-bar .field { min-width: 140px; }
.filters-bar label { margin-bottom: 4px; }
.filters-bar input, .filters-bar select { margin-bottom: 0; }

/* ---------------------------------------------------------------------- */
/* Table -> cartes responsive                                             */
/* ---------------------------------------------------------------------- */
.table-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
th { background: #FBFBF8; text-transform: uppercase; font-size: 10.5px; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF7; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.Nouveau { background: #EAF2FF; color: #1D4ED8; }
.badge.Validé  { background: #EAF6DC; color: #3F6B12; }
.badge.Refusé  { background: #FEF2F2; color: #B91C1C; }
.badge.En.attente { background: #FFF7E6; color: #B45309; }
.badge.Doublon { background: #F1F2F4; color: #4B5563; }
.badge.Suspect { background: #FFEDD5; color: #9A3412; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { font-size: 11px; padding: 6px 10px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

@media (max-width: 760px) {
  .wrap { padding: 18px 14px 50px; }
  table, thead, tbody, th, tr, td { display: block; }
  thead { display: none; }
  .table-card table { border: none; }
  tr {
    background: var(--surface); border-radius: var(--radius); margin-bottom: 12px;
    box-shadow: var(--shadow); padding: 6px 4px; border-bottom: none;
  }
  td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border); padding: 10px 14px; text-align: right;
  }
  td:last-child { border-bottom: none; }
  td::before { content: attr(data-label); font-weight: 700; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  .actions { justify-content: flex-end; }
}

/* ---------------------------------------------------------------------- */
/* Bannière d'installation PWA                                            */
/* ---------------------------------------------------------------------- */
.install-banner {
  display: none; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 22px;
}
.install-banner.show { display: flex; flex-wrap: wrap; }
.install-banner p { font-size: 13.5px; opacity: .9; margin: 0; }
.install-banner strong { display: block; font-size: 14.5px; margin-bottom: 2px; }

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(14,33,72,.55); z-index: 300;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); max-width: 460px; width: 100%; padding: 26px; box-shadow: var(--shadow-lg); }
.modal h3 { color: var(--navy); font-size: 17px; margin-bottom: 14px; }
.modal ol { padding-left: 20px; font-size: 13.5px; color: var(--text); line-height: 1.9; }
.modal .close-modal { margin-top: 18px; width: 100%; }

.kv-list { font-size: 13.5px; }
.kv-list .row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv-list .row:last-child { border-bottom: none; }
.kv-list .row span:first-child { color: var(--text-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; word-break: break-all; }
