/* =========================
   Modal Shell
   ========================= */

#ean-stats-overlay {
  position: fixed;
  inset: 0;
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
  transition: opacity .2s ease, visibility .2s ease;
}

#ean-stats-overlay.visible {
  opacity: 1;
  visibility: visible;
}

#ean-stats-modal {
  position: fixed;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 9998;
  width: min(650px, calc(100vw - 28px));
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: #f5f7fa;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 18px 42px rgba(0,0,0,.2);
  transition: top .25s ease, transform .25s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#ean-stats-modal.ean-modal-visible {
  top: 56px;
  transform: translate(-50%, 0);
}

/* =========================
   Header
   ========================= */

#ean-stats-modal .sl-container-head {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 14px;
  background: #0d3b66;
  color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#ean-stats-modal .sl-modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  user-select: none;
}

#ean-stats-modal .sl-modal-x {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#ean-stats-modal .sl-modal-x:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.34);
}

#ean-stats-modal .sl-modal-x:focus,
#ean-stats-modal .sl-modal-x:focus-visible,
#ean-stats-modal .sl-modal-x:active {
  outline: none;
  box-shadow: none;
}

/* =========================
   Body
   ========================= */

#ean-stats-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  background: #f3f6fb;
  scrollbar-width: thin;
  scrollbar-color: rgba(100,116,139,.45) transparent;
}

#ean-stats-body::-webkit-scrollbar {
  width: 8px;
}

#ean-stats-body::-webkit-scrollbar-track {
  background: transparent;
}

#ean-stats-body::-webkit-scrollbar-thumb {
  background: rgba(100,116,139,.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* =========================
   Tabs
   ========================= */

.ean-stats-tabs {
  display: flex;
  gap: 18px;
  padding: 12px 16px;
  border-bottom: 1px solid #d8dee7;
  background: #f3f6fb;
  user-select: none;
}

.ean-stats-tab {
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 4px 0 6px;
  font: inherit;
  font-weight: 600;
  color: #7a8898;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ean-stats-tab:hover {
  color: #334155;
  background: transparent !important;
}

.ean-stats-tab:focus,
.ean-stats-tab:focus-visible,
.ean-stats-tab:active {
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.ean-stats-tab::-moz-focus-inner {
  border: 0;
}

.ean-stats-tab.is-active {
  color: #0f172a;
}

.ean-stats-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -13px;
  height: 3px;
  border-radius: 2px;
  background: #475569;
}

#ean-stats-modal ::selection {
  background: transparent;
  color: inherit;
}

/* =========================
   Panels
   ========================= */

.ean-stats-panels {
  padding: 14px;
}

.ean-stats-panel {
  display: none;
}

.ean-stats-panel.is-active {
  display: block;
}

.ean-stats-panel.is-active > .ean-stats-card {
  margin: 0;
}

/* =========================
   Overview Grid
   ========================= */

.ean-stats-grid {
  display: grid;
  gap: 12px;
}

.ean-stats-grid-overview {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* =========================
   Shared Card Styling
   ========================= */

.ean-stats-card {
  position: relative;
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 16px;
  margin: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.05);
  overflow: hidden;
  isolation: isolate;
  clip-path: inset(0 round 18px);
  -webkit-clip-path: inset(0 round 18px);
}

.ean-stats-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(148,163,184,.18);
  pointer-events: none;
  z-index: 2;
}

.ean-stats-card:hover::before {
  border-color: rgba(100,116,139,.24);
}

.ean-stats-card-wide {
  grid-column: 1 / -1;
}

