:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dfe6f1;
  --text: #111936;
  --muted: #667085;
  --up: #059669;
  --down: #dc2626;
  --flat: #64748b;
  --chart-grid: #e5e7eb;
  --chart-tick: #4b5563;
  --shadow: 0 10px 24px rgba(17, 25, 54, 0.06);
  --hover-shadow: 0 14px 30px rgba(37, 99, 235, 0.12);
  --button-bg: #ffffff;
  --active-bg: #111936;
  --active-text: #ffffff;
}

:root[data-theme="dark"] {
  --bg: #121826;
  --panel: #1b2334;
  --line: #334155;
  --text: #f8fafc;
  --muted: #a9b4c7;
  --up: #34d399;
  --down: #fb7185;
  --flat: #94a3b8;
  --chart-grid: #2f3a4e;
  --chart-tick: #cbd5e1;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  --hover-shadow: 0 14px 30px rgba(59, 130, 246, 0.18);
  --button-bg: #111827;
  --active-bg: #3b82f6;
  --active-text: #ffffff;
}

* {
  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;
}

button {
  font: inherit;
  color: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-right: auto;
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

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

.rate-card {
  min-height: 184px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.rate-card:hover,
.rate-card.active {
  border-color: #2563eb;
  box-shadow: var(--hover-shadow);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}

.currency-icon {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.code,
.name {
  display: block;
}

.code {
  font-size: 19px;
  font-weight: 800;
}

.name {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.quote-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  padding: 14px 0 8px;
  border-top: 1px solid var(--line);
}

.quote-cell {
  min-width: 0;
}

.quote-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.quote-cell strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.quote-cell em {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.up {
  color: var(--up);
}

.down {
  color: var(--down);
}

.flat {
  color: var(--flat);
}

.updated {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 72px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--button-bg);
}

.mode-button {
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.mode-button.active {
  background: var(--active-bg);
  color: var(--active-text);
}

.chart-wrap {
  height: 430px;
  padding: 20px;
}

.chart-foot {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  padding: 0 20px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.error {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--down);
}

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 16px;
  }

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

  .page-head {
    align-items: center;
  }

  .chart-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    padding: 16px;
  }

  .chart-head h2 {
    font-size: 18px;
    line-height: 1.15;
  }

  .segmented {
    grid-template-columns: repeat(2, 54px);
    justify-self: end;
  }

  .mode-button {
    height: 34px;
    font-size: 13px;
  }

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

  .chart-wrap {
    height: 360px;
    padding: 12px;
  }

  .chart-foot {
    align-items: flex-start;
    flex-direction: column;
  }
}
