html {
  overflow-x: clip;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --color-text: #0f172a;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-th: #f1f5f9;
  --color-input-bg: #ffffff;
  --color-btn-bg: #ffffff;
  --color-btn-hover: #e2e8f0;
  --color-chip-active-fg: #f8fafc;
  --color-chip-active-bg: #1e293b;
  --color-link: #2563eb;
  --spark-ref: #ea580c;
  --diff-bg: #e0f2fe;
  --diff-border: #7dd3fc;
  --stale-fg: #78350f;
  --stale-bg: #fef3c7;
  --stale-border: #fcd34d;
  --error-fg: #b91c1c;
  --error-bg: #fef2f2;
  --detail-bg: #f8fafc;
  --pre-bg: #ffffff;
  --shadow: rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  --color-text: #e2e8f0;
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-muted: #94a3b8;
  --color-border: #334155;
  --color-th: #334155;
  --color-input-bg: #0f172a;
  --color-btn-bg: #1e293b;
  --color-btn-hover: #334155;
  --color-chip-active-fg: #0f172a;
  --color-chip-active-bg: #e2e8f0;
  --color-link: #38bdf8;
  --spark-ref: #fb923c;
  --diff-bg: #0c4a6e;
  --diff-border: #0369a1;
  --stale-fg: #fde68a;
  --stale-bg: #422006;
  --stale-border: #b45309;
  --error-fg: #fecaca;
  --error-bg: #450a0a;
  --detail-bg: #0f172a;
  --pre-bg: #020617;
  --shadow: rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
}

body.dashboard-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  margin-inline: 0;
  padding: clamp(0.5rem, 1.25vw, 1.25rem);
}

.dashboard-body > .dashboard-shell {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  /* Center the dashboard column; inner panels handle scrolling. */
  width: max-content;
  max-width: calc(100vw - 2.75rem);
  min-width: 0;
  margin-inline: auto;
  box-sizing: border-box;
  /* Avoid clipping KPI cards / bell badge at narrow widths. */
  overflow: visible;
}

.dashboard-shell > .site-header-bar,
.dashboard-shell > .app-tab-bar {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-body > dialog {
  flex-shrink: 0;
  /* Default flex cross-axis stretch would force dialogs to full dashboard width when closed in tree; avoid. */
  align-self: flex-start;
}

.dashboard-shell > .site-footer {
  flex-shrink: 0;
  margin-top: 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-main-stack {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainDataPanel:not([hidden]),
#opsPanel:not([hidden]),
#settingsPanel:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mainDataPanel:not([hidden]) {
  position: relative;
}

#opsPanel:not([hidden]) {
  overflow: hidden;
  min-width: 0;
}

#settingsPanel:not([hidden]) {
  overflow-y: auto;
}

#mainDataPanel:not([hidden]) .error,
#mainDataPanel:not([hidden]) .meta {
  flex-shrink: 0;
}

#mainDataPanel:not([hidden]) .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: auto;
  margin: 0;
  padding: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 1px 2px var(--shadow);
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

.site-header-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  min-width: 0;
}

.site-header-bar h1 {
  flex: 0 1 auto;
  min-width: 0;
}

.site-header-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: 0 0 auto;
  min-width: 0;
  margin-left: auto;
  /* Room for notification badge (positioned past the button edge) */
  padding-inline-end: 0.35rem;
}

.theme-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--color-border);
  background: var(--color-btn-bg);
  color: var(--color-text);
}

.theme-toggle-btn:hover {
  background: var(--color-btn-hover);
}

.theme-toggle-btn.theme-toggle-btn--system {
  border-color: color-mix(in srgb, var(--color-link) 42%, var(--color-border));
  background: color-mix(in srgb, var(--color-link) 12%, var(--color-btn-bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-link) 22%, transparent);
}

