/* Silsal BI Dashboard — soft pastel BI aesthetic */
:root {
  /* Dark UI palette */
  --bg: #0E0B1A;
  --bg-2: #181428;
  --surface: #15111F;
  --surface-2: #1E1930;
  --border: #2A2440;
  --border-2: #3A3358;
  --ink: #F5F2FF;
  --ink-2: #C9C3DD;
  --ink-3: #9089AD;
  --ink-4: #6C6587;
  --muted: #4A4566;

  /* Accent (violet-blue, picked from option 1 #3B82F6 reinterpreted on pastel) */
  --accent: #7C7CF5;
  --accent-2: #9090F8;
  --accent-soft: rgba(124, 124, 245, 0.18);
  --accent-softer: rgba(124, 124, 245, 0.10);

  /* Series — pastel rainbow */
  --c1: #7C7CF5;  /* violet */
  --c2: #FF8FB1;  /* pink */
  --c3: #6FD2C0;  /* mint */
  --c4: #FFB876;  /* peach */
  --c5: #87B6FF;  /* sky */
  --c6: #C39BF5;  /* lilac */
  --c7: #F4D35E;  /* sunny */
  --c8: #93E0A4;  /* sage */

  /* Semantic */
  --pos: #4ECB94;
  --pos-soft: rgba(78, 203, 148, 0.16);
  --neg: #FF6B7E;
  --neg-soft: rgba(255, 107, 126, 0.16);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.30);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}

#root { min-height: 100vh; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sb {
  background: #0A0A12;
  border-right: 1px solid #1F1B2E;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}
.sb-logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--c1), var(--c6) 60%, var(--c2));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
  box-shadow: 0 4px 14px rgba(91,91,240,0.35);
  letter-spacing: -0.02em;
}
.sb-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; color: #fff; }
.sb-sub { font-size: 11px; color: #8A8499; margin-top: 1px; }

.sb-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6E6880;
  padding: 14px 10px 6px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  color: #C8C3D9;
  cursor: default;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s ease;
  position: relative;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active {
  background: rgba(91,91,240,0.18);
  color: #fff;
}
.sb-item.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.sb-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: #8A8499;
}
.sb-item.active .sb-icon { color: #A5A5FF; }

.sb-foot {
  margin-top: auto;
  padding: 10px;
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid #1F1B2E;
  color: #8A8499;
}
.sb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c4), var(--c2));
  color: white; font-weight: 600; font-size: 11px;
  display: grid; place-items: center;
}

