/* ═══════════════════════════════════════════════════════════════════════════
   IQlarity — Dashboard
   Professional BI Platform design (Power BI / Tableau inspired)
   Consistent with landing.css color language (indigo #4f46e5 / cyan #06b6d4)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* ── Sidebar (medium-dark panel) */
  --db-sidebar-bg: #1e293b;
  --db-sidebar-bg-hover: rgba(255, 255, 255, 0.06);
  --db-sidebar-border: rgba(255, 255, 255, 0.09);
  --db-sidebar-text: #e2e8f0;
  --db-sidebar-text-muted: #94a3b8;
  --db-sidebar-active-bg: rgba(99, 102, 241, 0.2);
  --db-sidebar-active-text: #c7d2fe;
  --db-sidebar-active-border: #6366f1;
  --db-sidebar-logo-ring: rgba(99, 102, 241, 0.4);

  /* ── Top nav (frosted white — consistent with landing page) */
  --db-nav-bg: rgba(255, 255, 255, 0.93);
  --db-nav-border: rgba(0, 0, 0, 0.07);
  --db-nav-text: #0f172a;
  --db-nav-text-muted: #64748b;

  /* ── Toolbar (light strip) */
  --db-toolbar-bg: #ffffff;
  --db-toolbar-border: #e9ecf0;
  --db-toolbar-btn-bg: #f8fafc;
  --db-toolbar-btn-bg-hover: #eef2ff;
  --db-toolbar-btn-border: #e2e8f0;
  --db-toolbar-btn-border-hover: #c7d2fe;
  --db-toolbar-btn-text: #334155;
  --db-toolbar-btn-text-hover: #4f46e5;
  --db-toolbar-primary-bg: #4f46e5;
  --db-toolbar-primary-hover: #4338ca;

  /* ── Page & surfaces */
  --db-page-bg: #eef1f7;
  --db-surface: #ffffff;
  --db-surface-raised: #f8faff;
  --db-chart-bg: #ffffff;

  /* ── Brand — aligned with landing.css */
  --db-primary: #4f46e5;
  --db-primary-dark: #4338ca;
  --db-primary-light: #6366f1;
  --db-accent: #06b6d4;
  --db-accent-2: #8b5cf6;

  /* ── Text hierarchy */
  --db-text: #0f172a;
  --db-text-secondary: #475569;
  --db-text-muted: #94a3b8;

  /* ── Borders & Shadows */
  --db-border: rgba(0, 0, 0, 0.07);
  --db-border-medium: rgba(0, 0, 0, 0.11);
  --db-shadow-xs:  0 1px 2px rgba(15, 23, 42, 0.05);
  --db-shadow-sm:  0 1px 4px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.05);
  --db-shadow-md:  0 4px 16px rgba(15, 23, 42, 0.09), 0 2px 6px rgba(15, 23, 42, 0.05);
  --db-shadow-lg:  0 8px 32px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.07);
  --db-shadow-chart: 0 2px 8px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);

  /* ── Layout dimensions (driven by layout-tokens.css) */
  --db-nav-height: var(--layout-nav-h, 52px);
  --db-search-row-height: var(--layout-search-row-h, 60px);
  --db-sidebar-width: var(--layout-sidebar, 248px);
  --db-right-sidebar-width: var(--layout-sidebar-right, 248px);
  --db-main-max-width: 1280px;
  --db-main-inline-padding: var(--layout-padding, 1.25rem);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BASE OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

.db-body {
  font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--db-page-bg);
  color: var(--db-text);
  margin: 0;
  overflow-x: hidden;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOP NAVIGATION BAR
   ═══════════════════════════════════════════════════════════════════════════ */

.db-topnav {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  height: var(--db-nav-height);
  padding: 0 1rem;
  background: var(--db-nav-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--db-nav-border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.06);
  box-sizing: border-box;
  gap: 0.5rem;
}

.db-topnav-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.db-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.db-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
}

.db-brand-link:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 3px;
}

.db-brand-logo {
  width: 150px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3), var(--db-shadow-xs);
}

.db-brand-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.db-brand-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--db-nav-text-muted);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.db-brand-tagline {
  font-size: 0.7rem;
  color: var(--db-nav-text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.db-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.db-breadcrumb-sep {
  color: #94a3b8;
  font-size: 0.85rem;
}

.db-breadcrumb-item {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Top Nav Buttons */
.db-topnav-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.db-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
  width: auto;
  margin-bottom: 0;
  box-shadow: none;
}

.db-nav-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.db-nav-btn--ghost {
  background: transparent;
  color: var(--db-nav-text-muted);
  border-color: transparent;
}

.db-nav-btn--ghost:hover {
  background: rgba(79, 70, 229, 0.07);
  color: var(--db-primary);
  border-color: rgba(79, 70, 229, 0.15);
  transform: none;
  box-shadow: none;
}

.db-nav-btn--primary {
  background: var(--db-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.3);
}

.db-nav-btn--primary:hover {
  background: var(--db-primary-dark);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.35);
  transform: none;
}

/* ── Center zone of top nav: action buttons ── */
.db-topnav-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}
.db-topnav-center::-webkit-scrollbar { display: none; }

/* ── Action Buttons in the nav (same class as before: toolbar-btn) */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.7rem;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.09);
  background: #f8fafc;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  width: auto;
  min-width: unset;
  margin-bottom: 0;
  letter-spacing: 0.01em;
}

.toolbar-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}

.toolbar-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4f46e5;
  box-shadow: 0 1px 6px rgba(79, 70, 229, 0.14);
  transform: none;
}

.toolbar-btn:hover svg { opacity: 1; }

.toolbar-btn:active {
  transform: scale(0.97);
  box-shadow: none;
}

.toolbar-btn:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.4);
  outline-offset: 2px;
}

.toolbar-btn.is-primary {
  background: #4f46e5;
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.32);
}

.toolbar-btn.is-primary svg { opacity: 0.9; color: #fff; }

.toolbar-btn.is-primary:hover {
  background: #4338ca;
  border-color: rgba(129, 140, 248, 0.6);
  color: #fff;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.38);
}

.toolbar-separator {
  width: 1px;
  height: 18px;
  background: rgba(0,0,0,0.1);
  margin: 0 0.15rem;
  flex-shrink: 0;
}

/* ── Search bar row (between nav and layout) ── */
.db-search-row {
  position: sticky;
  top: var(--db-nav-height);
  z-index: 1100;
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
  box-shadow: none;
  padding: 0.32rem calc(var(--db-right-sidebar-width) + var(--db-main-inline-padding)) 0 calc(var(--db-sidebar-width) + var(--db-main-inline-padding));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: calc(var(--db-search-row-height) - 10px);
  pointer-events: none;
}

.db-search-header,
#header_class {
  width: 100%;
  max-width: var(--db-main-max-width);
  margin: 0 auto;
  padding: 0 var(--db-main-inline-padding);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  pointer-events: auto;
}