.theme-toggle-btn.theme-toggle-btn--light {
  border-color: color-mix(in srgb, #ca8a04 55%, var(--color-border));
  background: color-mix(in srgb, #ca8a04 14%, var(--color-btn-bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #ca8a04 28%, transparent);
}

.theme-toggle-btn.theme-toggle-btn--dark {
  border-color: color-mix(in srgb, #6366f1 50%, var(--color-border));
  background: color-mix(in srgb, #6366f1 16%, var(--color-btn-bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #6366f1 26%, transparent);
}

html[data-theme="dark"] .theme-toggle-btn.theme-toggle-btn--system {
  background: color-mix(in srgb, var(--color-link) 18%, var(--color-btn-bg));
}

html[data-theme="dark"] .theme-toggle-btn.theme-toggle-btn--light {
  background: color-mix(in srgb, #eab308 14%, var(--color-btn-bg));
  border-color: color-mix(in srgb, #eab308 45%, var(--color-border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #eab308 22%, transparent);
}

html[data-theme="dark"] .theme-toggle-btn.theme-toggle-btn--dark {
  background: color-mix(in srgb, #818cf8 18%, var(--color-btn-bg));
  border-color: color-mix(in srgb, #818cf8 48%, var(--color-border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #818cf8 24%, transparent);
}

.theme-toggle-svg {
  flex-shrink: 0;
}

.app-tab-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.35rem;
  min-width: 0;
}

.app-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  border-bottom: none;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.topbar-search {
  position: relative;
  display: block;
  margin: 0;
}

.topbar-search--toolbar {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
}

.site-header-actions .topbar-search-input {
  min-width: 0;
  max-width: 100%;
}

.topbar-search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--color-muted);
}

.topbar-search-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 10.5rem;
  max-width: 100%;
  margin: 0;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.38rem 0.55rem 0.38rem 2.15rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
}

.topbar-search-input:focus {
  outline: 2px solid color-mix(in srgb, var(--color-link) 45%, transparent);
  outline-offset: 1px;
}

.topbar-search-input::-webkit-search-cancel-button {
  margin-left: 0.25rem;
}

.coin-alerts-dropdown-root {
  position: relative;
  flex-shrink: 0;
}

.coin-alerts-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: min(22rem, calc(100vw - 2rem));
  max-width: 28rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 8px 24px var(--shadow);
}

.coin-alerts-feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--color-border);
}

.coin-alerts-feed-toolbar-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.coin-alerts-dismiss-all {
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
}

.coin-alerts-feed-empty {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.coin-alerts-feed-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
}

.coin-alerts-feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.35rem 0.15rem;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  font-size: 0.84rem;
  line-height: 1.35;
}

.coin-alerts-feed-item:last-child {
  border-bottom: none;
}

.coin-alerts-feed-time {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  white-space: nowrap;
  padding-top: 0.05rem;
}

.coin-alerts-feed-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

button.coin-alerts-feed-dismiss {
  flex-shrink: 0;
  min-width: 1.65rem;
  min-height: 1.65rem;
  margin: -0.1rem 0 0;
  padding: 0;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid transparent;
}

button.coin-alerts-feed-dismiss:hover {
  color: var(--color-text);
  border-color: var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 85%, var(--color-border));
}

.th-split--exch {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.th-split--uniformity,
.th-split--health,
.th-split--volaccel,
.th-split--vol24h {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.24rem;
}

.exch-col-heading {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--color-text);
}

.exchange-filter-wrap--th .exchange-filter-summary {
  min-width: 5.5rem;
  font-size: 0.72rem;
}

