/* ============================================================
   BFIP — Banking & FinTech Intelligence Platform
   Design System — main.css
   ST Bank | E-Banking Department
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root,
html[data-theme="dark"] {
  /* Colors */
  --bg-base:        #030B1A;
  --bg-surface:     #060F24;
  --bg-sidebar:     rgba(4, 10, 24, 0.95);
  --bg-card:        rgba(10, 20, 45, 0.75);
  --bg-card-hover:  rgba(15, 28, 58, 0.90);
  --bg-glass:       rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.07);

  /* Brand */
  --blue-500:  #3B82F6;
  --blue-400:  #60A5FA;
  --blue-600:  #2563EB;
  --blue-glow: rgba(59, 130, 246, 0.35);

  --gold-400:  #FBBF24;
  --gold-500:  #F59E0B;
  --gold-glow: rgba(251, 191, 36, 0.25);

  --cyan-400:  #22D3EE;
  --cyan-glow: rgba(34, 211, 238, 0.2);

  /* Status */
  --green-400:  #34D399;
  --green-500:  #10B981;
  --red-400:    #F87171;
  --red-500:    #EF4444;
  --orange-400: #FB923C;
  --orange-500: #F97316;
  --purple-400: #A78BFA;
  --purple-500: #8B5CF6;

  /* Text */
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --text-accent:    #60A5FA;

  /* Borders */
  --border:        rgba(255, 255, 255, 0.07);
  --border-active: rgba(59, 130, 246, 0.5);
  --border-gold:   rgba(251, 191, 36, 0.3);

  /* Spacing */
  --sidebar-w: 260px;
  --header-h:  60px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-blue: 0 0 20px var(--blue-glow);
  --shadow-gold: 0 0 20px var(--gold-glow);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s ease;

  --grid-line: rgba(59, 130, 246, 0.03);
}

html[data-theme="light"] {
  /* Light Mode Colors */
  --bg-base:        #F1F5F9 !important;
  --bg-surface:     #FFFFFF !important;
  --bg-sidebar:     #FFFFFF !important;
  --bg-card:        #FFFFFF !important;
  --bg-card-hover:  #F8FAFC !important;
  --bg-glass:       rgba(15, 23, 42, 0.03) !important;
  --bg-glass-hover: rgba(15, 23, 42, 0.06) !important;

  /* Brand Adjustments for Light Backgrounds */
  --blue-500:  #2563EB !important;
  --blue-400:  #2563EB !important;
  --blue-600:  #1D4ED8 !important;
  --blue-glow: rgba(37, 99, 235, 0.15) !important;

  --gold-400:  #D97706 !important;
  --gold-500:  #B45309 !important;
  --gold-glow: rgba(217, 119, 6, 0.15) !important;

  --cyan-400:  #0891B2 !important;
  --cyan-glow: rgba(8, 145, 178, 0.15) !important;

  /* Status */
  --green-400:  #059669 !important;
  --green-500:  #10B981 !important;
  --red-400:    #DC2626 !important;
  --red-500:    #EF4444 !important;
  --orange-400: #EA580C !important;
  --orange-500: #F97316 !important;
  --purple-400: #7C3AED !important;
  --purple-500: #8B5CF6 !important;

  /* Text - High Contrast */
  --text-primary:   #0F172A !important;
  --text-secondary: #334155 !important;
  --text-muted:     #64748B !important;
  --text-accent:    #2563EB !important;

  /* Borders */
  --border:        rgba(0, 0, 0, 0.09) !important;
  --border-active: rgba(37, 99, 235, 0.4) !important;
  --border-gold:   rgba(217, 119, 6, 0.3) !important;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06) !important;
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08) !important;
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.12) !important;
  --shadow-blue: 0 0 20px rgba(37, 99, 235, 0.12) !important;
  --shadow-gold: 0 0 20px rgba(217, 119, 6, 0.12) !important;

  --grid-line: rgba(148, 163, 184, 0.12) !important;
}

/* ── Light Mode Component Overrides ────────────────────────── */
html[data-theme="light"] body {
  background-color: #F1F5F9 !important;
  color: #0F172A !important;
}