.db-progress-note {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  border: 1px dashed rgba(100, 116, 139, 0.42);
  background: rgba(148, 163, 184, 0.12);
  color: #475569;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}

.db-tabs-row {
  display: flex;
  align-items: flex-end;
  gap: 0.3rem;
  width: 100%;
  min-height: 34px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.36);
  margin-bottom: -1px;
}

.db-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0.26rem;
  flex: 0 1 auto;
  max-width: calc(100% - 32px);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 0;
}

.db-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 100px;
  max-width: 220px;
  height: 32px;
  padding: 0 0.38rem 0 0.76rem;
  border-radius: 9px 9px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-bottom: none;
  background: linear-gradient(180deg, #f5f8fc 0%, #e9eff8 100%);
  color: #4b5563;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.db-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: rgba(148, 163, 184, 0.36);
}

.db-tab:hover {
  transform: none;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5fb 100%);
  color: #334155;
  border-color: rgba(148, 163, 184, 0.62);
  box-shadow: none;
}

.db-tab.is-active {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.56);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.95) inset, 0 1px 0 rgba(255, 255, 255, 0.96);
  z-index: 2;
}

.db-tab.is-active::after {
  background: #ffffff;
}

.db-tab-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.db-tab.has-content .db-tab-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #22c55e;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.db-tab.is-active.has-content .db-tab-label::before {
  background: #a7f3d0;
}

.db-tab-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  width: 26px;
  height: 26px;
  align-self: flex-end;
  padding: 0;
  border-radius: 7px 7px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-bottom: none;
  background: linear-gradient(180deg, #f5f8fc 0%, #e9eff8 100%);
  color: #64748b;
  cursor: pointer;
  margin-bottom: 0;
  box-shadow: none;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.db-tab-add:hover {
  transform: none;
  background: #ffffff;
  color: #334155;
  border-color: rgba(148, 163, 184, 0.58);
  box-shadow: none;
}

.db-tab-add svg {
  width: 14px;
  height: 14px;
}

.db-tab-close {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
}

.db-tab-close svg {
  width: 11px;
  height: 11px;
}

.db-tab-close:hover {
  transform: none;
  background: rgba(148, 163, 184, 0.28);
  color: #1f2937;
  box-shadow: none;
}

.db-tab.is-active .db-tab-close {
  color: #475569;
}

.db-tab.is-renaming {
  background: #ffffff;
}

.db-tab.is-renaming .db-tab-close {
  display: none;
}

.db-tab-input {
  width: 100%;
  min-width: 0;
  height: 20px;
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0 0.35rem;
  box-sizing: border-box;
}

.db-tab-input:focus {
  outline: none;
  border-color: rgba(79, 70, 229, 0.72);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.14);
}

.dashboard-search {
  width: 100%;
  max-width: 920px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP SHELL LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.db-layout {
  display: flex;
  align-items: stretch;
  height: calc(100vh - var(--db-nav-height));
  margin-top: calc(-1 * var(--db-search-row-height));
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.db-sidebar {
  width: var(--db-sidebar-width);
  min-width: var(--db-sidebar-width);
  background: var(--db-sidebar-bg);
  border-right: 1px solid var(--db-sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  padding-top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  flex-shrink: 0;
  box-shadow: 2px 0 16px rgba(0,0,0,0.2);
}

#sidebar-left.db-sidebar {
  width: var(--db-sidebar-width);
  min-width: var(--db-sidebar-width);
  margin-top: 0;
  padding-top: 0;
}

#sidebar-right.db-sidebar {
  width: var(--db-right-sidebar-width);
  min-width: var(--db-right-sidebar-width);
  margin-top: 0;
  padding-top: 0;
}

#sidebar-left.db-sidebar,
#sidebar-right.db-sidebar {
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
}

/* Override legacy ID styles from styles.css (width + left sidebar top spacing) */
#sidebar-left.db-sidebar {
  margin-top: 0;
}

.db-sidebar-right {
  width: var(--db-right-sidebar-width);
  min-width: var(--db-right-sidebar-width);
  border-right: none;
  border-left: 1px solid var(--db-sidebar-border);
  box-shadow: -2px 0 16px rgba(0,0,0,0.2);
  overflow-y: hidden;
}

.db-sidebar-right .db-sidebar-section-label {
  padding-top: 1.05rem;
}

.db-sidebar::-webkit-scrollbar { width: 4px; }
.db-sidebar::-webkit-scrollbar-track { background: transparent; }
.db-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

/* ── Sidebar Header */
.db-sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--db-sidebar-border);
  flex-shrink: 0;
}

.db-sidebar-header--dataset-left {
  padding: 0.9rem 1rem 0.8rem;
}

.db-sidebar-dataset-btn {
  width: 100%;
  min-height: 52px;
  padding: 0.52rem 0.6rem 0.56rem;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.42);
  background: linear-gradient(150deg, rgba(30, 41, 59, 0.94) 0%, rgba(15, 23, 42, 0.9) 62%, rgba(30, 58, 138, 0.36) 100%);
  color: #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px rgba(2, 6, 23, 0.24);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  text-align: left;
  cursor: default;
}

.db-sidebar-dataset-btn:hover {
  transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px rgba(2, 6, 23, 0.24);
  background: linear-gradient(150deg, rgba(30, 41, 59, 0.94) 0%, rgba(15, 23, 42, 0.9) 62%, rgba(30, 58, 138, 0.36) 100%);
}

.db-sidebar-dataset-btn:focus {
  outline: none;
}

.db-sidebar-dataset-main {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.62rem;
}

.db-sidebar-dataset-btn-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.46);
  background: rgba(79, 70, 229, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}

.db-sidebar-dataset-btn-logo img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.db-sidebar-dataset-btn-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.db-sidebar-dataset-btn-caption {
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  line-height: 1.1;
}

.db-sidebar-dataset-btn-value {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f1f5f9;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.db-sidebar-dataset-btn.is-empty .db-sidebar-dataset-btn-value {
  color: #94a3b8;
  font-weight: 600;
}

.db-sidebar-dataset-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.db-sidebar-dataset-action-btn {
  margin: 0;
  width: 100%;
  min-height: 24px;
  padding: 0.24rem 0.45rem;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(148, 163, 184, 0.13);
  color: #e2e8f0;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: default;
  box-shadow: none;
}

.db-sidebar-dataset-action-btn:hover {
  transform: none;
  box-shadow: none;
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.46);
}

.db-sidebar-dataset-action-btn:focus {
  outline: none;
}

/* ── Active Filters flyout — filter row items */
.filter-flyout-panel {
  border-radius: 12px !important;
  bottom: auto !important;
  right: auto !important;
  height: auto !important;
  max-height: min(70vh, 480px) !important;
  overflow: hidden;
}

