:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #23211e;
  --ink-soft: #6f6a62;
  --line: #e8e5df;
  --accent: #b99d74;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 25, 15, 0.05), 0 6px 20px rgba(30, 25, 15, 0.06);
  --shadow-hover: 0 2px 4px rgba(30, 25, 15, 0.06), 0 12px 32px rgba(30, 25, 15, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---------- En-tête ---------- */
.topbar {
  background: rgba(246, 245, 242, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 26px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.greeting { text-align: right; font-weight: 600; }
.greeting .date {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-soft);
  text-transform: capitalize;
}

/* ---------- Sections ---------- */
.section { margin: 36px 0 48px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h2 { font-size: 22px; letter-spacing: -0.02em; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* ---------- Totaux ---------- */
.totals {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  background: linear-gradient(120deg, #2b2620, #4a4034);
  color: #fdfcf9;
  border-radius: var(--radius);
  padding: 22px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.totals-value { font-size: 34px; font-weight: 750; letter-spacing: -0.02em; display: block; }
.totals-label { font-size: 13px; opacity: 0.75; }

/* ---------- Cartes boutiques ---------- */
.stores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
}
.store-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 16px;
  border-top: 4px solid var(--accent);
  min-height: 220px;
  display: flex;
  flex-direction: column;
}
.store-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.store-name { font-size: 17px; font-weight: 700; }
.store-link { font-size: 12px; color: var(--ink-soft); text-decoration: none; }
.store-link:hover { color: var(--ink); }
.store-today { margin-bottom: 4px; }
.store-today-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.store-today-label { font-size: 13px; color: var(--ink-soft); }
.store-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.kpi-value { font-weight: 700; font-size: 15px; display: block; }
.kpi-label { font-size: 11.5px; color: var(--ink-soft); }
.sparkline { margin-top: auto; width: 100%; height: 44px; display: block; }

/* ---------- Squelettes de chargement ---------- */
@keyframes shimmer { 0% { opacity: 0.55; } 50% { opacity: 1; } 100% { opacity: 0.55; } }
.skeleton { animation: shimmer 1.4s ease-in-out infinite; background: #eceae5; box-shadow: none; border-top-color: #dcd8d0; }
.skeleton-block.loading .totals-value { opacity: 0.4; }

/* ---------- Annuaire d'applications ---------- */
.search {
  width: 320px;
  max-width: 100%;
  padding: 10px 16px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(185, 157, 116, 0.18); }

.category { margin-bottom: 28px; }
.category-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.app-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.app-name { font-weight: 650; font-size: 15px; }
.app-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }

/* ---------- Authentification ---------- */
.auth-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-hover);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.auth-brand { font-size: 22px; margin-bottom: 20px; }
.auth-title { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 8px; }
.auth-sub { font-size: 14px; color: var(--ink-soft); margin-bottom: 18px; text-align: left; }
#auth-login .auth-sub, #auth-denied .auth-sub { text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  padding: 11px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(185, 157, 116, 0.18); }
.btn-primary {
  padding: 12px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
  background: #2b2620;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-primary:hover { background: #46403a; }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-link { background: none; border: none; color: var(--ink-soft); font-size: 13px; margin-top: 14px; cursor: pointer; text-decoration: underline; }
.auth-error {
  background: #fdecea;
  color: #a33a2f;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  margin: 0;
}
.auth-error-inline { color: #a33a2f; font-size: 13.5px; min-height: 1em; margin: 0; }
.auth-hint { font-size: 12.5px; color: var(--ink-soft); margin: 12px 0; }
.auth-hint code { user-select: all; word-break: break-all; }
.enroll-qr { width: 190px; height: 190px; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- Menu utilisateur ---------- */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; font-size: 20px; padding: 4px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-pop {
  position: absolute;
  right: 0;
  top: 36px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 250px;
  z-index: 30;
}
.user-menu-email { font-size: 12.5px; color: var(--ink-soft); padding: 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.user-menu-pop button {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 10px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
}
.user-menu-pop button:hover { background: var(--bg); }

/* ---------- Modales ---------- */
.modal {
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-hover);
  padding: 26px 28px;
  width: 100%;
  max-width: 400px;
}
.modal-wide { max-width: 520px; }
.modal::backdrop { background: rgba(35, 33, 30, 0.45); }
.modal h3 { margin-bottom: 16px; }
.modal h4 { margin: 20px 0 10px; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 15px; cursor: pointer; color: var(--ink-soft); }
.team-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; padding: 7px 10px; background: var(--bg); border-radius: 8px; }
.team-actions button { background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 4px; }
.team-add .checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }

/* ---------- Divers ---------- */
.error {
  background: #fdecea;
  color: #a33a2f;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
}
.footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 40px;
  color: var(--ink-soft);
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .totals { gap: 24px; padding: 18px 20px; }
  .totals-value { font-size: 26px; }
  .greeting { display: none; }
  .section { margin: 24px 0 36px; }
}
