:root {
  --paper: #f6f5f1;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #68717d;
  --line: #d9dedb;
  --teal: #087f73;
  --teal-strong: #04665d;
  --amber: #d98f2f;
  --amber-soft: #f7e2c4;
  --green: #27865f;
  --red: #bd5050;
  --graphite: #2f353b;
  --shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(217, 222, 219, 0.9);
  background: rgba(246, 245, 241, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(8, 127, 115, 0.4);
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 13px;
  letter-spacing: 0;
}

.brand-name {
  font-size: 18px;
  white-space: nowrap;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.topnav a {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.topnav a:hover,
.topnav a:focus-visible {
  background: rgba(8, 127, 115, 0.1);
  color: var(--teal-strong);
  outline: none;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--graphite);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.sync-pill.is-live .sync-dot {
  background: var(--green);
}

.sync-pill.is-error .sync-dot {
  background: var(--red);
}

.app-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.market-strip > div {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
}

.market-strip strong {
  display: block;
  min-height: 31px;
  margin-top: 4px;
  overflow: hidden;
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.converter-panel,
.quote-panel,
.rates-panel,
.lower-grid .panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 4px 0 0;
  color: var(--ink);
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  max-width: 680px;
  font-size: clamp(32px, 5vw, 56px);
}

h2 {
  font-size: clamp(21px, 2.5vw, 28px);
}

.updated-badge {
  flex: 0 0 auto;
  max-width: 180px;
  padding: 8px 10px;
  border: 1px solid rgba(8, 127, 115, 0.24);
  border-radius: 8px;
  background: rgba(8, 127, 115, 0.08);
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: right;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: min(420px, 100%);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf0ed;
}

.segment {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.12);
}

.calculator {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr);
  gap: 12px;
  margin: 18px 0;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  outline: none;
  padding: 10px 12px;
}

input:focus,
select:focus {
  border-color: rgba(8, 127, 115, 0.65);
  box-shadow: 0 0 0 3px rgba(8, 127, 115, 0.12);
}

.quote-summary {
  display: grid;
  grid-template-columns: minmax(200px, 0.65fr) minmax(260px, 1fr);
  align-items: stretch;
  gap: 16px;
  min-height: 190px;
  margin-top: 12px;
}

.quote-summary > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.quote-summary strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 2.5vw, 34px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

#rateChart {
  display: block;
  width: 100%;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(8, 127, 115, 0.08), rgba(255, 255, 255, 0)),
    #fbfbf8;
}

.stack-form {
  display: grid;
  gap: 13px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--teal-strong);
  background: var(--teal);
  color: #fff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-strong);
  outline: none;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--graphite);
  padding: 9px 12px;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: rgba(8, 127, 115, 0.45);
  color: var(--teal-strong);
  outline: none;
}

.form-note {
  min-height: 38px;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f4f2ea;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.rates-panel {
  margin-top: 18px;
}

.rate-actions {
  display: flex;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f4f5f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: var(--graphite);
  font-size: 14px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.provider-name {
  display: grid;
  gap: 3px;
}

.provider-name strong {
  color: var(--ink);
}

.provider-name span,
.subtle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-cell {
  color: var(--teal-strong);
  font-size: 16px;
  font-weight: 950;
  white-space: nowrap;
}

.best-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #8b5618;
  font-size: 11px;
  font-weight: 950;
}

.reserve-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid rgba(8, 127, 115, 0.35);
  border-radius: 8px;
  background: rgba(8, 127, 115, 0.08);
  color: var(--teal-strong);
  font-weight: 900;
}

.reserve-button:hover,
.reserve-button:focus-visible {
  background: rgba(8, 127, 115, 0.14);
  outline: none;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  margin-top: 18px;
}

.source-list {
  display: grid;
  gap: 10px;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.source-row strong {
  min-width: 140px;
}

.source-row span {
  color: var(--muted);
  font-weight: 750;
  text-align: right;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.source-links a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 850;
}

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

.pair-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.pair-tile {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--graphite);
  font-weight: 900;
  box-shadow: 0 8px 25px rgba(23, 33, 43, 0.05);
}

.pair-tile:hover,
.pair-tile:focus-visible {
  border-color: rgba(8, 127, 115, 0.42);
  color: var(--teal-strong);
  outline: none;
}

.disclaimer-panel {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 22px;
  margin-top: 18px;
  padding: 22px;
  border: 1px solid rgba(217, 143, 47, 0.38);
  border-radius: 8px;
  background: #fffaf1;
  box-shadow: var(--shadow);
}

.disclaimer-panel h2 {
  max-width: 420px;
}

.disclaimer-panel p {
  margin: 0;
  color: var(--graphite);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
}

.site-footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 22px clamp(16px, 4vw, 44px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-brand .brand-mark {
  width: 36px;
  height: 36px;
  font-size: 11px;
}

.footer-brand .brand-name {
  font-size: 15px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.footer-links a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  background: rgba(8, 127, 115, 0.1);
  color: var(--teal-strong);
  outline: none;
}

.site-footer p {
  margin: 0;
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  text-align: right;
}

.legal-shell {
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 58px;
}

.legal-panel {
  padding: 30px;
}

.legal-panel h1 {
  max-width: 760px;
  font-size: clamp(34px, 5vw, 54px);
}

.legal-panel h2 {
  margin-top: 28px;
}

.legal-panel p,
.legal-panel li {
  color: var(--graphite);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.6;
}

.legal-panel a {
  color: var(--teal-strong);
  font-weight: 850;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topnav {
    display: none;
  }

  .market-strip,
  .workspace-grid,
  .lower-grid,
  .disclaimer-panel,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .footer-links {
    justify-content: flex-start;
  }

  .site-footer p {
    max-width: none;
    text-align: left;
  }

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

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

  .partner-grid .primary-button {
    grid-column: span 2;
  }

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

@media (max-width: 680px) {
  .topbar {
    gap: 12px;
    min-height: 64px;
    padding-inline: 12px;
  }

  .brand-name {
    display: none;
  }

  .sync-pill {
    max-width: 180px;
  }

  .app-shell {
    width: min(100% - 20px, 1220px);
    padding-top: 14px;
  }

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

  .market-strip > div,
  .converter-panel,
  .quote-panel,
  .rates-panel,
  .lower-grid .panel {
    padding: 14px;
  }

  .panel-heading {
    display: grid;
  }

  .updated-badge {
    max-width: none;
    text-align: left;
  }

  .calculator,
  .partner-grid {
    grid-template-columns: 1fr;
  }

  .partner-grid .primary-button {
    grid-column: auto;
  }

  .source-row {
    display: grid;
  }

  .source-row span {
    text-align: left;
  }

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