html[data-theme="light"] .sidebar {
  background: #FFFFFF !important;
  border-right-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .sidebar-logo,
html[data-theme="light"] .sidebar-status,
html[data-theme="light"] .user-card {
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .nav-item {
  color: #334155 !important;
}

html[data-theme="light"] .nav-item:hover {
  background: rgba(37, 99, 235, 0.06) !important;
  color: #2563EB !important;
}

html[data-theme="light"] .nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.1), transparent) !important;
  color: #2563EB !important;
  border-left-color: #2563EB !important;
}

html[data-theme="light"] .ticker-bar {
  background: #FFFFFF !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .ticker-item {
  color: #334155 !important;
}

html[data-theme="light"] .card,
html[data-theme="light"] .kpi-card,
html[data-theme="light"] .source-card,
html[data-theme="light"] .health-strip,
html[data-theme="light"] .modal-body,
html[data-theme="light"] .analysis-item,
html[data-theme="light"] .copilot-banner {
  background: #FFFFFF !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.09) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
}

html[data-theme="light"] .card:hover,
html[data-theme="light"] .source-card:hover,
html[data-theme="light"] .kpi-card:hover {
  background: #F8FAFC !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .card-title,
html[data-theme="light"] .page-title,
html[data-theme="light"] .source-name,
html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] h4 {
  color: #0F172A !important;
}

html[data-theme="light"] .page-subtitle,
html[data-theme="light"] .kpi-label,
html[data-theme="light"] .section-label,
html[data-theme="light"] .text-muted,
html[data-theme="light"] .source-meta {
  color: #64748B !important;
}

html[data-theme="light"] input[type="text"],
html[data-theme="light"] input[type="search"],
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: #F8FAFC !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: #94A3B8 !important;
}

html[data-theme="light"] table,
html[data-theme="light"] th,
html[data-theme="light"] td {
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #0F172A !important;
}

html[data-theme="light"] th {
  background: #F8FAFC !important;
  color: #475569 !important;
}

html[data-theme="light"] .cat-tab {
  background: #F1F5F9 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #475569 !important;
}

html[data-theme="light"] .cat-tab:hover {
  background: rgba(37, 99, 235, 0.08) !important;
  color: #2563EB !important;
}

html[data-theme="light"] .cat-tab.active {
  background: rgba(37, 99, 235, 0.12) !important;
  border-color: rgba(37, 99, 235, 0.3) !important;
  color: #2563EB !important;
}

html[data-theme="light"] .watchlist-pill {
  background: #F8FAFC !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #0F172A !important;
}

