:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --line: #d8dee6;
  --line-strong: #b8c2cf;
  --text: #17202a;
  --muted: #66758a;
  --accent: #0c4a6e;
  --accent-deep: #083449;
  --focus: #1d6f9f;
  --shadow: 0 20px 45px rgba(22, 34, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 246, 248, 0.82)),
    repeating-linear-gradient(90deg, rgba(12, 74, 110, 0.03) 0, rgba(12, 74, 110, 0.03) 1px, transparent 1px, transparent 96px),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 48px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

h1 {
  margin: 0;
  color: var(--accent-deep);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0;
}

.rate-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.refresh-time {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.data-source {
  margin: 0;
  color: #7d8998;
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a6b5;
  box-shadow: 0 0 0 4px rgba(102, 117, 138, 0.12);
  flex: 0 0 auto;
}

.status-dot.is-success {
  background: #16803c;
  box-shadow: 0 0 0 4px rgba(22, 128, 60, 0.14);
}

.status-dot.is-error {
  background: #c23631;
  box-shadow: 0 0 0 4px rgba(194, 54, 49, 0.14);
}

.status-dot.is-loading {
  background: #98a6b5;
  box-shadow: 0 0 0 4px rgba(102, 117, 138, 0.12);
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 48px auto;
}

.rate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.currency-card {
  position: relative;
  overflow: hidden;
  min-height: 168px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), var(--panel-muted));
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.currency-card > div,
.currency-card .amount-field {
  position: relative;
  z-index: 1;
}

.currency-symbol {
  position: absolute;
  top: 24px;
  right: 24px;
  color: rgba(0, 116, 217, 0.85);
  font-family: "Times New Roman", Georgia, serif;
  font-size: clamp(44px, 5vw, 64px);
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
}

.currency-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.flag {
  font-size: 24px;
  line-height: 1;
}

.currency-code {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.amount-field {
  position: relative;
  width: 100%;
  height: 46px;
}

input,
.amount-display {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 22px;
  font-weight: 700;
}

input {
  color: var(--accent-deep);
  background: #ffffff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.amount-display {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text);
  background: #ffffff;
  pointer-events: none;
}

.amount-display.is-visible {
  display: flex;
}

.amount-display .minor-digits {
  color: #9ca8b6;
}

.amount-field.has-display input:not(:focus) {
  color: transparent;
}

.amount-field.has-display input:not(:focus)::placeholder {
  color: transparent;
}

input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 111, 159, 0.16);
}

input::placeholder {
  color: #9ca8b6;
  opacity: 1;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.split-refresh {
  position: relative;
  display: flex;
  align-items: center;
}

button {
  min-width: 132px;
  height: 42px;
  border: 1px solid var(--accent-deep);
  border-radius: 6px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent-deep);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.refresh-main {
  border-radius: 6px 0 0 6px;
}

.refresh-caret {
  min-width: 44px;
  width: 44px;
  padding: 0;
  border-left-color: rgba(255, 255, 255, 0.3);
  border-radius: 0 6px 6px 0;
  font-size: 17px;
}

.provider-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: none;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(22, 34, 51, 0.16);
}

.provider-menu.is-open {
  display: grid;
  gap: 4px;
}

.provider-menu button {
  width: 100%;
  min-width: 0;
  height: 38px;
  justify-content: flex-start;
  border-color: transparent;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.provider-menu button:hover,
.provider-menu button.is-selected {
  color: var(--accent-deep);
  background: #edf4f8;
}

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

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 111, 159, 0.18);
}

.button-secondary {
  color: var(--accent-deep);
  background: #ffffff;
  border-color: var(--line-strong);
}

.button-secondary:hover {
  color: #ffffff;
  background: #445469;
  border-color: #445469;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 28px;
  color: #8a96a6;
  font-size: 13px;
}

.copyright-mark {
  font-size: 13px;
  line-height: 1;
}

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  h1 {
    font-size: 28px;
  }

  .refresh-time {
    white-space: normal;
    line-height: 1.5;
  }

  .rate-meta {
    justify-items: start;
  }

  .data-source {
    white-space: normal;
    line-height: 1.5;
  }

  .page-shell {
    width: calc(100% - 32px);
    margin: 28px auto;
  }

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

  .actions {
    flex-direction: column;
  }

  .split-refresh {
    width: 100%;
  }

  .refresh-main {
    flex: 1;
  }

  button {
    width: 100%;
  }

  .refresh-caret {
    width: 46px;
    flex: 0 0 46px;
  }

  .provider-menu {
    width: 100%;
  }
}