.filter-flyout-panel .flyout-list {
  flex: 0 0 auto;
  min-height: auto;
  overflow-y: auto;
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  grid-template-columns: none;
  padding: 0.5rem 0.75rem;
}

.filter-flyout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.42rem 0.75rem;
  border-radius: 7px;
  gap: 0.5rem;
  transition: background 0.12s ease;
}

.filter-flyout-item:hover {
  background: var(--db-surface-raised);
}

.filter-flyout-item__name {
  font-size: 0.82rem;
  color: var(--db-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-flyout-item__remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--db-text-secondary);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: color 0.12s ease, background 0.12s ease;
  box-shadow: none;
  width: auto;
  min-height: unset;
}

.filter-flyout-item__remove:hover {
  color: var(--db-text);
  background: var(--db-border);
  transform: none;
  box-shadow: none;
}

/* ── Active Filters flyout — date/numeric range row */
.filter-flyout-range {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 7px;
  background: var(--db-surface-raised);
  border: 1px solid var(--db-border-medium);
  flex-wrap: nowrap;
}

.filter-flyout-range__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--db-text-secondary);
  flex-shrink: 0;
}

.filter-flyout-range__value {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--db-text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.db-sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(79, 70, 229, 0.15);
  border: 1px solid rgba(79, 70, 229, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--db-sidebar-logo-ring);
}

.db-sidebar-logo img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.db-sidebar-title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.db-sidebar-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.db-sidebar-sub {
  font-size: 0.7rem;
  color: var(--db-sidebar-text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Sidebar Section Labels */
.db-sidebar-section-label {
  padding: 0.68rem 1rem 0.32rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--db-sidebar-text-muted);
  flex-shrink: 0;
}

/* ── Options Panel (graph-options) */
.db-options-panel,
#graph-options {
  display: flex;
  flex-direction: column;
  gap: 0.36rem;
  box-sizing: border-box;
  padding: 0.1rem 0.65rem 1rem;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

/* Sidebar option buttons — override global button styles */
.db-options-panel button:not(.search-input-action):not(.result-action-btn),
#graph-options button {
  text-align: left;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  background: transparent;
  color: var(--db-sidebar-text);
  border: 1px solid transparent;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  box-shadow: none;
  letter-spacing: 0.01em;
  margin-bottom: 0;
}

.db-options-panel button:not(.search-input-action):not(.result-action-btn):hover,
#graph-options button:hover {
  background: var(--db-sidebar-bg-hover);
  color: #f1f5f9;
  border-color: var(--db-sidebar-border);
  transform: none;
  box-shadow: none;
}

/* Active sidebar button */
.db-options-panel button.is-active:not(.search-input-action):not(.result-action-btn),
#graph-options button.is-active,
.db-options-panel button[aria-pressed="true"]:not(.search-input-action):not(.result-action-btn),
#graph-options button[aria-pressed="true"] {
  background: var(--db-sidebar-active-bg);
  color: var(--db-sidebar-active-text);
  border-color: rgba(79, 70, 229, 0.35);
  font-weight: 600;
}

/* ── Graph type dropdown inside sidebar (scrollable) */
.graph-type-dropdown,
#graph-type-dropdown-div {
  display: none;
  position: relative;
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--db-sidebar-border);
  border-radius: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 260px;
  margin-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.graph-type-dropdown.is-open,
#graph-type-dropdown-div.is-open {
  display: block;
}

.graph-type-list {
  list-style: none;
  padding: 0.2rem;
  margin: 0;
}

.graph-type-dropdown-item {
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--db-sidebar-text);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
  background: transparent;
  border: none;
  margin: 0;
  display: block;
  width: 100%;
  text-align: left;
  box-shadow: none;
  margin-bottom: 0;
}

.graph-type-dropdown-item:hover {
  background: rgba(79, 70, 229, 0.18);
  color: var(--db-sidebar-active-text);
  transform: none;
}

/* Shared settings primitives */
.db-settings-section {
  margin-top: 0;
  border: 1px solid var(--db-sidebar-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.db-settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--db-sidebar-border);
  color: var(--db-sidebar-text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.15s ease;
}

/* When one section is open, subtly compact closed sections for extra room */
#graph-options:has(.db-settings-section:not(.is-collapsed)) .db-settings-section.is-collapsed .db-settings-section-header {
  padding-top: 0.44rem;
  padding-bottom: 0.44rem;
  opacity: 0.96;
}

.db-settings-section-header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.db-settings-section-title {
  color: var(--db-sidebar-text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.db-settings-section-body {
  padding: 3.5% 4.5% 4.2%;
  overflow: hidden;
  max-height: 1000px;
  opacity: 1;
  transition:
    max-height 0.26s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.22s ease,
    padding-top 0.22s ease,
    padding-bottom 0.22s ease;
}

.db-settings-section.is-collapsed > .db-settings-section-body {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.db-settings-section:not(.is-collapsed) > .db-settings-section-body {
  /* Keep other accordion headers visible; long sections scroll internally */
  max-height: min(44vh, 520px);
  overflow-y: auto;
}

.db-settings-label {
  color: var(--db-sidebar-text);
  font-size: 0.78rem;
  line-height: 1.3;
}

.db-settings-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--db-sidebar-text);
  border: 1px solid var(--db-sidebar-border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  font-family: inherit;
  line-height: 1.3;
}

.db-settings-input::placeholder {
  color: var(--db-sidebar-text-muted);
}

.db-settings-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.16);
}

.db-settings-button {
  background: var(--db-sidebar-surface);
  color: var(--db-sidebar-text);
  border: 1px solid var(--db-sidebar-border);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.db-settings-button:hover {
  background: var(--db-sidebar-bg-hover);
  color: #f1f5f9;
  border-color: var(--db-sidebar-border);
}

/* Rename title/axis panel in left settings */
.rename-title-axis-panel {
  overflow: hidden;
}

.rename-title-axis-content {
  display: grid;
  gap: 0.6rem;
}

.rename-title-axis-row {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0;
}

.rename-title-axis-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

/* Rename columns panel in left settings */
.rename-columns-panel {
  overflow: hidden;
}

.rename-columns-content {
  display: grid;
  gap: 0.6rem;
}

.rename-columns-row {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0;
}

.rename-columns-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.rename-columns-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--db-sidebar-text-muted);
}

/* ── Chart settings panel inside sidebar ── */
.chart-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.cs-section {
  overflow: visible;  /* must be visible so sliders/selects aren't clipped */
}

.cs-section-header {
  justify-content: space-between;
  border-radius: 8px 8px 0 0;
}

.cs-chevron {
  color: var(--db-sidebar-text-muted);
  font-size: 0.75rem;
  margin-left: auto;
  transition: transform 0.22s ease;
}

.db-settings-section.is-collapsed .cs-chevron {
  transform: rotate(0deg);
}

