:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #1b2420;
  --muted: #66736d;
  --line: #d7dfda;
  --teal: #0f766e;
  --teal-2: #115e59;
  --gold: #b7791f;
  --red: #b42318;
  --green: #14804a;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(29, 48, 41, 0.1);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.09), rgba(246, 247, 244, 0) 360px),
    var(--bg);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar,
.toolbar,
.summary-strip,
.source-layout {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--gold);
}

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

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

.toolbar {
  grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(120px, 0.75fr) 44px;
  align-items: end;
  margin-bottom: 14px;
}

.field {
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.field > span,
.field legend {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.static-field strong {
  display: block;
  min-height: 34px;
  line-height: 34px;
}

select {
  width: 100%;
  min-height: 34px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-weight: 750;
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  border: 1px solid var(--line);
}

.check-group label {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  font-weight: 750;
}

.check-group input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.icon-button:hover {
  background: var(--teal-2);
}

.icon-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.summary-strip span,
.summary-strip strong {
  display: block;
}

.summary-strip span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.summary-strip strong {
  font-size: 0.98rem;
}

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

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

.rate-card {
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.pair {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.rate {
  overflow-wrap: anywhere;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.change {
  display: inline-flex;
  min-width: 92px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.change.up {
  background: rgba(20, 128, 74, 0.11);
  color: var(--green);
}

.change.down {
  background: rgba(180, 35, 24, 0.1);
  color: var(--red);
}

.change.neutral {
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue);
}

.rate-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
}

.rate-card dl div {
  min-height: 66px;
  padding: 11px;
  border-radius: 8px;
  background: var(--surface-2);
}

.rate-card dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.rate-card dd {
  margin: 0;
  font-weight: 800;
}

.source-line {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.source-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  margin-top: 16px;
}

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

.panel {
  min-height: 246px;
  padding: 18px;
}

.health-panel {
  min-height: 0;
  margin-top: 16px;
}

.converter-panel {
  min-height: 0;
  margin: 0 0 16px;
}

.converter-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.amount-field,
.conversion-result {
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.amount-field span,
.conversion-result span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.amount-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 850;
  outline: 0;
  padding: 0 10px;
}

.amount-field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.conversion-result strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 1.05rem;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: right;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
}

.thresholds {
  display: grid;
  gap: 12px;
}

.threshold-item {
  display: grid;
  gap: 8px;
  min-height: 84px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.threshold-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.threshold-title span:last-child {
  color: var(--muted);
  font-weight: 750;
}

.meter {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6e1;
}

.meter span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--meter-width);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.helper {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

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

.source-item {
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.source-item strong,
.source-item span {
  display: block;
}

.source-item strong {
  margin-bottom: 3px;
}

.source-item span:last-child {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.source-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
}

.source-item.is-ok .source-dot {
  background: var(--green);
}

.empty-state {
  display: grid;
  min-height: 176px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 820px) {
  .topbar,
  .toolbar,
  .summary-strip,
  .rates-grid,
  .source-layout,
  .converter-grid,
  .source-health {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .status-pill {
    width: fit-content;
  }

  .toolbar {
    align-items: stretch;
  }

  .icon-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .card-head,
  .panel-heading {
    display: grid;
  }

  .rate-card dl {
    grid-template-columns: 1fr;
  }
}
