/* ===== Design tokens (match reference dashboard) ===== */
:root {
  --bg-primary: #1c1e24;
  --bg-card: #2f323a;
  --sidebar-bg: #412bcf;
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #ffffff;
  --text-secondary: #a0a4ac;
  --accent-green: #4caf50;
  --accent-red: #ff6347;
  --accent-yellow: #ffd700;
  --accent-purple: #9c27b0;
  --accent-orange: #ff9800;
  --progress-bg: rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --sidebar-width: 72px;
  --sidebar-width-expanded: 220px;
  --transition-sidebar: 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-btn: 0.2s ease;
  --transition-card: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== Base ===== */
.dashboard-body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg-primary) 0%, #252830 50%, #1a1c22 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  position: relative;
  isolation: isolate;
}

/* Full-screen background texture — fixed so it never scrolls.
   ↓ Tweak these two lines to taste once confirmed working: */
.dashboard-body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url('../assets/login-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.3;             /* ← lower this (e.g. 0.07–0.12) for subtlety  */
  mix-blend-mode: normal; /* ← try 'luminosity' to strip colour from image */
  pointer-events: none;
}

/* ===== Dashboard header (logo in same row as actions) ===== */
.dashboard-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dashboard-header-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* App branding next to logo */
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.brand-by {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  letter-spacing: 0.01em;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start; /* prevents flex from stretching sidebar to page height */
}

/* Sidebar only visible when logged in */
.app-layout:not(.with-sidebar) .sidebar {
  display: none;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  transition: width var(--transition-sidebar);
  overflow: hidden;
  flex-shrink: 0;
  will-change: width;
  /* Stick to the viewport — sidebar never scrolls with the page */
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar.expanded {
  width: var(--sidebar-width-expanded);
  align-items: stretch;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  /* Both icons are position:absolute so the button needs relative + fixed size */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  transition: background var(--transition-btn), transform var(--transition-btn);
  flex-shrink: 0;
}

.sidebar.expanded .sidebar-toggle {
  align-self: flex-end;
  margin-right: 12px;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

.sidebar-toggle:active {
  transform: scale(0.94);
}

/* Icons are stacked on top of each other and crossfade.
   JS controls opacity + transform; CSS just defines the timing. */
.sidebar-toggle-icon-open,
.sidebar-toggle-icon-close {
  position: absolute;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none; /* click lands on button, not icon */
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 12px;
  flex: 1; /* allows margin-top: auto on .sidebar-link-bottom to push it to the bottom */
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: background var(--transition-btn), color var(--transition-btn);
  white-space: nowrap;
  min-height: 44px;
  box-sizing: border-box;
}

.sidebar-link i {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-link.active {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.sidebar-label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-6px);
  /* Collapse: content disappears quickly before the width closes */
  transition:
    opacity 0.12s ease,
    max-width var(--transition-sidebar),
    transform 0.15s ease;
}

.sidebar.expanded .sidebar-label {
  opacity: 1;
  max-width: 160px;
  transform: translateX(0);
  /* Expand: width opens first, then labels slide + fade in */
  transition:
    opacity 0.2s ease 0.1s,
    max-width var(--transition-sidebar),
    transform 0.24s cubic-bezier(0.34, 1.4, 0.64, 1) 0.1s;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-link-bottom {
  margin-top: auto;
}

/* ===== Main content ===== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 32px;
  overflow-x: hidden;
}

.content-section {
  max-width: 1400px;
  margin: 0 auto;
}

.content-section.hidden {
  display: none !important;
}

/* ===== App loader ===== */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease;
}

.app-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.app-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.app-loader-logo {
  height: 72px;
  width: auto;
  opacity: 0.85;
  animation: loader-pulse 2s ease-in-out infinite;
}

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

.app-loader-ring {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--sidebar-bg);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ===== Dashboard loading skeleton ===== */
@keyframes shimmer-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* Cards shimmer while data is in flight */
.dashboard-section.is-loading .card {
  position: relative;
  overflow: hidden;
}

.dashboard-section.is-loading .card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.055) 50%,
    transparent 65%
  );
  animation: shimmer-sweep 1.6s ease-in-out infinite;
}

