:root {
  /* Modern Brutalist Palette */
  --bg-deep: #050505;
  --bg-surface: #0c0c0c;
  --bg-surface-high: #141414;
  --accent: #d9ff3f; /* Keep the neon yellow but optimize contrast */
  --accent-soft: rgba(217, 255, 63, 0.1);
  --accent-text: #000000;

  --ink: #ffffff;
  --ink-dim: #cccccc;
  --ink-ghost: #888888;

  --border: rgba(255, 255, 255, 0.06);
  --border-bright: rgba(255, 255, 255, 0.12);

  --positive: #089981; /* TradingView Green */
  --negative: #f23645; /* TradingView Red */

  /* Spatial */
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 60px;
  --header-height: 60px;
  --row-height: 60px;
  --table-visible-rows: 10;

  /* Border Radius */
  --radius-sm: 8px; /* Small elements (icons, buttons) */
  --radius-md: 12px; /* Cards, panels */
  --radius-full: 999px; /* Pills, fully rounded */

  /* Spacing Scale */
  --space-xs: 0.5rem; /* 8px - Tight spacing */
  --space-sm: 0.75rem; /* 12px - Small gaps */
  --space-md: 1rem; /* 16px - Standard spacing */
  --space-lg: 1.5rem; /* 24px - Section padding */
  --space-xl: 2rem; /* 32px - Large gaps */
  --space-2xl: 2.5rem; /* 40px - Panel padding */
  --space-3xl: 3rem; /* 48px - Major sections */
  --space-4xl: 4rem; /* 64px - Page margins */

  /* Legacy spatial variables */
  --card-radius: var(--radius-md);
  --panel-glow: 0 18px 40px rgba(0, 0, 0, 0.6);

  /* Typography */
  --font-display: "Fraunces", serif;
  --font-sans: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  /* Typography Scale */
  --text-xs: 10px; /* Labels, timestamps, system text */
  --text-sm: 11px; /* Buttons, badges, table headers */
  --text-base: 13px; /* Body text, table cells */
  --text-lg: 16px; /* Meta values */
  --text-display: 32px; /* Large stats */

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.8);

  /* Legacy variable mappings to minimize breaks */
  --bg-dark: var(--bg-deep);
  --bg-panel: var(--bg-surface);
  --bg-card: var(--bg-surface-high);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --border-color: var(--border);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-dim);
  --color-success: var(--positive);
  --color-danger: var(--negative);
  --paper: var(--bg-deep);
  --panel: var(--bg-surface);
  --shadow: var(--shadow-lg);
}

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