.db-settings-section:not(.is-collapsed) .cs-chevron {
  transform: rotate(0deg);
}

.cs-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* ── Shared row layout */
.cs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 28px;
  margin-bottom: 0;
}

.cs-label {
  color: var(--db-sidebar-text);
  font-size: 0.78rem;
  flex: 1;
  line-height: 1.3;
}

/* ── Toggle switch */
.cs-toggle-row {
  cursor: pointer;
  padding: 0.1rem 0;
}

.cs-switch {
  position: relative;
  width: 32px;
  height: 17px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.cs-switch.is-on {
  background: var(--db-primary);
}

.cs-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.28);
  transition: transform 0.2s ease;
}

.cs-switch.is-on .cs-switch-knob {
  transform: translateX(15px);
}

/* ── Slider */
.cs-slider-row {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding-top: 0;
  padding-bottom: 0;
}

.cs-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-slider-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--db-sidebar-active-text);
  min-width: 28px;
  text-align: right;
}

.cs-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.18);
  outline: none;
  margin: 0.15rem 0;
  cursor: pointer;
}

.cs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}

.cs-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.cs-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Select */
.cs-select-row {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.cs-select-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-hint-icon {
  font-size: 11px;
  color: #6366f1;
  cursor: help;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.15s ease;
  user-select: none;
  line-height: 1;
}

.cs-hint-icon:hover {
  opacity: 1;
}

/* Shared popup for select-option hints — appended to <body> so it
   is never clipped by sidebar overflow */
#cs-hint-popup {
  display: none;
  position: fixed;
  z-index: 9999;
  max-width: 230px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.55;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.cs-select {
  width: 100%;
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--db-sidebar-border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--db-sidebar-text);
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.cs-select:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* select option text must be dark (rendered by OS) */
.cs-select option {
  background: #1e293b;
  color: #e2e8f0;
}

#chart-settings-wrapper {
  margin-top: 0.35rem;
}

/* ── Filter / flyout elements
   These render INSIDE flyout panels (white background), NOT directly
   in the sidebar. All must use dark text on white for readability.       */

.filter-dropdown {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.filter-tab {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab.active {
  background: var(--db-primary);
  color: #ffffff;
  border-color: var(--db-primary);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}

.filter-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-option {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font-size: 0.83rem;
  border-radius: 7px;
  padding: 6px 10px;
}

.filter-option:hover {
  background: #f8fafc;
  border-color: #c7d2fe;
}

.filter-range input[type="date"],
.filter-range input[type="number"] {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #0f172a;
  font-size: 0.85rem;
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s ease;
}

.filter-range input[type="date"]:focus,
.filter-range input[type="number"]:focus {
  border-color: var(--db-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* pill-button in flyout panels */
.pill-button {
  background: var(--db-primary);
  color: #ffffff;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.3);
  width: auto;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.pill-button:hover {
  background: var(--db-primary-dark);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.4);
  transform: none;
}

.pill-button.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  box-shadow: none;
}

.pill-button.secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: none;
  box-shadow: none;
}

/* checklist items in flyout panels — dark text on white */
.checklist-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font-size: 0.83rem;
  padding: 0.6rem 0.85rem;
  gap: 10px;
  border-radius: 8px;
  justify-content: flex-start;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.checklist-item:hover {
  background: #f8fafc;
  border-color: #c7d2fe;
}

/* Select series flyout: single column, selected first, datasets collapsible */
.flyout-list.flyout-list--series-picker {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  grid-template-columns: none;
  padding: 0.15rem 0.35rem 0.5rem;
}

.flyout-list--series-picker .flyout-empty {
  grid-column: unset;
}

.series-picker-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.series-picker-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0 0.15rem;
}

.series-picker-rows {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.series-picker-rows--nested {
  padding: 0.35rem 0.45rem 0.5rem;
  gap: 0.08rem;
}

.series-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.55rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.series-row:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.series-row--selected {
  background: #eef2ff;
  border-color: #e0e7ff;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  cursor: default;
}

.series-row--selected:hover {
  background: #e8edff;
  border-color: #c7d2fe;
}

/* Inner horizontal row: checkbox · name/subtitle · toggle · color */
.series-row__main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.series-row--in-group {
  padding: 0.32rem 0.4rem;
  font-size: 0.8125rem;
  background: transparent;
  border-radius: 6px;
}

.series-row--in-group:hover {
  background: #f8fafc;
  border-color: transparent;
}

.series-row__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
  flex: 1;
}

.series-row__name {
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}

.series-row__ds-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-row .column-color-input {
  flex-shrink: 0;
}

/* ── Renamed subtitle: shown when a custom label exists and field is collapsed ── */
.series-row__renamed-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: #6366f1;
  margin-top: 0.06rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Chevron toggle button ── */
.series-row__rename-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0;         /* hide any text content; use pseudo-element arrow */
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.series-row__rename-toggle::before {
  content: "";
  display: block;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-0.1rem);
  transition: transform 0.18s ease;
}

.series-row__rename-toggle.is-expanded::before {
  transform: rotate(225deg) translateY(-0.1rem);
}

.series-row__rename-toggle:hover {
  background: #f1f5f9;
  border-color: #c7d2fe;
  color: #6366f1;
}

/* Highlighted when a custom name is already set */
.series-row__rename-toggle.has-rename {
  border-color: #a5b4fc;
  color: #6366f1;
  background: #eef2ff;
}

.series-row__rename-toggle.has-rename.is-expanded {
  background: #e0e7ff;
  border-color: #818cf8;
}

/* ── Expandable rename row (full width, below the main row content) ── */
.series-row__rename {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, padding-top 0.22s ease;
}

.series-row__rename.is-expanded {
  max-height: 2.8rem;
  opacity: 1;
  padding-top: 0.4rem;
}

.series-row__rename-input {
  flex: 1;
  min-width: 0;
  height: 1.75rem;
  padding: 0 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.series-row__rename-input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2.5px rgba(129, 140, 248, 0.2);
}

.series-row__rename-input::placeholder {
  color: #94a3b8;
  font-style: italic;
}