/* Skeleton placeholder lines for callout values */
.dashboard-section.is-loading .callout-value,
.dashboard-section.is-loading .callout-week-change,
.dashboard-section.is-loading .callout-detail {
  color: transparent !important;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  min-height: 1em;
  user-select: none;
}

/* ===== Empty states ===== */
/* Used in tables (raw data, top movers, monopoly) */
.empty-state-cell {
  text-align: center;
  padding: 48px 24px !important;
  color: var(--text-secondary);
}

.empty-state-cell .empty-icon {
  font-size: 2rem;
  opacity: 0.3;
  display: block;
  margin-bottom: 12px;
}

.empty-state-cell .empty-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.empty-state-cell .empty-hint {
  font-size: 0.8rem;
  color: rgba(160, 164, 172, 0.6);
  margin: 0;
}

/* ===== Auth & onboarding ===== */
.auth-section,
.onboarding-section {
  /* Full-viewport background, independent of the main-content padding */
  position: fixed;
  inset: 0;
  max-width: none;
  margin: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  overflow-y: auto;
  background:
    linear-gradient(rgba(8, 8, 14, 0.62), rgba(8, 8, 14, 0.78)),
    url('../assets/login-bg.png') center / cover no-repeat;
}

/* Branding block above the sign-in card */
.auth-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  height: 80px;
  width: auto;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.6));
}

.auth-brand-title {
  font-size: 2rem;
  font-weight: 800;
  color: #ffffff;
  margin: -20px 0 -7px 0;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.auth-brand-tagline {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
  text-transform: uppercase;
}

.auth-footer {
  max-width: 420px;
  width: 100%;
  margin-top: 20px;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.38);
}

.auth-footer-link {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.auth-footer-link:hover {
  color: rgba(255, 255, 255, 0.9);
}

.auth-socials {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.auth-privacy-link {
  margin-top: 16px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.2s ease;
}

.auth-privacy-link:hover {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.1rem;
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.auth-social-link:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* Divider between primary and demo actions */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.auth-demo-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.9rem;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.auth-demo-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

/* ─── Demo mode ──────────────────────────────────────────────────────────── */

/* Hide the Settings nav link entirely in demo mode */
.is-demo .sidebar-link[data-page="settings"] {
  display: none;
}

/* Subtle pill badge — sits inside .dashboard-actions, directly beside the Home button */
.is-demo .dashboard-actions::before {
  content: 'DEMO';
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-orange);
  border: 1px solid var(--accent-orange);
  border-radius: 4px;
  padding: 2px 7px;
  opacity: 0.85;
}

.auth-card,
.onboarding-card {
  max-width: 420px;
  width: 100%;
  /* Glassmorphism overlay — more readable on the background image */
  background: rgba(28, 30, 36, 0.82) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.auth-title,
.onboarding-card .auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-primary);
}

.auth-subtitle,
.onboarding-card .auth-subtitle {
  color: var(--text-secondary);
  margin: 0 0 24px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.input-dark {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 16px;
  transition: border-color var(--transition-btn), box-shadow var(--transition-btn);
}

.input-dark::placeholder {
  color: var(--text-secondary);
}

.input-dark:focus {
  outline: none;
  border-color: var(--sidebar-bg);
  box-shadow: 0 0 0 3px rgba(108, 71, 228, 0.2);
}

.url-error {
  color: var(--accent-red);
  font-size: 0.875rem;
  margin-top: 8px;
}

/* ===== Settings page ===== */
.settings-section .dashboard-header {
  margin-bottom: 24px;
}

.settings-card {
  max-width: 560px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-message {
  font-size: 0.9rem;
  margin: 0;
}

.settings-message.success {
  color: var(--accent-green);
}

.settings-message.error {
  color: var(--accent-red);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background var(--transition-btn), transform var(--transition-btn), box-shadow var(--transition-btn);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--sidebar-bg);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: #5a3bc7;
  box-shadow: 0 4px 14px rgba(108, 71, 228, 0.4);
}

.btn-success {
  background: var(--accent-green);
  color: white;
  width: 100%;
}

.btn-success:hover {
  background: #43a047;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.875rem;
}

/* ===== Cards ===== */
.card {
  background: rgba(47, 50, 58, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border-subtle);
  border-top: none; /* replaced by ::before gradient */
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32), 0 8px 28px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-card), box-shadow var(--transition-card);
}

