/* Shared material tokens. Business content remains on opaque reading surfaces. */
:root {
  --glass-ink: #172640;
  --glass-muted: #4c5d76;
  --glass-accent: #434cbb;
  --glass-edge: rgba(255,255,255,.9);
  --glass-surface: rgba(255,255,255,.7);
  --glass-shadow: 0 8px 28px -18px rgba(44,66,109,.3);
  --glass-inset: inset 0 1px 0 rgba(255,255,255,.98);
}

.site-footer {
  width: 100%;
  padding: 18px 24px 22px;
  border-top: 1px solid rgba(210, 222, 238, 0.75);
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.site-footer a {
  color: #475569;
  text-decoration: underline;
  text-decoration-color: #cbd5e1;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.site-footer a:hover {
  color: #3730a3;
  text-decoration-color: #818cf8;
}

@media (max-width: 480px) {
  .site-footer { padding: 16px 20px 20px; }
}
.dashboard-shell {
  background: var(--bg-primary, #FAF8F5);
  color: var(--glass-ink);
}

/* Sidebar: Desktop Docked & Narrower with Smooth Collapse */
@media(min-width:1024px) {
  .dashboard-shell #sidebarNav {
    margin: 0;
    height: 100dvh;
    border-radius: 0;
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    border-right: 1px solid rgba(210, 222, 238, 0.75);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: none;
    backdrop-filter: blur(20px) saturate(135%);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    width: 224px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .dashboard-shell #sidebarNav > :first-child {
    height: 56px;
    min-height: 56px;
    padding: 0 14px;
    border-color: rgba(133, 156, 187, 0.18);
  }
  .dashboard-shell #sidebarNav > :last-child {
    border-color: rgba(133, 156, 187, 0.18);
    padding: 8px 10px;
  }

  /* Collapsed Sidebar State on Desktop */
  .dashboard-shell.sidebar-collapsed #sidebarNav {
    width: 62px;
  }
  .dashboard-shell.sidebar-collapsed .sidebar-text,
  .dashboard-shell.sidebar-collapsed .sidebar-group-title,
  .dashboard-shell.sidebar-collapsed .sidebar-brand {
    display: none !important;
  }
  .dashboard-shell.sidebar-collapsed #sidebarNav > :first-child {
    padding: 0 8px;
    justify-content: center;
  }
  .dashboard-shell.sidebar-collapsed #btnToggleSidebar .sidebar-collapse-icon {
    transform: rotate(180deg);
  }
  .dashboard-shell.sidebar-collapsed .nav-tab {
    justify-content: center;
    padding: 6px 0;
    width: 44px;
    margin-left: auto;
    margin-right: auto;
  }
  .dashboard-shell.sidebar-collapsed #logout {
    justify-content: center;
    padding: 6px 0;
    width: 44px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Sidebar Modern Squircle Icon Badges */
.nav-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.nav-icon-badge svg {
  width: 15px;
  height: 15px;
}
.dashboard-shell.sidebar-collapsed .nav-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.dashboard-shell.sidebar-collapsed .nav-icon-badge svg {
  width: 17px;
  height: 17px;
}

