:root {
  --color-primary: #0072BC;
  --color-primary-light: #338EC9;
  --color-primary-dark: #00568D;
  --color-navy: #18375F;
  --color-teal: #00B398;
  --color-red: #EF4A60;
  --color-yellow: #F5C205;
  --background-page: #FFFFFF;
  --background-soft: #F5F7F9;
  --text-primary: #18375F;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-light: #E5E5E5;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--background-soft); color: var(--text-primary); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, .btn, a, input, select { min-height: 44px; }

/* ── Login background ── */
.login-bg {
  display: none;
  position: fixed; inset: 0; z-index: -1;
  background: url('../img/bg-camp.jpg') center/cover no-repeat;
  transition: background-image .4s ease;
}
.login-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,64,120,.60) 0%, rgba(0,114,188,.45) 100%);
  transition: background .4s ease;
}
body.otp-mode .login-bg {
  background: url('../img/bg-otp.jpg') center/cover no-repeat;
}
body.otp-mode .login-bg::after {
  background: linear-gradient(135deg, rgba(0,64,120,.55) 0%, rgba(0,114,188,.40) 100%);
}
body.login-mode .login-bg { display: block; }
body.login-mode { background: transparent; }
body.login-mode .agp-main { max-width: 100%; padding: 0; display: flex; flex-direction: column; min-height: 100dvh; justify-content: center; align-items: center; }
body.login-mode #view-login,
body.login-mode #view-enroll { width: 100%; max-width: 520px; padding: 16px; }

/* ── Glass card ── */
.glass-card {
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 24px;
  padding: 36px 36px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,.28), 0 1px 0 rgba(255,255,255,.25) inset;
  color: #fff;
}
.glass-enroll { margin: 0 auto; }

/* logo */
.glass-logo-wrap { margin-bottom: 28px; text-align: center; }
.glass-logo-full { width: 100%; max-width: 380px; height: auto; display: block; margin: 0 auto; }

.glass-title { font-size: 1.25rem; font-weight: 600; text-align: center; margin: 0 0 10px; }
.glass-text { text-align: center; font-size: .92rem; opacity: .85; margin: 0 0 16px; }
.glass-text-sm { font-size: .82rem; opacity: .75; }
.glass-qr { background: rgba(255,255,255,.92); border-radius: 16px; padding: 12px; margin-bottom: 16px; }