.series-row__rename-reset {
  flex-shrink: 0;
  flex-grow: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.series-row__rename-reset:hover {
  background: #ede9fe;
  color: #4338ca;
  border-color: #c4b5fd;
}

.column-color-input--compact {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  padding: 1px;
}

.series-dataset-group {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.series-dataset-group__header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border: none;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.series-dataset-group__header:hover {
  background: #f1f5f9;
}

.series-dataset-group__chevron {
  flex-shrink: 0;
  width: 1rem;
  color: #64748b;
  font-size: 0.7rem;
}

.series-dataset-group__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-dataset-group__count {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: #475569;
  background: #e2e8f0;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
}

.series-dataset-group__body {
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

/* Info section at bottom of sidebar */
.info {
  margin: auto 0 0;
  padding: 0 0.65rem 0.75rem;
  display: flex;
  flex-direction: row;
  gap: 0.35rem;
  border: none;
  border-top: 1px solid var(--db-sidebar-border);
  padding-top: 0.75rem;
  flex-wrap: wrap;
}

.info > button {
  margin: 0;
  width: auto;
  flex: 1;
  min-width: 60px;
  font-size: 0.72rem;
  padding: 0.4rem 0.4rem;
  background: rgba(255,255,255,0.06);
  color: var(--db-sidebar-text);
  border: 1px solid var(--db-sidebar-border);
  border-radius: 6px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  white-space: normal;
  box-shadow: none;
}

.info > button:hover {
  background: rgba(255,255,255,0.1);
  color: #f1f5f9;
  transform: none;
}

/* ── Sidebar scrollbar for dropdown-div */
.dropdown-div {
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */

.db-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(0.32rem + var(--db-search-row-height) - 10px) var(--db-main-inline-padding) 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--db-page-bg);
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
  max-width: var(--db-main-max-width);
  margin: 0 auto;
  box-sizing: border-box;
}

/* ── Search bar (compact, lives in .db-search-row) ── */
.search-hero {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

/* "AI DATASET FINDER" pill — inline to the left of the bar, tiny */
.search-meta-row {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 0.5rem;
}

.search-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  border: 1px solid rgba(79, 70, 229, 0.18);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: none;
}

/* Hide the long subtitle text in the toolbar context */
.search-subtitle { display: none; }

/* The input bar itself — slimmed down */
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  max-width: 760px;
  padding: 8px 8px 8px 20px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1), 0 0 36px rgba(79, 70, 229, 0.08);
  min-height: auto;
  transition: border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
  position: relative;
}

.search-input-wrap:hover {
  border-color: rgba(0, 0, 0, 0.14);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12), 0 0 46px rgba(79, 70, 229, 0.11);
}

.search-input-wrap:focus-within {
  background: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12), 0 0 0 4px rgba(79, 70, 229, 0.12);
}

/* Search icon — small, plain */
.search-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-icon svg {
  width: 22px;
  height: 22px;
}

/* Input field */
#search-bar,
.search-input {
  flex: 1;
  height: 44px;
  border-radius: 0;
  border: none;
  font-size: 0.98rem;
  font-weight: 500;
  background: transparent;
  color: var(--db-text);
  padding: 0;
  box-shadow: none;
  outline: none;
}

#search-bar::placeholder,
.search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
  font-size: 0.94rem;
}

#search-bar:focus,
.search-input:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

/* Send button — compact pill */
.search-input-action {
  position: static;
  transform: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #06b6d4 100%);
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  right: auto;
  top: auto;
  margin-bottom: 0;
  padding: 0;
}

.search-input-action svg {
  width: 18px;
  height: 18px;
}

.search-input-action:hover {
  transform: scale(1.04);
  box-shadow: 0 7px 20px rgba(79, 70, 229, 0.45);
}

/* ai-search-output — small status text below the input */
#ai-search-output,
.search-status {
  display: none !important;
}

/* Search results — floating dropdown below the search row */
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  width: min(860px, 100%);
  z-index: 1300;
  margin: 0;
  padding: 0;
}

#search-results.results {
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.13);
  padding: 0.85rem 1rem;
  color: var(--db-text);
  max-height: 60vh;
  overflow-y: auto;
}

.db-sidebar-right #right-sidebar-actions {
  width: 100%;
  box-sizing: border-box;
  gap: 0.6rem;
  padding-top: 0.2rem;
  flex: 1;
  min-height: 0;
}

.db-sidebar-right #right-sidebar-actions.dashboard-search {
  max-width: 100%;
}

.db-sidebar-right .search-hero {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
}

.db-sidebar-right .search-meta-row {
  display: none;
}

.db-sidebar-right .search-input-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0.4rem;
  border-radius: 16px;
  gap: 0.45rem;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.52);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.db-sidebar-right .search-input-wrap:hover {
  border-color: rgba(148, 163, 184, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.db-sidebar-right .search-input-wrap:focus-within {
  background: rgba(15, 23, 42, 0.52);
  border-color: rgba(129, 140, 248, 0.58);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.22);
}

.db-sidebar-right .search-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  color: #94a3b8;
}

.db-sidebar-right .search-icon svg {
  width: 16px;
  height: 16px;
}

.db-sidebar-right #search-bar,
.db-sidebar-right .search-input {
  height: 32px;
  font-size: 0.82rem;
  min-width: 0;
  color: #e2e8f0 !important;
  -webkit-text-fill-color: #e2e8f0 !important;
  background: transparent !important;
  caret-color: #cbd5e1;
}

.db-sidebar-right #search-bar:-webkit-autofill,
.db-sidebar-right .search-input:-webkit-autofill,
.db-sidebar-right #search-bar:-webkit-autofill:hover,
.db-sidebar-right .search-input:-webkit-autofill:hover,
.db-sidebar-right #search-bar:-webkit-autofill:focus,
.db-sidebar-right .search-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #e2e8f0;
  -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.01) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.db-sidebar-right #search-bar:focus,
.db-sidebar-right .search-input:focus {
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc !important;
}

.db-sidebar-right #search-bar:hover,
.db-sidebar-right .search-input:hover,
.db-sidebar-right #search-bar:active,
.db-sidebar-right .search-input:active {
  color: #e2e8f0 !important;
  -webkit-text-fill-color: #e2e8f0 !important;
}

.db-sidebar-right #search-bar::placeholder,
.db-sidebar-right .search-input::placeholder {
  font-size: 0.79rem;
  color: #94a3b8;
}

.db-sidebar-right .search-input-action {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  box-shadow: none;
}

.db-sidebar-right .search-input-action svg {
  width: 14px;
  height: 14px;
}

.db-sidebar-right .search-input-action:hover {
  background: rgba(148, 163, 184, 0.36);
  border-color: rgba(148, 163, 184, 0.42);
  box-shadow: none;
  transform: none;
}

.db-sidebar-right #search-results {
  position: static;
  top: auto;
  left: auto;
  right: auto;
  width: 100%;
  margin-top: 0.4rem;
  z-index: auto;
  flex: 1;
  min-height: 0;
}

.db-sidebar-right #search-results.results {
  padding: 0;
  max-height: none;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}

.db-sidebar-right .results-list {
  display: grid;
  margin-top: 0;
  gap: 0.22rem;
}

.db-sidebar-right .result-item {
  padding: 0.34rem 0.1rem 0.4rem;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  background: transparent;
  transform: none !important;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.db-sidebar-right .result-item:last-child {
  border-bottom: none;
}

.db-sidebar-right .result-item:hover {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.32);
  box-shadow: none;
  transform: none !important;
}

.db-sidebar-right .result-title {
  display: flex;
  align-items: flex-start;
  gap: 0.32rem;
  margin-bottom: 0.12rem;
}

