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

body {
  background: #0b1224;
  color: #e2e8f0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  overflow-x: hidden;
}

html.ui-scale-normal {
  font-size: 14px;
}

html.ui-scale-large {
  font-size: 16px;
}

html.ui-scale-xlarge {
  font-size: 18px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

.app-shell-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.app-shell-body .layout {
  flex: 1 1 auto;
  min-width: 0;
}

.side-nav {
  flex: 0 0 220px;
  width: 220px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.75rem;
  padding: 0.75rem;
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  transition: width 0.18s ease, flex-basis 0.18s ease, padding 0.18s ease;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.side-nav-toggle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.55);
}

.side-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.side-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-content: flex-start;
  padding: 0.55rem 0.65rem;
  border-radius: 0.65rem;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}

.side-nav-item:hover,
.side-nav-item:focus {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.18);
}

.side-nav-item.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 1rem;
  line-height: 1;
}

.side-nav-item.active .nav-icon {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.22);
}

.side-nav:not(.open) {
  flex-basis: 62px;
  width: 62px;
  padding: 0.65rem 0.5rem;
}

.side-nav:not(.open) .nav-label {
  display: none;
}

.side-nav:not(.open) .side-nav-item {
  justify-content: center;
  padding: 0.5rem;
}

.maximized .side-nav {
  display: none;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
}

.brand .muted {
  font-size: 0.95rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-switch {
  display: inline-flex;
  gap: 0.4rem;
}

.pill {
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1f2937;
  cursor: pointer;
}

.pill.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.muted {
  color: #94a3b8;
}

.card {
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-inner {
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 0.6rem;
  padding: 0.5rem;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.symbol-search {
  min-width: 240px;
}

.search-box {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  position: relative;
}

.search-box input {
  flex: 1;
}

.icon-btn {
  border-radius: 0.5rem;
  padding: 0.35rem 0.55rem;
}

.symbol-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 2.5rem;
  max-height: 160px;
  overflow-y: auto;
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.6);
  border-radius: 0.5rem;
  padding: 0.4rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.symbol-dropdown.hidden {
  display: none;
}

.symbol-option-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.3rem 0.45rem;
  background: transparent;
  color: inherit;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.symbol-option-market {
  color: #94a3b8;
  opacity: 0.8;
  font-size: 0.85rem;
}

.symbol-option-btn:hover,
.symbol-option-btn:focus {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats.compact .stat span {
  opacity: 0.7;
}

.last-update {
  font-size: 0.85rem;
  color: #94a3b8;
}

.inline-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: clamp(320px, 52vh, 560px);
  min-height: 320px;
}

.chart-toolbar {
  position: relative;
  z-index: 120;
}

.symbol-dropdown {
  position: absolute;
  z-index: 140;
}

.ohlc-legend {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  background: rgba(2, 6, 23, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0.55rem;
  font-size: 0.82rem;
  line-height: 1;
  pointer-events: none;
  z-index: 60;
  max-width: calc(100% - 1.1rem);
  backdrop-filter: blur(4px);
}

.ohlc-legend.hidden {
  display: none;
}

.ohlc-legend .ohlc-time {
  flex: 0 0 100%;
  margin-bottom: 0.15rem;
}

.ohlc-legend .ohlc-label {
  color: #94a3b8;
  opacity: 0.95;
}

.ohlc-legend .ohlc-val {
  font-variant-numeric: tabular-nums;
}

.ohlc-legend .ohlc-delta.up {
  color: #22c55e;
}

.ohlc-legend .ohlc-delta.down {
  color: #ef4444;
}

.ohlc-legend .tiny {
  font-size: 0.75rem;
}

.chart-wrap canvas,
.chart-wrap #chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.indicator-panel {
  margin-top: 0.5rem;
  position: relative;
  height: clamp(260px, 34vh, 460px);
  overflow: hidden;
}

.indicator-panel.collapsed {
  display: none;
}

#indicatorChartsContainer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
}

.indicator-chart-card {
  background: #020617;
  border-radius: 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 0.5rem 0.6rem 0.6rem;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.indicator-chart-title {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

.indicator-chart-card canvas {
  display: block;
  width: 100%;
  flex: 1 1 0;
}

.indicator-chart-empty {
  position: absolute;
  inset: 0.5rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  color: #94a3b8;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.75);
  pointer-events: none;
}

.indicator-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.maximized .layout {
  grid-template-columns: 1fr;
}

.layout {
  display: grid;
  grid-template-columns: 1.4fr 1.1fr;
  gap: 1rem;
  align-items: start;
}

.layout-side {
  min-width: 280px;
}

.route-home .layout {
  grid-template-columns: 1fr;
}

.route-home .layout-side,
.route-home .layout-side.card {
  display: none;
}

.watchlist-expanded .layout {
  grid-template-columns: 1fr;
}

.watchlist-expanded .layout-main {
  display: none;
}

.watchlist-expanded .layout-side {
  width: 100%;
  grid-column: 1;
}

.watchlist-expanded .layout-side .card-header {
  align-items: center;
}

.watchlist-expanded .quotes-list {
  display: block;
}

.watchlist-expanded .quote-item {
  width: 100%;
}

.quotes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.7rem;
  width: 100%;
}

.layout-side.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quotes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.7rem;
  width: 100%;
  box-sizing: border-box;
}

.quote-item {
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.6rem;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
}

.quote-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.quote-head.compact {
  align-items: center;
}

.price-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.quote-left {
  display: flex;
  flex-direction: column;
}

.quote-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pct-pos {
  color: #22c55e;
}

.pct-neg {
  color: #ef4444;
}

.alert-log-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quote-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.35rem 0.75rem;
}