/* Color palettes for sidebar icon badges - gentle pastel base */
.nav-icon-indigo  { background: rgba(238, 242, 255, 0.9); color: #4f46e5; border: 1px solid rgba(224, 231, 255, 0.9); }
.nav-icon-cyan    { background: rgba(240, 249, 255, 0.9); color: #0284c7; border: 1px solid rgba(224, 242, 254, 0.9); }
.nav-icon-emerald { background: rgba(236, 253, 245, 0.9); color: #059669; border: 1px solid rgba(209, 250, 229, 0.9); }
.nav-icon-amber   { background: rgba(254, 243, 199, 0.85); color: #d97706; border: 1px solid rgba(253, 230, 138, 0.85); }
.nav-icon-rose    { background: rgba(255, 241, 242, 0.9); color: #e11d48; border: 1px solid rgba(254, 205, 211, 0.9); }
.nav-icon-douyin  { background: #09090b; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.15); }
.nav-icon-teal    { background: rgba(240, 253, 250, 0.9); color: #0d9488; border: 1px solid rgba(204, 251, 241, 0.9); }
.nav-icon-slate   { background: rgba(241, 245, 249, 0.9); color: #475569; border: 1px solid rgba(226, 232, 240, 0.9); }
.nav-icon-logout  { background: rgba(241, 245, 249, 0.85); color: #64748b; border: 1px solid rgba(226, 232, 240, 0.8); }

/* Active states for icon badges */
.dashboard-shell .nav-tab.active .nav-icon-indigo  { background: #4f46e5; color: #fff; border-color: #4338ca; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-cyan    { background: #0284c7; color: #fff; border-color: #0369a1; box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-emerald { background: #059669; color: #fff; border-color: #047857; box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-amber   { background: #d97706; color: #fff; border-color: #b45309; box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-rose    { background: #e11d48; color: #fff; border-color: #be123c; box-shadow: 0 2px 8px rgba(225, 29, 72, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-douyin  { box-shadow: 0 2px 10px rgba(37, 244, 238, 0.35), 0 2px 10px rgba(254, 44, 85, 0.3); border-color: rgba(37, 244, 238, 0.5); transform: translateY(-0.5px); }
.dashboard-shell .nav-tab.active .nav-icon-teal    { background: #0d9488; color: #fff; border-color: #0f766e; box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-slate   { background: #334155; color: #fff; border-color: #1e293b; box-shadow: 0 2px 8px rgba(51, 65, 85, 0.35); }
.dashboard-shell .nav-tab.active .nav-icon-logout  { background: #475569; color: #ffffff; }

/* Ensure icon inside active badge is crisp white for outline icons (excluding Douyin which has custom 3D colors) */
.dashboard-shell .nav-tab.active .nav-icon-badge:not(.nav-icon-douyin) svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}
.dashboard-shell .nav-tab.active .nav-icon-badge:not(.nav-icon-douyin) svg[fill="currentColor"],
.dashboard-shell .nav-tab.active .nav-icon-badge:not(.nav-icon-douyin) svg *[fill="currentColor"] {
  fill: #ffffff !important;
}

/* Hover effects */
.dashboard-shell .nav-tab:hover .nav-icon-badge {
  transform: translateY(-0.5px);
  filter: brightness(0.97);
}
#logout:hover .nav-icon-logout { background: #ffe4e6; color: #e11d48; border-color: #fecdd3; }

.dashboard-shell .nav-tab { min-height: 40px; padding: 6px 9px; border-radius: 10px; color: #465870; font-size: 13px; font-weight: 500; transition: background .18s ease,color .18s ease,box-shadow .18s ease; gap: 9px; }
.dashboard-shell .nav-tab:hover { background: rgba(255,255,255,.65); color: #1e293b; }
.dashboard-shell .nav-tab.active {
  color: #1e293b;
  font-weight: 600;
  background: linear-gradient(115deg,rgba(255,255,255,.98),rgba(235,241,255,.76));
  border-color: rgba(255,255,255,.96);
  box-shadow: inset 0 1px 0 #fff,0 2px 6px rgba(58,80,132,.08);
}
.dashboard-shell #logout { color: #536078; }

/* KPI Question Mark Interactive Button */
.kpi-info-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(203, 213, 225, 0.7);
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
/* Transparent hit areas leave the visible controls and layout unchanged. */
@media (any-pointer: coarse) {
  .dashboard-shell .kpi-info-btn::after { content: ''; position: absolute; inset: -12px; }
  .dashboard-shell .month-chip-btn { position: relative; }
  .dashboard-shell .month-chip-btn::after { content: ''; position: absolute; inset: -4px 0; }
  #btnOpenSidebar, #btnCloseSidebar { position: relative; }
  #btnOpenSidebar::after, #btnCloseSidebar::after { content: ''; position: absolute; inset: -6px; }
}
.kpi-info-btn:hover,
.kpi-info-btn.active {
  background: #ffffff;
  border-color: #818cf8;
  color: #4f46e5;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.16), 0 0 0 2px rgba(99, 102, 241, 0.12);
  transform: scale(1.08);
}
.kpi-info-btn svg {
  width: 12px;
  height: 12px;
}

/* Metric Popover Container & Micro Elements */
.metric-popover {
  position: fixed;
  z-index: 1050;
  width: 275px;
  max-width: calc(100vw - 24px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 11px;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.12), 0 3px 8px -2px rgba(15, 23, 42, 0.05);
  padding: 10px 12px;
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  font-family: var(--font-serif, ui-serif, Georgia, "Songti SC", "SimSun", serif);
}
.metric-popover.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.metric-popover-arrow {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.9);
  transform: rotate(45deg);
}
.metric-popover.placement-bottom .metric-popover-arrow {
  top: -4.5px;
  border-bottom: none;
  border-right: none;
}
.metric-popover.placement-top .metric-popover-arrow {
  bottom: -4.5px;
  border-top: none;
  border-left: none;
}

.metric-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}
.metric-popover-title {
  font-size: 12.5px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}
.metric-popover-badge {
  font-size: 9.5px !important;
  font-weight: 600 !important;
  padding: 1px 5px !important;
  border-radius: 4px;
  line-height: 1.25 !important;
  white-space: nowrap !important;
}
.metric-popover-unit {
  font-size: 10px !important;
  color: #64748b !important;
  font-family: var(--font-mono, monospace) !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
}
.metric-popover-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-popover-desc {
  font-size: 11.5px !important;
  color: #334155 !important;
  line-height: 1.45 !important;
  margin: 0;
}
.metric-popover-formula-row {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 3.5px 7px;
  font-size: 10.5px !important;
  line-height: 1.35 !important;
}
.metric-popover-formula-tag {
  color: #94a3b8;
  font-size: 10px !important;
  font-weight: 500;
  flex-shrink: 0;
}
.metric-popover-formula {
  font-family: var(--font-mono, monospace) !important;
  color: #1e293b !important;
  word-break: break-all;
}

/* Category Badge theme colors for popover */
.metric-popover-badge.badge-cat-indigo { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.metric-popover-badge.badge-cat-emerald{ background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.metric-popover-badge.badge-cat-cyan   { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }
.metric-popover-badge.badge-cat-amber  { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.metric-popover-badge.badge-cat-rose   { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.metric-popover-badge.badge-cat-purple { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }

.dashboard-shell #mainContentScroll > header {
  background: rgba(242,247,253,.78);
  border-bottom-color: rgba(210, 222, 238, 0.75);
  box-shadow: 0 1px 0 rgba(112,139,175,.08);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}
.dashboard-shell #mainContentScroll > header > div { min-height: 56px; height: 56px; padding-top: 0; padding-bottom: 0; }
.dashboard-shell .bento-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: box-shadow .2s ease,border-color .2s ease;
}
.dashboard-shell .bento-card:hover { transform: none; border-color: rgba(203, 213, 225, 0.95); box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -1px rgba(15, 23, 42, 0.03); }
.dashboard-shell #tabPane-overview > .grid:first-child > .bento-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.dashboard-shell #monthPickerTrigger {
  min-height: 36px; border-radius: 9px; border-color: rgba(255,255,255,.95);
  background: linear-gradient(135deg,#ffffffed,#ffffff85);
  box-shadow: var(--glass-inset),0 1px 3px rgba(55,75,110,.06);
}
.dashboard-shell #monthPickerDropdown {
  background: rgba(249,252,255,.96); border-color: #fff; border-radius: 14px;
  box-shadow: 0 12px 30px -15px rgba(36,59,98,.45),var(--glass-inset);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
}

/* Requirement 2: Filter Segmented Control Color Adjustment */
.dashboard-shell .filter-btn {
  min-height: 28px;
  padding: 3px 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #556987;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  transition: all 0.15s ease;
}
.dashboard-shell .filter-btn:hover {
  color: #0f172a;
}
.dashboard-shell .filter-btn.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 600;
  border-color: rgba(203, 213, 225, 0.85);
  box-shadow: 0 1px 2.5px rgba(15, 23, 42, 0.08), 0 0.5px 1px rgba(15, 23, 42, 0.04);
}

/* Month Chip in Dropdown */
.dashboard-shell .month-chip-btn { min-height: 36px; background: #ffffffc9; border-color: #dce4ef; border-radius: 8px; color: #334155; font-size: 12px; transition: all 0.15s ease; }
.dashboard-shell .month-chip-btn:hover { border-color: #94a3b8; background: #f8fafc; }
.dashboard-shell .month-chip-btn.active { background: #1e293b!important; border-color: #1e293b!important; color: #fff!important; font-weight: 600; box-shadow: 0 1px 3px rgba(15,23,42,0.18); }

.dashboard-shell #dataStatus { color: #53657f; font-size: 11px; line-height: 1.6; padding-top: 0; }
.dashboard-shell footer { background: rgba(255,255,255,.35); border-color: #ffffffa6; }
.dashboard-shell .text-slate-400 { color: #5e6d84; }
.dashboard-shell .text-slate-500 { color: #52627a; }
.dashboard-shell #metricSearchInput { background: #ffffffb3; border-color: #ced9e8; min-height: 42px; }
.dashboard-shell button:focus-visible,.dashboard-shell input:focus-visible { outline: 2px solid #4650b6; outline-offset: 3px; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .dashboard-shell #sidebarNav,.dashboard-shell #mainContentScroll > header,.dashboard-shell #monthPickerDropdown { background: #f5f8fc; }
}
@media(max-width:1023px) {
  .dashboard-shell #sidebarNav { margin: 8px; height: calc(100dvh - 16px); width: 260px; border-radius: 16px; border: 1px solid var(--glass-edge); box-shadow: var(--glass-inset),var(--glass-shadow); background: rgba(246,249,254,.96); }
  .dashboard-shell #sidebarNav.-translate-x-full { transform: translateX(calc(-100% - 16px)); }
  .dashboard-shell #mainContentScroll > header > div { min-height: 56px; height: 56px; }
  .dashboard-shell #monthPickerTrigger { min-height: 38px; }
  .dashboard-shell #tabPane-overview > .grid:first-child > .bento-card { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media(prefers-reduced-transparency:reduce) {
  .dashboard-shell #sidebarNav,.dashboard-shell .bento-card,.dashboard-shell #mainContentScroll > header,.dashboard-shell #monthPickerDropdown { background: #f8fbff; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media(prefers-reduced-motion:reduce) {
  .dashboard-shell *, .dashboard-shell *::before, .dashboard-shell *::after { animation: none!important; transition: none!important; scroll-behavior: auto!important; }
}
@media print {
  .dashboard-shell { background: #fff; }
  .dashboard-shell .bento-card { background: #fff!important; box-shadow: none!important; backdrop-filter: none!important; }
}
/* Keep metric values together */
.dashboard-shell .bento-card [id^="kpi"]:not([id$="Sub"]):not([id*="Popover"]) { font-size: 21px; white-space: nowrap; line-height: 1.4; }
@media(min-width:1600px) { .dashboard-shell .bento-card [id^="kpi"]:not([id$="Sub"]):not([id*="Popover"]) { font-size: 24px; } }
@media(min-width:1024px) and (max-width:1399px) { .dashboard-shell #tabPane-overview > .grid:first-child { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media(max-width:390px) { .dashboard-shell .bento-card [id^="kpi"]:not([id$="Sub"]):not([id*="Popover"]) { font-size: 18px; } }
