:root {
  --bg-a: #f6fafc;
  --bg-b: #edf3f8;
  --ink: #142330;
  --ink-soft: #5b6e7d;
  --panel: #ffffffd9;
  --panel-strong: #ffffffef;
  --line: #d7e2ea;
  --line-soft: #e7eef3;
  --accent: #0f7c82;
  --accent-2: #1797a0;
  --accent-deep: #0c6368;
  --warn-bg: #fff5e8;
  --warn-line: #e7c28d;
  --tone-strong: #e8f7f4;
  --tone-strong-line: #9fd9cb;
  --tone-good: #eff8ef;
  --tone-good-line: #b8dfb9;
  --tone-watch: #fff6e8;
  --tone-watch-line: #efd09d;
  --tone-risk: #fff0ee;
  --tone-risk-line: #ecb8ae;
  --tone-neutral: #f3f6f8;
  --tone-neutral-line: #d3dde4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 92% -15%, #dcecf4 0%, transparent 44%),
    radial-gradient(circle at -15% 18%, #e9f2f7 0%, transparent 42%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.page {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 18px 44px;
}

.hero {
  margin-bottom: 18px;
}

.calibration-panel {
  margin-bottom: 14px;
}

.calibration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-size: 0.77rem;
  font-weight: 700;
}

