/* ============================================================
   stats.myguestbox.com — feuille de style (charte reprise de site/).
   Outfit + Playfair Display, fond crème #f6f1e7, accent or #b8933e.
   Chargée en fichier externe (CSP: style-src 'self' 'unsafe-inline').
   Polices système — aucune dépendance réseau tierce (pas de CDN).
   ============================================================ */

:root {
  --bg: #f6f1e7;
  --surface: #ffffff;
  --surface-2: #faf7f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1a1a18;
  --text-dim: rgba(26, 26, 24, 0.42);
  --text-mid: rgba(26, 26, 24, 0.65);
  --accent: #b8933e;
  --accent-2: #c9a94e;
  --accent-glow: rgba(184, 147, 62, 0.18);
  --green: #3f9b6b;
  --green-soft: rgba(63, 155, 107, 0.12);
  --orange: #d98a3a;
  --orange-soft: rgba(217, 138, 58, 0.14);
  --red: #e05252;
  --red-soft: rgba(224, 82, 82, 0.10);
  --grey-soft: rgba(26, 26, 24, 0.06);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Grain de fond discret (même que site/) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
}

/* ---------- Barre de navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(20px);
  background: rgba(246, 241, 231, 0.82);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.logo span { font-weight: 400; color: var(--text-dim); font-style: italic; font-size: 0.85em; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 0.78rem; color: var(--text-mid); }
.link-btn {
  font-size: 0.78rem;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-family: inherit;
}
.link-btn:hover { color: var(--text); }

/* ---------- Layout ---------- */
.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

.page-head { margin: 8px 2px 20px; }
.page-head h1 { font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif; font-size: 1.7rem; font-weight: 700; }
.page-head .sub { font-size: 0.86rem; color: var(--text-mid); font-weight: 300; margin-top: 2px; }

/* ---------- Barre de filtres ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar label { font-size: 0.7rem; color: var(--text-dim); letter-spacing: .04em; }
.toolbar input[type="date"] {
  font-family: inherit; font-size: 0.8rem; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 9px; padding: 7px 9px; background: #fff; outline: none;
}
.toolbar input[type="date"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.custom-range { display: none; align-items: center; gap: 6px; }
.custom-range.show { display: inline-flex; }

/* ---------- Bandeau mode dégradé ---------- */
.banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  background: var(--orange-soft);
  border: 1px solid rgba(217, 138, 58, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.84rem;
  color: var(--text);
}
.banner.show { display: flex; }
.banner.info { background: var(--accent-glow); border-color: rgba(184, 147, 62, 0.35); }
.banner .ico { flex: 0 0 auto; width: 20px; height: 20px; color: var(--orange); }
.banner.info .ico { color: var(--accent); }
.banner b { font-weight: 700; }
.banner .muted { color: var(--text-mid); }

/* ---------- Grilles de sections ---------- */
.section { margin-bottom: 30px; }
.section > h2 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 0 2px 12px;
}
.section > h2 .tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 0.62rem;
  letter-spacing: .06em;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--text-mid);
  vertical-align: middle;
}
.section > h2 .tag.resa { background: var(--accent-glow); color: var(--accent); }

.grid { display: grid; gap: 14px; }
.kpi-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.pad-sm { padding: 14px 16px; }
.card h3 { font-size: 0.92rem; font-weight: 700; margin-bottom: 2px; }
.card .card-sub { font-size: 0.74rem; color: var(--text-dim); margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin-bottom: 0; }

/* ---------- Carte KPI ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 118px;
  position: relative;
  overflow: hidden;
}
.kpi .kpi-label { font-size: 0.72rem; color: var(--text-dim); letter-spacing: .03em; font-weight: 500; }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.05; }
.kpi .kpi-value.empty { color: var(--text-dim); font-weight: 600; font-size: 1.3rem; }
.kpi .kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.kpi .kpi-hint { font-size: 0.68rem; color: var(--text-dim); }
.kpi .delta { font-size: 0.72rem; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .delta.flat { color: var(--text-dim); }
.kpi .kpi-spark { position: absolute; right: 10px; bottom: 10px; opacity: 0.9; }

/* ---------- Tableaux ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.tbl th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .rank { color: var(--text-dim); font-weight: 700; width: 26px; }
.tbl .barcell { position: relative; min-width: 90px; }
.tbl .barcell .bar { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 22px; background: var(--accent-glow); border-radius: 5px; z-index: 0; }
.tbl .barcell .val { position: relative; z-index: 1; padding-left: 8px; font-variant-numeric: tabular-nums; }

/* Pastilles de statut (cockpit) */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.converti { background: var(--green-soft); color: var(--green); }
.pill.converti .dot { background: var(--green); }
.pill.occupe { background: var(--orange-soft); color: var(--orange); }
.pill.occupe .dot { background: var(--orange); }
.pill.vacant { background: var(--grey-soft); color: var(--text-mid); }
.pill.vacant .dot { background: var(--text-dim); }