/* Gradient top-border accent (purple → teal) */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(108, 71, 228, 0.7), rgba(43, 209, 192, 0.55));
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.42), 0 16px 44px rgba(0, 0, 0, 0.28);
}

.card-category {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Dashboard header ===== */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* Reduced — page title below provides the remaining vertical rhythm */
  margin-bottom: 12px;
}

/* Page title shown below the branding/actions bar */
.page-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.data-week-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-style: italic;
  margin: 0;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: -16px 0 24px;
}

/* Kept for backwards-compat; no longer used in HTML */
.dashboard-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.dashboard-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  width: 220px;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-btn), width var(--transition-btn);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:focus {
  outline: none;
  border-color: var(--sidebar-bg);
}

/* ===== Dashboard grid ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.donuts-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .donuts-row {
    grid-template-columns: 1fr;
  }
}

/* Chart cards ===== */
.chart-card {
  min-height: 260px;
}

.chart-card-value,
.analytics-value,
.trend-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.chart-card-change {
  font-size: 0.95rem;
  margin: 4px 0 12px;
}

.chart-card-change.positive {
  color: var(--accent-green);
}

.chart-card-change.negative {
  color: var(--accent-red);
}

.chart-card-canvas-wrap {
  height: 140px;
  margin-top: 12px;
  position: relative;
}

