/* ========================================================
   COCA-COLA SSD INTELLIGENCE PLATFORM — LIGHT THEME
   ======================================================== */
:root {
  --red: #E61B23;
  /* Coca-Cola Red */
  --red-dark: #B8161C;
  --red-deep: #7A0F13;
  --red-glow: rgba(230, 27, 35, 0.14);
  --red-soft: rgba(230, 27, 35, 0.05);

  --bg-main: #F9FAFB;
  /* Light canvas background */
  --surface: #FFFFFF;
  /* White cards and panels */
  --surface-2: #F3F4F6;
  /* Muted inputs, tabs background */
  --surface-3: #E5E7EB;
  /* Hover and disabled states */
  --surface-4: #D1D5DB;

  --border: #E5E7EB;
  /* Subtle grey borders */
  --border-red: rgba(230, 27, 35, 0.25);

  --text-1: #111827;
  /* Primary Charcoal text */
  --text-2: #4B5563;
  /* Secondary text */
  --text-3: #9CA3AF;
  /* Tertiary/Muted text */

  --green: #10B981;
  /* Emerald for growth */
  --amber: #F59E0B;
  /* Amber for warnings */
  --blue: #3B82F6;
  /* Blue for highlights */

  --sidebar-w: 248px;
  --topbar-h: 58px;
  --steps-h: 52px;
  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  --shadow-red: 0 4px 14px rgba(230, 27, 35, 0.22);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-main);
  color: var(--text-1);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ====== SIDEBAR ====== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh !important;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden !important;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.01);
}


.sidebar-brand {
  background: linear-gradient(135deg, var(--red-dark) 0%, var(--red) 100%);
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.brand-logo {
  margin-bottom: 4px;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
}

.sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 14px 18px 6px;
}

.sidebar-section-label.brand-portfolio-label {
  text-align: center;
}

.sidebar-section-label.nav-label {
  text-align: left;
}

/* .brand-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
} */

/* Sidebar: scrollable brands + brand image showcase */
.brand-scroll-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 10px 12px;
  flex: 1 1 auto;
  /* take remaining vertical space inside sidebar */
  min-height: 0;
  /* allow children to size/scroll correctly */
  overflow: hidden;
  /* wrapper hides overflow; brand-list will scroll */
}


/* Make the brand list scrollable and occupy roughly ~60% of viewport height.
   This creates the "3/4 of sidebar" visual effect when combined with footer/header space. */
.brand-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Snugger gap to match the photo */
  flex: 1 1 auto;
  /* fill the available scroll area */
  min-height: 0;
  /* enable proper internal scrolling */
  max-height: 486px;
  /* Limits height to show exactly 14 brands snugly like in the photo */
  overflow-y: auto;
  /* scrollbar only for the brand list */
  padding-right: 6px;
}

/* Sidebar Category & Brand Select Dropdowns */
.sidebar-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-1, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  color: var(--text-1, #111827);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.sidebar-select:hover {
  border-color: var(--border-hover, #d1d5db);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.sidebar-select:focus {
  border-color: #f40009;
  box-shadow: 0 0 0 3px rgba(244, 0, 9, 0.15);
}


/* Nice thin scrollbar (WebKit browsers). */
.brand-list::-webkit-scrollbar {
  width: 8px;
}

.brand-list::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, 0.14);
  border-radius: 6px;
}

.brand-list::-webkit-scrollbar-track {
  background: transparent;
}

/* Brand photo / showcase area below the list */
.brand-photo {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  height: 28vh;
  /* occupies the remaining portion below the scroll area */
  display: none;
  align-items: center;
  justify-content: center;
}

/* Image fills the panel */
.brand-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Ensure brand item name still ellipses correctly inside the scrollable area */
.bi-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  /* Snugger padding to match the photo */
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border: 1px solid transparent;
}

.brand-item:hover {
  background: var(--surface-2);
  transform: translateX(2px);
}

.brand-item.selected {
  background: var(--red-soft);
  border-color: var(--border-red);
}

.bi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bi-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-item.selected .bi-name {
  color: var(--text-1);
  font-weight: 600;
}

.sidebar-bottom-wrap {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  margin-top: auto;
  /* Docks container to bottom of flex layout */
  background: var(--surface);
}


