
:root {
  --bg: #0b1020;
  --panel: #11182b;
  --text: #e8ecf8;
  --muted: #9aa4bf;
  --line: #24304f;
  --positive: #33d29a;
  --negative: #ff6b8a;
  --accent: #9b6cff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar,
.controls,
.table-wrap,
.footer,
.detail-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 0 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.controls label,
.floating-filter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.controls input,
.controls select,
.controls > button,
.floating-popover button,
.floating-popover input,
.floating-popover select {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
}

.controls > button,
.floating-popover button {
  cursor: pointer;
}

.search-control {
  width: min(280px, 100%);
  flex: 0 0 auto;
}

.search-control input {
  width: 100%;
}

.overview-actions,
.detail-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.overview-actions {
  margin-left: auto;
}

.overview-controls {
  align-items: center;
}

.auto-toggle {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  color: var(--text) !important;
  user-select: none;
}

.auto-toggle span {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
}

.auto-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.icon-btn {
  width: 46px;
  height: 46px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn:focus-visible,
.open-btn:hover,
.open-btn:focus-visible {
  border-color: rgba(155, 108, 255, 0.55);
  outline: none;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  display: block;
}

.table-wrap {
  padding-bottom: 24px;
}

.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}


.overview-table .col-asset { width: 14%; }
.overview-table .col-metric { width: 18%; }
.overview-table .col-chg { width: 7%; }
.overview-table .col-action { width: 8%; }


.data-table thead th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table thead th.action-col {
  width: 1%;
}

.data-table thead th.chg-col,
.data-table tbody td.chg-col {
  width: 92px;
}

.data-table thead th.chg-col {
  text-align: right;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(36, 48, 79, 0.6);
}

.metric-value-col,
.chg-col,
.action-col {
  white-space: nowrap;
}

.table-num {
  display: inline-block;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.metric-value-col {
  font-variant-numeric: tabular-nums;
}

.chg-col {
  text-align: right;
}

.action-col {
  text-align: right;
}

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

.metric-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-cell .value {
  font-variant-numeric: tabular-nums;
}

.change {
  font-size: 13px;
  min-width: 76px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.standalone-change {
  display: inline-block;
  width: 100%;
  min-width: 0;
}

.change.positive { color: var(--positive); }
.change.negative { color: var(--negative); }
.change.muted { color: var(--muted); }

.table-error-cell {
  color: #ffd3df;
  font-size: 14px;
}

.ticker-link,
.open-btn,
.back-link,
.footer a {
  color: #9fc1ff;
  text-decoration: none;
}

.open-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: inline-block;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
}

.hidden { display: none !important; }

.sort-header {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.1;
}

.sort-header:hover,
.sort-header:focus-visible {
  color: var(--text);
  outline: none;
}

.sort-header.active {
  color: var(--text);
}

.sort-header-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: rgba(232, 236, 248, 0.9);
}

.sort-header.active .sort-header-icon {
  color: var(--accent);
}

.sort-header-icon svg {
  display: block;
  width: 14px;
  height: 14px;
}

.sort-header-label {
  letter-spacing: 0.01em;
}

.sort-header-right {
  justify-content: flex-end;
}

.data-table thead th {
  cursor: default;
}

.data-table thead th.action-col,
.data-table thead th.action-col * {
  cursor: default;
}

.data-table thead th .sort-header,
.data-table thead th .sort-header *,
.data-table thead th .sort-header-icon,
.data-table thead th .sort-header-label {
  cursor: pointer;
}

.floating-filter-wrap {
  position: relative;
  align-items: flex-start;
}

.floating-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(420px, calc(100vw - 48px));
  background: linear-gradient(180deg, rgba(20, 25, 42, 0.985), rgba(15, 20, 36, 0.985));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.floating-popover-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
}

.floating-popover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.single-column-grid {
  grid-template-columns: minmax(0, 1fr);
}

.floating-popover-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

.floating-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.04) !important;
}

.page-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 32, 0.52);
  backdrop-filter: blur(1px);
  z-index: 100;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 32, 0.52);
  backdrop-filter: blur(1px);
  z-index: 30;
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: #7aa2ff;
  animation: detail-spin 0.9s linear infinite;
}

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

.detail-body .topbar,
.detail-body .controls,
.detail-body .detail-shell {
  width: min(1700px, calc(100vw - 24px));
}

.detail-topbar {
  padding-bottom: 4px;
}

.detail-heading h1 {
  margin-bottom: 0;
}

.detail-controls {
  padding-bottom: 12px;
  justify-content: flex-start;
}

.compact-detail-controls {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.detail-shell {
  padding-bottom: 24px;
  display: flex;
  justify-content: flex-start;
}

.detail-panel {
  position: relative;
  width: 100%;
  height: calc(100vh - 148px);
  min-width: 720px;
  min-height: 260px;
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.detail-chart-container {
  width: 100%;
  height: 100%;
}

.pane-badge-layer {
  position: absolute;
  inset: 0 0 28px 0;
  pointer-events: none;
  z-index: 24;
}

.pane-badge {
  position: absolute;
  padding: 4px 9px;
  border-radius: 10px;
  background: rgba(6, 11, 26, 0.88);
  border: 1px solid rgba(36, 48, 79, 0.85);
  color: #e8ecf8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.detail-status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
}

.detail-status.hidden {
  display: none;
}

.detail-status.error {
  color: #ffd3df;
  border-color: rgba(255, 107, 138, 0.4);
}

.detail-status.info {
  color: var(--muted);
}

.scale-resize-handle {
  position: absolute;
  top: 0;
  right: 108px;
  width: 16px;
  bottom: 28px;
  cursor: col-resize;
  z-index: 26;
}

.panel-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 28;
  border-right: 2px solid rgba(155, 108, 255, 0.7);
  border-bottom: 2px solid rgba(155, 108, 255, 0.7);
  border-bottom-right-radius: 6px;
}

.is-resizing-scale {
  cursor: col-resize;
  user-select: none;
}

.is-resizing-panel {
  cursor: nwse-resize;
  user-select: none;
}

@media (max-width: 900px) {
  .controls,
  .compact-detail-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .overview-actions,
  .detail-actions {
    justify-content: flex-start;
  }

  .detail-panel {
    min-width: 0;
    width: 100% !important;
    height: max(260px, calc(100vh - 164px)) !important;
  }
}
