/* =============================================
   US LIQUIDITY MONITOR — STYLES
   Dark mode, modern clean design
============================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Pure blacks with warm undertone — no blue */
  --bg-primary: #09090b;
  --bg-secondary: #0e0e10;
  --bg-card: #131316;
  --bg-card-hover: #1a1a1e;
  --bg-surface: #1c1c20;
  --bg-drawer: #0c0c0e;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-active: rgba(201, 169, 110, 0.5);

  /* Warm gold/amber accent */
  --accent: #c9a96e;
  --accent-2: #b8956a;
  --accent-glow: rgba(201, 169, 110, 0.12);
  --accent-hover: #d4b87a;

  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --orange: #f97316;
  --pink: #ec4899;

  /* Warm neutral text */
  --text-primary: #e8e6e3;
  --text-secondary: #9c9891;
  --text-muted: #5c5852;
  --text-accent: #d4b87a;

  --sidebar-width: 220px;
  --topbar-height: 60px;
  --drawer-width: 360px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(201, 169, 110, 0.15);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  --font-mono: 'JetBrains Mono', monospace;
}


html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* =============================================
   LAYOUT
============================================= */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
============================================= */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-drawer);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  transition: var(--transition-slow);
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}

.logo-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.logo-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-hover);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.data-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.loading {
  background: var(--yellow);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-dot.error {
  background: var(--red);
}

.last-updated {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
  overflow: hidden;
  white-space: nowrap;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

/* =============================================
   MAIN CONTENT
============================================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* =============================================
   TOPBAR
============================================= */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(20px);
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sidebar-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-surface);
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-range-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}

.range-btn {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.range-btn:hover {
  color: var(--text-primary);
}

.range-btn.active {
  background: var(--accent);
  color: white;
}

.refresh-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.refresh-btn svg {
  width: 15px;
  height: 15px;
}

.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* =============================================
   TAB CONTENT
============================================= */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Scrollbar */
.tab-content::-webkit-scrollbar {
  width: 4px;
}

.tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* =============================================
   METRIC CARDS
============================================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card-skeleton {
  height: 110px;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

  100% {
    background-position: -200% 0;
  }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-color, var(--accent));
  opacity: 0.7;
  transition: var(--transition);
}

.metric-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.metric-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  line-height: 1.3;
}

.card-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  line-height: 1;
}

.card-change {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

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

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

.card-change.neutral {
  color: var(--text-muted);
}

.card-change svg {
  width: 12px;
  height: 12px;
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* =============================================
   SECTION HEADERS
============================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.section-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--green);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 3px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.section-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

/* =============================================
   MINI CHARTS GRID
============================================= */
.mini-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.rates-grid {
  grid-template-columns: repeat(4, 1fr);
}

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

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

.rates-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.mini-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.mini-chart-card::after {
  content: '⤢';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.mini-chart-card:hover::after {
  opacity: 1;
}

.mini-chart-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}



.mini-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mini-chart-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mini-chart-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.mini-chart-container {
  height: 70px;
  margin-top: 6px;
}

/* Card unit badge */
.card-unit {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}


/* =============================================
   OVERVIEW CHART
============================================= */
.overview-section .section-header {
  margin-bottom: 0;
}

.chart-type-pills {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}

.pill {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.pill.active {
  background: var(--accent);
  color: white;
}

.overview-chart-container {
  margin-top: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.overview-chart {
  height: 320px;
}

/* =============================================
   CHART BUILDER — LAYOUT
============================================= */
.builder-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  position: relative;
}

#tab-builder {
  padding: 0;
  overflow: hidden;
}

#tab-builder.active {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.builder-chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.builder-chart-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

.builder-chart {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}


.chart-toolbar {
  height: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-drawer);
}

.toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.toolbar-right {
  display: flex;
  gap: 6px;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.toolbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.toolbar-btn svg {
  width: 15px;
  height: 15px;
}

/* =============================================
   SETTINGS DRAWER
============================================= */
.settings-drawer {
  width: 0;
  min-width: 0;
  background: var(--bg-drawer);
  border-left: 1px solid transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-drawer.open {
  width: var(--drawer-width);
  min-width: var(--drawer-width);
  border-left-color: var(--border);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  min-width: var(--drawer-width);
}

.drawer-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.drawer-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.drawer-close svg {
  width: 13px;
  height: 13px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-width: var(--drawer-width);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-body::-webkit-scrollbar {
  width: 3px;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* =============================================
   SERIES LIST
============================================= */
.series-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.series-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.series-item:hover {
  border-color: var(--border-hover);
}

.series-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.series-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.series-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-axis-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.series-remove {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: var(--transition);
  font-size: 16px;
  line-height: 1;
}

.series-remove:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}


.add-series-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  width: 100%;
}

.add-series-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.add-series-btn svg {
  width: 14px;
  height: 14px;
}

/* =============================================
   SERIES SELECTOR
============================================= */
.series-selector {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.series-selector.hidden {
  display: none;
}

.selector-header {
  padding: 8px;
}

.selector-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: var(--transition);
}

.selector-search:focus {
  border-color: var(--accent);
}

.selector-search::placeholder {
  color: var(--text-muted);
}

.series-options {
  max-height: 200px;
  overflow-y: auto;
}

.series-options::-webkit-scrollbar {
  width: 3px;
}

.series-options::-webkit-scrollbar-thumb {
  background: var(--border);
}

.series-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
}

.series-option:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
}

.series-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.series-option.added {
  opacity: 0.5;
  cursor: default;
}

.series-option.added:hover {
  background: transparent;
  color: var(--text-secondary);
}

/* =============================================
   CHART TYPE BUTTONS
============================================= */
.chart-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.chart-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.chart-type-btn svg {
  width: 30px;
  height: 20px;
}

.chart-type-btn span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-type-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.chart-type-btn.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-hover);
}

/* =============================================
   ACTIVE SERIES CONFIG
============================================= */
.active-series-config {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px;
}

.config-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.config-toggles {
  display: flex;
  gap: 4px;
}

.config-toggle {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.config-toggle.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-hover);
}

.config-color {
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-color input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 2px;
}

.config-color span {
  font-size: 11px;
  color: var(--text-muted);
}

.config-checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateY(-50%) translateX(16px);
  background: white;
}

/* =============================================
   CHART OVERLAY (MAXIMIZED — builder)
============================================= */
.chart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100dvh;
  background: var(--bg-primary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.chart-overlay.hidden {
  display: none;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.overlay-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.overlay-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.overlay-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.overlay-close svg {
  width: 16px;
  height: 16px;
}

.overlay-chart {
  flex: 1;
  min-height: 0;
  padding: 12px 16px 24px;
}

/* =============================================
   MINI-CHART POPUP (expanded view)
============================================= */
.mini-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.mini-popup-backdrop.hidden {
  display: none;
}

.mini-popup-box {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  width: 80vw;
  max-width: 1000px;
  height: 65vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.mini-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mini-popup-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.mini-popup-header .popup-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: 8px;
}

.mini-popup-chart {
  flex: 1;
  min-height: 0;
  padding: 8px 12px 16px;
  position: relative;
}


/* =============================================
   DATA TABLE
============================================= */
#tab-data.active {
  flex-direction: column;
}

.data-table-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-search {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: var(--transition);
  width: 240px;
}

.table-search:focus {
  border-color: var(--accent);
}

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

.export-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.export-btn svg {
  width: 14px;
  height: 14px;
}

.table-wrapper {
  flex: 1;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.table-wrapper::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
}

th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  white-space: nowrap;
  font-family: var(--font-mono);
}

td:first-child {
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* =============================================
   LOADING OVERLAY
============================================= */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: opacity 0.4s;
}