.bi-share {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.2s var(--ease);
  text-decoration: none;
  border: none;
  background: none;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.nav-link.active {
  color: var(--red);
  background: var(--red-soft);
  font-weight: 600;
}

.nl-icon {
  font-size: 15px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.sf-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.sf-period {
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 2px;
}

.sf-source {
  font-size: 10px;
  color: var(--text-3);
}

/* ====== SIDEBAR BACKDROP ====== */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 240;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ====== MENU TOGGLE (HAMBURGER) ====== */
.menu-toggle {
  display: none;
  /* Hidden on desktop */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  gap: 4px;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}

.menu-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-red);
}

.menu-toggle .bar {
  width: 18px;
  height: 2px;
  background-color: var(--text-2);
  border-radius: 2px;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease), background-color 0.25s var(--ease);
}

.menu-toggle.open .bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
  background-color: var(--red);
}

.menu-toggle.open .bar:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open .bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
  background-color: var(--red);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ====== MAIN ====== */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ====== TOPBAR ====== */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: relative;
  /* Scrolls naturally with standard page layout */
  z-index: 150;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.01);
  text-decoration: none !important;
}

/* BREADCRUMB */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bc-item {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s;
}

.bc-item:hover {
  color: var(--red);
}

.bc-item.bc-current {
  color: var(--text-1);
  cursor: default;
}

.bc-item.bc-home {
  color: var(--red);
}

.bc-sep {
  color: var(--text-3);
  font-size: 14px;
  user-select: none;
}

.period-chips::-webkit-scrollbar {
  height: 5px;
}

.period-chips::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.period-chips::-webkit-scrollbar-thumb {
  background: var(--red, #e41e2b);
  border-radius: 4px;
}

.period-chips::-webkit-scrollbar-thumb:hover {
  background: #ff3b30;
}


/* PERIOD CHIPS */
.period-chips {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 4px;
}

.period-chips::-webkit-scrollbar {
  height: 4px;
}

.period-chips::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.period-chips::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

.period-chip {
  padding: 5px 14px;
  border-radius: 18px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.period-chip.active {
  background: var(--red);
  color: #fff;
  box-shadow: var(--shadow-red);
}

.period-chip:hover:not(.active) {
  color: var(--text-1);
  background: var(--surface-3);
}

/* METRIC TOGGLE */
.metric-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  text-decoration: none !important;
}

.mt-btn {
  padding: 5px 13px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-decoration: none !important;
  /* Removes text underlines */
}

.mt-btn.active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 6px rgba(230, 27, 35, 0.15);
  text-decoration: none !important;
}

/* ====== DRILL STEPS BAR ====== */
.drill-steps-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--steps-h);
  overflow-x: auto;
}

.ds-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0.4;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
  cursor: default;
  flex-shrink: 0;
}

.ds-step.active {
  opacity: 1;
}

.ds-step.done {
  opacity: 0.8;
  cursor: pointer;
}

.ds-step.done:hover {
  opacity: 1;
  background: var(--surface-2);
}

.ds-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}

.ds-step.active .ds-num {
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 8px rgba(230, 27, 35, 0.3);
}

.ds-step.done .ds-num {
  background: var(--green);
  color: #fff;
}

.ds-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.ds-step.active .ds-lbl {
  color: var(--text-1);
  font-weight: 700;
}

.ds-arrow {
  color: var(--text-3);
  font-size: 18px;
  padding: 0 4px;
  user-select: none;
  flex-shrink: 0;
}

/* ====== CONTENT AREA ====== */
.content-area {
  padding: 24px 28px;
  flex: 1;
}

.view {
  display: none;
  animation: fadeUp 0.35s var(--ease);
}

.view.active-view {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====== VIEW HEADER ====== */
.view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.back-btn {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.back-btn:hover {
  background: var(--surface-2);
  color: var(--red);
  border-color: var(--border-red);
}

.view-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-1);
}

.view-desc {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ====== KPI STRIP ====== */
.kpi-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.kpi-pill {
  flex: 1;
  min-width: 160px;
  border-radius: 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.kpi-red {
  background: linear-gradient(135deg, rgba(230, 27, 35, 0.05) 0%, rgba(230, 27, 35, 0.01) 100%);
  border-color: var(--border-red);
}

.kpi-dark {
  background: var(--surface);
}

.kpi-green {
  background: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.25);
}

.kpi-amber {
  background: rgba(245, 158, 11, 0.04);
  border-color: rgba(245, 158, 11, 0.25);
}

.kp-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

.kp-val {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1);
}