.settings-panel {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-section-hint--compact {
  max-width: 100%;
  line-height: 1.5;
}

.dashboard-shell .ops-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.settings-panel-title {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.settings-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.settings-section:last-of-type {
  border-bottom: none;
}

.settings-section-title {
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.settings-section-hint {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0 0 0.65rem;
  line-height: 1.45;
}

.settings-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.settings-label {
  font-size: 0.9rem;
  color: var(--color-text);
}

.settings-select {
  min-width: 6rem;
}

.settings-actions {
  margin: 0.35rem 0 0;
}

.settings-export-toolbar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.notify-tier-a-btn--on {
  background: color-mix(in srgb, #16a34a 22%, var(--color-surface));
  border-color: #16a34a;
  color: #14532d;
  font-weight: 600;
}

html[data-theme="dark"] .notify-tier-a-btn--on {
  background: color-mix(in srgb, #22c55e 18%, var(--color-surface));
  border-color: #4ade80;
  color: #bbf7d0;
}

.app-tab {
  flex-shrink: 0;
  font: inherit;
  padding: 0.35rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}

.app-tab:hover {
  color: var(--color-text);
}

.app-tab.is-active {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
  border-bottom-color: var(--color-bg);
  margin-bottom: -1px;
  font-weight: 600;
}

html[data-theme="dark"] .app-tab.is-active {
  border-bottom-color: var(--color-bg);
}

.tab-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-text);
}

/* Author `display` on `.tab-badge` overrides the UA `[hidden]` rule; force badges off when hidden. */
.tab-badge[hidden] {
  display: none !important;
}

.toolbar-advanced {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  background: var(--color-surface);
}

.toolbar-advanced-summary {
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--color-muted);
  list-style: none;
}

.toolbar-advanced-summary::-webkit-details-marker {
  display: none;
}

.toolbar-advanced-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.toolbar-advanced-body input[type="url"] {
  min-width: 12rem;
}

.export-toolbar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-select {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  max-width: 100%;
}

.th-split {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.th-filter-select {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  max-width: 4.6rem;
}

.th-split--volaccel .th-filter-select {
  max-width: 5.75rem;
}

.th-split--g7chart .th-filter-select--chartdist,
.th-split--g30chart .th-filter-select--chartdist {
  max-width: 5.85rem;
}

tr.coin-row--watchlist-only td {
  background: color-mix(in srgb, var(--color-surface) 85%, var(--color-muted) 15%);
}

html[data-theme="dark"] tr.coin-row--watchlist-only td {
  background: color-mix(in srgb, var(--color-surface) 90%, var(--color-muted) 10%);
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar label.poll-toolbar select {
  margin-left: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
}

.exchange-filter-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.exchange-filter-label {
  font-size: 0.9rem;
  color: var(--color-text);
}

.exchange-filter-details {
  position: relative;
  display: inline-block;
}

.exchange-filter-summary {
  list-style: none;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  font-size: 0.9rem;
  min-width: 8.5rem;
}

.exchange-filter-summary::-webkit-details-marker {
  display: none;
}

.exchange-filter-summary::after {
  content: " ▾";
  font-size: 0.75rem;
  color: var(--color-muted);
}

.exchange-filter-details[open] .exchange-filter-summary::after {
  content: " ▴";
}

.exchange-filter-panel {
  position: absolute;
  z-index: 20;
  left: 0;
  top: calc(100% + 4px);
  min-width: 11rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 6px 16px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.exchange-cb-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--color-text);
}

.exchange-cb-row input {
  accent-color: var(--color-link);
}

.exchange-filter-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--color-border);
}

.api-budget-panel {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--color-text);
  background: var(--diff-bg);
  border: 1px solid var(--diff-border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.75rem;
  max-width: 100%;
}

.api-budget-panel--settings {
  max-width: 100%;
}

.api-budget-heading {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.api-budget-note {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.api-budget-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.api-budget-item {
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--color-border);
}

.api-budget-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.api-budget-rowhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.35rem;
}

.api-budget-meta {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-weight: 500;
}

.api-budget-bar-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--color-muted) 35%, transparent);
  overflow: hidden;
  margin: 0.25rem 0 0.35rem;
}

.api-budget-bar-track--thin {
  height: 6px;
  margin: 0.15rem 0 0;
  flex: 1;
  min-width: 4rem;
}

.api-budget-bar-fill {
  height: 100%;
  border-radius: 5px;
  min-width: 0;
  transition: width 0.25s ease;
}

.api-budget-bar-fill.budget-meter--ok {
  background-color: #15803d;
}

.api-budget-bar-fill.budget-meter--warn {
  background-color: #ca8a04;
}

.api-budget-bar-fill.budget-meter--danger {
  background-color: #b91c1c;
}

.api-budget-bar-fill.budget-meter--neutral {
  background-color: color-mix(in srgb, var(--color-muted) 55%, var(--color-border));
}

