:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1b2330;
  --border: #2b3544;
  --text: #edf2f7;
  --muted: #97a6ba;
  --green: #34d399;
  --blue: #60a5fa;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #f87171;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.topbar {
  align-items: center;
  background: rgba(13, 17, 23, 0.92);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: 16px;
}

.topnav a,
.back-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.page {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px;
}

.dashboard-head,
.detail-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  font-size: 42px;
  line-height: 1.05;
  margin-bottom: 0;
}

.duration,
.stats-grid > div,
.filter-panel,
.candidate-card,
.detail-panel,
.empty-state,
.message {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.duration {
  min-width: 150px;
  padding: 14px 16px;
  text-align: right;
}

.duration span,
.stats-grid span,
dt {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.duration strong,
.stats-grid strong {
  font-size: 24px;
}

.filter-panel {
  margin-bottom: 18px;
  padding: 18px;
}

.filter-form {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

label span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

input,
select {
  background: #0f141c;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  min-height: 42px;
  padding: 0 10px;
  width: 100%;
}

.scan-button,
.detail-link {
  align-items: center;
  background: var(--green);
  border: 0;
  border-radius: 6px;
  color: #06120d;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, 1fr);
  margin: 18px 0;
}

.stats-grid > div {
  padding: 14px;
}

.message-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.message {
  padding: 12px 14px;
}

.warnings {
  background: var(--panel);
  border: 1px solid rgba(251, 146, 60, 0.45);
  border-radius: 8px;
  margin: 16px 0;
  padding: 12px 14px;
}

.warnings summary {
  color: var(--orange);
  cursor: pointer;
  font-weight: 800;
}

.message.error {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--red);
}

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

.candidate-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.candidate-header,
.pill-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.candidate-header h2 {
  font-size: 28px;
  margin-bottom: 3px;
}

.candidate-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.score-block {
  text-align: right;
}

.score-block strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 26px;
  padding: 5px 10px;
}

.action-ENTER_NOW,
.rating-STRONG,
.liquidity-EXCELLENT,
.put-quality-EXCELLENT {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--green);
}

.action-WAIT_FOR_PULLBACK,
.rating-WATCH {
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(251, 146, 60, 0.45);
  color: var(--orange);
}

.action-SKIP,
.rating-AVOID,
.liquidity-POOR {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--red);
}

.rating-GOOD,
.liquidity-GOOD,
.put-quality-GOOD {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--blue);
}

.liquidity-FAIR,
.put-quality-FAIR {
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--yellow);
}

.put-quality-WEAK {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--red);
}

.pricing-note {
  color: var(--yellow);
  font-size: 12px;
  margin: 10px 0 0;
}

.secondary-button {
  background: var(--blue);
  color: #07111f;
}

.save-banner,
.history-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 16px 0;
}

.save-banner {
  color: var(--green);
  font-weight: 700;
  padding: 14px 16px;
}

.save-banner a {
  color: var(--text);
  margin-left: 8px;
}

.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  border-collapse: collapse;
  min-width: 1120px;
  width: 100%;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.history-table a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.compact-history-table {
  min-width: 720px;
}

.card-action-status {
  border-radius: 6px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
  padding: 10px 12px;
  text-align: center;
}

.card-decision,
.card-put {
  display: grid;
  gap: 6px;
}

.decision-row {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.decision-label {
  color: var(--muted);
  font-size: 13px;
}

.decision-value {
  font-weight: 700;
  text-align: right;
}

.card-put {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.quality-fallback {
  color: var(--yellow);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.compact-pill-row {
  justify-content: flex-start;
  margin-top: 4px;
}

.card-section h3,
.detail-panel h2 {
  font-size: 15px;
  margin-bottom: 12px;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.metric-grid div {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 10px;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.levels {
  margin-top: 12px;
}

.levels h4 {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.level-row {
  align-items: center;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
  grid-template-columns: 0.8fr 0.8fr 1fr 0.8fr;
  padding: 8px 0;
}

.level-row span,
.muted,
.empty-state p {
  color: var(--muted);
}

.empty-state {
  padding: 24px;
}

.detail-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-panel {
  padding: 18px;
}

.chart-panel {
  min-height: 460px;
}

.chart {
  height: 420px;
  width: 100%;
}

.hero-panel {
  align-items: start;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-panel h2 {
  font-size: 32px;
}

.full-width {
  grid-column: 1 / -1;
}

.levels-table {
  border-collapse: collapse;
  width: 100%;
}

.levels-table th,
.levels-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
}

.levels-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.loading {
  align-items: center;
  background: rgba(13, 17, 23, 0.82);
  display: none;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 20;
}

.loading.is-visible {
  display: flex;
  flex-direction: column;
}

.spinner {
  animation: spin 0.8s linear infinite;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  height: 44px;
  width: 44px;
}

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

@media (max-width: 1100px) {
  .filter-form,
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .results-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar,
  .dashboard-head {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }

  .page {
    padding: 18px;
  }

  h1 {
    font-size: 34px;
  }

  .filter-form,
  .stats-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

.mode-banner {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 16px 0;
  padding: 14px 16px;
}

.mode-banner p {
  margin: 0;
}

.mode-pill {
  background: rgba(96, 165, 250, 0.16);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--blue);
}

.mode-pill-live {
  background: rgba(251, 146, 60, 0.16);
  border-color: rgba(251, 146, 60, 0.45);
  color: var(--orange);
}

.detail-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-link-row .detail-link {
  flex: 1;
}

.secondary-detail-link {
  background: var(--blue);
  color: #07111f;
}

.detail-link-disabled {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  cursor: default;
  font-weight: 600;
  font-size: 13px;
}

.live-filters {
  flex-basis: 100%;
}

.live-filters .eyebrow {
  margin: 0 0 6px;
}

.detail-summary {
  margin: 16px 0;
}

.detail-summary-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.detail-summary-head h2 {
  font-size: 30px;
  margin: 0;
}

.detail-summary-score {
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

.detail-summary-action {
  border-radius: 6px;
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  padding: 4px 10px;
}

.detail-summary-grid {
  display: grid;
  gap: 10px 20px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0;
}

.detail-summary-grid dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.detail-summary-grid dd {
  font-weight: 700;
  margin: 0;
}

.entry-message {
  color: var(--muted);
  margin: 0 0 12px;
}

.levels-columns {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}

.put-groups {
  display: grid;
  gap: 10px;
}

.put-group-label {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.put-group-value {
  font-weight: 700;
  margin: 0;
}

.put-source-note {
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0 0;
}

@media (max-width: 700px) {
  .levels-columns {
    grid-template-columns: 1fr;
  }
}