.quote-metrics.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.metric-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.5rem;
}

.metric-left {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.metric-label {
  color: #94a3b8;
  font-size: 0.85rem;
}

.metric-value {
  font-weight: 700;
  color: #e2e8f0;
}

.metric-value.stale {
  color: #f59e0b;
}

.metric-subtext {
  color: #94a3b8;
  font-size: 0.78rem;
  line-height: 1.2;
}

.small-input {
  width: 80px;
  padding: 0.3rem 0.4rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 0.35rem;
  color: #e2e8f0;
}

.watchlist-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: flex-end;
}

/* Hide legacy watchlist sort/refresh controls (header sorting is used instead) */
.sort-control {
  display: none;
}

#refreshIndicators {
  display: none;
}

.watchlist-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
}

.watchlist-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.watchlist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.watchlist-table th,
.watchlist-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

.watchlist-table th {
  color: #9ca3af;
  font-weight: 600;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.watchlist-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.watchlist-table tr:last-child td {
  border-bottom-color: transparent;
}

.watchlist-table .watchlist-symbol-cell {
  font-weight: 600;
}

.watchlist-table .watchlist-price-cell .price {
  font-weight: 600;
}

.watchlist-table .tf-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.watchlist-table .tf-line {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.35rem;
}

.watchlist-table .tf-line .metric-label,
.watchlist-table .tf-line .metric-value {
  font-size: 0.9rem;
}

.watchlist-table .tf-tags-inline {
  margin-left: 0.25rem;
  display: inline-flex;
  gap: 0.15rem;
}

.metric-value.pct-pos {
  color: #22c55e;
}

.metric-value.pct-neg {
  color: #ef4444;
}

.watchlist-table .tf-change {
  font-weight: 600;
}

.watchlist-table .tf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.watchlist-table .sortable {
  cursor: pointer;
}

.watchlist-table .sort-icon {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.7;
}

.watchlist-table .sortable.active {
  color: #e2e8f0;
}

.watchlist-table .sortable.active .sort-icon {
  opacity: 1;
}

.watchlist-table .tf-header-main {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.watchlist-table .tf-header-sub {
  margin-top: 0.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.watchlist-table .tf-sort-btn {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 0.86rem;
  padding: 0;
  cursor: pointer;
}

.watchlist-table .tf-sort-btn:hover {
  color: #e5e7eb;
}

.watchlist-table .tf-sort-btn.active {
  color: #e5e7eb;
  font-weight: 600;
}

.watchlist-table .tf-sort-btn .tf-sort-icon {
  margin-left: 0.15rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

.alert-item {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: #0b1224;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.alert-meta {
  display: flex;
  flex-direction: column;
}

.alert-type {
  font-size: 0.85rem;
  opacity: 0.85;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #0b1224;
}

.badge.warn {
  background: #fbbf24;
}

.badge.stale {
  background: #f97316;
  color: #0b1224;
}

.badge.danger {
  background: #f87171;
}

.badge.info {
  background: #38bdf8;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  max-width: 720px;
  width: 94%;
  max-height: 80vh;
  overflow: hidden;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#indicatorSettingsModal .modal-content {
  overflow-y: auto;
}

.info-list {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.settings-option {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.settings-option:last-child {
  border-bottom: none;
}

.settings-option input {
  margin-top: 0.3rem;
}

.settings-option .option-meta strong {
  display: block;
  font-weight: 600;
  color: #e2e8f0;
}

.settings-option .option-meta span {
  display: block;
}

.settings-footer {
  justify-content: flex-end;
  margin-top: 1rem;
}

.settings-error {
  color: #f87171;
  font-size: 0.85rem;
  margin: 0.25rem 0 0.35rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.badge-fresh {
  color: #0b1224;
  background: #22c55e;
}

.fresh-ok {
  background: #22c55e !important;
  color: #06280f !important;
}

.fresh-warn {
  background: #f59e0b !important;
  color: #0f0f05 !important;
}

.fresh-stale {
  background: #ef4444 !important;
  color: #330707 !important;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.88rem;
}

input,
select,
button {
  background: #0b1224;
  border: 1px solid #1f2937;
  color: #e2e8f0;
  padding: 0.4rem 0.6rem;
  border-radius: 0.45rem;
  font-family: inherit;
}

button {
  cursor: pointer;
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.35);
}

.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.hidden {
  display: none !important;
}

html.preauth #authScreen {
  display: none !important;
}

body.booting #bootScreen {
  display: flex;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(10px);
}

.boot-card {
  width: min(520px, calc(100vw - 2rem));
  margin: 0;
}

.boot-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.boot-card p {
  margin: 0;
}

@keyframes watchlistFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
  25% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.22);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.watchlist-flash {
  animation: watchlistFlash 480ms ease-out;
}

@keyframes watchlistMetaFlash {
  0% {
    color: #94a3b8;
  }
  30% {
    color: #bfdbfe;
  }
  100% {
    color: #94a3b8;
  }
}

.watchlist-meta-flash {
  animation: watchlistMetaFlash 520ms ease-out;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-screen {
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.18), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(2, 132, 199, 0.24), transparent 32%),
    #0f172a;
}

.auth-card {
  max-width: 440px;
  width: 100%;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.tab {
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.32);
}

.tab-active {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.auth-error {
  color: #f87171;
  margin-top: 1rem;
  min-height: 1.25rem;
}

.pill-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}

.pill-tag.alert {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecdd3;
}

.pill-tag.warn {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fef08a;
}

.watchlist-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.35rem;
  width: 100%;
}

.watchlist-controls select {
  min-width: 120px;
}

.small {
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
}

.watchlist-pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  justify-content: flex-end;
  padding: 0 0.75rem;
}