.db-sidebar-right .result-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.08rem;
  height: 1.08rem;
  border-radius: 7px;
  font-size: 0.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #f8fafc;
}

.db-sidebar-right .result-heading {
  display: flex;
  flex-direction: column;
  gap: 0.06rem;
  min-width: 0;
}

.db-sidebar-right .result-name {
  font-size: 0.72rem;
  color: #f8fafc;
  line-height: 1.22;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-sidebar-right .result-id {
  color: #94a3b8;
  font-size: 0.63rem;
}

.db-sidebar-right .result-meta {
  color: #cbd5e1;
  font-size: 0.65rem;
  line-height: 1.25;
}

.db-sidebar-right .result-id,
.db-sidebar-right .result-meta,
.db-sidebar-right .result-link {
  font-size: 0.67rem;
}

.db-sidebar-right .result-score {
  margin-top: 0.14rem;
}

.db-sidebar-right .score-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.db-sidebar-right .score-text {
  font-size: 0.62rem;
  color: #a5b4fc;
  font-weight: 700;
}

.db-sidebar-right .score-bar {
  margin-top: 0.12rem;
  height: 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  overflow: hidden;
}

.db-sidebar-right .score-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1 0%, #06b6d4 100%);
}

.db-sidebar-right .result-columns {
  margin-top: 0.14rem;
  display: flex;
  align-items: baseline;
  gap: 0.22rem;
  min-width: 0;
}

.db-sidebar-right .columns-label {
  display: inline;
  font-size: 0.62rem;
  color: #94a3b8;
  margin-bottom: 0;
  white-space: nowrap;
}

.db-sidebar-right .columns-text {
  display: inline;
  font-size: 0.62rem;
  color: #dbeafe;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
}

.db-sidebar-right .result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.2rem;
  margin-top: 0.25rem;
}

.db-sidebar-right .result-link.select-dataset-link,
.db-sidebar-right .result-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.2rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
  font-size: 0.62rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}

.db-sidebar-right .result-action-btn {
  margin: 0;
  min-width: 0;
  width: 100%;
}

.db-sidebar-right .result-link.select-dataset-link:hover,
.db-sidebar-right .result-action-btn:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(148, 163, 184, 0.48);
  background: rgba(148, 163, 184, 0.3);
  color: #f8fafc;
}

.db-sidebar-right #search-results .results-message {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.72);
  color: #cbd5e1;
  font-size: 0.7rem;
  line-height: 1.3;
  padding: 0.5rem 0.55rem;
}

.results-header {
  display: none;
}

.result-item {
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: none;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.result-item:hover {
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.result-name { color: var(--db-text); font-weight: 700; font-size: 0.85rem; }
.result-id, .result-meta, .result-desc { color: #475569; font-size: 0.78rem; }
.result-link { color: var(--db-primary); font-size: 0.8rem; }

.columns-chip,
.column-chip {
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.18);
  color: var(--db-primary);
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHART SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.db-chart-section,
#main-graph {
  background: var(--db-chart-bg);
  border-radius: 14px;
  border: 1px solid var(--db-border);
  box-shadow: var(--db-shadow-chart);
  padding: 1.1rem 1.25rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  margin-bottom: 0;
}

/* Subtle indigo top accent line */
.db-chart-section::before,
#main-graph::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4f46e5 0%, #06b6d4 60%, transparent 100%);
  border-radius: 14px 14px 0 0;
}

.db-chart-canvas,
#mainChart {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: transparent;
  border-radius: 10px;
  border: none;
  box-shadow: none;
  position: relative;
}

#mainChart svg {
  max-width: 100%;
  height: auto;
}

/* Chart area: empty / waiting (transient) / fatal — always inside #mainChart */
.chart-render-state {
  max-width: 36rem;
  margin: 1.25rem auto;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  text-align: left;
  line-height: 1.55;
  font-size: 0.9rem;
}

.chart-render-state__title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.chart-render-state__detail {
  margin: 0;
  color: inherit;
  opacity: 0.95;
}

.chart-render-state__list {
  margin: 0;
  padding-left: 1.25rem;
}

.chart-render-state__list li {
  margin-bottom: 0.35rem;
}

.chart-render-state--empty {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
}

.chart-render-state--transient {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fdba74;
  color: #9a3412;
  box-shadow: 0 2px 12px rgba(234, 88, 12, 0.12);
}

.chart-render-state--fatal {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #f87171;
  color: #991b1b;
  box-shadow: 0 2px 12px rgba(220, 38, 38, 0.1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FILTER STRIP
   ═══════════════════════════════════════════════════════════════════════════ */

.db-filters-strip,
#applied-filters-bar {
  width: 100%;
  flex-shrink: 0;
}

.applied-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--db-border);
  border-radius: 10px;
  background: var(--db-surface);
  box-shadow: var(--db-shadow-xs);
}

.applied-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.applied-filter-title {
  font-weight: 700;
  color: #334155;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.applied-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 160px;
}

.applied-filter-hint {
  color: #64748b;
  font-size: 0.8rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(79,70,229,0.2);
  background: rgba(79,70,229,0.07);
  color: var(--db-primary);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: auto;
  margin-bottom: 0;
}

.filter-chip:hover {
  background: rgba(79,70,229,0.14);
  border-color: rgba(79,70,229,0.35);
  transform: none;
  box-shadow: none;
}

.chip-close {
  font-weight: 700;
  opacity: 0.6;
  font-size: 1rem;
  line-height: 1;
}

.filter-toggle,
.filter-clear-all {
  background: #f8fafc;
  color: var(--db-text-secondary);
  border: 1px solid var(--db-border-medium);
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  width: auto;
  margin-bottom: 0;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.filter-toggle:hover,
.filter-clear-all:hover {
  background: #eef2ff;
  border-color: rgba(79,70,229,0.3);
  color: var(--db-primary);
  transform: none;
  box-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FLYOUT PANELS
   ═══════════════════════════════════════════════════════════════════════════ */

.flyout-panel {
  top: 70px;
  left: calc(var(--db-sidebar-width) + 20px);
  right: calc(var(--db-right-sidebar-width) + 20px);
  bottom: 0;
  transform: none;
  width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 40px);
  height: auto;
  max-height: none;
  max-width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 40px);
  box-sizing: border-box;
  background: var(--db-surface);
  border: 1px solid var(--db-border-medium);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--db-shadow-lg), 0 0 0 1px rgba(79,70,229,0.06);
}

.flyout-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--db-border);
}

.flyout-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--db-text);
  letter-spacing: 0.01em;
}