.api-budget-bar-fill--share {
  background-color: color-mix(in srgb, var(--color-accent, #ea580c) 75%, var(--color-muted));
  opacity: 0.9;
}

.api-budget-bar-track--cg {
  position: relative;
  height: 1.125rem;
  overflow: hidden;
}

.api-budget-bar-track--cg .api-budget-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  height: 100%;
  border-radius: 5px;
}

.api-budget-cg-onbar {
  position: absolute;
  left: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  text-shadow:
    0 0 4px var(--color-bg),
    0 0 8px var(--color-bg),
    0 1px 2px color-mix(in srgb, var(--color-bg) 85%, transparent);
  pointer-events: none;
  white-space: nowrap;
}

.api-budget-breakdown {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.api-budget-br-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(4rem, 40%);
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-size: 0.78rem;
}

.api-budget-br-label {
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-budget-br-count {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.api-budget-risk {
  margin: 0.15rem 0 0.25rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.api-budget-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

.api-budget-link {
  font-size: 0.8rem;
}

.budget-meter--ok {
  color: #15803d;
  font-weight: 600;
}

.budget-meter--warn {
  color: #a16207;
  font-weight: 600;
}

.budget-meter--danger {
  color: #b91c1c;
  font-weight: 600;
}

.budget-meter--neutral {
  color: var(--color-muted);
  font-weight: 500;
}

html[data-theme="dark"] .budget-meter--ok {
  color: #4ade80;
}

html[data-theme="dark"] .budget-meter--warn {
  color: #facc15;
}

html[data-theme="dark"] .budget-meter--danger {
  color: #f87171;
}

input[type="url"],
input[type="search"] {
  color: var(--color-text);
  background: var(--color-input-bg);
  border-color: var(--color-border);
}

input[type="url"] {
  flex: 1 1 220px;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

button {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-btn-bg);
  color: var(--color-text);
  cursor: pointer;
}

button:hover {
  background: var(--color-btn-hover);
}

button:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

button.secondary {
  border-color: var(--color-muted);
  background: var(--color-surface);
}

.filters {
  align-items: center;
}

.filters input[type="search"] {
  min-width: 10rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.sort-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-text);
  text-decoration: underline dotted;
}

.sort-btn:hover {
  color: var(--color-link);
}

.sort-btn:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
  border-radius: 2px;
}

th.sort-asc .sort-btn::after {
  content: " ▲";
  text-decoration: none;
}

th.sort-desc .sort-btn::after {
  content: " ▼";
  text-decoration: none;
}

.meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.kpi-strip {
  display: grid;
  /* minmax(10rem,1fr) forces ~40rem minimum row width and gets clipped when shell is overflow:hidden */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.kpi-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-surface) 82%, #0ea5e9 18%);
  padding: 0.5rem 0.65rem 0.55rem;
  min-width: 0;
}

html[data-theme="dark"] .kpi-card {
  background: color-mix(in srgb, var(--color-surface) 85%, #1d4ed8 15%);
}

.kpi-label {
  margin: 0;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  font-weight: 600;
}

.kpi-value {
  margin: 0.2rem 0 0;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.snapshot-loading-overlay[hidden] {
  display: none !important;
}

.snapshot-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  background: color-mix(in srgb, var(--color-bg) 84%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.snapshot-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
}

.snapshot-loading-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  border-top-color: var(--color-link);
  animation: spin 0.8s linear infinite;
}

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

/* Do not set display:flex without [hidden] guard — it overrides the UA display:none from the hidden attribute. */
.snapshot-telemetry-panel[hidden] {
  display: none !important;
}

.snapshot-telemetry-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.snapshot-telemetry-panel .health-strip,
.snapshot-telemetry-panel .relay-health-strip,
.snapshot-telemetry-panel .regime-strip,
.snapshot-telemetry-panel .diff-banner {
  margin-bottom: 0;
}

.telemetry-dismiss-row {
  display: flex;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

.diff-banner {
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--diff-bg);
  border: 1px solid var(--diff-border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
}

.watch-banner[hidden] {
  display: none !important;
}

.watch-banner:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--stale-fg);
  background: var(--stale-bg);
  border: 1px solid var(--stale-border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  max-width: 52rem;
}

.sym-cell-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  vertical-align: middle;
}

.pin-btn {
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0.1rem 0.2rem;
  margin: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--color-muted);
  border-radius: 4px;
}

.pin-btn:hover {
  color: var(--color-link);
  background: var(--color-btn-hover);
}

.pin-btn:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
}

.pin-btn[aria-pressed="true"] {
  color: #ca8a04;
}

html[data-theme="dark"] .pin-btn[aria-pressed="true"] {
  color: #facc15;
}

tr.coin-row--pinned td.sym-cell {
  box-shadow: inset 3px 0 0 0 #ca8a04;
}

html[data-theme="dark"] tr.coin-row--pinned td.sym-cell {
  box-shadow: inset 3px 0 0 0 #eab308;
}