/* Main */
.main { min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.tb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid #1F1B2E;
  background: #0A0A12;
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
  color: #fff;
}
.tb-left { display: flex; align-items: center; gap: 14px; }
.tb-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: #fff; }
.tb-crumb { color: #8A8499; font-size: 13px; }

.tb-right { display: flex; align-items: center; gap: 8px; }
.tb .btn {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
  color: #E6E2F0;
}
.tb .btn:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.18); color: #fff; }
.tb .btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.tb .btn-primary:hover { background: #4848e0; border-color: #4848e0; }
.tb .btn-ghost { background: transparent; border-color: transparent; color: #C8C3D9; }
.tb .btn-ghost:hover { background: rgba(255,255,255,0.08); }

/* Buttons & controls */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: default;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--ink); }
.btn-primary {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(91,91,240,0.3);
}
.btn-primary:hover { background: #4848e0; border-color: #4848e0; color: white; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(91,91,240,0.06); }
.btn-icon { width: 32px; padding: 0; justify-content: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: default;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.seg {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.seg-item {
  height: 26px;
  padding: 0 12px;
  display: inline-flex; align-items: center;
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
  cursor: default;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.seg-item:hover { color: var(--ink-2); }
.seg-item.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  padding: 10px 28px;
  background: rgba(14, 11, 26, 0.85);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 65px; z-index: 19;
  backdrop-filter: blur(12px);
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.tab {
  position: relative;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: default;
  display: flex; align-items: center; gap: 8px;
  transition: color 0.12s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab > svg { flex-shrink: 0; }
.tab > * { white-space: nowrap; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px;
  background: var(--accent);
}
.tab-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
}
.tab.active .tab-dot { background: var(--accent); }

/* Content area */
.content {
  padding: 22px 28px 60px;
  display: flex; flex-direction: column; gap: 18px;
}

/* AI Banner */
.ai-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(95deg, rgba(124,124,245,0.14) 0%, rgba(255,143,177,0.10) 50%, rgba(111,210,192,0.08) 100%);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.ai-banner::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(600px circle at 0% 50%, rgba(91,91,240,0.08), transparent 60%);
  pointer-events: none;
}
.ai-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--c1), var(--c6));
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 2px 8px rgba(91,91,240,0.3);
}
.ai-content { flex: 1; min-width: 0; display: flex !important; flex-direction: column !important; gap: 3px; }
.ai-title { display: flex; align-items: center; gap: 6px; }
.ai-title.row { gap: 6px; }
.ai-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}
.ai-text { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.ai-text b { color: var(--ink); font-weight: 600; }
.ai-text .pos { color: var(--pos); font-weight: 600; }
.ai-text .neg { color: var(--neg); font-weight: 600; }
.ai-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Cards / KPI */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.card-head-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-title { display: block; }
.card-sub { display: block; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}
.card-sub {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 2px;
  font-weight: 400;
}
.card-actions { display: flex; gap: 4px; align-items: center; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-1-1 { grid-template-columns: 1fr 1fr; }

/* KPI card */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: all 0.15s ease;
}
.kpi:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.kpi-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.kpi-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-unit { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
  font-size: 11.5px;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.kpi-delta.pos { color: var(--pos); background: var(--pos-soft); }
.kpi-delta.neg { color: var(--neg); background: var(--neg-soft); }
.kpi-prev { color: var(--ink-4); font-variant-numeric: tabular-nums; }

.kpi-spark {
  margin-top: 10px;
  margin-left: -16px; margin-right: -16px; margin-bottom: -14px;
  height: 36px;
}

/* Tooltip */
.tt {
  position: absolute;
  pointer-events: none;
  background: #0A0814;
  border: 1px solid var(--border-2);
  color: #F5F2FF;
  font-size: 11.5px;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  white-space: nowrap;
  z-index: 100;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  font-variant-numeric: tabular-nums;
}
.tt::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: #0A0814;
  border-right: 1px solid var(--border-2);
  border-bottom: 1px solid var(--border-2);
}
.tt-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.tt-label { color: rgba(255,255,255,0.65); }
.tt-val { font-weight: 600; }
.tt-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* Date range popover */
.pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 30;
  min-width: 220px;
}
.pop-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: default;
}
.pop-item:hover { background: var(--bg-2); color: var(--ink); }
.pop-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pop-divider { height: 1px; background: var(--border); margin: 6px 0; }
.pop-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); padding: 6px 10px; }

/* Country flags */
.flag {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 11px;
  background: var(--bg-2);
  overflow: hidden;
  flex-shrink: 0;
}

/* Funnel — restructured: bar + side legend so labels never get squished */
.funnel-row {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 14px;
  align-items: center;
  margin-bottom: 6px;
}
.funnel-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}
.funnel-row-track {
  position: relative;
  height: 44px;
  background: rgba(91,91,240,0.04);
  border-radius: 10px;
  overflow: hidden;
}
.funnel-step {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
  border-radius: 10px;
  padding: 0 14px;
  color: white;
  font-weight: 500;
  transition: width 0.4s ease;
  min-width: 90px;
}
.funnel-step .fs-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-step .funnel-conv {
  font-size: 10.5px;
  padding: 2px 7px;
  background: rgba(255,255,255,0.22);
  border-radius: 5px;
  font-weight: 600;
  margin-left: 10px;
}
.funnel-row-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.funnel-row-meta .neg { color: var(--neg); font-weight: 600; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; }
.tbl .strong { color: var(--ink); font-weight: 500; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 600;
}
.badge.pos { color: var(--pos); background: var(--pos-soft); }
.badge.neg { color: var(--neg); background: var(--neg-soft); }
.badge.neutral { color: var(--ink-3); background: var(--bg-2); }