.loading-overlay.hidden {
  display: none;
}

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

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-content p {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* =============================================
/* =============================================
   MODALS
============================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  background: #131316;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  width: 440px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.modal-search {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  outline: none;
  margin-bottom: 10px;
  transition: var(--transition);
}

.modal-search:focus {
  border-color: var(--accent);
}

.modal-search::placeholder {
  color: var(--text-muted);
}

.modal-list {
  flex: 1;
  overflow-y: auto;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-list::-webkit-scrollbar {
  width: 4px;
}

.modal-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.modal-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-list-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.add-axis-btn {
  transition: all 0.2s;
}

.add-axis-btn:hover {
  background: var(--bg-surface) !important;
  border-color: var(--text-primary) !important;
  color: var(--text-primary) !important;
}

.modal-list-item.added {
  opacity: 0.45;
  cursor: default;
}

.modal-list-item.added:hover {
  border-color: var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.modal-list-item .item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.modal-list-item .item-drag {
  color: var(--text-muted);
  cursor: grab;
  font-size: 14px;
  user-select: none;
}

.modal-list-item .item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-list-item .item-unit {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.modal-list-item.dragging {
  opacity: 0.4;
}

.modal-list-item.drag-over {
  border-color: var(--accent);
}

.modal-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
}

.modal-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #09090b;
}

.modal-btn.primary:hover {
  background: var(--accent-hover);
}

/* Toggle switch in modal */
.modal-toggle {
  width: 36px;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.modal-toggle:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.modal-toggle:checked::after {
  left: 18px;
  background: #09090b;
}

/* =============================================
   BUILDER TOOLTIP
============================================= */
.builder-tooltip {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 100;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.tooltip-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tooltip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tooltip-val {
  font-weight: 600;
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* =============================================
   MOBILE NAVIGATION
============================================= */
.mobile-nav {
  display: none;
}

/* =============================================
   RESPONSIVE
============================================= */
@media (max-width: 900px) {
  .sidebar {
    width: 64px;
    min-width: 64px;
  }

  .sidebar .logo-text,
  .sidebar .nav-item span,
  .sidebar .data-status span,
  .sidebar .last-updated {
    display: none;
  }

  .settings-drawer.open {
    width: 300px;
    min-width: 300px;
  }
}

@media (max-width: 768px) {

  /* Hide sidebar completely and remove toggle */
  .sidebar,
  .sidebar-toggle {
    display: none;
  }

  /* Main content takes full width and pads for bottom nav */
  .main-content {
    width: 100vw;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  /* Mobile Bottom Navigation Bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(12, 12, 14, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 10000;
    justify-content: space-around;
    align-items: center;
  }

  .mobile-nav .nav-item {
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    font-size: 10px;
    width: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
    justify-content: center;
  }

  .mobile-nav .nav-item svg {
    width: 22px;
    height: 22px;
    margin: 0 auto;
  }

  .mobile-nav .nav-item.active {
    background: transparent;
    color: var(--accent);
    box-shadow: none;
  }

  .mobile-nav .nav-item.active svg {
    filter: drop-shadow(0 0 8px rgba(201, 169, 110, 0.4));
  }

  /* Padding adjustments for mobile */
  .dashboard-layout {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }

  /* Topbar shrink elements */
  .page-title {
    font-size: 16px;
  }

  .time-range-selector {
    gap: 2px;
  }

  .range-btn {
    padding: 4px 6px;
    font-size: 10px;
  }

  /* Grids and Metrics */
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .metric-card {
    padding: 12px;
  }

  .card-value {
    font-size: 16px;
  }

  .mini-charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Builder Drawer to Bottom Sheet logic */
  .builder-layout {
    flex-direction: column;
  }

  .builder-chart-area {
    width: 100%;
    height: 60vh;
  }

  .settings-drawer {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 0;
    width: 100vw;
    height: 65vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9000;
  }

  .settings-drawer.open {
    transform: translateY(0);
    width: 100vw;
    min-width: 100vw;
  }

  /* Popups */
  .mini-popup-box {
    width: 95vw;
    height: 50vh;
  }

  .modal-box {
    width: 95vw;
  }

  /* Data Table mobile sizing */
  .table-controls {
    flex-wrap: wrap;
    width: 100%;
  }

  .table-search {
    flex: 1;
    min-width: 150px;
  }
}

@media (max-width: 480px) {

  /* Smaller mobile screen adjustments */
  .range-btn {
    padding: 3px 5px;
    font-size: 9px;
  }

  .refresh-btn {
    width: 28px;
    height: 28px;
  }

  .refresh-btn svg {
    width: 14px;
    height: 14px;
  }
}