.flyout-count {
  background: rgba(79,70,229,0.1);
  color: var(--db-primary);
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.flyout-close {
  background: #f1f5f9;
  border: 1px solid var(--db-border);
  color: var(--db-text-secondary);
  min-width: 30px;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 0;
  box-shadow: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flyout-close:hover {
  background: #e2e8f0;
  transform: none;
  box-shadow: none;
}

.sheet-search input {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.88rem;
  padding: 0.6rem 0.85rem;
  background: #ffffff;
  color: #0f172a;
  width: 100%;
  box-sizing: border-box;
}

.sheet-search input:focus {
  outline: none;
  border-color: var(--db-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.flyout-actions {
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--db-border);
}

/* Flyout pill buttons — already correctly styled by global .pill-button rules above */

/* ═══════════════════════════════════════════════════════════════════════════
   DROPDOWNS (color, data-selection)
   ═══════════════════════════════════════════════════════════════════════════ */

#graph-color-dropdown-div,
#graph-type-dropdown-div,
#dropdown,
#dataset-selection-dropdown-div,
#column-selection-dropdown-div,
#row-selection-dropdown-div,
#column-color-dropdown-div {
  background: var(--db-surface);
  border: 1px solid var(--db-border-medium);
  border-radius: 10px;
  box-shadow: var(--db-shadow-lg);
  padding: 0.5rem;
}

#dropdown li,
#dataset-list li,
#graph-type-dropdown li,
.data-selection-item {
  color: var(--db-text);
  font-size: 0.83rem;
}

#dropdown li:hover,
#dataset-list li:hover,
.data-selection-item:hover:not(.disabled) {
  background: #f0f4ff;
  color: var(--db-primary);
  border-radius: 6px;
}

.data-selection-item label {
  color: var(--db-text);
  font-size: 0.83rem;
  margin: 0;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COLOR PICKER OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

.column-color-item {
  border-bottom-color: #f1f5f9;
}

.column-name {
  color: #0f172a;
  font-weight: 600;
  font-size: 0.82rem;
}

.reset-color-btn {
  font-size: 0.72rem;
  border-radius: 5px;
  padding: 3px 8px;
  border: 1px solid var(--db-border-medium);
  background: #f8fafc;
  color: var(--db-text-secondary);
}

.reset-color-btn:hover {
  background: #eef2ff;
  color: var(--db-primary);
  border-color: rgba(79,70,229,0.3);
}

/* ── Chart empty state */
.db-chart-canvas:empty::after,
#mainChart:empty::after {
  content: 'Select a dataset to visualize your data';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--db-text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  pointer-events: none;
}

/* Make display:flex work for the ::after pseudo element */
#mainChart:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LEGACY overrides (keep compatibility with dynamically rendered content)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Prevent landing.css body background bleeding into dashboard */
.db-body {
  background: var(--db-page-bg) !important;
}

/* Remove the old .container layout when db-layout is present */
.db-body .container {
  display: none;
}

/* Old aside / sidebar-left must be inert if db-layout present */
.db-body #sidebar-left:not(.db-sidebar) {
  display: none;
}

/* Override old top-nav when db-topnav present */
.db-body .top-nav {
  display: none;
}

/* Override old workspace-toolbar */
.db-body .workspace-toolbar {
  display: none;
}

/* ─── HR inside sidebar */
.db-sidebar hr {
  border: none;
  border-top: 1px solid var(--db-sidebar-border);
  margin: 0.5rem 0;
}

/* ─── Sidebar label over h2 */
.db-sidebar h2,
#sidebar-left h2 {
  display: none;
}

/* ── Old logo-card (hidden in favour of db-sidebar-header) */
.db-body .logo-card {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  .db-brand-tagline { display: none; }
  .toolbar-btn { padding: 0 0.5rem; font-size: 0.74rem; gap: 0.25rem; }

  .flyout-panel {
    top: 60px;
    left: calc(var(--db-sidebar-width) + 12px);
    right: calc(var(--db-right-sidebar-width) + 12px);
    width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 24px);
    max-width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 24px);
    border-radius: 12px 12px 0 0;
  }
  .flyout-header { padding: 0.6rem 0.85rem; }
  .flyout-title { font-size: 0.82rem; }
  .flyout-list {
    gap: 0.35rem;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    padding: 0.2rem;
  }
  .flyout-actions { padding: 0.5rem 0.85rem; }
  .checklist-item {
    font-size: 0.78rem;
    padding: 0.45rem 0.65rem;
    gap: 8px;
  }
  .series-row {
    padding: 0.35rem 0.45rem;
    font-size: 0.78rem;
    gap: 0.4rem;
  }
  .series-row__name { font-size: 0.78rem; }
  .series-row__ds-hint { font-size: 0.68rem; }
  .series-picker-section-title { font-size: 0.64rem; }
  .series-dataset-group__header { padding: 0.4rem 0.55rem; font-size: 0.75rem; }
  .pill-button { font-size: 0.74rem; padding: 0.35rem 0.7rem; }
  .filter-tab { font-size: 0.75rem; padding: 0.38rem 0.6rem; }
}

@media (max-width: 1100px) {
  .db-search-row {
    padding-left: calc(var(--db-sidebar-width) + var(--db-main-inline-padding));
    padding-right: calc(var(--db-right-sidebar-width) + var(--db-main-inline-padding));
  }
  .flyout-panel {
    left: calc(var(--db-sidebar-width) + 16px);
    right: calc(var(--db-right-sidebar-width) + 16px);
    bottom: auto;
    width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 32px);
    height: 80vh;
    max-height: 80vh;
    max-width: calc(100dvw - var(--db-sidebar-width) - var(--db-right-sidebar-width) - 32px);
  }
}

@media (max-width: 860px) {
  .db-layout {
    flex-direction: column;
    margin-top: 0;
    height: calc(100vh - var(--db-nav-height) - var(--db-search-row-height));
  }
  .db-sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 260px;
    flex-direction: row;
    flex-wrap: nowrap;
    padding-top: 0;
    border-right: none;
    border-bottom: 1px solid var(--db-sidebar-border);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .db-sidebar-header { flex-shrink: 0; }
  .db-sidebar-right {
    width: 100%;
    min-width: unset;
    max-height: none;
    height: auto;
    flex-direction: column;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--db-sidebar-border);
    box-shadow: none;
    overflow: visible;
  }
  #sidebar-left.db-sidebar,
  #sidebar-right.db-sidebar {
    width: 100%;
    min-width: unset;
    margin-top: 0;
    height: auto;
    padding-top: 0;
  }
  .db-search-row {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.07);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .db-search-header,
  #header_class {
    max-width: none;
    padding: 0;
  }
  .db-progress-note {
    font-size: 0.72rem;
    letter-spacing: 0.03em;
  }
  .search-input-wrap { max-width: none; }
  #search-results { width: 100%; }
  .db-sidebar-right #search-results {
    flex: unset;
    min-height: auto;
  }
  .flyout-panel {
    left: 5%;
    right: 5%;
    bottom: auto;
    width: 90dvw;
    height: 80vh;
    max-height: 80vh;
    max-width: 90dvw;
  }
  .db-main { padding: 1rem; }
  .db-breadcrumb { display: none; }
}