body {
  background-color: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-loading {
  overflow: hidden;
}

/* Subtle background grain and grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: -1;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.03;
  mix-blend-mode: overlay;
  z-index: -1;
  pointer-events: none;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-width: 100%;
  background:
    radial-gradient(
      circle at top right,
      rgba(217, 255, 63, 0.08),
      transparent 45%
    ),
    var(--bg-deep);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(
    180deg,
    rgba(12, 12, 12, 0.95),
    rgba(5, 5, 5, 0.95)
  );
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  transition:
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s;
  position: relative;
}

.brand:hover {
  background-color: var(--bg-hover);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--accent-text);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  transition: opacity 0.2s;
  z-index: 1;
}

.sidebar-toggle-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.brand:hover .logo-icon {
  opacity: 0;
}

.brand:hover .sidebar-toggle-btn {
  opacity: 1;
}

.sidebar:not(.collapsed) .brand {
  padding: 0 1rem;
  justify-content: space-between;
}

.sidebar:not(.collapsed) .logo-icon {
  opacity: 1;
  display: grid;
}

.sidebar:not(.collapsed) .sidebar-toggle-btn {
  position: static;
  transform: none;
  opacity: 1;
}

.sidebar:not(.collapsed) .brand:hover .logo-icon {
  opacity: 1;
}

.sidebar:not(.collapsed) .brand:hover .sidebar-toggle-btn {
  color: var(--accent);
}

.logo-text {
  display: none;
}

.sidebar.collapsed .brand {
  padding: 0;
  justify-content: center;
}

.main-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0.5rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg);
  height: 44px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.nav-item span {
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s;
}

.nav-item svg {
  opacity: 0.7;
  transition: opacity 0.2s;
}

.nav-item:hover svg,
.nav-item.active svg {
  opacity: 1;
}

.sidebar.collapsed .nav-item span {
  display: none;
}

.sidebar.collapsed .sidebar-footer .status-text {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.nav-item::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background-color: var(--accent);
  transition: width 0.2s;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-item.active::after {
  width: 4px;
}

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

.sidebar.collapsed .sidebar-footer {
  padding: var(--space-lg) 0;
  display: flex;
  justify-content: center;
}

.system-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-dim);
}

.sidebar.collapsed .status-text {
  display: none;
}

.status-dot {
  width: 4px;
  height: 4px;
  background-color: var(--positive);
  box-shadow: 0 0 8px var(--positive);
  animation: pulse-status 1.5s infinite;
}

@keyframes pulse-status {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.top-bar {
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-4xl);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    90deg,
    rgba(12, 12, 12, 0.98),
    rgba(20, 20, 20, 0.98)
  );
  z-index: 10;
  gap: var(--space-md);
  position: sticky;
  top: 0;
  width: 100%;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-surface-high);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.menu-toggle:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.breadcrumbs {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.current-section {
  color: var(--ink);
  font-weight: 700;
}

.actions {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.last-update {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-dim);
  letter-spacing: 0.05em;
}

/* Buttons */
.btn {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid var(--border-bright);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--ink);
  color: var(--bg-deep);
  border-color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

/* Content Area */
.content-area {
  padding: var(--space-xl) var(--space-4xl) var(--space-4xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* Overview Panel */
.overview-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
  padding: var(--space-2xl) var(--space-3xl);
  background: linear-gradient(
    135deg,
    rgba(20, 20, 20, 0.95),
    rgba(10, 10, 10, 0.95)
  );
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--panel-glow);
  position: relative;
}

.overview-main {
  flex: 1;
  min-width: 0;
}

.overview-panel::before {
  content: "PORTFOLIO_SUMMARY";
  position: absolute;
  top: var(--space-md);
  left: var(--space-lg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-ghost);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - var(--space-xl));
}

.overview-panel::after {
  content: "";
  position: absolute;
  left: var(--space-lg);
  right: var(--space-lg);
  bottom: var(--space-sm);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.2;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-display);
  line-height: 1.2;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value.positive {
  color: var(--positive);
}

.stat-value.negative {
  color: var(--negative);
}

.stat-trend.positive {
  color: var(--positive);
}

.stat-trend.negative {
  color: var(--negative);
}

.overview-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-lg);
  padding-left: var(--space-xl);
  border-left: 1px solid var(--border);
  min-width: 120px;
}

@media (max-width: 768px) {
  .overview-panel {
    padding: var(--space-lg) var(--space-xl);
  }

  .overview-meta {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: var(--space-lg);
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }
}

.meta-label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.meta-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink);
}

.ticker-tape-container {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  overflow: visible;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

#ticker-tape-widget {
  width: 100% !important;
  height: auto !important;
}

/* Tabs & Table */
.tabs-container {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 12, 0.8);
}

.tab-group {
  display: flex;
  gap: var(--space-md);
  height: 100%;
  align-items: center;
}

.tab-btn {
  height: 64px;
  padding: 0 var(--space-lg);
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: flex;
  align-items: center;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 2px;
  background: var(--accent);
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  height: calc((var(--row-height) * var(--table-visible-rows)) + 48px);
  min-height: calc((var(--row-height) * var(--table-visible-rows)) + 48px);
  scroll-snap-type: y mandatory;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  -webkit-overflow-scrolling: touch;
  position: relative;
  isolation: isolate;
}

.table-wrapper::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