.donut-chart-wrap {
  height: 180px;
  margin-top: 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-legend {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 6px 0 0;
  text-align: center;
  line-height: 1.5;
}

/* Rich legend rows inside .donut-legend */
.dlr-row {
  display: grid;
  grid-template-columns: 8px 1fr auto auto auto;
  align-items: center;
  gap: 0 7px;
  padding: 3px 0;
}

.dlr-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dlr-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlr-pct {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 38px;
}

.dlr-count {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.dlr-unit {
  font-size: 0.68rem;
  opacity: 0.7;
}

.dlr-value {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  min-width: 68px;
}

/* Analytics card ===== */
.analytics-card {
  min-height: 260px;
}

.analytics-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Separator between the chart title and its content */
.chart-card .analytics-title {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 16px;
}

/* Treemap: the separator lives on the flex header row, not the h3 */
.treemap-header-row {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 12px;
}
.treemap-header-row .analytics-title {
  padding-bottom: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.section-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.progress-wrap {
  height: 8px;
  background: var(--progress-bg);
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0 16px;
}

.progress-wrap.progress-sm {
  height: 6px;
  margin: 8px 0 0;
}

.progress-bar {
  height: 100%;
  background: var(--sidebar-bg);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-bar-yellow { background: var(--accent-yellow); }
.progress-bar-purple { background: var(--accent-purple); }
.progress-bar-green { background: var(--accent-green); }
.progress-bar-orange { background: var(--accent-orange); }

.analytics-table-wrap {
  overflow-x: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.analytics-table th,
.analytics-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.analytics-table th {
  color: var(--text-secondary);
  font-weight: 500;
}

.analytics-table td.positive {
  color: var(--accent-green);
}

.analytics-table td.negative {
  color: var(--accent-red);
}

.analytics-table .muted {
  color: var(--text-secondary);
  font-style: italic;
}

/* Metrics row (4 small cards) ===== */
.metrics-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }
}

.metrics-row-full {
  grid-column: 1 / -1;
}

.dashboard-row-two {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 2fr;
  gap: 24px;
  align-items: stretch;
}

/* Callout stack fills the row height set by the grid */
.callouts-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  height: 580px;
}

.callouts-stack > .card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

@media (max-width: 900px) {
  .dashboard-row-two {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

/* Treemap card stretches to fill the full row height */
.sets-bar-card {
  position: relative;
  z-index: 1;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
}

/* Chart area fills whatever space the card has left after the header */
/* ===== Treemap outlier toggle ===== */
.treemap-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.treemap-header-row .analytics-title {
  margin: 0;
}

.treemap-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  margin: 0 15px 0 0;
}

.treemap-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.treemap-toggle-track {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  transition: background 0.22s ease, border-color 0.22s ease;
  flex-shrink: 0;
}

.treemap-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.22s ease;
}

.treemap-toggle-input:checked + .treemap-toggle-track {
  background: var(--accent, #6c47e4);
  border-color: var(--accent, #6c47e4);
}

.treemap-toggle-input:checked + .treemap-toggle-track .treemap-toggle-thumb {
  transform: translateX(16px);
  background: #ffffff;
}

.treemap-toggle-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: color 0.18s ease;
}

.treemap-toggle-input:checked ~ .treemap-toggle-text {
  color: var(--text-primary);
}

.treemap-toggle-wrap:hover .treemap-toggle-track {
  border-color: rgba(255, 255, 255, 0.3);
}

.sets-bar-wrap {
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  position: relative;
}

.sets-bar-card .analytics-title {
  margin: 0;
}

/* Set-Level Capital Allocation treemap (reuses sets-bar-wrap height) */
#setsTreemapChart {
  display: block;
  width: 100%;
  height: 100%;
}

/* Top Movers table */
.top-movers-row {
  grid-column: 1 / -1;
}

.top-movers-card {
  min-height: 320px;
}

.top-movers-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
}

.top-movers-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-btn), color var(--transition-btn), border-color var(--transition-btn);
}

.top-movers-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.top-movers-tab.active {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-bg);
  color: white;
}

.top-movers-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.top-movers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.top-movers-table th {
  text-align: left;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.top-movers-table th.col-prev-price,
.top-movers-table th.col-diff,
.top-movers-table th.col-curr-price,
.top-movers-table th.col-country-stock,
.top-movers-table th.col-total-stock {
  text-align: right;
}

.top-movers-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.top-movers-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.top-movers-table .col-image {
  width: 72px;
  padding: 8px 12px;
}

.top-movers-img-cell {
  position: relative;
  width: 72px;
}

.top-movers-img-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 68px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 1.25rem;
}

.top-movers-img-placeholder.hidden {
  display: none;
}