@keyframes pin-enter-flash {
  0% {
    background-color: rgba(34, 197, 94, 0.38);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes pin-enter-flash-dark {
  0% {
    background-color: rgba(34, 197, 94, 0.22);
  }
  100% {
    background-color: transparent;
  }
}

tr.coin-row--pin-enter td {
  animation: pin-enter-flash 2.4s ease-out 1;
}

html[data-theme="dark"] tr.coin-row--pin-enter td {
  animation: pin-enter-flash-dark 2.4s ease-out 1;
}

.stale-banner {
  font-size: 0.85rem;
  color: var(--stale-fg);
  background: var(--stale-bg);
  border: 1px solid var(--stale-border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
}

.snapshot-validation-banner {
  font-size: 0.82rem;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
  border: 1px solid var(--diff-border);
  background: var(--diff-bg);
  color: var(--color-text);
}

.snapshot-validation-banner--warn {
  border-color: #ca8a04;
  background: rgba(202, 138, 4, 0.12);
}

.snapshot-validation-banner--error {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

.compare-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle, #334155);
  background: var(--panel-bg, rgba(15, 23, 42, 0.35));
  font-size: 0.85rem;
}

.compare-bar-label {
  flex: 1 1 12rem;
  min-width: 0;
}

.th-compare {
  width: 2.5rem;
  text-align: center;
}

.th-compare-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.compare-td {
  text-align: center;
  vertical-align: middle;
}

.compare-cb {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.compare-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.compare-dialog-box {
  max-width: min(96vw, 920px);
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #334155);
  background: var(--color-surface, #0f172a);
  color: var(--color-text);
}

.compare-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle, #334155);
}

.compare-dialog-title {
  margin: 0;
  font-size: 1.05rem;
}

.compare-dialog-close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.compare-dialog-body {
  padding: 0.75rem;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .compare-dialog-body {
    grid-template-columns: 1fr;
  }
}

.compare-col {
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 8px;
  padding: 0.65rem;
  min-width: 0;
}

.compare-col h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.compare-col dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.82rem;
}

.compare-col dt {
  margin: 0;
  color: var(--color-muted, #94a3b8);
}

.compare-col dd {
  margin: 0;
}

.compare-spark-wrap {
  margin-top: 0.65rem;
}

.health-strip {
  font-size: 0.8rem;
  color: var(--color-text);
  background: var(--diff-bg);
  border: 1px solid var(--diff-border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  margin-bottom: 0.75rem;
  white-space: pre-line;
  line-height: 1.45;
  max-width: 56rem;
}

.relay-health-strip.is-warn {
  color: var(--stale-fg);
  background: var(--stale-bg);
  border-color: var(--stale-border);
}

.regime-strip {
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--diff-bg);
  border: 1px solid var(--diff-border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  max-width: 52rem;
  line-height: 1.4;
}

.regime-strip.is-warn {
  color: var(--stale-fg);
  background: var(--stale-bg);
  border-color: var(--stale-border);
}

.empty-banner {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-text);
  background: var(--diff-bg);
  border: 1px solid var(--diff-border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  max-width: 52rem;
}

tr.coin-row {
  cursor: pointer;
}

tr.coin-row:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
}

tr.coin-detail td {
  background: var(--detail-bg);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.detail-cell {
  padding: 0.75rem 0.65rem !important;
}

.detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
}

.detail-heading {
  font-weight: 600;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.detail-pre {
  overflow: auto;
  max-height: 14rem;
  font-size: 0.72rem;
  line-height: 1.35;
  margin: 0.25rem 0 0;
  padding: 0.5rem;
  background: var(--pre-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
}

.detail-muted {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin: 0.35rem 0 0;
}

.detail-muted code {
  font-size: 0.75rem;
}

.chart-thumb {
  display: block;
  max-width: min(100%, 360px);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  vertical-align: middle;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-new {
  background: #22c55e;
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow);
}

table.qualified-grid {
  width: auto;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--color-border);
  /* `overflow: hidden` on <table> breaks `position: sticky` on header cells; scroll + clip live on `.table-scroll`. */
  overflow: visible;
  border-radius: 0;
  box-shadow: none;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

table.qualified-grid th,
table.qualified-grid td {
  border: 1px solid var(--color-border);
  vertical-align: middle;
}

table.qualified-grid tbody td {
  position: relative;
  z-index: 0;
  white-space: nowrap;
}

.name-col {
  box-sizing: border-box;
  min-width: min(11rem, 34vw);
  max-width: min(22rem, 88vw);
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

table.qualified-grid thead th#col-name {
  box-sizing: border-box;
  min-width: min(11rem, 34vw);
  max-width: min(22rem, 88vw);
}

.name-col-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
  max-width: 100%;
}

.coin-name-line {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.coin-name-line .coin-listing-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.coin-token {
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.coin-logo {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  flex: 0 0 auto;
}

.coin-logo--fallback {
  background: color-mix(in srgb, var(--color-border) 78%, transparent);
}

.venue-cell {
  font-weight: 600;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.exchange-logo {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  background: var(--color-surface);
  flex: 0 0 auto;
}

.exchange-chip {
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-border) 72%, transparent);
}

.exchange-chip--coinbase {
  background: color-mix(in srgb, #0052ff 18%, var(--color-surface));
}

.exchange-chip--kraken {
  background: color-mix(in srgb, #5741d9 18%, var(--color-surface));
}

.exchange-chip--mexc {
  background: color-mix(in srgb, #00c389 18%, var(--color-surface));
}

.spark-cell {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: nowrap;
  box-sizing: border-box;
}

.spark-fs-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: nowrap;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: zoom-in;
  border-radius: 6px;
  max-width: 100%;
  box-sizing: border-box;
}

.spark-fs-btn:hover {
  background: color-mix(in srgb, var(--color-th) 55%, transparent);
}

.spark-fs-btn:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

.spark-cell-chart {
  flex: 0 0 auto;
  width: 168px;
  min-width: 168px;
  max-width: 168px;
  overflow: hidden;
  pointer-events: none;
}

.spark-from-high {
  pointer-events: none;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--color-muted);
  white-space: nowrap;
  min-width: 2.75rem;
  text-align: right;
}

.spark-td {
  min-width: 11.75rem;
  max-width: 15rem;
  overflow: hidden;
  box-sizing: border-box;
  vertical-align: middle;
}

table.qualified-grid thead th {
  position: sticky !important;
  top: 0;
  z-index: 25;
  isolation: isolate;
  background: var(--color-th);
  background-clip: padding-box;
  box-shadow: 0 1px 0 var(--color-border);
}

table.qualified-grid thead {
  position: static;
}

table.qualified-grid tbody tr:nth-child(even) td:not(.btbest-cell) {
  background: color-mix(in srgb, var(--color-surface) 92%, var(--color-th) 8%);
}

html[data-theme="dark"] table.qualified-grid tbody tr:nth-child(even) td:not(.btbest-cell) {
  background: color-mix(in srgb, var(--color-surface) 88%, var(--color-th) 12%);
}

.th-sub {
  font-weight: 500;
  opacity: 0.75;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72em;
}

caption {
  caption-side: top;
  text-align: left;
}

th,
td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-th);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text);
}

table:not(.qualified-grid) tbody tr:last-child td {
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gain-pos {
  color: #16a34a;
  font-weight: 700;
}

html[data-theme="dark"] .gain-pos {
  color: #4ade80;
}

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}

.health-ring {
  --pct: 0;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: conic-gradient(#22c55e calc(var(--pct) * 1%), color-mix(in srgb, var(--color-border) 80%, transparent) 0);
  box-shadow: inset 0 0 0 2px var(--color-surface);
  flex: 0 0 auto;
}

.health-ring--uniformity {
  background: conic-gradient(#0ea5e9 calc(var(--pct) * 1%), color-mix(in srgb, var(--color-border) 80%, transparent) 0);
}

table.qualified-grid td.btbest-cell {
  --pct: 0;
  border-radius: 4px;
  background: color-mix(
    in srgb,
    hsl(calc(var(--pct) * 1.2), 66%, 45%) 72%,
    var(--color-surface) 28%
  );
}

table.qualified-grid td.btbest-cell.btbest-cell--na {
  background: color-mix(in srgb, var(--color-surface) 84%, var(--color-th) 16%);
}

.btbest-text--light {
  color: #f8fafc;
  font-weight: 700;
}

.btbest-text--dark {
  color: #0f172a;
  font-weight: 700;
}

.error {
  color: var(--error-fg);
  background: var(--error-bg);
  padding: 0.75rem;
  border-radius: 6px;
}

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

a {
  color: var(--color-link);
}

.cell-muted {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.exch-col {
  vertical-align: middle;
  max-width: 10rem;
}

.exch-sheet {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.72rem;
  background: var(--color-input-bg);
}

.exch-sheet th,
.exch-sheet td {
  border: 1px solid var(--color-border);
  padding: 0.2rem 0.35rem;
  text-align: left;
}

.exch-sheet th {
  background: var(--color-th);
  font-weight: 600;
  font-size: 0.68rem;
}

.exch-sheet .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.coin-listing-link {
  color: var(--color-link);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.coin-listing-link:hover {
  opacity: 0.88;
}

.th-split--vol24h {
  min-width: 7.5rem;
}

.spark-svg {
  display: block;
  color: var(--color-link);
  width: 168px;
  height: 44px;
  max-width: min(168px, 100%);
  box-sizing: border-box;
}

.spark-svg .spark-line-main {
  stroke: currentColor;
}

.spark-svg .spark-ref-line {
  stroke: var(--spark-ref);
  stroke-width: 1.35;
  stroke-opacity: 0.95;
  vector-effect: non-scaling-stroke;
}

.spark-svg .spark-hilo-line {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1;
  stroke-opacity: 0.9;
  vector-effect: non-scaling-stroke;
}

html[data-theme="light"] .spark-svg .spark-hilo-line {
  stroke: rgba(15, 23, 42, 0.45);
}

.bt-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 5rem;
}

.bt-chart-link {
  font-size: 0.8rem;
  white-space: nowrap;
}

.bt-sheet-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
}

.sheet-heading {
  font-size: 0.95rem;
  margin: 1rem 0 0.35rem;
  font-weight: 600;
}

.sheet-heading:first-child {
  margin-top: 0;
}

.sheet-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.78rem;
  background: var(--color-input-bg);
}

.sheet-table th,
.sheet-table td {
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.45rem;
  text-align: left;
}

.sheet-table th {
  background: var(--color-th);
  font-weight: 600;
  white-space: nowrap;
}

.sheet-table td {
  font-variant-numeric: tabular-nums;
}

.sheet-table--strategy tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--color-th) 72%, var(--color-surface) 28%);
}

html[data-theme="dark"] .sheet-table--strategy tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--color-th) 52%, var(--color-surface) 48%);
}