table {
  width: 100%;
  min-width: fit-content;
  border-collapse: collapse;
}

thead {
  background-color: var(--bg-surface-high);
}

/* Fix for widget alignment + font consistency */
tv-ticker-tag {
  vertical-align: middle;
  margin-left: -4px;
  font-family: var(--font-sans) !important;
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--bg-surface-high);
  height: 48px;
  padding: 0 var(--space-md);
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
}

th:not(:first-child) {
  z-index: 70;
}

th:first-child,
td:first-child {
  padding-left: var(--space-md);
  position: sticky;
  left: 0;
  z-index: 85;
  background-color: var(--bg-surface-high);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.5);
}
th:first-child {
  z-index: 95;
  background: var(--bg-surface-high);
  color: var(--accent);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.5);
}
th:last-child,
td:last-child {
  padding-right: var(--space-md);
}

th:hover {
  color: var(--ink);
  background-color: var(--bg-surface-high);
}

td {
  height: var(--row-height);
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--ink);
  vertical-align: middle;
  white-space: nowrap;
  background: var(--bg-surface);
  font-variant-numeric: tabular-nums;
}

tbody tr {
  scroll-snap-align: start;
  scroll-margin-top: 48px;
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
  scroll-snap-align: end;
  scroll-margin-bottom: 0;
}

