:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2a2f3d;
  --text: #e4e6ed;
  --text-muted: #8b90a0;
  --accent: #6366f1;
  --positive: #22c55e;
  --negative: #ef4444;
  --warning: #f59e0b;
  --sidebar-width: 270px;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0 0; /* Remove bottom padding to let footer sit flush */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.25); /* Subtle dark contrast for footer */
  flex-shrink: 0;
}

.logout-link {
  color: var(--text-muted) !important;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem; /* Spacious padding aligned with sidebar header */
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.logout-link:hover {
  background: rgba(239, 68, 68, 0.08); /* Soft red tint background on hover */
  color: var(--negative) !important; /* Vibrant red text */
  text-decoration: none;
}

.logout-link svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
}

.logout-link:hover svg {
  transform: translateX(3px); /* Interactive slide out nudge */
  color: var(--negative);
}

.sidebar-header {
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.crypto-nav {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  gap: 0.2rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.35);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-home-icon {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.85;
}

.sidebar-home-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(99, 102, 241, 0.25);
}

.sidebar-home-link.active {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.35);
}

.crypto-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0.1rem 0;
  border: 1px solid transparent;
}

.crypto-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: translateX(2px);
  border-color: rgba(255, 255, 255, 0.02);
}

.crypto-link.active {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.2);
  font-weight: 500;
}

.crypto-link--stale {
  opacity: 0.55;
}

.crypto-link--stale:hover {
  opacity: 0.85;
}

.crypto-link-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.crypto-all-icon {
  color: var(--accent);
  flex-shrink: 0;
}

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

.crypto-status-dot--dry {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.5);
}

.crypto-status-dot--live {
  background: var(--positive);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.45);
}

.crypto-status-dot--stopped {
  background: var(--text-muted);
  opacity: 0.7;
}

.crypto-status-dot--disabled {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
}

.crypto-link--dry {
  border-left: 3px solid var(--accent);
  background: rgba(99, 102, 241, 0.07);
}

.crypto-link--live {
  border-left: 3px solid var(--positive);
  background: rgba(34, 197, 94, 0.07);
}

.crypto-link--stopped {
  border-left: 3px solid rgba(139, 144, 160, 0.55);
  background: rgba(139, 144, 160, 0.06);
}

.crypto-link--halted {
  opacity: 0.62;
}

.crypto-link--halted:hover {
  opacity: 0.82;
}

.crypto-link--dry.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.35);
}

.crypto-link--live.active {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.crypto-link--stopped.active {
  background: rgba(139, 144, 160, 0.12);
  color: var(--text);
}

.sidebar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0;
  padding-bottom: 0.5rem;
}

.nav-section + .nav-section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.nav-section-toggle {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  opacity: 1;
  margin: 0;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-section-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-section-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-section-toggle .nav-section-icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0.85;
  flex-shrink: 0;
}