.sheet-table--strategy .sheet-bh-name {
  color: #7c3aed;
  font-weight: 600;
}

html[data-theme="dark"] .sheet-table--strategy .sheet-bh-name {
  color: #c4b5fd;
}

.bt-modal-thumb {
  margin: 0.5rem 0 0;
}

.chart-thumb-modal {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  display: block;
}

.bt-modal-chart {
  margin: 0;
  font-size: 0.9rem;
}

/* Backtest results: `inline-flex` shrink-wraps to the strategy table; plain `max-content` on <dialog> often stays full-viewport. */
.bt-modal {
  box-sizing: border-box;
  --bt-modal-gutter: clamp(1rem, 3vw, 2rem);
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(calc(100vw - 2 * var(--bt-modal-gutter)), 100%);
  margin: auto;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 12px 40px var(--shadow);
}

/* Closed <dialog> must stay hidden (UA `display: none`); `.bt-modal { display: … }` overrides it — force off when not [open]. */
.bt-modal:not([open]) {
  display: none !important;
}

.bt-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.bt-modal-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-height: min(90vh, 56rem);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bt-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.bt-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.bt-modal-close {
  border: none;
  background: var(--color-btn-bg);
  color: var(--color-text);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.bt-modal-close:hover {
  background: var(--color-btn-hover);
}

.bt-modal-body {
  padding: 0.75rem 1rem 1rem;
  overflow: auto;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.bt-modal .sheet-table {
  width: max-content;
  max-width: 100%;
}

/* First-visit notification permission prompt */
.notify-prompt-dialog {
  box-sizing: border-box;
  --notify-prompt-gutter: clamp(1rem, 4vw, 1.75rem);
  width: min(22rem, calc(100vw - 2 * var(--notify-prompt-gutter)));
  max-width: calc(100vw - 2 * var(--notify-prompt-gutter));
  margin: auto;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 12px 40px var(--shadow);
}

.notify-prompt-dialog:not([open]) {
  display: none !important;
}

.notify-prompt-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.notify-prompt-box {
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.notify-prompt-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.notify-prompt-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-muted);
}

.notify-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.notify-prompt-enable {
  border-color: color-mix(in srgb, var(--color-link) 55%, var(--color-border));
  background: var(--color-link);
  color: #fff;
}

.notify-prompt-enable:hover {
  background: color-mix(in srgb, var(--color-link) 88%, #000);
}

html[data-theme="dark"] .notify-prompt-enable:hover {
  background: color-mix(in srgb, var(--color-link) 82%, #fff);
}

/* Full-viewport hourly chart (distinct SVG vs table sparkline). */
.chart-fs-dialog {
  box-sizing: border-box;
  --chart-fs-gutter: clamp(0.5rem, 2vw, 1.25rem);
  width: calc(100vw - 2 * var(--chart-fs-gutter));
  max-width: calc(100vw - 2 * var(--chart-fs-gutter));
  height: calc(100dvh - 2 * var(--chart-fs-gutter));
  max-height: calc(100dvh - 2 * var(--chart-fs-gutter));
  margin: auto;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 12px 40px var(--shadow);
}

.chart-fs-dialog:not([open]) {
  display: none !important;
}

.chart-fs-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.chart-fs-box {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.chart-fs-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 auto;
}

.chart-fs-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chart-fs-close {
  border: none;
  background: var(--color-btn-bg);
  color: var(--color-text);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.chart-fs-close:hover {
  background: var(--color-btn-hover);
}

.chart-fs-stats {
  flex: 0 0 auto;
  padding: 0.5rem 0.85rem 0;
}

.chart-fs-dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.85rem;
}

.chart-fs-dl > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.chart-fs-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--color-muted);
}

.chart-fs-dl dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.chart-fs-svg-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.5rem 0.85rem 0.85rem;
  overflow: auto;
}