tbody tr:hover {
  background: transparent;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

tbody tr:hover td:first-child {
  background-color: var(
    --bg-surface-high
  ); /* Fully opaque hover for sticky column */
}

td:first-child {
  color: var(--ink);
}

/* Numeric columns refinement */
/* td:nth-child(n+2) rule removed to allow Sans-Serif default */

/* Custom renderers */
.cell-weight {
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  border: none;
  background: transparent;
}

.badge.positive {
  color: var(--positive);
}

.badge.negative {
  color: var(--negative);
}

.score-high,
.score-low,
.score-mid {
  font-weight: inherit;
  /* Color will be dynamically set via JS */
}

.btn-remove-cell {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-ghost);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove-cell:hover {
  background: var(--negative);
  color: white;
  border-color: var(--negative);
}

/* Inline quantity control (holdings table) */
.qty-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.qty-input {
  width: 84px;
  height: 34px;
  padding: 0 30px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: inherit;
  font-size: var(--text-base);
  outline: none;
}

.qty-input:focus {
  border-color: var(--border-bright);
  background: var(--bg-hover);
}

.qty-input:disabled {
  opacity: 0.45;
}

/* hide native spinners */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-input[type="number"] {
  -moz-appearance: textfield;
}

.qty-spin {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qty-spin-btn {
  width: 18px;
  height: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border-radius: 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
  font-size: 9px;
  font-family: inherit;
  user-select: none;
  touch-action: none;
}

.qty-spin-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.qty-spin-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Quick Add Inline */
.quick-add-compact {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--border);
  padding: 1px;
  height: 36px;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.quick-add-compact input {
  background: var(--bg-deep);
  border: none;
  color: var(--ink);
  padding: 0 var(--space-md);
  font-family: inherit;
  font-size: var(--text-sm);
  height: 100%;
  width: 120px;
  outline: none;
  transition: background 0.2s;
}

.quick-add-compact input:focus {
  background: var(--bg-surface-high);
}

.btn-add-mini {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  color: var(--accent-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

/* TradingView override basics */
tv-ticker-tag {
  --tv-color-platform-background: transparent !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  background: var(--bg-surface-high);
  color: var(--ink);
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-transform: uppercase;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast-fade {
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.4s ease;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  overflow: hidden;
}

.loader {
  width: 60px;
  height: 2px;
  background: var(--border-bright);
  position: relative;
  overflow: hidden;
}

.loader::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: var(--accent);
  animation: loader-slide 1.5s infinite ease-in-out;
}

@keyframes loader-slide {
  0% {
    left: -30%;
  }
  100% {
    left: 100%;
  }
}

.loading-text {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* Heatmap & Calendar */
.heatmap-container,
.calendar-container {
  min-height: 600px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: visible;
  padding: 0 0 var(--space-md);
  box-shadow: var(--shadow-sm);
}

/* TradingView widgets need an explicit parent height when using height: 100% */
#heatmap-section,
#calendar-section {
  height: calc(
    100vh - var(--header-height) - var(--space-xl) - var(--space-4xl)
  );
}

#heatmap-widget-container,
#calendar-section .tradingview-widget-container {
  flex: 1;
  min-height: 0;
}

#heatmap-widget-container > .tradingview-widget-container__widget,
#calendar-section .tradingview-widget-container__widget {
  height: 100%;
}

#heatmap-widget-container iframe,
#calendar-section iframe {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Responsive */
@media (max-width: 1024px) {
  /* Hide sidebar completely when thin/mobile */
  .sidebar {
    width: 0 !important;
    border-right: none;
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1000;
  }

  .sidebar:not(.collapsed) {
    width: var(--sidebar-width) !important;
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Show the brand icon in the top bar on mobile since sidebar is gone */
  .top-bar-left::before {
    content: "";
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l6-6 4 4 7-7' /%3E%3Cpath d='M14 8h7v7' /%3E%3C/svg%3E");
    background-size: 20px;
    background-position: center;
    background-repeat: no-repeat;
    margin-right: var(--space-sm);
    cursor: pointer;
  }

  .breadcrumbs {
    display: flex; /* Re-enable on mobile if we use logo as toggle */
  }

  .content-area {
    padding: var(--space-lg) var(--space-md);
  }

  .overview-panel {
    grid-template-columns: 1fr;
    padding: var(--space-lg);
  }

  .overview-meta {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: var(--space-lg);
  }

  .stat-value {
    font-size: var(--text-display);
  }

  .top-bar {
    padding: 0 var(--space-md);
  }

  .breadcrumbs {
    display: none;
  }

  /* Compact Table for Mobile */
  th,
  td {
    padding: 0 var(--space-sm);
  }

  th:first-child,
  td:first-child {
    padding-left: var(--space-md);
  }

  th:last-child,
  td:last-child {
    padding-right: var(--space-md);
  }
}

/* Docked terminal layout tune (layout-only, keeps existing theme colors) */
.content-area {
  padding: var(--space-sm) 0 0;
  gap: var(--space-sm);
}

.overview-panel {
  margin: 0;
  border-left: none;
  border-right: none;
  border-radius: 0;
  box-shadow: none;
  padding: var(--space-md) var(--space-xl);
}

.overview-panel::after {
  left: 0;
  right: 0;
  bottom: 0;
}

.ticker-tape-container {
  border-left: none;
  border-right: none;
  border-radius: 0;
  box-shadow: none;
  padding: 2px 0;
}

.stats-strip {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  min-height: 40px;
  padding: 0 var(--space-xl);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.stats-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.stats-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-ghost);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stats-trend.positive {
  color: var(--positive);
}

.stats-trend.negative {
  color: var(--negative);
}

.stats-trend.neutral {
  color: var(--ink);
}

#preact-root {
  min-height: 0;
}

.tabs-container {
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  box-shadow: none;
}

.tabs-header {
  height: 52px;
  padding: 0 var(--space-xl);
}

.tab-btn {
  height: 52px;
}

.table-wrapper {
  height: calc((var(--row-height) * var(--table-visible-rows)) + 48px);
  min-height: calc((var(--row-height) * var(--table-visible-rows)) + 48px);
}

@media (max-width: 1024px) {
  .content-area {
    padding: var(--space-sm) 0 0;
    gap: var(--space-sm);
  }

  .overview-panel {
    padding: var(--space-md);
  }

  .tabs-header {
    padding: 0 var(--space-md);
  }

  .stats-strip {
    padding: 0 var(--space-md);
    gap: var(--space-md);
    flex-wrap: wrap;
    min-height: 44px;
  }
}
