/* ============================
   RESET & VARIABLES
   ============================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F5F3EF;
  --surface: #ffffff;
  --surface2: #F0EDE8;
  --border: #E2DDD6;
  --text: #1a1a1a;
  --muted: #7a7570;
  --green: #2D6A4F;
  --green-light: #E8F5EE;
  --green-mid: #A8D8BC;
  --orange: #C85F2B;
  --orange-light: #FEF0E8;
  --radius: 10px;
  --radius-lg: 14px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

button { cursor: pointer; font-family: 'DM Sans', sans-serif; border: none; outline: none; }
input, select, textarea { font-family: 'DM Sans', sans-serif; font-size: 13px; }

/* ============================
   AUTH
   ============================ */
.auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: #1a2e22;
}
.auth-card {
  background: #fff; border-radius: 20px;
  padding: 48px 40px; width: 340px; text-align: center;
}
.auth-logo { font-size: 36px; margin-bottom: 8px; }
.auth-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-card p { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.auth-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 13px 16px; font-size: 20px; letter-spacing: 8px;
  text-align: center; background: var(--bg); transition: border .2s;
}
.auth-input:focus { outline: none; border-color: var(--green); }
.auth-btn {
  width: 100%; background: var(--green); color: #fff;
  border-radius: 10px; padding: 13px; font-size: 14px;
  font-weight: 500; margin-top: 14px;
}
.auth-error { color: #B5451B; font-size: 12px; margin-top: 8px; min-height: 18px; }

/* ============================
   APP SHELL
   ============================ */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ============================
   TOPBAR
   ============================ */
.topbar {
  background-color: #1a2e22 !important;
  padding: 0 20px;
  display: flex; align-items: center; height: 54px; gap: 8px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo {
  font-size: 15px !important; font-weight: 700 !important;
  color: #ffffff !important;
  margin-right: 16px; white-space: nowrap;
}
.topbar-nav { display: flex; gap: 20px; flex: 1; justify-content: center; }

.nav-btn {
  color: #ffffff !important;
  background: transparent !important;
  border: 1.5px solid rgba(255,255,255,0.25) !important;
  padding: 7px 16px; border-radius: 8px;
  font-size: 13px !important; font-weight: 500 !important;
  transition: all .15s;
}
.nav-btn:hover {
  background: rgba(255,255,255,0.15) !important;
  border-color: rgba(255,255,255,0.4) !important;
}
.nav-btn.active {
  background: #ffffff !important;
  color: #1a2e22 !important;
  border-color: #ffffff !important;
  font-weight: 700 !important;
}

.logout-btn {
  background: rgba(255,255,255,0.15) !important;
  color: #ffffff !important;
  padding: 6px 14px; border-radius: 8px;
  font-size: 12px !important; font-weight: 500 !important;
  border: 1.5px solid rgba(255,255,255,0.3) !important;
  white-space: nowrap;
}
.logout-btn:hover { background: rgba(255,255,255,0.25) !important; }

/* ============================
   MAIN CONTENT
   ============================ */
.main {
  flex: 1; padding: 20px;
  max-width: 1080px; margin: 0 auto; width: 100%;
}

/* ============================
   MONTH NAV
   ============================ */
.month-nav {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.marrow {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text);
}
.marrow:hover { background: var(--surface2); }
.mtitle { font-size: 20px; font-weight: 600; min-width: 190px; text-align: center; }
.month-link-wrap {
  margin-left: auto; display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap;
}
.link-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.link-input {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; width: 230px;
  color: var(--text); background: var(--surface);
}

/* ============================
   BUTTONS
   ============================ */
.btn-green {
  background: var(--green); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 500;
}
.btn-outline {
  background: transparent; border: 1px solid var(--green);
  color: var(--green); border-radius: 8px; padding: 6px 12px; font-size: 12px;
}
.btn-add {
  background: var(--green); color: #fff;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500;
}
.btn-save {
  background: var(--orange); color: #fff;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500;
}
.btn-del {
  background: transparent; border: 1px solid #F4C7B3;
  color: var(--orange); border-radius: 6px; padding: 4px 9px; font-size: 12px;
}
.btn-del:hover { background: var(--orange-light); }
.copy-btn {
  background: var(--green); color: #fff; border-radius: 8px;
  padding: 7px 14px; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}

/* ============================
   STAT CARDS
   ============================ */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 18px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat-label {
  font-size: 11px; color: var(--muted); margin-bottom: 3px;
  text-transform: uppercase; letter-spacing: .5px;
}
.stat-value { font-size: 26px; font-weight: 600; }
.stat-value.g { color: var(--green); }
.stat-value.o { color: var(--orange); }

/* ============================
   SECTIONS / CARDS
   ============================ */
.section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 16px;
}
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.sec-title { font-size: 14px; font-weight: 600; color: var(--text); }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500;
}
.bw { background: #FEF0E8; color: var(--orange); border: 1px solid #F4C7B3; }
.bg { background: var(--green-light); color: var(--green); border: 1px solid var(--green-mid); }

/* ============================
   MISSING LIST
   ============================ */
.missing-list { display: flex; flex-direction: column; gap: 6px; }
.miss-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--surface2); border-radius: 8px;
}
.avi {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; color: #fff;
}
.avi.g { background: var(--green); }
.avi.o { background: var(--orange); }
.tag { border-radius: 20px; padding: 2px 8px; font-size: 11px; font-weight: 500; }
.tag-tt { background: #EEF2FF; color: #3730A3; }
.tag-off { background: var(--orange-light); color: var(--orange); }

/* ============================
   LOCATION TABS
   ============================ */
.loc-tabs-wrap {
  display: flex; align-items: center;
  margin-bottom: 16px; background: var(--surface2);
  border-radius: 12px; padding: 4px;
}
.loc-tab-arrow {
  background: transparent; color: var(--muted);
  width: 30px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; border: none;
}
.loc-tab-arrow:hover { background: var(--border); color: var(--text); }
.loc-tab-arrow:disabled { opacity: .3; cursor: default; }
.loc-tabs-inner { display: flex; gap: 2px; flex: 1; }
.loc-tab {
  flex: 1; text-align: center; padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  background: transparent; border: none;
}
.loc-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.1); font-weight: 600;
}