.chart-fs-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 12rem;
}

.chart-fs-svg--7d .chart-fs-line {
  stroke: #0ea5e9;
}

.chart-fs-svg--30d .chart-fs-line {
  stroke: #8b5cf6;
}

.chart-fs-grid {
  stroke: var(--color-border);
  stroke-width: 1;
  stroke-dasharray: 4 6;
  opacity: 0.85;
}

.chart-fs-area {
  stroke: none;
}

.chart-fs-ref-last {
  stroke: var(--spark-ref);
  stroke-width: 1.25;
  stroke-dasharray: 6 5;
  opacity: 0.9;
}

.chart-fs-ylab {
  fill: var(--color-muted);
  font-size: 11px;
  font-family: system-ui, sans-serif;
}

.chart-fs-caption {
  fill: var(--color-muted);
  font-size: 11px;
  font-family: system-ui, sans-serif;
}

.chart-fs-caption--top {
  font-size: 12px;
  font-weight: 500;
  fill: var(--color-text);
  opacity: 0.9;
}

.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-muted);
}

.site-footer-lead {
  margin: 0 0 0.35rem;
}

.donate-row {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  line-height: 1.5;
}

.donate-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

.donate-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  line-height: 0;
  vertical-align: middle;
}

.donate-copy:hover,
.donate-copy:focus-visible {
  color: var(--color-link);
  background: var(--color-th);
  outline: none;
}