h1 {
  margin: 8px 0;
  line-height: 1.08;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.sub {
  margin: 0;
  color: var(--ink-soft);
  max-width: 74ch;
}

.hero-link-row {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-link {
  color: #0d646a;
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.hero-link:hover {
  color: #0a4f54;
}

a:focus-visible,
button:focus-visible,
.tab-btn:focus-visible,
input:focus-visible {
  outline: 3px solid #8fd0d2;
  outline-offset: 3px;
}

a:focus-visible,
.hero-link:focus-visible {
  border-radius: 6px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  background: #ffffffd1;
  color: #486070;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.tab-btn:hover {
  border-color: #bfcfda;
}

.tab-btn.is-active {
  color: #ffffff;
  border-color: #2e9ca2;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tab-btn:focus-visible {
  outline-color: #5cb8bf;
}

.tab-panel {
  animation: reveal 170ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(3px);
  box-shadow: 0 10px 22px #1b3f5810;
  padding: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 122px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--tone-neutral-line);
  background: var(--tone-neutral);
  color: #35566a;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-badge-good {
  border-color: var(--tone-good-line);
  background: var(--tone-good);
  color: #1f5b31;
}

.status-badge-watch {
  border-color: var(--tone-watch-line);
  background: var(--tone-watch);
  color: #7a4b12;
}

.status-badge-risk {
  border-color: var(--tone-risk-line);
  background: var(--tone-risk);
  color: #8f2d1f;
}

.status-badge-neutral {
  border-color: var(--tone-neutral-line);
  background: var(--tone-neutral);
  color: #486070;
}

.form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logs-controls {
  display: flex;
  gap: 10px;
  align-items: end;
}

.logs-controls label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  font: inherit;
}

input:focus {
  outline: 2px solid #b8dde0;
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 9px;
  color: #ffffff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px #117c8440;
}

button:focus-visible {
  box-shadow: 0 0 0 4px #d9f0f1, 0 6px 14px #117c8440;
}

button:disabled {
  cursor: default;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.status {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid #d8e6ee;
  background: #f8fcff;
  color: #35566a;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
}

.status.error {
  border-color: #efc7bf;
  background: #fff4f2;
  color: #8f2d1f;
}

.progress-wrap {
  margin-top: 10px;
  border: 1px solid #d8e6ee;
  border-radius: 10px;
  background: #f8fcff;
  padding: 10px;
}

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

.progress-stage,
.progress-percent {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: #35566a;
}

.progress-percent {
  font-weight: 700;
}

.progress-track {
  margin-top: 8px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #cde2ec;
  background: #eaf3f8;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease-out;
}

.progress-counters {
  margin: 8px 0 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.77rem;
  color: #4b6574;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.report-summary article,
.report-panel {
  box-shadow: 0 14px 30px #12324712;
}

.summary article {
  background: var(--panel-strong);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px;
}

.k {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.v {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.warnings {
  margin-top: 12px;
}

.calibration-note-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.calibration-note {
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #f8fcff;
  color: #35566a;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.calibration-note.warn-chip {
  margin: 0;
}

.warnings h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.warn-chip {
  margin: 0 0 6px;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: #7a4b12;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.89rem;
}

.table-wrap {
  border: 1px solid #deebf2;
  border-radius: 16px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  overflow-x: auto;
}

#results-wrap,
#market-results-wrap {
  margin-top: 12px;
}

.report-panel {
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.section-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.15;
}

.section-note {
  margin: 0;
  max-width: 48ch;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
}

#tab-methodology {
  margin-top: 6px;
}

.method-text {
  margin: 0 0 10px;
  color: var(--ink-soft);
}

.method-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--ink);
}

.learn-page {
  max-width: 980px;
}

.learn-section {
  margin-top: 12px;
}

.learn-section h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.learn-section h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.learn-section p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.learn-card {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #ffffffeb;
  padding: 10px;
}

.learn-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.learn-math {
  border: 1px solid #d8e6ee;
  border-radius: 10px;
  background: #f8fcff;
  padding: 10px;
}

.learn-math p {
  margin: 0 0 8px;
}

.learn-math p:last-child {
  margin-bottom: 0;
}

.learn-chart {
  margin: 0;
}

.learn-chart svg {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid #d8e6ee;
}

.learn-chart figcaption {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.chart-text {
  font-family: "IBM Plex Mono", monospace;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.results-table {
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid #e3edf3;
  padding: 9px 10px;
  text-align: left;
  font-size: 0.89rem;
  vertical-align: top;
}

th {
  color: #5f7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.73rem;
  background: #f6fafc;
}

tbody tr:hover {
  background: #f5f9fc;
}

.results-table tbody tr {
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.results-table tbody tr:hover {
  transform: translateY(-1px);
  box-shadow: inset 3px 0 0 var(--accent);
}

.results-table td:first-child {
  width: 70px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent-2));
  color: #ffffff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  font-weight: 700;
}

.spread-cell,
.credit-cell,
.ticker-cell,
.safety-cell {
  display: grid;
  gap: 9px;
}

.ticker-warning-list {
  display: grid;
  gap: 6px;
}

.ticker-warning-list .warn-chip {
  margin: 0;
  font-size: 0.78rem;
  padding: 6px 8px;
}

.spread-pair,
.ticker-line,
.meta-row,
.metric-pill-row,
.liquidity-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.leg-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 0.86rem;
}

.leg-chip-short {
  background: #e9f7f7;
  color: var(--accent-deep);
}

.leg-chip-long {
  background: #eef4fb;
  color: #375a73;
}

.spread-divider {
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta-row {
  color: var(--ink-soft);
  font-size: 0.77rem;
  line-height: 1.4;
}

.meta-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-row span::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #b5c8d4;
}

.meta-row span:first-child::before {
  display: none;
}

.score-block {
  display: grid;
  gap: 6px;
}

.score-block-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.score-block-head strong,
.hero-metric,
.metric-pill strong,
.leg-stat strong,
.ticker-symbol {
  font-family: "IBM Plex Mono", monospace;
}

.score-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9f1f5;
  overflow: hidden;
}

.score-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.metric-pill-row {
  gap: 6px;
}

.metric-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  border: 1px solid var(--tone-neutral-line);
  background: var(--tone-neutral);
  border-radius: 999px;
  padding: 6px 10px;
  line-height: 1;
}

.metric-pill-help {
  position: relative;
  cursor: help;
}

.metric-pill-help::before,
.metric-pill-help::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 2;
}