.kp-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ====== CHARTS GRID ====== */
.charts-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  min-width: 0;
  /* Prevents chart canvases from stretching the grid layout */
}

.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  /* Ensures canvas stays within card bounds */
}


.chart-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.chart-card:hover::before {
  opacity: 1;
}

.chart-card:hover {
  border-color: var(--border-red);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(230, 27, 35, 0.05);
}

.chart-card.cc-primary::before {
  opacity: 1;
}

.chart-card.cc-primary {
  border-color: rgba(230, 27, 35, 0.2);
}

.chart-card.full-span {
  grid-column: 1/-1;
}

.chart-card.competitor-card {
  margin-bottom: 16px;
}

.cc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.cc-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-1);
}

.cc-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid rgba(230, 27, 35, 0.15);
  padding: 3px 9px;
  border-radius: 20px;
}

/* ====== DRILL HINT ====== */
.drill-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--red-soft);
  border: 1px dashed rgba(230, 27, 35, 0.2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
}

.dh-icon {
  font-size: 18px;
}

/* ====== ROOT CAUSE CARDS ====== */
.root-cause-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.rc-card {
  border-radius: var(--r);
  padding: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.rc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}

.rc-card.rc-danger::before {
  background: var(--red);
}

.rc-card.rc-warn::before {
  background: var(--amber);
}

.rc-card.rc-ok::before {
  background: var(--green);
}

.rc-card.rc-danger {
  background: rgba(230, 27, 35, 0.02);
  border-color: rgba(230, 27, 35, 0.15);
}

.rc-card.rc-warn {
  background: rgba(245, 158, 11, 0.02);
  border-color: rgba(245, 158, 11, 0.15);
}

.rc-card.rc-ok {
  background: rgba(16, 185, 129, 0.02);
  border-color: rgba(16, 185, 129, 0.15);
}

.rc-icon {
  font-size: 26px;
}

.rc-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: 4px;
}

.rc-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1);
}

.rc-desc {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.4;
}

.rc-status-danger {
  color: var(--red);
  font-weight: 700;
}

.rc-status-warn {
  color: var(--amber);
  font-weight: 700;
}

.rc-status-ok {
  color: var(--green);
  font-weight: 700;
}

/* ====== COMPETITOR TABLE ====== */
.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.comp-table th {
  text-align: left;
  padding: 9px 14px;
  color: var(--text-2);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.comp-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}

.comp-table tr:hover td {
  background: var(--red-soft);
}

.comp-table .rank-num {
  color: var(--red);
  font-weight: 800;
}

.comp-table .brand-name {
  font-weight: 600;
  color: var(--text-1);
}

.comp-table .highlight {
  color: var(--red);
  font-weight: 700;
}

.share-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-bar-bg {
  flex: 1;
  max-width: 100px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
}

.share-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--red);
}

.tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tag-tccc {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(230, 27, 35, 0.15);
}

.tag-comp {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ====== AI PANEL ====== */
.ai-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 28px;
  margin-top: auto;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.02);
}

.ai-panel-header {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-1);
}

.ai-icon-badge {
  font-size: 20px;
}

.ai-badge-live {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(16, 185, 129, 0.1);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 2px 7px;
  border-radius: 20px;
}

.ai-panel-sub {
  font-size: 12.5px;
  color: var(--text-2);
}

.ai-examples {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ai-ex-label {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

.ai-example-btn {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
}

.ai-example-btn:hover {
  background: var(--red-soft);
  border-color: var(--border-red);
  color: var(--red);
}

.ai-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.ai-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 16px;
  color: var(--text-1);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(230, 27, 35, 0.08);
  background: var(--surface);
}

.ai-input::placeholder {
  color: var(--text-3);
}

.ai-submit-btn {
  padding: 11px 22px;
  background: linear-gradient(135deg, var(--red-dark), var(--red));
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-red);
  white-space: nowrap;
}

.ai-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(230, 27, 35, 0.32);
}

.ai-submit-btn:active {
  transform: none;
}