.watchlist-pagination .page-size {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
  gap: 0.25rem;
  margin-right: 0.5rem;
  font-size: 0.85rem;
}

.watchlist-pagination .page-size select {
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
}

.watchlist-pagination .page-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.watchlist-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.watchlist-pagination.top {
  margin-top: 0.25rem;
}

.watchlist-pagination.bottom {
  margin: 0.5rem 0 0.25rem;
}

.watchlist-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  padding: 0;
  width: auto;
}

.tiny {
  font-size: 0.78rem;
}

.watchlist-controls label {
  align-items: flex-start;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  max-width: 720px;
  width: 94%;
  max-height: 80vh;
  overflow: hidden;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-content .alert-log-list {
  max-height: 60vh;
}

.heatmap {
  margin-top: 0.75rem;
}

.heatmap-header h3 {
  margin: 0;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem;
}

.heatmap-tile {
  border-radius: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(135deg, #0f172a, #0b1224);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

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

.heatmap-rsi {
  font-weight: 700;
}

@media (max-width: 620px) {
  .chart-toolbar {
    flex-direction: column;
  }
  .chart-meta {
    flex-direction: column;
    align-items: flex-start;
  }
  .app-shell-body {
    flex-direction: column;
  }
  .side-nav {
    position: relative;
    top: auto;
    width: 100%;
    flex-basis: auto;
    border-radius: 0.75rem;
  }
  .side-nav:not(.open) .nav-label {
    display: inline;
  }
  .side-nav:not(.open) .side-nav-item {
    justify-content: flex-start;
    padding: 0.55rem 0.65rem;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .layout-side {
    width: 100%;
  }
  .watchlist-controls {
    align-items: flex-start;
  }
  .watchlist-subbar {
    flex-direction: column;
    align-items: stretch;
  }
  .watchlist-subbar .watchlist-filters,
  .watchlist-subbar .watchlist-pagination {
    width: 100%;
  }
  .watchlist-pagination {
    width: 100%;
    justify-content: flex-end;
  }
}
.watchlist-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem 0.9rem;
  padding: 0.25rem 0;
  width: 100%;
  padding-left: 0.75rem;
}

.watchlist-filters {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: flex-end;
}

.watchlist-subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.55rem 0.9rem;
  padding: 0 0.75rem;
}

.watchlist-filters.watchlist-filters-left {
  margin-left: 0;
}

.watchlist-subbar .watchlist-pagination {
  padding: 0;
  margin-top: 0;
}

.watchlist-subbar .watchlist-pagination.top {
  margin-top: 0;
}

.watchlist-filters .filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  position: relative;
}

#watchlistMarketBtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 180px;
  padding-right: 2rem;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#watchlistMarketBtn::after {
  content: "▾";
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.85;
  font-size: 0.8rem;
  pointer-events: none;
  transition: transform 0.15s ease;
}