@media (max-width: 1024px) {
  .db-brand-logo { width: 120px; height: 28px; }
  .db-breadcrumb { display: none; }
  .db-nav-btn { padding: 0.35rem 0.55rem; font-size: 0.78rem; }
  .db-tab { min-width: 80px; max-width: 160px; font-size: 0.72rem; }
  .db-sidebar-dataset-btn { min-height: 44px; }
  .flyout-list {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.3rem;
  }
  .checklist-item {
    font-size: 0.74rem;
    padding: 0.38rem 0.55rem;
    gap: 6px;
    border-radius: 6px;
  }
  .series-row {
    padding: 0.3rem 0.4rem;
    font-size: 0.74rem;
    border-radius: 6px;
  }
  .column-color-input { width: 26px; height: 26px; }
  .column-color-input--compact { width: 24px; height: 24px; min-width: 24px; }
}

@media (max-width: 640px) {
  .db-nav-btn span { display: none; }
  .db-nav-btn { padding: 0.4rem 0.5rem; }
  .db-topnav { padding: 0 0.75rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RIGHT SIDEBAR — MODE TOGGLE
   ═══════════════════════════════════════════════════════════════════════════ */

.db-sidebar-right .db-mode-toggle {
  display: flex;
  gap: 5px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  flex-shrink: 0;
}

.db-sidebar-right .db-mode-tab {
  flex: 1;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: transparent;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  line-height: 1.3;
}

.db-sidebar-right .db-mode-tab.is-active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.42);
  color: #c7d2fe;
}

.db-sidebar-right .db-mode-tab:hover:not(.is-active) {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RIGHT SIDEBAR — SEARCH LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.db-sidebar-right .db-search-loading {
  margin-top: 10px;
  padding: 18px 14px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.18);
  animation: db-loading-fade-in 0.25s ease;
}

@keyframes db-loading-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.db-search-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.db-search-loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.18);
  border-top-color: #6366f1;
  animation: db-loading-spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

.db-search-loading-title {
  font-size: 0.71rem;
  font-weight: 700;
  color: #e2e8f0;
  text-align: center;
  line-height: 1.3;
}

.db-search-loading-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.db-search-loading-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.64rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.3;
  transition: color 0.25s ease;
}

.db-search-loading-step::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  transition: all 0.25s ease;
}

.db-search-loading-step.is-active {
  color: #a5b4fc;
}

.db-search-loading-step.is-active::before {
  border-color: #6366f1;
  border-top-color: transparent;
  animation: db-loading-spin 0.75s linear infinite;
}

.db-search-loading-step.is-done {
  color: #4ade80;
}

.db-search-loading-step.is-done::before {
  border-color: #4ade80;
  background: #4ade80;
  animation: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: 9px;
  background-repeat: no-repeat;
  background-position: center;
}

/* Source attribution (supports multiple datasets / provenance rows) */
.source-attribution {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 12px;
  padding: 6px 16px;
  font-size: 12px;
  color: #a6adc8;
  border-top: 1px solid #313244;
}
.source-attribution .source-label {
  flex-shrink: 0;
  font-weight: 500;
  color: #7f849c;
  padding-top: 2px;
}
.source-attribution .source-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.source-attribution .source-entry {
  line-height: 1.4;
  word-break: break-word;
}
.source-attribution .source-dataset-name {
  font-weight: 500;
  color: #bac2de;
}
.source-attribution .source-link {
  color: #89b4fa;
  text-decoration: none;
}
.source-attribution .source-link:hover {
  text-decoration: underline;
}
.source-attribution .source-desc {
  color: #a6adc8;
}

/* Add to graph button */
.result-action-btn--add-to-graph {
  background: #a6e3a1;
  color: #1e1e2e;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.result-action-btn--add-to-graph:hover {
  background: #94e2d5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOOLBAR MODALS, TOASTS, AND EXPORT MENU
   ═══════════════════════════════════════════════════════════════════════════ */

.load-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.load-modal {
  width: min(560px, calc(100vw - 36px));
  max-height: min(78vh, 720px);
  background: #ffffff;
  color: #0f172a;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.load-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.load-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.01em;
}

.load-modal-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.load-modal-close:hover {
  color: #334155;
}

.load-modal-body {
  padding: 14px 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.load-modal-section {
  margin: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.load-modal-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.load-modal-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.load-modal-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}

.load-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.load-modal-item:hover {
  border-color: #c7d2fe;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.08);
}

.load-modal-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.load-modal-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.load-modal-item-date {
  font-size: 11px;
  color: #64748b;
}

.load-modal-item-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.load-modal-item-load,
.load-modal-item-delete {
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.load-modal-item-load {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

.load-modal-item-load:hover {
  background: #e0e7ff;
  color: #3730a3;
}

.load-modal-item-delete {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.load-modal-item-delete:hover {
  background: #ffe4e6;
  color: #9f1239;
}

.load-modal-file-btn {
  padding: 8px 14px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.load-modal-file-btn:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
}

.export-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-menu {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 12px;
  padding: 24px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.export-menu h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.export-menu-btn {
  padding: 10px 16px;
  background: #89b4fa;
  color: #1e1e2e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.export-menu-btn:hover {
  background: #74c7ec;
}

.export-menu-close {
  padding: 8px 16px;
  background: #313244;
  color: #cdd6f4;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.save-template-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.save-template-modal {
  width: min(460px, calc(100vw - 36px));
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  color: #0f172a;
  overflow: hidden;
}

.save-template-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.save-template-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.save-template-modal-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.save-template-modal-body {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.save-template-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.save-template-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
}

.save-template-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: #ffffff;
}

.save-template-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

.save-template-btn {
  border: none;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.save-template-btn-cancel {
  background: #e2e8f0;
  color: #334155;
}

.save-template-btn-cancel:hover {
  background: #cbd5e1;
}

.save-template-btn-submit {
  background: #4f46e5;
  color: #ffffff;
}

.save-template-btn-submit:hover {
  background: #4338ca;
}

.toolbar-toast {
  position: fixed;
  top: 68px;
  right: 18px;
  z-index: 10001;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.toolbar-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toolbar-toast-success {
  color: #14532d;
  border: 1px solid rgba(22, 163, 74, 0.45);
  background: rgba(134, 239, 172, 0.72);
  backdrop-filter: blur(3px);
}

.toolbar-toast-warning {
  color: #7c2d12;
  border: 1px solid rgba(234, 88, 12, 0.45);
  background: rgba(254, 215, 170, 0.8);
  backdrop-filter: blur(3px);
}

.toolbar-toast-error {
  color: #7f1d1d;
  border: 1px solid rgba(220, 38, 38, 0.42);
  background: rgba(254, 202, 202, 0.82);
  backdrop-filter: blur(3px);
}