/* ============================
   QUESTION CARDS (résultats)
   ============================ */
.q-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 10px;
}
.q-head {
  padding: 10px 14px; background: var(--surface2);
  display: flex; align-items: flex-start; gap: 8px;
}
.qnum {
  min-width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.qtext { font-size: 13px; font-weight: 500; flex: 1; line-height: 1.4; color: var(--text); }
.q-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qtype {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  border: 1px solid var(--border); color: var(--muted); background: #fff;
}
.qavg { font-size: 13px; font-weight: 700; color: var(--green); }
.q-ans { padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; }
.ans-row { display: flex; align-items: center; gap: 8px; }
.ans-avi {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0; color: var(--text);
}
.stars-wrap { display: flex; gap: 2px; }

/* ============================
   PROGRESS BARS
   ============================ */
.bar-wrap { margin-bottom: 8px; }
.bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 3px; color: var(--muted);
}
.bar-bg { background: var(--surface2); border-radius: 20px; height: 7px; }
.bar-fill { height: 100%; border-radius: 20px; transition: width .5s; }
.bar-fill.g { background: var(--green); }
.bar-fill.o { background: var(--orange); }

/* ============================
   ADMIN
   ============================ */
.atabs {
  display: flex; gap: 3px; background: var(--surface2);
  border-radius: 10px; padding: 3px; margin-bottom: 18px;
}
.atab {
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  background: transparent; border: none;
}
.atab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600;
}

.a-section { display: flex; flex-direction: column; gap: 8px; }
.a-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface2);
  border-radius: 8px; flex-wrap: wrap;
}

.inp {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px;
  background: var(--surface); color: var(--text);
}
.sel {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px;
  background: var(--surface); color: var(--text);
}

.add-row { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.q-edit-block {
  background: var(--surface2); border-radius: 10px;
  padding: 12px; display: flex; flex-direction: column;
  gap: 7px; margin-bottom: 6px;
}
.q-edit-row { display: flex; align-items: center; gap: 8px; }
.q-check { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.hint { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ============================
   NOTIFICATION TOAST
   ============================ */
/* Generic toast — white card so it pops on any page background. The
   per-type accent (left border + small icon-like pill) carries the meaning
   without sacrificing legibility. */
.notif {
  position: fixed; top: 16px; right: 16px;
  max-width: min(360px, calc(100vw - 32px));
  background: #ffffff; color: #1a2e22;
  padding: 12px 16px 12px 18px;
  border-radius: 10px;
  border-left: 4px solid #2D6A4F;
  font-size: 13px; font-weight: 500; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 9999;
  opacity: 0; transform: translateY(-12px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.notif.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.notif.success { border-left-color: #2D6A4F; color: #14532D; }
.notif.error   { border-left-color: #C2410C; color: #7C2D12; background: #FFF7F3; }
.notif.info    { border-left-color: #1E40AF; color: #1E3A8A; }

/* ============================
   EMPTY STATE
   ============================ */
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 4px; }

/* ============================
   DASHBOARD GRID
   ============================ */
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 16px;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 700px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .month-link-wrap { margin-left: 0; width: 100%; }
  .topbar-nav .nav-btn { padding: 6px 10px; font-size: 12px !important; }
}
/* ============================
   DISTRIBUTION ÉTOILES
   ============================ */
.star-col:hover .star-bar-tooltip {
  display: block !important;
}
.star-bar-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Boutons filtre pôle */
.pole-filter-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.pole-filter-btn:hover {
  border-color: var(--green);
  color: var(--green);
}
.pole-filter-btn.active {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}