/* ---------- Flux ventes du jour ---------- */
.flux { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.flux li { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.flux li:last-child { border-bottom: none; }
.flux .t { font-variant-numeric: tabular-nums; font-size: 0.78rem; color: var(--text-mid); width: 48px; flex: 0 0 auto; }
.flux .who { flex: 1 1 auto; min-width: 0; }
.flux .who .b { font-weight: 600; font-size: 0.86rem; }
.flux .who .s { font-size: 0.74rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flux .amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- États vides ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 28px 18px;
  color: var(--text-dim);
}
.empty .em-dash { font-size: 1.8rem; font-weight: 300; color: var(--text-dim); line-height: 1; }
.empty .em-txt { font-size: 0.82rem; color: var(--text-mid); max-width: 280px; }
.empty .em-ico { width: 28px; height: 28px; opacity: 0.5; margin-bottom: 2px; }

/* Bloc masqué en mode dégradé */
.resa-only.is-hidden { display: none !important; }

/* ---------- SVG charts ---------- */
.chart-wrap { width: 100%; overflow: visible; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 0.74rem; color: var(--text-mid); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Jauge */
.gauge-num { font-size: 1.5rem; font-weight: 700; }
.gauge-sub { font-size: 0.74rem; color: var(--text-dim); }

/* Heatmap calendrier */
.cal-months { display: flex; gap: 22px; font-size: 0.66rem; color: var(--text-dim); margin-top: 4px; padding-left: 22px; }

/* Tooltip (titre natif SVG <title>) — pas de JS supplémentaire requis */

/* ---------- Loader / messages ---------- */
.skeleton { background: linear-gradient(90deg, var(--grey-soft) 25%, rgba(0,0,0,0.03) 37%, var(--grey-soft) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; font-size: 0.82rem; padding: 11px 18px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2); opacity: 0; pointer-events: none; transition: all .3s; z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- Auth (login) ---------- */
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 96px 24px 48px; }
.auth-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--border); border-radius: 22px; padding: 32px 26px; box-shadow: var(--shadow); }
.auth-card h1 { font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif; font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.auth-card .sub { font-size: 0.82rem; color: var(--text-mid); margin-bottom: 22px; font-weight: 300; }
.auth-card label { display: block; font-size: 0.72rem; color: var(--text-dim); margin-bottom: 6px; letter-spacing: .04em; }
.auth-card input { width: 100%; padding: 13px 14px; background: #fff; border: 1.5px solid var(--border); border-radius: 12px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 0.95rem; color: var(--text); outline: none; transition: all .3s; margin-bottom: 16px; }
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.btn { width: 100%; padding: 15px; border: none; border-radius: 13px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: all .3s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 28px var(--accent-glow); }
.btn:disabled { opacity: .6; cursor: wait; transform: none; }
.msg { font-size: 0.8rem; margin-bottom: 14px; min-height: 18px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Splash de chargement (index) ---------- */
.splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 10; }
.splash .ring { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--accent-glow); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Écran configuration (formulaires) ---------- */
.cfg-form { display: flex; flex-direction: column; gap: 4px; }
.cfg-form label { font-size: 0.72rem; color: var(--text-dim); letter-spacing: .04em; margin: 8px 0 2px; }
.cfg-form input[type="text"],
.cfg-form input[type="password"],
.cfg-form select {
  width: 100%; padding: 10px 12px; background: #fff;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.9rem; color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s;
}
.cfg-form input:focus, .cfg-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cfg-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.84rem; color: var(--text); letter-spacing: 0; }
.cfg-check input { width: auto; }
.cfg-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.btn-sm { width: auto; padding: 9px 16px; font-size: 0.82rem; border-radius: 10px; }

/* Champs inline dans les tableaux (mapping box, iCal) */
.cfg-input {
  width: 100%; min-width: 120px; padding: 7px 9px; background: #fff;
  border: 1.5px solid var(--border); border-radius: 9px;
  font-family: inherit; font-size: 0.82rem; color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s;
}
.cfg-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cfg-input-wide { min-width: 220px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .page-head h1 { font-size: 1.4rem; }
  .kpi .kpi-value { font-size: 1.45rem; }
  .toolbar { gap: 6px; padding: 8px; }
  .seg button { padding: 6px 9px; font-size: 0.74rem; }
  .nav-user { display: none; }
  .wrap { padding: 16px 12px 56px; }
  .card { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