.top-movers-card-img {
  width: 48px;
  height: 68px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.top-movers-card-img.hidden {
  display: none;
}

.top-movers-table .col-name {
  min-width: 160px;
  font-weight: 500;
  color: var(--text-primary);
}

.top-movers-table .col-set {
  color: var(--text-secondary);
  min-width: 80px;
}

.top-movers-table .col-prev-price {
  min-width: 110px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.top-movers-table .col-diff {
  min-width: 110px;
  font-weight: 600;
  text-align: right;
}

.top-movers-table .col-diff.positive {
  color: var(--accent-green);
}

.top-movers-table .col-diff.negative {
  color: var(--accent-red);
}

.top-movers-table .col-curr-price {
  min-width: 110px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.top-movers-table .col-country-stock,
.top-movers-table .col-total-stock {
  min-width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.top-movers-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 24px;
}

.callout-total .callout-value {
  font-size: 1.75rem;
}

.metric-card {
  padding: 18px;
}

/* Tighter layout for the stacked callout-total cards */
.callout-total {
  padding: 12px 14px;
}

.callout-total .metric-icon {
  margin-bottom: 8px; /* ← increase/decrease this to control icon-to-text gap */
  font-size: 1.1rem;
}

.metric-icon {
  font-size: 1.25rem;
  margin-bottom: 8px;
  opacity: 0.9;
}

.metric-icon-yellow { color: var(--accent-yellow); }
.metric-icon-purple { color: var(--accent-purple); }
.metric-icon-green  { color: var(--accent-green); }
.metric-icon-orange { color: var(--accent-orange); }
.metric-icon-red    { color: var(--accent-red); }
.metric-icon-teal   { color: #00a195; }

/* Coloured left-border on callout cards — matches the icon accent */
/* Gloss sheen on callout cards only */
@keyframes card-sheen {
  0%   { background-position: -80%  0; opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { background-position: 180%  0; opacity: 0; }
}

.callout-card {
  border-left-width: 3px;
  border-left-style: solid;
  transition: background 0.3s ease, box-shadow var(--transition-card);
}

.callout-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.04) 38%,
    rgba(255, 255, 255, 0.13) 50%,
    rgba(255, 255, 255, 0.04) 62%,
    transparent 80%
  );
  background-size: 220% 100%;
  background-position: -80% 0;
  opacity: 0;
  pointer-events: none;
}

.callout-card:hover::after {
  animation: card-sheen 0.65s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.callout-card:hover {
  background: rgba(62, 65, 76, 0.9);
}
.callout-card:has(.metric-icon-yellow) { border-left-color: var(--accent-yellow); }
.callout-card:has(.metric-icon-green)  { border-left-color: var(--accent-green); }
.callout-card:has(.metric-icon-red)    { border-left-color: var(--accent-red); }
.callout-card:has(.metric-icon-orange) { border-left-color: var(--accent-orange); }
.callout-card:has(.metric-icon-teal)   { border-left-color: #00a195; }
.callout-card:has(.metric-icon-purple) { border-left-color: var(--accent-purple); }

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.callout-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.callout-title {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 3px;
}

.callout-value {
  font-size: 1.35rem;
  margin: 2px 0 1px;
}

.callout-detail {
  font-size: 0.78rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.callout-value.positive { color: var(--accent-green); }
.callout-value.negative { color: var(--accent-red); }
.callout-detail.positive { color: var(--accent-green); }
.callout-detail.negative { color: var(--accent-red); }

.callout-week-change {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 1px 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.callout-week-change.positive { color: var(--accent-green); }
.callout-week-change.negative { color: var(--accent-red); }

/* ===== Language selector ===== */
.lang-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 3px 6px;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 12px;
  opacity: 0.45;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.lang-btn:hover {
  opacity: 0.85;
  transform: scale(1.15);
}

.lang-btn.lang-btn-active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

.callout-alerts-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-red);
  opacity: 0.8;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.callout-alerts-link:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Alerts legend (collapsible) */
.alerts-legend {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.alerts-legend-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.alerts-legend-toggle::-webkit-details-marker { display: none; }
.alerts-legend-toggle:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.alerts-legend-toggle .fa-info-circle { color: var(--accent-blue, #5c8ee6); font-size: 0.78rem; }

.alerts-legend-chevron {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.22s ease;
}
.alerts-legend[open] .alerts-legend-chevron { transform: rotate(180deg); }

.alerts-legend-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 4px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.alerts-legend-col {
  flex: 1 1 260px;
  padding: 10px 10px 0;
}

.alerts-legend-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 8px 0;
  flex-shrink: 0;
}

.alerts-legend-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.alerts-legend-sub {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.alerts-legend-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.alerts-legend-row .table-badge {
  flex-shrink: 0;
  margin-top: 1px;
  min-width: 22px;
  text-align: center;
}

.alerts-legend-row strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Alerts table filter controls */
.alerts-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 4px;
}

.alerts-filter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 5px 10px;
}

.alerts-filter-icon {
  font-size: 0.72rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.alerts-filter-select {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23888' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 14px;
}

.alerts-filter-select option {
  background: var(--bg-secondary, #1a1d2e);
  color: var(--text-primary);
}

/* Circular progress card ===== */
.circular-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.circular-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.circular-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 4px 0 12px;
}

.circular-progress-wrap {
  width: 100px;
  height: 100px;
  margin: 8px 0;
}

.circular-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.circular-bg {
  fill: none;
  stroke: var(--progress-bg);
  stroke-width: 2.5;
}

.circular-fill {
  fill: none;
  stroke: var(--accent-orange);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.8s ease;
}

.chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.chip-pink {
  background: rgba(255, 98, 71, 0.2);
  color: var(--accent-orange);
}

/* Table card ===== */
.table-card {
  padding: 24px;
}

.table-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.table-scroll {
  overflow: auto;
  max-height: min(90vh, 1000px);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.raw-data-section .table-scroll {
  max-height: min(90vh, 1000px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.7rem;
}

.raw-img-th {
  width: 60px;
  min-width: 60px;
  padding: 8px 10px !important;
  cursor: default !important;
  background: #25282e;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.raw-img-cell {
  width: 60px;
  min-width: 60px;
  padding: 4px 8px !important;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table thead th {
  background: #25282e;
  color: var(--text-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: relative;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.data-table thead th:last-child {
  border-right: none;
}

.data-table-th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.data-table-th-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table-th-sortable {
  cursor: pointer;
  user-select: none;
}

.data-table-th-sortable:hover {
  color: var(--accent-purple);
}

.table-sort-icon {
  flex-shrink: 0;
  width: 14px;
  opacity: 0.8;
  font-size: 0.65rem;
}

.table-sort-icon.sort-asc,
.table-sort-icon.sort-desc {
  opacity: 1;
  color: var(--sidebar-bg);
}

.table-filter-btn-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.table-filter-btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.table-filter-btn-icon.active {
  color: var(--sidebar-bg);
}

.table-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 1;
}

.table-resize-handle:hover,
body.table-resizing .table-resize-handle {
  background: rgba(108, 71, 228, 0.25);
}

body.table-resizing {
  cursor: col-resize;
  user-select: none;
}

.data-table tbody tr {
  transition: background var(--transition-btn);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table td {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table td.muted {
  color: var(--text-secondary);
  font-style: italic;
}

.table-flag {
  font-size: 1.1em;
  line-height: 1;
}

.table-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #1c1e24;
  white-space: nowrap;
}

.table-badge-condition {
  /* background-color from CONDITION_BADGES applied inline */
  color: #1a1a1a;
}

.table-badge-alerts-urgent {
  color: #fff !important;
}

.table-badge-yes {
  background-color: #66bb6a;
  color: #fff;
}

.table-badge-no {
  background-color: #ef5350;
  color: #fff;
}

.table-link {
  color: var(--sidebar-bg);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

/* Excel-style filter popover */
.table-filter-popover {
  position: fixed;
  z-index: 1000;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-filter-search-wrap {
  margin-bottom: 8px;
}

.table-filter-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.table-filter-search::placeholder {
  color: var(--text-secondary);
}

.table-filter-search:focus {
  outline: none;
  border-color: var(--sidebar-bg);
}

.table-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
}

.table-filter-cb {
  flex-shrink: 0;
  cursor: pointer;
}

.table-filter-list {
  overflow-y: auto;
  max-height: 200px;
  min-height: 60px;
  margin: 6px 0 10px;
}

.table-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.table-filter-btn {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.table-filter-ok {
  background: var(--sidebar-bg);
  color: white;
}

.table-filter-ok:hover {
  background: #5a3bc7;
}

.table-filter-clear {
  background: transparent;
  color: var(--text-secondary);
}

.table-filter-clear:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ===== Animations ===== */
.animate-in {
  animation: fadeSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: calc(var(--delay, 0) * 0.08s);
}

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

/* Stagger children if needed */
.dashboard-section .card {
  animation: fadeSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

/* Button press animation */
.btn:active {
  transform: scale(0.98);
}

.btn-primary:active,
.btn-success:active {
  transform: translateY(0) scale(0.98);
}

/* ===== Card image hover preview ===== */
.card-img-preview {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.15s ease, transform 0.15s ease;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: #1c1e24;
  padding: 5px;
}

.card-img-preview.visible {
  opacity: 1;
  transform: scale(1);
}

.card-img-preview img {
  display: block;
  width: 230px;
  border-radius: 6px;
}

.top-movers-img-cell {
  cursor: zoom-in;
}

/* ===== Scatter charts row ===== */
.scatter-charts-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 900px) {
  .scatter-charts-row {
    grid-template-columns: 1fr;
  }
}

.scatter-chart-wrap {
  height: 320px;
  margin-top: 12px;
  position: relative;
}

.scatter-chart-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.scatter-chart-hint .hint-below {
  color: #2bd1c0;
  font-weight: 600;
}

.scatter-chart-hint .hint-above {
  color: #e9536f;
  font-weight: 600;
}

/* ===== Regional Market Monopoly table ===== */
.monopoly-row {
  grid-column: 1 / -1;
}

.monopoly-card {
  min-height: 260px;
}

.monopoly-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.monopoly-lang-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.monopoly-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.monopoly-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.monopoly-pill.active {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-bg);
  color: #fff;
}

.monopoly-search-wrap {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.monopoly-search-field {
  position: relative;
  flex: 1;
  min-width: 140px;
}

.monopoly-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.75rem;
  pointer-events: none;
}

.monopoly-search {
  width: 100%;
  padding: 6px 10px 6px 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.82rem;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.monopoly-search::placeholder {
  color: var(--text-secondary);
}

.monopoly-search:focus {
  outline: none;
  border-color: var(--sidebar-bg);
}

.monopoly-table-wrap {
  margin-top: 10px;
  overflow: auto;
  max-height: 420px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.monopoly-cell {
  white-space: nowrap;
  color: var(--text-secondary);
}

.monopoly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.monopoly-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.monopoly-th {
  padding: 11px 16px;
  text-align: left;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.monopoly-th:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-card) 92%, white);
}

.monopoly-th.monopoly-th-active {
  color: #6c47e4;
}

.monopoly-th.monopoly-th-num {
  text-align: right;
}

.monopoly-sort-arrow {
  margin-left: 4px;
  font-size: 0.75rem;
  opacity: 0.7;
}

.monopoly-th.monopoly-th-active .monopoly-sort-arrow {
  opacity: 1;
  color: #6c47e4;
}

.monopoly-table td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-primary);
}

.monopoly-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.monopoly-th-img {
  width: 56px;
  min-width: 56px;
  padding: 8px 10px;
  cursor: default !important;
}

.monopoly-img-cell {
  width: 56px;
  min-width: 56px;
  padding: 6px 10px !important;
}

.monopoly-card-link {
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(108, 71, 228, 0.45);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.monopoly-card-link:hover {
  color: #a68fff;
  border-bottom-color: #a68fff;
}

.monopoly-name {
  min-width: 160px;
  font-weight: 500;
}

.monopoly-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-secondary);
}

.monopoly-index {
  font-weight: 600;
  color: var(--text-primary) !important;
}

.monopoly-index-high {
  color: #e9536f !important;
}

.monopoly-index-mid {
  color: #ff8934 !important;
}

.monopoly-empty {
  text-align: center;
  padding: 28px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ===== Arbitrage Availability Engine chart ===== */
.arbitrage-row {
  grid-column: 1 / -1;
}

.arbitrage-chart-wrap {
  height: 400px;
  margin-top: 14px;
  position: relative;
}

.alerts-row {
  grid-column: 1 / -1;
}

/* The alerts table reuses .monopoly-table styles; this just adds the
   sticky header background to match the monopoly table fix */
.alerts-table thead th {
  background: var(--bg-card) !important;
}