/* Mini bar */
.minibar {
  height: 4px;
  background: var(--bg-2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.minibar > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

/* Skeleton dots and shimmer for AI */
@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.ai-pulse {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

/* Range slider track for date picker */
input[type=range].rng {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--border); border-radius: 2px; outline: none;
}
input[type=range].rng::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Scroll tweak */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 5px; border: 2px solid var(--bg); background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); border: 2px solid var(--bg); background-clip: content-box; }

/* Utility */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; }
.muted { color: var(--ink-4); }
.tnum { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* Legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ===== Mobile / tablet responsive ===== */

/* Tablet: collapse 4-col KPIs to 2-col, narrow side-by-sides become stacked */
@media (max-width: 1024px) {
  .app { grid-template-columns: 200px 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile: sidebar becomes horizontal scrolling top nav */
@media (max-width: 768px) {
  .app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .sb {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border-right: none;
    border-bottom: 1px solid #1F1B2E;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky; top: 0; z-index: 50;
    flex: 0 0 auto;
  }
  .sb-brand { padding: 0; margin: 0; gap: 8px; }
  .sb-section { display: none; }
  .sb-items {
    display: flex; flex-direction: row; gap: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -12px; padding: 4px 12px;
    scrollbar-width: none;
  }
  .sb-items::-webkit-scrollbar { display: none; }
  .sb-item {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 12.5px;
    border-radius: 8px;
  }
  .sb-item.active::before { display: none; }

  .main { width: 100%; min-width: 0; }

  .tb {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px !important;
  }
  .tb-left, .tb-right { width: 100%; flex-wrap: nowrap; }
  .tb-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .tb-right .btn {
    min-width: 0;
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
    overflow: hidden;
    white-space: nowrap;
  }
  .tb-right > :not(.btn-icon) {
    flex: 1 1 0;
  }
  .tb-title { font-size: 17px; }
  .tb-crumb { font-size: 11.5px; }

  /* Tab bar (Compare / View toggles) — allow horizontal scroll so nothing cuts off */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 14px !important;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .spacer { display: none; }
  .tabs .row { padding-right: 14px; flex-wrap: nowrap; }
  .tabs .seg { flex: 0 0 auto; }

  /* Refresh icon button: compact, sits inline with country/date */
  .tb-right .btn-icon {
    flex: 0 0 38px !important;
    width: 38px;
    padding: 8px !important;
  }

  /* KPI internal layout: compact prev label so it fits next to delta badge */
  .kpi-meta { flex-wrap: wrap; gap: 4px 8px; }
  .kpi-meta > span { font-size: 10.5px; }

  /* Content + cards */
  html, body { overflow-x: hidden; }
  .app, .main, .content { max-width: 100vw; overflow-x: hidden; }
  .content { padding: 14px !important; gap: 12px !important; }
  .grid { gap: 10px !important; }
  /* KPI tiles stay 2-col; everything else stacks 1-col */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2, .grid-2-1, .grid-1-2, .grid-1-1 { grid-template-columns: 1fr; }
  .card {
    padding: 14px !important;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  .card svg { max-width: 100%; height: auto; }
  .card-head { flex-wrap: wrap; gap: 8px; }
  .card-title { font-size: 14px; }
  .card-sub { font-size: 11px; }

  /* AI insight banner */
  .ai-banner, .ai { padding: 12px !important; }

  /* Tables: scroll horizontally inside card */
  .tbl { font-size: 11.5px; }
  .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Popovers should not exceed viewport */
  .pop {
    min-width: 0 !important;
    max-width: calc(100vw - 24px);
    right: 0 !important;
  }

  /* KPI tile compact */
  .kpi { padding: 12px !important; }
  .kpi-value { font-size: 22px !important; }
  .kpi-label { font-size: 11px !important; }
}

/* Very small phones: collapse 2-col KPI to 1-col */
@media (max-width: 420px) {
  .grid-4, .grid-3, .grid-2, .grid-1-1 { grid-template-columns: 1fr; }
}
