/* ══════════════════════════════════════════════════════════
       BASE
    ══════════════════════════════════════════════════════════ */
body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--amber-d);
  white-space: nowrap;
}
.topbar-logo span {
  color: var(--ink);
}
.topbar-etab {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.topbar-time {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink3);
  white-space: nowrap;
}
.btn-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: var(--r-full);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink2);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-nav:hover {
  border-color: var(--amber-d);
  color: var(--amber-d);
}
.btn-refresh {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.btn-refresh:hover {
  border-color: var(--amber);
  background: var(--amber-l);
}
.btn-refresh.loading {
  animation: spin 0.8s linear infinite;
}
.btn-deco {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.btn-deco:hover {
  border-color: var(--rust);
  background: var(--rust-l);
}

/* ── Bandeau date ───────────────────────────────────────── */
.date-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  background: var(--bg);
  flex-shrink: 0;
}
.date-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink3);
}
.date-label span {
  color: var(--ink);
  font-size: 0.82rem;
}
.realtime-dot {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--green);
}
.realtime-dot .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ── Contenu scrollable ─────────────────────────────────── */
.main {
  flex: 1;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════
       SECTION SESSION
    ══════════════════════════════════════════════════════════ */
.session-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  border: 2px solid;
  transition: all 0.2s;
}
.session-banner.ouverte {
  background: var(--green-l);
  border-color: #a7f3d0;
}
.session-banner.fermee {
  background: var(--surface2);
  border-color: var(--border);
}
.sb-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.sb-info {
  flex: 1;
  min-width: 0;
}
.sb-title {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--ink);
}
.sb-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink3);
  margin-top: 2px;
}
.sb-badge {
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.session-banner.ouverte .sb-badge {
  background: var(--green);
  color: white;
}
.session-banner.fermee .sb-badge {
  background: var(--border);
  color: var(--ink3);
}

/* ══════════════════════════════════════════════════════════
       KPI CARDS
    ══════════════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.kpi-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--t-fast);
}
.kpi-card:hover {
  box-shadow: var(--shadow-sm);
}
.kpi-card.principal {
  grid-column: 1 / -1;
  background: var(--amber-l);
  border-color: var(--border-d);
  padding: 20px;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kpi-icon {
  font-size: 1.3rem;
}
.kpi-card.principal .kpi-label {
  font-size: 0.78rem;
}
.kpi-card.principal .kpi-icon {
  font-size: 1.6rem;
}

.kpi-val {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.kpi-card.principal .kpi-val {
  font-size: 2.6rem;
  color: var(--amber-d);
}

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink3);
}
.kpi-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--r-full);
}
.kpi-trend.up {
  background: var(--green-l);
  color: var(--green);
}
.kpi-trend.down {
  background: var(--rust-l);
  color: var(--rust);
}
.kpi-trend.flat {
  background: var(--surface2);
  color: var(--ink3);
}

/* Skeleton KPI */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--surface2) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ══════════════════════════════════════════════════════════
       GRAPHIQUE 7 JOURS (SVG sparkline natif)
    ══════════════════════════════════════════════════════════ */
.chart-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}
.chart-sub {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink3);
  margin-top: 2px;
}

.sparkline-wrap {
  position: relative;
}
.sparkline-svg {
  width: 100%;
  display: block;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}
.chart-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink4);
  text-align: center;
}
.chart-label.today {
  color: var(--amber-d);
  font-weight: 900;
}

/* Tooltip SVG */
.tooltip-box {
  position: absolute;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  z-index: 10;
}
.tooltip-box.show {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════
       TOP PRODUITS
    ══════════════════════════════════════════════════════════ */
.section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 10px;
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  transition: box-shadow var(--t-fast);
}
.top-item:hover {
  box-shadow: var(--shadow-sm);
}

.top-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 900;
  flex-shrink: 0;
}
.top-rank.r1 {
  background: var(--amber);
  color: var(--ink);
}
.top-rank.r2 {
  background: var(--surface2);
  color: var(--ink3);
  border: 1.5px solid var(--border-d);
}
.top-rank.r3 {
  background: var(--surface2);
  color: var(--ink3);
  border: 1.5px solid var(--border-d);
}
.top-rank.r4,
.top-rank.r5 {
  background: var(--bg);
  color: var(--ink4);
  border: 1.5px solid var(--border);
}

.top-ico {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.top-info {
  flex: 1;
  min-width: 0;
}
.top-nom {
  font-size: 0.83rem;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-qty {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink3);
  margin-top: 1px;
}
.top-total {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--amber-d);
  white-space: nowrap;
  flex-shrink: 0;
}

.top-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.top-bar {
  height: 100%;
  background: var(--amber);
  border-radius: 2px;
  transition: width 0.6s ease;
}

.top-empty {
  text-align: center;
  padding: 24px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink3);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
}

/* ══════════════════════════════════════════════════════════
       ALERTES STOCKS
    ══════════════════════════════════════════════════════════ */
.alerte-card {
  border: 2px solid;
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}
.alerte-card.rouge {
  background: var(--rust-l);
  border-color: #fca5a5;
}
.alerte-card.rouge:hover {
  background: #fee2e2;
}
.alerte-card.orange {
  background: var(--amber-ll);
  border-color: var(--border-d);
}
.alerte-card.orange:hover {
  background: var(--amber-l);
}
.alerte-card.ok {
  background: var(--green-l);
  border-color: #a7f3d0;
  cursor: default;
}

.al-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.al-info {
  flex: 1;
}
.al-title {
  font-size: 0.85rem;
  font-weight: 900;
}
.alerte-card.rouge .al-title {
  color: var(--rust);
}
.alerte-card.orange .al-title {
  color: var(--amber-dd);
}
.alerte-card.ok .al-title {
  color: #065f46;
}
.al-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink3);
  margin-top: 2px;
}
.al-arrow {
  font-size: 0.9rem;
  color: var(--ink3);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
       NAVIGATION RAPIDE
    ══════════════════════════════════════════════════════════ */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.nav-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.nav-card:hover {
  border-color: var(--amber);
  background: var(--amber-ll);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-card:active {
  transform: scale(0.97);
}
.nc-icon {
  font-size: 1.5rem;
}
.nc-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink2);
  text-align: center;
}

/* ══════════════════════════════════════════════════════════
       RESPONSIVE
    ══════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .kpi-card.principal {
    grid-column: span 2;
  }
}
@media (max-width: 480px) {
  .topbar-etab {
    display: none;
  }
  .topbar-time {
    display: none;
  }
  .kpi-val {
    font-size: 1.6rem;
  }
  .kpi-card.principal .kpi-val {
    font-size: 2.1rem;
  }
  .main {
    gap: 14px;
    padding: 0 12px 28px;
  }
  .nav-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .nav-card {
    padding: 14px;
    flex-direction: row;
    gap: 10px;
  }
  .nc-icon {
    font-size: 1.2rem;
  }
  .nc-label {
    font-size: 0.78rem;
    text-align: left;
  }
}
@media (max-width: 360px) {
  .kpi-val {
    font-size: 1.4rem;
  }
  .kpi-card.principal .kpi-val {
    font-size: 1.8rem;
  }
  .kpi-icon {
    font-size: 1.1rem;
  }
}
