:root {
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --surface-alt: #fafbfc;
  --input-bg: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --border: #e5e7eb;
  --accent: #164a9c;
  --accent-soft: #eef3fb;
  --up: #15803d;
  --down: #b91c1c;
  --error-bg: #fdf2f2;
  --error-border: #f5c2c2;
  --error-text: #9c2626;
  --radius: 12px;
  --max-width: 880px;
  font-size: 16px;
}

html[data-theme="dark"] {
  --bg: #11141a;
  --card-bg: #1a1e27;
  --surface-alt: #20242f;
  --input-bg: #161a22;
  --text: #e7e9ee;
  --muted: #98a2b3;
  --border: #2b303c;
  --accent: #5b9dff;
  --accent-soft: #1c2b45;
  --up: #34d399;
  --down: #f87171;
  --error-bg: #3a1f22;
  --error-border: #5c2b30;
  --error-text: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  height: auto;
  min-height: 64px;
  gap: 10px;
  padding: 10px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.logo-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.logo-dot {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle,
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang-flag {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.theme-toggle {
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1;
}

.lang-toggle:hover,
.theme-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.hero {
  padding: 40px 0 20px;
  text-align: center;
}

.hero h1 {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 15px;
}

.subtitle strong {
  color: var(--text);
}

.status {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.summary-section {
  margin: 24px 0 20px;
  text-align: center;
}

.summary-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}

.summary-title strong {
  color: var(--accent);
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-fixed {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.stat-arrow {
  font-size: 14px;
}

.stat-arrow.up { color: var(--up); }
.stat-arrow.down { color: var(--down); }
.stat-arrow.flat { color: var(--muted); }

.stat-diff {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
}

.stat-diff.up { color: var(--up); }
.stat-diff.down { color: var(--down); }
.stat-diff.flat { color: var(--muted); }

.tools-grid,
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.tool-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.input,
.select {
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}

.converter-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}

.swap-btn {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  align-self: end;
}

.swap-btn:hover {
  background: var(--accent);
  color: #fff;
}

.converter-result {
  margin-top: 16px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  padding: 12px;
  background: var(--accent-soft);
  border-radius: 8px;
}

.vat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.vat-results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vat-result-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-radius: 8px;
}

.vat-result-line.vat-total {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}

.chart-holder {
  width: 100%;
}

.chart-holder svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-area {
  fill: var(--accent-soft);
  stroke: none;
}

.chart-dot {
  fill: var(--accent);
}

.chart-label {
  font-size: 9px;
  fill: var(--muted);
}

.chart-value-label {
  font-size: 10px;
  fill: var(--text);
  font-weight: 600;
}

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.table-scroll {
  overflow-x: auto;
}

.rates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.rates-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-alt);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.rates-table thead th.date-col {
  text-align: right;
}

.rates-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.rates-table tbody tr:last-child td {
  border-bottom: none;
}

.rates-table tbody tr:nth-child(even) {
  background: var(--surface-alt);
}

.rates-table tbody tr:hover {
  background: var(--accent-soft);
}

.rates-table tbody tr.pinned-last td {
  border-bottom: 2px solid var(--border);
}

.code-cell {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.flag-img {
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.flag-icon {
  margin-right: 6px;
  font-size: 15px;
}

.name-cell {
  color: var(--text);
}

.date-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rate-value {
  font-weight: 600;
}

.rate-diff {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
}

.rate-diff.up { color: var(--up); }
.rate-diff.down { color: var(--down); }
.rate-diff.flat { color: var(--muted); }

.loading-row td,
.error-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
  white-space: normal;
}

.disclaimer {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  margin: 0 0 40px;
}

.info-banner-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.info-banner-link:hover {
  text-decoration: underline;
}

.robor-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  line-height: 1.7;
}

.robor-link-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0 32px;
  font-size: 13px;
  color: var(--muted);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

@media (max-width: 640px) {
  .hero { padding: 28px 0 16px; }
  .hero h1 { font-size: 22px; }

  .site-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .stat-tiles {
    grid-template-columns: 1fr;
  }

  .tools-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .converter-row {
    grid-template-columns: 1fr 1fr;
  }

  .swap-btn {
    justify-self: center;
  }

  .rates-table thead { display: none; }

  .rates-table, .rates-table tbody, .rates-table tr, .rates-table td {
    display: block;
    width: 100%;
  }

  .rates-table tbody tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .rates-table tbody td {
    border-bottom: none;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    white-space: normal;
  }

  .rates-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
  }

  .code-cell::before { content: ""; }
  .code-cell { font-size: 16px; padding-bottom: 4px !important; }

  .date-cell { text-align: right; }
}