#watchlistMarketBtn[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
}

#watchlistMarketBtn:hover,
#watchlistMarketBtn:focus {
  background: rgba(148, 163, 184, 0.08);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 180px;
  max-width: min(320px, calc(100vw - 3rem));
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.6rem;
  padding: 0.35rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.6);
  z-index: 200;
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.45rem;
  border-radius: 0.45rem;
  cursor: pointer;
  user-select: none;
}

.dropdown-item:hover {
  background: rgba(59, 130, 246, 0.12);
}

.market-group-row td {
  padding: 0.55rem 0.5rem;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.08);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.symbol-name {
  margin-top: 0.15rem;
}

.sort-control {
  display: none;
}

.watchlist-toolbar label:last-child {
  margin-left: auto;
}

.sort-dir-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sort-dir-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.5);
  font-size: 0.8rem;
  transition: background 0.2s, border-color 0.2s;
}

.sort-dir-btn .icon {
  font-size: 0.75rem;
}

.sort-dir-btn.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.watchlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.watchlist-title-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.watchlist-title h2 {
  margin: 0;
}

.watchlist-title .muted {
  display: block;
}

.heatmap-header-inline {
  padding: 0 0.75rem;
  margin: 0.25rem 0 0.35rem;
}

.heatmap-header-inline h3 {
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.circle-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
}

.watchlist-buttons {
  display: inline-flex;
  gap: 0.35rem;
}

.icon-only {
  padding: 0.3rem 0.45rem;
  min-width: 34px;
  text-align: center;
  font-size: 0.95rem;
}

.watchlist-header .circle-btn {
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.quote-item .pill {
  padding: 0.2rem 0.45rem;
}
.quote-updated {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.quote-updated.warn {
  color: #f97316;
}
/* Stale data tooltip */
.badge.stale {
  position: relative;
  cursor: help;
}

.badge.stale::after {
  content: attr(data-tooltip);
  position: absolute;
  visibility: hidden;
  width: 250px;
  background-color: #1f2937;
  color: #e2e8f0;
  border: 1px solid #334155;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  z-index: 10;
  bottom: 125%;
  left: 50%;
  margin-left: -110px; /* Half of width */
  opacity: 0;
  transition: none; /* Show immediately */
  pointer-events: none;
  font-size: 0.85rem;
}

.badge.stale:hover::after {
  visibility: visible;
  opacity: 1;
}

/* Optional: arrow for the tooltip */
.badge.stale::before {
    content: '';
    position: absolute;
    visibility: hidden;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #1f2937;
    bottom: 110%;
    left: 50%;
    margin-left: -5px;
    z-index: 11;
    opacity: 0;
    transition: none;
}

.badge.stale:hover::before {
    visibility: visible;
    opacity: 1;
}