.donate-copy.is-copied {
  color: var(--color-link);
}

.donate-sep {
  color: var(--color-muted);
  user-select: none;
}

.donate-addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--color-muted);
  background: var(--color-th);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.site-footer a {
  color: var(--color-link);
  font-weight: 500;
}

.site-footer a:hover {
  text-decoration: underline;
}

.coin-alerts-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.45rem;
}

.coin-bell-svg {
  flex-shrink: 0;
}

.coin-alerts-badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1rem;
  padding: 0.05rem 0.28rem;
  font-size: 0.65rem;
  line-height: 1.2;
}

.diff-banner--coin,
.watch-banner--coin {
  margin-bottom: 0;
}

.tab-badge--alert {
  background: #c2410c;
  color: #fff;
}

html[data-theme="dark"] .tab-badge--alert {
  background: #ea580c;
  color: #fff;
}

.ops-panel-intro {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.ops-panel-lead-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.ops-panel-lead-line {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--color-muted);
  margin: 0;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ops-panel-lead-line:last-child {
  font-size: 0.82rem;
  opacity: 0.96;
}

.ops-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.ops-panel-actions .secondary {
  flex: 0 1 auto;
  min-width: 0;
}

#opsPanel #snapshotTelemetryPanel,
#opsPanel #staleBanner,
#opsPanel #emptyBanner {
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

#opsPanel .health-strip,
#opsPanel .relay-health-strip,
#opsPanel .regime-strip,
#opsPanel .stale-banner,
#opsPanel .empty-banner {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ops-feed-section {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.ops-feed-heading {
  font-size: 1rem;
  margin: 0 0 0.35rem;
  flex-shrink: 0;
}

.ops-feed-empty {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0 0 0.5rem;
  flex-shrink: 0;
}

.ops-feed-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ops-feed-item {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  line-height: 1.45;
}

.ops-feed-time {
  display: block;
  color: var(--color-muted);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.ops-feed-body {
  color: var(--color-text);
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 1200px) {
  .kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  table.qualified-grid thead th#col-name,
  table.qualified-grid td.name-col {
    min-width: 0;
    max-width: min(16rem, 72vw);
  }
}

@media (max-width: 420px) {
  .site-header-bar {
    flex-wrap: wrap;
  }
  .site-header-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}