.ean-stat-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.ean-stat-value {
  margin-top: 6px;
  color: #0f172a;
  font-size: clamp(34px, 3.2vw, 44px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.ean-stat-value-sm {
  font-size: clamp(28px, 2.2vw, 36px);
  line-height: 1.12;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ean-stat-sub {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.ean-insight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.ean-insight-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 14px;
  line-height: 1.4;
}

/* =========================
   Activity Summary
   ========================= */

.ean-activity-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.ean-activity-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.ean-activity-pill-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.ean-activity-pill-value {
  color: #0f172a;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}

/* =========================
   Hourly Activity Chart
   ========================= */

.ean-hourly-chart-wrap {
  margin-top: 12px;
  padding: 10px 10px 8px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  clip-path: inset(0 round 14px);
  -webkit-clip-path: inset(0 round 14px);
}

.ean-hourly-chart {
  width: 100%;
}

.ean-hourly-svg {
  display: block;
  width: 100%;
  height: 220px;
}

.ean-svg-bar {
  fill: url(#eanBarGradient);
}

.ean-hourly-svg defs linearGradient stop:first-child {
  stop-color: #7aa2c8;
}

.ean-hourly-svg defs linearGradient stop:last-child {
  stop-color: #315b86;
}

.ean-svg-x-label {
  fill: #64748b;
  font-size: 10px;
  font-weight: 700;
  dominant-baseline: middle;
  user-select: none;
}

/* fallback when browser ignores gradient defs lookup order */
.ean-svg-bar-group rect {
  fill: #4e79a7;
}

.ean-svg-bar.ean-bar-normal { fill: #4e79a7 !important; }
.ean-svg-bar.ean-bar-elevated { fill: #6fa8dc !important; }
.ean-svg-bar.ean-bar-spike { fill: #f4a261 !important; }
.ean-svg-bar.ean-bar-surge { fill: #e63946 !important; }
.ean-svg-bar.ean-bar-low { fill: #94a3b8 !important; }

/* =========================
   Rankings
   ========================= */

.ean-rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.ean-rank-item {
  display: grid;
  align-items: center;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.ean-rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.ean-rank-name {
  min-width: 0;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.ean-rank-val {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

/* =========================
   Mobile
   ========================= */

@media (max-width: 640px) {
  #ean-stats-modal {
    width: calc(100vw - 20px);
  }

  .ean-stats-tabs {
    gap: 14px;
  }

  .ean-stats-grid-overview {
    grid-template-columns: 1fr;
  }

  .ean-activity-meta {
    grid-template-columns: 1fr;
  }

  .ean-stat-value {
    font-size: 38px;
  }

  .ean-stat-value-sm {
    font-size: 24px;
  }

  .ean-hourly-svg {
    height: 190px;
  }
}


/* ================= DASHBOARD ================= */

.ean-dashboard-shell {
  padding: 16px;
}

.ean-dashboard-controls {
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:14px;
}

.ean-range-btn,
.ean-apply-range {
  appearance: none;
  -webkit-appearance: none;

  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #d0d7e2;

  background: #f5f7fb;
  color: #334155;

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;
  transition: all .15s ease;

  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* Hover — subtle, not aggressive */
.ean-range-btn:hover,
.ean-apply-range:hover {
  background: #eef2f7;
  border-color: #c2ccd8;
  color: #0f172a;
}

/* Active / selected */
.ean-range-btn.is-active {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}

/* Pressed state */
.ean-range-btn:active,
.ean-apply-range:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.1);
}

/* Kill ugly focus rings from themes */
.ean-range-btn:focus,
.ean-range-btn:focus-visible,
.ean-apply-range:focus,
.ean-apply-range:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Make date inputs match */
.ean-range-custom input {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  background: #f8fafc;
  font-size: 13px;
}

.ean-dashboard-grid {
  display:grid;
  gap:12px;
  grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
}


/* =========================
   Dashboard Loading State
   ========================= */

.ean-dashboard-shell {
  position: relative;
}

.ean-dashboard-shell.is-loading .ean-dashboard-grid,
.ean-dashboard-shell.is-loading .ean-dashboard-controls {
  opacity: .42;
  transition: opacity .18s ease;
}

.ean-dashboard-shell.is-loading .ean-dashboard-controls {
  pointer-events: none;
}

.ean-dashboard-loading {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(243, 246, 251, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: all;
}

.ean-dashboard-shell.is-loading .ean-dashboard-loading {
  display: flex;
}

.ean-dashboard-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(148,163,184,.25);
  border-top-color: #4e79a7;
  animation: ean-spin .8s linear infinite;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.ean-dashboard-loading-text {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
}

.ean-dashboard-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 12px;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

@keyframes ean-spin {
  to { transform: rotate(360deg); }
}


/* =========================
   Daily Trend Labels
   ========================= */

.ean-daily-svg {
  height: 220px;
}

.ean-svg-daily-label {
  fill: #64748b;
  font-size: 9px;
  font-weight: 700;
  dominant-baseline: middle;
  user-select: none;
}


/* =========================
   Bar Value Labels (Daily)
   ========================= */

.ean-svg-bar-value {
  fill: rgba(255,255,255,0.96);
  font-size: 11px;
  font-weight: 800;
  dominant-baseline: middle;
  letter-spacing: .01em;
  pointer-events: none;
  user-select: none;
}


/* =========================
   Chart Tooltips
   ========================= */

#ean-chart-tooltip {
  position: absolute;
  z-index: 10050;
  max-width: min(260px, calc(100vw - 16px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .14s ease, transform .14s ease;
}

#ean-chart-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ean-interactive-bar {
  cursor: pointer;
}

.ean-interactive-bar:focus {
  outline: none;
}

.ean-interactive-bar:focus-visible {
  stroke: rgba(15, 23, 42, 0.45);
  stroke-width: 1.5;
}

.ean-svg-bar-value {
  display: none;
}

/* =========================
   Anomaly Bar States
   ========================= */

.ean-bar-normal {
  fill: #4e79a7;
}

.ean-bar-elevated {
  fill: #6fa8dc;
}

.ean-bar-spike {
  fill: #f4a261;
}

.ean-bar-surge {
  fill: #e63946;
}

.ean-bar-low {
  fill: #94a3b8;
}