.metric-pill-help::before {
  content: "";
  bottom: calc(100% + 4px);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #173042 transparent transparent transparent;
}

.metric-pill-help::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 8px 10px;
  border-radius: 10px;
  background: #173042;
  color: #f7fbfd;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: normal;
  text-align: left;
  box-shadow: 0 14px 28px rgba(11, 28, 38, 0.24);
  white-space: normal;
}

.metric-pill-help:hover::before,
.metric-pill-help:hover::after,
.metric-pill-help:focus-visible::before,
.metric-pill-help:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.metric-pill-help:focus-visible {
  outline: 2px solid #4f95b5;
  outline-offset: 2px;
}

.metric-pill-label,
.leg-stat-label {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tone-strong {
  border-color: var(--tone-strong-line);
  background: var(--tone-strong);
}

.tone-good {
  border-color: var(--tone-good-line);
  background: var(--tone-good);
}

.tone-watch {
  border-color: var(--tone-watch-line);
  background: var(--tone-watch);
}

.tone-risk {
  border-color: var(--tone-risk-line);
  background: var(--tone-risk);
}

.tone-neutral {
  border-color: var(--tone-neutral-line);
  background: var(--tone-neutral);
}

.score-meter-fill.tone-strong {
  background: linear-gradient(90deg, #0f7c82, #25b8aa);
}

.score-meter-fill.tone-good {
  background: linear-gradient(90deg, #3d9363, #6dc47b);
}

.score-meter-fill.tone-watch {
  background: linear-gradient(90deg, #c78a1d, #efb85c);
}

.score-meter-fill.tone-risk {
  background: linear-gradient(90deg, #cb6d5e, #ef9a8e);
}

.score-meter-fill.tone-neutral {
  background: linear-gradient(90deg, #88a1b1, #b5c5d0);
}

.hero-metric {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

.liquidity-grid {
  align-items: stretch;
}

.leg-stat {
  display: grid;
  gap: 4px;
  min-width: 124px;
  border: 1px solid #dde8ef;
  border-radius: 12px;
  background: #fbfdff;
  padding: 9px 10px;
}

.leg-stat span:last-child {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.ticker-symbol {
  font-size: 1.08rem;
  font-weight: 700;
}

.mini-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  border: 1px solid #d8e6ee;
  background: #f7fbfd;
  color: #406170;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.mini-chip-warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: #7a4b12;
}

.empty-state-cell {
  padding: 22px 14px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.93rem;
}

.empty-inline {
  color: var(--ink-soft);
}

.subline {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
}

.hidden {
  display: none;
}

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

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logs-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 18px 12px 30px;
  }

  .panel {
    padding: 10px;
    border-radius: 12px;
  }

  .form {
    grid-template-columns: 1fr;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .tab-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .status {
    font-size: 0.8rem;
  }

  .chart-text {
    font-size: 10px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  #market-results-table {
    min-width: 0;
  }

  table thead,
  #market-results-table thead {
    display: none;
  }

  table tbody,
  #market-results-table tbody {
    display: grid;
    gap: 10px;
  }

  table tr,
  #market-results-table tr {
    display: block;
    border: 1px solid #dce8ef;
    border-radius: 10px;
    background: #ffffffd9;
    padding: 8px 10px;
  }

  table td,
  #market-results-table td {
    display: grid;
    grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
    gap: 8px;
    border: 0;
    padding: 5px 0;
    font-size: 0.85rem;
  }

  table td::before,
  #market-results-table td::before {
    content: attr(data-label);
    color: var(--ink-soft);
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
  }

  .report-panel {
    padding: 12px;
  }

  .results-table tbody tr:hover {
    transform: none;
    box-shadow: none;
  }

  .rank-badge {
    min-width: 30px;
    height: 30px;
  }

  .leg-stat {
    min-width: 0;
    width: 100%;
  }

  .ticker-line,
  .spread-pair,
  .metric-pill-row,
  .liquidity-grid,
  .meta-row {
    align-items: stretch;
  }
}