.nav-section-chevron {
  width: 12px;
  height: 12px;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.nav-section-toggle[aria-expanded="true"] .nav-section-chevron {
  transform: rotate(90deg);
}

.nav-section-wrapper {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.nav-section--collapsed .nav-section-wrapper {
  grid-template-rows: 0fr;
}

.nav-section-body {
  min-height: 0;
  padding-left: 0.4rem;
  margin-left: 0.7rem;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.nav-subsection {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav-subsection + .nav-subsection {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.nav-subsection-label {
  padding: 0 0.35rem 0.35rem;
}

.nav-subsection-label .pill {
  font-size: 0.6rem;
  padding: 0.1rem 0.45rem;
  letter-spacing: 0.04em;
}


.badges { display: flex; gap: 0.3rem; }

.badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
}

.badge-win { background: rgba(34, 197, 94, 0.15); color: var(--positive); }
.badge-loss { background: rgba(239, 68, 68, 0.15); color: var(--negative); }

.content {
  flex: 1;
  min-height: 0;
  padding: 1.5rem 2rem;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.top-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.top-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.top-nav a:hover { color: var(--text); background: var(--surface); }
.top-nav a.active { color: var(--accent); background: var(--surface); }

.page-title {
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-sub { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
.kpi-detail { font-size: 0.75rem; color: var(--text-muted); }

.mono { font-family: var(--font-mono); font-size: 0.9em; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.panel h3 { margin-bottom: 1rem; font-size: 1rem; }

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

.data-table.activity-table {
  table-layout: fixed;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table.activity-table th:first-child,
.data-table.activity-table td:first-child {
  padding-left: 0;
}

.data-table.activity-table th:last-child,
.data-table.activity-table td:last-child {
  padding-right: 0;
}

.data-table tr:hover td { background: var(--surface-hover); }

/* Shared activity table columns (dashboard, trades, markets) */
.data-table.activity-table .col-period {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table.activity-table .col-result {
  white-space: nowrap;
}

.data-table.activity-table .col-config {
  white-space: nowrap;
}

.data-table.activity-table .col-side {
  white-space: nowrap;
}

.data-table.activity-table .col-num,
.data-table.activity-table th.col-num {
  white-space: nowrap;
  text-align: right;
}

.data-table.activity-table .col-pnl,
.data-table.activity-table th.col-pnl {
  white-space: nowrap;
  text-align: right;
}

.data-table.activity-table--full col.col-period { width: 28%; }
.data-table.activity-table--full col.col-result { width: 12%; }
.data-table.activity-table--full col.col-side { width: 8%; }
.data-table.activity-table--full col.col-won-side { width: 8%; }
.data-table.activity-table--full col.col-price { width: 9%; }
.data-table.activity-table--full col.col-shares { width: 11%; }
.data-table.activity-table--full col.col-amount { width: 12%; }
.data-table.activity-table--full col.col-pnl { width: 12%; }

.data-table.activity-table--compact col.col-period { width: 40%; }
.data-table.activity-table--compact col.col-result { width: 16%; }
.data-table.activity-table--compact col.col-side { width: 8%; }
.data-table.activity-table--compact col.col-config { width: 12%; }
.data-table.activity-table--compact col.col-pnl { width: 12%; }

.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.pill-win { background: #14532d; color: var(--positive); }
.pill-loss { background: #450a0a; color: var(--negative); }
.pill-dry { background: #451a03; color: var(--warning); }
.pill-mode-dry { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; }

.data-table.errors-table .col-time {
  white-space: nowrap;
  width: 12%;
}
.data-table.errors-table .col-attempt {
  text-align: center;
  width: 7%;
}
.data-table.errors-table .col-error {
  width: 40%;
  max-width: 0;
}
.data-table.errors-table .error-message {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--negative);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters select,
.filters input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.filters button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.filters button:hover { opacity: 0.9; }

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination a {
  color: var(--accent);
  text-decoration: none;
}

.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.empty-state, .empty-hint {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

.empty-state h2 { margin-bottom: 0.5rem; color: var(--text); }

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  height: 280px;
  position: relative;
}

.chart-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.market-slug { color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.85rem; }
.market-kpis { margin-bottom: 1.25rem; }

.chart-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.chart-toolbar label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.chart-toolbar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.coverage-hint {
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.hint { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.75rem; }

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

code {
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.config-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.config-panel h3 {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.config-detail-table th {
  width: 42%;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.85rem;
}

.config-detail-table .config-key {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: right;
}

.config-compare-table .config-coin-code {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.config-raw {
  margin-top: 0.5rem;
}

.config-raw summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.25rem 0;
}

.config-db-banner {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-version-table .config-hash {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.config-version-current td {
  background: rgba(99, 102, 241, 0.08);
}

.config-raw-pre {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Mobile Header & Backdrop */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 1rem;
  z-index: 99;
  backdrop-filter: blur(12px);
  background: rgba(26, 29, 39, 0.85);
}

.mobile-menu-btn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.mobile-menu-btn:hover {
  background: var(--border);
  color: var(--accent);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 998; /* Just under sidebar but above content */
}

.layout.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive Table Container */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  background: var(--surface);
}

.table-container .data-table {
  margin-bottom: 0;
  border: none;
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }
  .layout {
    flex-direction: column;
    padding-top: 56px;
    box-sizing: border-box;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    border-right: 1px solid var(--border);
    z-index: 999;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }
  .layout.sidebar-open .sidebar {
    left: 0;
  }
  .sidebar-backdrop {
    display: block;
  }
  .crypto-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 0;
  }
  .content {
    padding: 1rem;
    width: 100%;
    overflow-x: hidden;
  }
  .top-nav {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .top-nav::-webkit-scrollbar {
    display: none;
  }
  .top-nav a {
    flex-shrink: 0;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .table-container .data-table {
    min-width: 750px;
  }
  .table-container .sim-market-table {
    min-width: 900px;
  }
  /* Hide price and amount columns in trades/markets table on mobile */
  .activity-table--full .col-price,
  .activity-table--full .col-amount {
    display: none !important;
  }
  .activity-table--full col.col-price,
  .activity-table--full col.col-amount {
    display: none !important;
  }
  .table-container .activity-table--full {
    min-width: 0 !important;
  }
  /* Hide the DRY pill in the result column on mobile */
  .col-result .pill-dry {
    display: none !important;
  }
  /* Hide side, config, and pnl columns in compact markets table on mobile */
  .activity-table--compact .col-side,
  .activity-table--compact .col-config,
  .activity-table--compact .col-pnl {
    display: none !important;
  }
  .activity-table--compact col.col-side,
  .activity-table--compact col.col-config,
  .activity-table--compact col.col-pnl {
    display: none !important;
  }
  .table-container .activity-table--compact {
    min-width: 0 !important;
  }
}

.crypto-label-pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-muted);
  margin-right: 0.5rem;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
}

/* Period statistics cards layout */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.period-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.period-card-header {
  font-size: 1.05rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.period-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.period-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.period-card-label {
  color: var(--text-muted);
}

.period-card-val {
  font-weight: 600;
}

.home-section {
  margin-bottom: 2rem;
}

.home-intro {
  margin-bottom: 1.5rem;
}

.home-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.home-section--compact {
  margin-bottom: 1.5rem;
}

.home-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.home-alert {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.home-alert:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.home-alert--error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.home-alert--warn {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.home-alert-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.home-alert--error .home-alert-title {
  color: var(--negative);
}

.home-alert--warn .home-alert-title {
  color: var(--warning);
}

.home-alert-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.home-leaders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.home-leader {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.home-leader-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.home-leader--best .home-leader-label {
  color: var(--positive);
}

.home-leader--worst .home-leader-label {
  color: var(--negative);
}

.home-leader-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.home-leader-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.home-leader-row:hover {
  background: var(--surface-hover);
}

.home-leader-row:hover .home-leader-name {
  color: var(--accent);
}

.home-leader-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.home-leader-rank {
  width: 1.1rem;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1;
}

.home-leader-name {
  font-size: 0.9rem;
  font-weight: 600;
  transition: color 0.15s ease;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.home-leader-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
}

.home-leader-pnl {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}

.home-leader-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.home-leader-meta-sep {
  color: rgba(255, 255, 255, 0.25);
  margin: 0 0.1rem;
}

.home-leader-empty {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.home-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.home-card {
  min-height: 100%;
}

.home-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.home-card-header .pill {
  font-size: 0.65rem;
  flex-shrink: 0;
}

.home-card-meta {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.home-card-vs {
  color: var(--text-muted);
  font-weight: 500;
}

.home-card-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.home-card-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .home-cards-grid,
  .home-leaders {
    grid-template-columns: 1fr;
  }
}

/* Charts dashboard grid */
.chart-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1.5rem;
}

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

/* ── Config Simulator ── */

.sim-form-wrapper {
  width: 100%;
  margin-bottom: 1.5rem;
}

.sim-form-toggle {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.25rem 0;
  user-select: none;
}

.sim-form-toggle:hover {
  color: var(--accent);
}

.sim-form {
  width: 100%;
  margin-top: 1rem;
}

.sim-form-section {
  width: 100%;
  margin-bottom: 1.25rem;
}

.sim-form-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.sim-form-row-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  opacity: 0.85;
}

.sim-form-row-label:first-of-type {
  margin-top: 0.25rem;
}

.sim-mode-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sim-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.45;
}

.sim-toggle-row input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.sim-toggle-hint {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.sim-toggle-hint code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.sim-slider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.sim-slider-field {
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.sim-slider-field:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.sim-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.sim-slider-header label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sim-ref-val {
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0.75;
  font-weight: normal;
  margin-left: 0.35rem;
  font-family: var(--font-mono);
}

.sim-num-input {
  width: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.45rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sim-num-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.sim-slider-track-wrap {
  position: relative;
}

/* Range slider styling */
.sim-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}

.sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25), 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.sim-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), 0 2px 8px rgba(0,0,0,0.4);
}

.sim-slider::-webkit-slider-thumb:active {
  transform: scale(1.25);
}

.sim-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25), 0 1px 4px rgba(0,0,0,0.3);
}

.sim-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.sim-slider-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  font-family: var(--font-mono);
}

.sim-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sim-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.sim-btn:hover { opacity: 0.9; }
.sim-btn:active { transform: scale(0.98); }

.sim-btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.sim-btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* Loading spinner */
.sim-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sim-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sim-spin 0.6s linear infinite;
}

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

/* Stats comparison grid */
.sim-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}

.sim-period-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.sim-period-header {
  font-size: 1.05rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.sim-period-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sim-period-table th {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sim-period-table th:first-child {
  text-align: left;
}

.sim-period-table th:nth-child(2),
.sim-period-table th:nth-child(3) {
  text-align: right;
}

.sim-period-table td {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  vertical-align: middle;
}

.sim-period-table tr:last-child td {
  border-bottom: none;
  padding-bottom: 0;
}

.sim-period-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
}

.sim-period-table td:nth-child(2),
.sim-period-table td:nth-child(3) {
  text-align: right;
  white-space: nowrap;
}

.sim-val-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
  width: 100%;
}

.sim-orig-val {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.sim-sim-val {
  font-weight: 600;
  font-size: 0.85rem;
}

.sim-delta {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.2;
}

.sim-delta-positive {
  background: rgba(34, 197, 94, 0.12);
  color: var(--positive);
}

.sim-delta-negative {
  background: rgba(239, 68, 68, 0.12);
  color: var(--negative);
}

/* Chart legend */
.sim-chart-legend {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sim-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sim-legend-line {
  display: inline-block;
  width: 24px;
  height: 2px;
}

.sim-legend-line-orig {
  background: var(--text-muted);
  background: repeating-linear-gradient(
    90deg,
    var(--text-muted) 0px,
    var(--text-muted) 4px,
    transparent 4px,
    transparent 7px
  );
}

.sim-legend-line-sim {
  background: var(--accent);
}

/* Market table row highlights */
.sim-row-new-win td { background: rgba(34, 197, 94, 0.06) !important; }
.sim-row-new-loss td { background: rgba(239, 68, 68, 0.06) !important; }
.sim-row-new td { background: rgba(99, 102, 241, 0.06) !important; }
.sim-row-skipped td { background: rgba(245, 158, 11, 0.06) !important; }
.sim-row-flip-win td { background: rgba(34, 197, 94, 0.08) !important; }
.sim-row-flip-loss td { background: rgba(239, 68, 68, 0.08) !important; }
.sim-row-flip td { background: rgba(99, 102, 241, 0.08) !important; }

.sim-diff-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.sim-diff-new {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.sim-diff-skip {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.sim-diff-flip {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

.sim-diff-same {
  background: var(--border);
  color: var(--text-muted);
}

.sim-market-table .truncate {
  max-width: 300px;
}

@media (max-width: 768px) {
  .sim-slider-grid {
    grid-template-columns: 1fr;
  }
  .sim-stats-grid {
    grid-template-columns: 1fr;
  }
  .sim-metric-vals {
    font-size: 0.78rem;
  }
}

.nav-section-header {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.9rem 1rem 0.35rem;
  font-weight: 700;
  opacity: 0.75;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
  margin-bottom: 0.35rem;
  margin-top: 0.65rem;
}



/* Data job toast notifications (fixed overlay, not in document flow) */
.data-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}

.data-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--positive);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: data-toast-in 0.25s ease-out;
}

.data-toast--failed {
  border-left-color: var(--negative);
}

.data-toast-body {
  flex: 1;
  min-width: 0;
}

.data-toast-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.data-toast-message {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}

.data-toast-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.data-toast-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.data-toast-link:hover {
  text-decoration: underline;
}

.data-toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.data-toast-close:hover {
  color: var(--text);
}

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

@media (max-width: 768px) {
  .data-toast-container {
    top: 4.25rem;
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Sortable Table Headers */
.data-table th.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.data-table th.sortable-header:hover {
  color: var(--text);
  background-color: var(--surface-hover);
}

.sort-indicator {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  vertical-align: middle;
}