.ai-submit-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-output-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 120px;
  padding: 18px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.01);
}

.ai-placeholder {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}

.ai-placeholder-icon {
  font-size: 26px;
  opacity: 0.6;
  color: var(--red);
}

.ai-response {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-1);
}

.ai-response h4 {
  font-weight: 700;
  color: var(--red);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.ai-response h4:first-child {
  margin-top: 0;
}

.ai-response ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-response li::before {
  content: '◆ ';
  color: var(--red);
  font-size: 10px;
}

.ai-response .positive {
  color: var(--green);
  font-weight: 600;
}

.ai-response .negative {
  color: var(--red);
  font-weight: 600;
}

.ai-response .neutral {
  color: var(--amber);
  font-weight: 600;
}

.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}

.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: aiPulse 1.2s ease-in-out infinite;
}

.ai-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes aiPulse {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--surface-2);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--red);
}

/* ====== RESPONSIVE ====== */
.mobile-brand-selector {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.mbs-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.mbs-select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-1);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  outline: none;
}

.mbs-select:focus {
  border-color: var(--red);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

a.text-white {
  color: #fff !important;
}

/* Make Step 6 (Store Analysis) bright only when Step 5 (Root Cause) is active */
#dsStep5.active~#dsStep6 {
  opacity: 1 !important;
}

.topbar-center {
  max-width: 450px;
  overflow-x: auto;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE and Edge */
}

.topbar-center::-webkit-scrollbar {
  display: none;
  /* Chrome, Safari, Opera */
}