html[data-theme="light"] .alert-card {
  background: #F8FAFC !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* ── Screen-Specific Light Mode Overrides ─────────────────── */
html[data-theme="light"] .copilot-sidebar-panel,
html[data-theme="light"] .chat-messages-container,
html[data-theme="light"] .chat-input-area,
html[data-theme="light"] .evidence-sidebar,
html[data-theme="light"] .evidence-detail-panel,
html[data-theme="light"] .evidence-card,
html[data-theme="light"] .radar-card,
html[data-theme="light"] .layer-chip,
html[data-theme="light"] .strat-card,
html[data-theme="light"] .reports-sidebar,
html[data-theme="light"] .report-preview-card,
html[data-theme="light"] .settings-card,
html[data-theme="light"] .notification-card,
html[data-theme="light"] .writer-sidebar,
html[data-theme="light"] .writer-canvas,
html[data-theme="light"] .linkedin-post,
html[data-theme="light"] .github-card,
html[data-theme="light"] .conf-card,
html[data-theme="light"] .matrix-table,
html[data-theme="light"] .news-card,
html[data-theme="light"] .feed-item,
html[data-theme="light"] .radar-box,
html[data-theme="light"] .comp-activity-card {
  background: #FFFFFF !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.09) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
}

/* Force dark inline backgrounds to turn white/light in light mode */
html[data-theme="light"] [style*="background: rgba(10, 20, 45"],
html[data-theme="light"] [style*="background:rgba(10, 20, 45"],
html[data-theme="light"] [style*="background: rgba(15, 23, 42"],
html[data-theme="light"] [style*="background:rgba(15, 23, 42"],
html[data-theme="light"] [style*="background: rgba(4, 10, 24"],
html[data-theme="light"] [style*="background:rgba(4, 10, 24"],
html[data-theme="light"] [style*="background: #060F24"],
html[data-theme="light"] [style*="background:#060F24"],
html[data-theme="light"] [style*="background: #030B1A"],
html[data-theme="light"] [style*="background:#030B1A"],
html[data-theme="light"] [style*="background: #0F172A"],
html[data-theme="light"] [style*="background:#0F172A"] {
  background: #FFFFFF !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.09) !important;
}

html[data-theme="light"] [style*="background: rgba(255, 255, 255, 0.0"],
html[data-theme="light"] [style*="background:rgba(255, 255, 255, 0.0"],
html[data-theme="light"] [style*="background: rgba(255,255,255,0.0"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.0"] {
  background: #F8FAFC !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .prompt-pill,
html[data-theme="light"] .filter-btn,
html[data-theme="light"] .strat-tab-btn {
  background: #F1F5F9 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #334155 !important;
}

html[data-theme="light"] .prompt-pill:hover,
html[data-theme="light"] .filter-btn:hover,
html[data-theme="light"] .strat-tab-btn:hover {
  background: rgba(37, 99, 235, 0.08) !important;
  color: #2563EB !important;
}

html[data-theme="light"] .matrix-table th {
  background: #F1F5F9 !important;
  color: #0F172A !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}

html[data-theme="light"] .matrix-table td {
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #0F172A !important;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Animated background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

/* Radial gradient overlay */
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(59,130,246,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.app-layout.sidebar-collapsed .main-content {
  margin-left: 0 !important;
  width: 100% !important;
}

.app-layout.sidebar-collapsed .sidebar {
  transform: translateX(-100%) !important;
}

.page-content {
  padding: 24px 28px;
  flex: 1;
}

/* ── Ticker Bar ────────────────────────────────────────────── */
.ticker-bar {
  background: linear-gradient(90deg, rgba(59,130,246,0.15), rgba(251,191,36,0.08), rgba(59,130,246,0.15));
  border-bottom: 1px solid var(--border);
  height: 36px;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.ticker-label {
  background: var(--blue-500);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 14px;
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.ticker-label.live::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #FF4444;
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.ticker-track {
  display: flex;
  align-items: center;
  animation: ticker-scroll 60s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticker-item .badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.ticker-item .badge.high    { background: rgba(239,68,68,0.25); color: #F87171; }
.ticker-item .badge.medium  { background: rgba(251,191,36,0.2); color: #FBBF24; }
.ticker-item .badge.low     { background: rgba(52,211,153,0.2); color: #34D399; }

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.page-title span {
  background: linear-gradient(135deg, var(--blue-400), var(--cyan-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

a {
  color: var(--blue-400);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover { color: var(--cyan-400); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Grid Utilities ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }

.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ── Flex Utilities ────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }

/* ── Section Labels ────────────────────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Divider ───────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 40px; opacity: 0.4; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

@keyframes pulse-ring {
  0%   { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 8px var(--blue-glow); }
  50%       { box-shadow: 0 0 24px var(--blue-glow); }
}

@keyframes counter-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Animation Utilities ───────────────────────────────────── */
.animate-fade-up   { animation: fadeInUp 0.5s ease forwards; }
.animate-fade-left { animation: fadeInLeft 0.4s ease forwards; }
.animate-slide-down{ animation: slideDown 0.3s ease forwards; }

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }

/* ── Skeleton Loader ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Mobile Header ─────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  min-height: 60px;
  padding: 7px 12px;
  background: rgba(6, 15, 36, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100% !important;
  box-sizing: border-box !important;
}
.mobile-header-actions {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}
.mobile-header-control,
.mobile-hamburger,
.mobile-action-btn,
.mobile-header .theme-toggle-btn {
  background: rgba(255, 255, 255, 0.055) !important;
  border: 1px solid rgba(148, 163, 184, 0.16) !important;
  outline: none !important;
  color: #E2E8F0 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 12px !important;
  transition: background-color 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease, transform 0.15s ease !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.mobile-header-control:hover,
.mobile-hamburger:hover,
.mobile-action-btn:hover,
.mobile-header .theme-toggle-btn:hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(148, 163, 184, 0.32) !important;
}
.mobile-header-control:active,
.mobile-hamburger:active,
.mobile-action-btn:active,
.mobile-header .theme-toggle-btn:active {
  transform: scale(0.92) !important;
}
.mobile-header-control:focus-visible {
  outline: 2px solid #93C5FD !important;
  outline-offset: 2px !important;
}

/* Primary mobile sync action */
.mobile-header .mobile-refresh-btn {
  position: relative !important;
  width: 44px !important;
  height: 44px !important;
  color: #DBEAFE !important;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.38), rgba(37, 99, 235, 0.14)) !important;
  border: 1px solid rgba(96, 165, 250, 0.48) !important;
  border-radius: 11px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 5px 14px rgba(37, 99, 235, 0.2) !important;
  transition: background 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease, transform 0.15s ease !important;
}
.mobile-header .mobile-refresh-btn:hover {
  color: #FFFFFF !important;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.58), rgba(37, 99, 235, 0.28)) !important;
  border-color: rgba(147, 197, 253, 0.75) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 7px 18px rgba(37, 99, 235, 0.34) !important;
  transform: translateY(-1px) !important;
}
.mobile-header .mobile-refresh-btn:active {
  transform: translateY(0) scale(0.94) !important;
}
.mobile-header .mobile-refresh-btn:focus-visible {
  outline: 2px solid #93C5FD !important;
  outline-offset: 2px !important;
}
.mobile-control-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.mobile-control-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mobile-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.mobile-brand-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #BFDBFE;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.42), rgba(37, 99, 235, 0.16));
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
}
.mobile-brand-icon .mobile-control-icon {
  width: 17px;
  height: 17px;
}
.mobile-brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mobile-brand-title {
  color: #F8FAFC;
  font-size: 16px;
  line-height: 1.1;
  letter-spacing: -0.25px;
}
.mobile-brand-title strong {
  color: var(--blue-400);
  font-weight: 800;
}
.mobile-sync-status {
  max-width: 118px;
  overflow: hidden;
  color: #94A3B8;
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-brand:hover {
  opacity: 0.85;
}
.mobile-brand:active {
  transform: scale(0.97);
}
@keyframes icon-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.mobile-refresh-btn.spinning {
  pointer-events: none;
}
.mobile-refresh-btn.spinning .mobile-control-icon {
  animation: icon-spin 0.8s linear infinite !important;
}
.mobile-header .mobile-refresh-btn.sync-success {
  color: #D1FAE5 !important;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.5), rgba(5, 150, 105, 0.2)) !important;
  border-color: rgba(52, 211, 153, 0.62) !important;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.24) !important;
}
.mobile-header .mobile-refresh-btn.sync-error {
  color: #FEE2E2 !important;
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.48), rgba(185, 28, 28, 0.2)) !important;
  border-color: rgba(248, 113, 113, 0.66) !important;
  box-shadow: 0 6px 18px rgba(185, 28, 28, 0.22) !important;
}

/* Light Mode Overrides for Mobile Header */
html[data-theme="light"] .mobile-header {
  background: rgba(255, 255, 255, 0.95) !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
html[data-theme="light"] .mobile-brand {
  color: #0F172A !important;
}
html[data-theme="light"] .mobile-brand-title { color: #0F172A; }
html[data-theme="light"] .mobile-brand-icon {
  color: #1D4ED8;
  background: linear-gradient(145deg, rgba(219, 234, 254, 0.98), rgba(191, 219, 254, 0.74));
  border-color: rgba(59, 130, 246, 0.36);
}
html[data-theme="light"] .mobile-sync-status { color: #64748B; }
html[data-theme="light"] .mobile-header-control,
html[data-theme="light"] .mobile-hamburger,
html[data-theme="light"] .mobile-action-btn,
html[data-theme="light"] .mobile-header .theme-toggle-btn {
  color: #0F172A !important;
  background: rgba(15, 23, 42, 0.035) !important;
  border-color: rgba(15, 23, 42, 0.1) !important;
}
html[data-theme="light"] .mobile-header-control:hover,
html[data-theme="light"] .mobile-hamburger:hover,
html[data-theme="light"] .mobile-action-btn:hover,
html[data-theme="light"] .mobile-header .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.06) !important;
}
html[data-theme="light"] .mobile-header .mobile-refresh-btn {
  color: #1D4ED8 !important;
  background: linear-gradient(145deg, rgba(219, 234, 254, 0.96), rgba(191, 219, 254, 0.7)) !important;
  border-color: rgba(59, 130, 246, 0.38) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 5px 14px rgba(37, 99, 235, 0.14) !important;
}
html[data-theme="light"] .mobile-header .mobile-refresh-btn:hover {
  color: #1E40AF !important;
  background: linear-gradient(145deg, #DBEAFE, #BFDBFE) !important;
  border-color: rgba(37, 99, 235, 0.58) !important;
}
html[data-theme="light"] .mobile-header .mobile-refresh-btn.sync-success {
  color: #065F46 !important;
  background: linear-gradient(145deg, #D1FAE5, #A7F3D0) !important;
  border-color: rgba(5, 150, 105, 0.48) !important;
}
html[data-theme="light"] .mobile-header .mobile-refresh-btn.sync-error {
  color: #991B1B !important;
  background: linear-gradient(145deg, #FEE2E2, #FECACA) !important;
  border-color: rgba(220, 38, 38, 0.44) !important;
}

@media (max-width: 360px) {
  .mobile-header { padding-inline: 8px; }
  .mobile-header-actions { gap: 4px !important; }
  .mobile-brand-icon { display: none; }
  .mobile-sync-status { max-width: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .mobile-header *,
  .mobile-header *::before,
  .mobile-header *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .mobile-refresh-btn.spinning .mobile-control-icon {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99990;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1400px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  /* Release the desktop stacking context so the fixed sidebar can sit above
     the page overlay. Keep page content above the decorative body layers. */
  .app-layout { z-index: auto; }
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    position: relative;
    z-index: 1;
  }
  .mobile-header { display: flex !important; }
  
  .sidebar { 
    width: 280px !important;
    max-width: 85vw !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(-100%) !important; 
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 99999 !important;
    background: #060F24 !important;
    border-right: 1px solid var(--border) !important;
    box-shadow: none;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 6px 0 36px rgba(0, 0, 0, 0.8) !important;
  }

  html[data-theme="light"] .sidebar {
    background: #FFFFFF !important;
    border-right-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 6px 0 36px rgba(0, 0, 0, 0.15) !important;
  }
  
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  
  /* Reset inline grids that were used for side-panels */
  div[style*="grid-template-columns:1fr 380px"],
  div[style*="grid-template-columns: 1fr 380px"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  
  .page-header { flex-direction: column; gap: 16px; align-items: flex-start; }
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .ticker-bar { display: none; }
}

/* ── Version Update Notification Banner & Badge ────────────── */
.bfip-update-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(59, 130, 246, 0.5);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 20px rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 440px;
  color: #fff;
  animation: slideUpUpdate 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpUpdate {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.bfip-update-icon {
  font-size: 28px;
  flex-shrink: 0;
  animation: pulseRocket 2s infinite ease-in-out;
}

@keyframes pulseRocket {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px) scale(1.06); }
}

.bfip-update-content {
  flex: 1;
  min-width: 0;
}

.bfip-update-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #60A5FA;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bfip-update-desc {
  font-size: 12px;
  color: #CBD5E1;
  margin-top: 2px;
  line-height: 1.35;
}

.bfip-update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bfip-update-btn {
  background: linear-gradient(135deg, #2563EB, #0284C7);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.bfip-update-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.02);
}

.bfip-update-btn:active {
  transform: scale(0.96);
}

.bfip-update-close {
  background: none;
  border: none;
  color: #94A3B8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.bfip-update-close:hover {
  color: #fff;
}

/* Sidebar Version Badge */
.sidebar-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.12);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.sidebar-version-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60A5FA;
  transform: scale(1.02);
}

/* Mobile specific styling for update banner */
@media (max-width: 900px) {
  .bfip-update-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
    padding: 12px 14px;
    gap: 10px;
  }
  .bfip-update-title {
    font-size: 12px;
  }
  .bfip-update-desc {
    font-size: 11px;
  }
  .bfip-update-btn {
    padding: 7px 12px;
    font-size: 11px;
  }
}

/* Light Theme Overrides for Update Banner */
html[data-theme="light"] .bfip-update-banner {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: rgba(37, 99, 235, 0.35) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 0 20px rgba(37, 99, 235, 0.15) !important;
  color: #0F172A !important;
}
html[data-theme="light"] .bfip-update-title {
  color: #2563EB !important;
}
html[data-theme="light"] .bfip-update-desc {
  color: #475569 !important;
}
html[data-theme="light"] .bfip-update-close {
  color: #64748B !important;
}
html[data-theme="light"] .bfip-update-close:hover {
  color: #0F172A !important;
}
html[data-theme="light"] .sidebar-version-badge {
  background: rgba(37, 99, 235, 0.08) !important;
  color: #2563EB !important;
  border-color: rgba(37, 99, 235, 0.2) !important;
}