/* field */
.glass-field {
  display: flex; align-items: center;
  background: rgba(255,255,255,.85); border-radius: 12px;
  padding: 0 14px; gap: 10px;
  margin-bottom: 14px;
  transition: box-shadow .2s;
}
.glass-field:focus-within { box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.glass-field-icon { color: #0072BC; font-size: 1rem; flex-shrink: 0; }
.glass-input {
  border: 0; background: transparent; flex: 1;
  padding: 14px 0; font-size: 1rem; color: #18375F;
  outline: none; min-height: unset;
}
.glass-input::placeholder { color: #9ab; }

/* button */
.glass-btn {
  width: 100%; padding: 15px 20px;
  background: #0072BC; color: #fff;
  border: 0; border-radius: 14px;
  font-size: 1rem; font-weight: 600; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer; min-height: unset;
  transition: background .2s, transform .15s;
  box-shadow: 0 4px 18px rgba(0,114,188,.5);
}
.glass-link-btn {
  width: 100%; margin-top: 10px; padding: 10px;
  background: transparent; border: 0; color: rgba(255,255,255,.88);
  font-size: .88rem; text-decoration: underline; cursor: pointer; min-height: unset;
}
.glass-link-btn:hover { color: #fff; }

/* footer notes */
.glass-footer-note { margin: 18px 0 0; font-size: .78rem; text-align: center; opacity: .7; }
.glass-page-footer { color: rgba(255,255,255,.7); font-size: .78rem; text-align: center; margin-top: 18px; }

.agp-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--color-primary); color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.agp-logo { height: 36px; width: auto; display: block; object-fit: contain; }
.agp-header-text { flex: 1; line-height: 1.15; min-width: 0; }
.agp-header-title { color: var(--color-yellow); font-size: 1rem; }
.agp-header-text small { display: block; color: rgba(255,255,255,.88); font-size: 12px; margin-top: 2px; }
.agp-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-header-icon {
  width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%;
  background: #fff; color: var(--color-primary); border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.btn-header-icon i { font-size: 1.1rem; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,.95); color: var(--color-navy);
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; flex-shrink: 0; }
.chip-on { background: rgba(255,255,255,.95); color: var(--color-navy); }
.chip-on .chip-dot { background: var(--color-teal); }
.chip-off { background: rgba(255,255,255,.95); color: var(--color-navy); }
.chip-off .chip-dot { background: var(--color-yellow); }
.chip-sync { background: #fff; color: var(--color-primary); }

body.app-shell { background: var(--background-soft); }
body.app-shell .agp-main {
  padding: 14px 14px calc(100px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}

/* ── Stats bar ── */
#stats-bar,
.stats-bar {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0;
  background: #343a40; color: #fff;
  border-radius: 20px; padding: 14px 8px; margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(24,55,95,.07);
}
.stats-item {
  display: flex; align-items: center; gap: 8px; padding: 0 6px;
  border-right: none;
}
.stats-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
  background: #fff; color: #0072bc;
}
.stats-text { min-width: 0; line-height: 1.2; }
.stats-text small { display: block; font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.stats-text strong { display: block; font-size: 13px; color: #f4c208; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Home action cards ── */
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-tile {
  background: #fff; border: 0; border-radius: 20px; padding: 14px 12px;
  min-height: 118px; text-align: left; color: var(--color-navy);
  box-shadow: 0 4px 18px rgba(24,55,95,.07);
  display: flex; flex-direction: column; gap: 8px; position: relative;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.home-tile:active { transform: scale(.98); }
.home-tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.home-tile-icon {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
  background: #E6F2FA; color: var(--color-primary);
}
.home-tile-chevron {
  width: 28px; height: 28px; min-height: 28px; border-radius: 50%; border: 0;
  background: var(--background-soft); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  pointer-events: none; font-size: .85rem;
}
.home-tile-title {
  font-weight: 700; font-size: .92rem; line-height: 1.25;
  text-transform: uppercase;
  margin-top: 4px;
  margin-bottom: -6px;
  color: #000;
}
.home-tile-desc { font-size: .72rem; color: var(--text-secondary); line-height: 1.35; margin: 0; }

/* ── Bottom nav ── */
.app-bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 25; display: flex; align-items: stretch;
  background: #fff; border-radius: 22px; padding: 6px 4px;
  box-shadow: 0 8px 32px rgba(24,55,95,.14);
  max-width: 696px; margin: 0 auto;
}
.nav-item {
  flex: 1; border: 0; background: transparent; padding: 6px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-muted); font-size: 10px; font-weight: 600; min-height: unset;
  position: relative; cursor: pointer;
}
.nav-item:not(:last-child)::after {
  content: ''; position: absolute; right: 0; top: 18%; height: 64%;
  width: 1px; background: var(--border-light);
}
.nav-item i { font-size: 1.15rem; }
.nav-item.active {
  background: #0072bc;
  color: #fff;
  border-radius: 18px;
}

/* ── FAB ── */
.app-fab {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 24; width: 56px; height: 56px; min-height: 56px; border-radius: 50%;
  border: 0; background: var(--color-primary); color: #fff;
  box-shadow: 0 6px 20px rgba(0,114,188,.45);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; cursor: pointer; transition: transform .15s;
}
.app-fab:active { transform: scale(.95); }

/* ── Swal loading logo ── */
.swal2-popup.swal-loading-popup { border-radius: 20px; padding: 1.75rem 2rem; }
.swal-loading-logo { width: min(260px, 72vw); height: auto; display: block; margin: 0 auto 14px; }
.swal-loading-text { margin: 0; color: var(--color-navy); font-weight: 600; font-size: .95rem; }

.agp-main { padding: 16px; max-width: 720px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.login-card {
  background: #fff; border-radius: 16px; padding: 24px; margin-top: 24px;
  box-shadow: 0 8px 24px rgba(24,55,95,.08);
  text-align: center;
}
.login-card h1, .login-card h2 { font-size: 1.35rem; }
.login-card .form-label, .login-card input, .login-card button { text-align: left; }
.login-logo { width: 88px; height: 88px; margin-bottom: 8px; }
.qr-box { display: flex; justify-content: center; margin: 12px auto; min-height: 180px; }
.secret-hint { font-size: 13px; color: var(--text-muted); }

.sync-meta { display: none; }

.wizard-head h2 { font-size: 1.25rem; font-weight: 700; margin: 0 0 10px; }
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.list-head h2, .page-title {
  margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--color-navy);
}
.btn-list-add {
  flex-shrink: 0; border-radius: 14px; padding: 0 16px;
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; min-height: 40px; box-shadow: 0 4px 14px rgba(0,114,188,.25);
}
.wizard-actions { display: flex; gap: 8px; margin-top: 16px; }
.wizard-actions .btn { flex: 1; }
.hh-card { background: #fff; border-radius: 12px; padding: 12px; margin-top: 8px; }
.comp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.list-item {
  background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 8px;
  width: 100%; text-align: left; border: 1px solid var(--border-light);
}
.badge-st { font-size: 11px; padding: 3px 8px; border-radius: 999px; }
.st-en_attente { background: #FDF3CD; color: #B89204; }
.st-en_cours { background: #CCE3F2; color: #00568D; }
.st-refere { background: #F9B7BF; color: #B33848; }
.st-resolue { background: #CCF0EA; color: #00786C; }

.lock-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.lock-bg {
  position: absolute; inset: 0; z-index: 0;
  background: url('../img/bg-lock.jpg') center/cover no-repeat;
}
.lock-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,64,120,.55) 0%, rgba(0,114,188,.40) 100%);
}
.lock-overlay .glass-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 520px; margin: 0;
}
.glass-lock .glass-logo-wrap-sm { margin-bottom: 20px; }
.glass-lock .glass-logo-full { max-width: 280px; }
.glass-lock .glass-title { margin-bottom: 6px; }
.glass-lock .glass-text-sm { margin-bottom: 14px; }
.glass-lock .glass-link-btn { margin-top: 12px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.photo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-row img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }

@media (min-width: 768px) {
  body.app-shell .agp-main, .agp-main { max-width: 960px; }
  .app-bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: min(720px, calc(100% - 24px)); }
  .app-fab { right: max(18px, calc(50% - 360px + 18px)); }
}