.period-chips {
  display: flex !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

@media (max-width: 768px) {
  .topbar-center {
    max-width: none !important;
    /* Allow the selector to grow naturally on tablet */
  }
}

@media (max-width:1200px) {
  .charts-grid-2 {
    grid-template-columns: 1fr;
  }

  .charts-grid-3 {
    grid-template-columns: 1fr 1fr;
  }

  .root-cause-cards {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width:900px) {
  .sidebar {
    width: 56px;
    z-index: 250;
    transition: width 0.3s var(--ease), transform 0.3s var(--ease);
  }

  .sidebar:not(.mobile-open) .bi-name,
  .sidebar:not(.mobile-open) .bi-share,
  .sidebar:not(.mobile-open) .sidebar-section-label,
  .sidebar:not(.mobile-open) .brand-subtitle,
  .sidebar:not(.mobile-open) .sf-badge,
  .sidebar:not(.mobile-open) .sf-period,
  .sidebar:not(.mobile-open) .sf-source,
  .sidebar:not(.mobile-open) .nav-link span:last-child,
  .sidebar:not(.mobile-open) .sidebar-footer {
    display: none;
  }

  .main-wrap {
    margin-left: 56px;
  }

  .charts-grid-3 {
    grid-template-columns: 1fr;
  }

  .mobile-brand-selector {
    display: flex;
  }

  /* Sidebar open state on tablet */
  .sidebar.mobile-open {
    width: 248px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  /* Centered elements when collapsed */
  .sidebar:not(.mobile-open) .sidebar-brand {
    padding: 12px 6px;
    text-align: center;
  }

  .sidebar:not(.mobile-open) .sidebar-brand svg {
    width: 44px;
    height: auto;
  }

  .sidebar:not(.mobile-open) .brand-logo {
    margin-bottom: 0;
  }

  .sidebar:not(.mobile-open) .brand-item,
  .sidebar:not(.mobile-open) .nav-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
  }

  .sidebar:not(.mobile-open) .brand-list,
  .sidebar:not(.mobile-open) .sidebar-nav {
    padding: 0 4px;
  }

  .sidebar:not(.mobile-open) .bi-dot {
    margin: 0;
  }

  /* Show toggle on responsive */
  .menu-toggle {
    display: flex;
  }
}

@media (max-width:600px) {
  .sidebar {
    display: flex !important;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 248px;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    z-index: 250;
    overflow: hidden;
    /* add this */
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  }

  /* Ensure all sidebar elements are visible when open on mobile */
  .sidebar.mobile-open .bi-name,
  .sidebar.mobile-open .bi-share,
  .sidebar.mobile-open .sidebar-section-label,
  .sidebar.mobile-open .brand-subtitle,
  .sidebar.mobile-open .sf-badge,
  .sidebar.mobile-open .sf-period,
  .sidebar.mobile-open .sf-source,
  .sidebar.mobile-open .nav-link span:last-child,
  .sidebar.mobile-open .sidebar-footer {
    display: block !important;
  }

  .sidebar.mobile-open .brand-item {
    justify-content: flex-start !important;
    padding: 8px 10px !important;
    gap: 9px !important;
  }

  .sidebar.mobile-open .nav-link {
    justify-content: flex-start !important;
    padding: 9px 10px !important;
    gap: 9px !important;
  }

  .sidebar.mobile-open .brand-logo {
    display: block !important;
  }

  .sidebar.mobile-open .brand-list,
  .sidebar.mobile-open .sidebar-nav {
    padding: 0 10px !important;
  }

  .sidebar.mobile-open .sidebar-brand {
    padding: 22px 18px 18px !important;
    text-align: left !important;
  }

  .sidebar.mobile-open .sidebar-brand svg {
    width: 150px !important;
  }

  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .main-wrap {
    margin-left: 0;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .topbar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 12px;
    text-decoration: none !important;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    width: 100% !important;
    max-width: none !important;
  }


  .period-chips,
  .metric-toggle {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Hide scrollbars on Firefox */
    text-decoration: none !important;
  }

  .period-chips::-webkit-scrollbar,
  .metric-toggle::-webkit-scrollbar {
    display: none;
    /* Hide scrollbars on Chrome/Safari/Opera */
  }

  .period-chip,
  .mt-btn {
    flex: 0 0 auto;
    text-align: center;
    padding: 6px 12px;
    font-size: 11.5px;
    text-decoration: none !important;
  }

  .drill-steps-bar {
    padding: 0 16px;
    height: 46px;
  }

  .ds-step {
    padding: 6px;
  }

  .ds-lbl {
    font-size: 11px;
  }

  .content-area {
    padding: 16px;
  }

  /* Make the Brand Selector card stack vertically on mobile */
  .mobile-brand-selector {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px !important;
  }

  .mbs-select {
    width: 100% !important;
    min-width: 0 !important;
    /* Prevents long option names from overflowing */
  }

  /* Stack view headers (back button and description) vertically */
  .view-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* Allow badges inside chart card headers to wrap safely */
  .cc-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Ensure the Step 5 competitive table scrolls horizontally inside its card */
  #competitorTable {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #competitorTable table {
    min-width: 450px !important;
    /* Prevents headers from squishing */
  }

  .kpi-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }

  .kpi-pill {
    min-width: 0;
    padding: 10px 12px;
  }

  .kp-label {
    font-size: 9px;
  }

  .kp-val {
    font-size: 18px;
  }

  .kp-sub {
    font-size: 10px;
  }

  .chart-card {
    padding: 14px;
  }

  .ai-panel {
    padding: 16px;
  }

  .ai-input-row {
    flex-direction: column;
    gap: 8px;
  }

  .ai-submit-btn {
    width: 100%;
    text-align: center;
  }
}

/* Custom Region and Retailer KPI strip styling (stretching to screen size) */
#kpiStrip3, #kpiStrip4 {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.region-kpi-pill, .retailer-kpi-pill {
  flex: 1;
  min-width: 160px;
  border-radius: 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}
.region-kpi-pill:hover, .retailer-kpi-pill:hover {
  border-color: #E61B23;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}
.region-kpi-pill.active, .retailer-kpi-pill.active {
  border-color: #E61B23;
  background: rgba(230, 27, 35, 0.04);
  box-shadow: 0 0 0 1px #E61B23;
}
.region-kpi-pill .kpr-name, .retailer-kpi-pill .kpr-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 4px;
}
.region-kpi-pill .kpr-val, .retailer-kpi-pill .kpr-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 2px;
}
.region-kpi-pill .kpr-delta, .retailer-kpi-pill .kpr-delta {
  font-size: 10px;
  font-weight: 600;
}
.region-kpi-pill .kpr-delta.positive, .retailer-kpi-pill .kpr-delta.positive {
  color: #16A34A;
}
.region-kpi-pill .kpr-delta.negative, .retailer-kpi-pill .kpr-delta.negative {
  color: #DC2626;
}
