:root {
  --paper: #f4efe6;
  --paper-deep: #e7dfd0;
  --card: #fffdf8;
  --ink: #1c1915;
  --muted: #5e584e;
  --pine: #1b4332;
  --pine-soft: #2d6a4f;
  --gold: #9a7432;
  --line: #ddd4c4;
  --tax: #8d3d2c;
  --shadow: 0 16px 40px rgba(48, 36, 16, 0.08);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(154, 116, 50, 0.16), transparent 60%),
    radial-gradient(800px 380px at 100% 0%, rgba(27, 67, 50, 0.12), transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.6;
}
::selection { background: #d7e6dc; }
a { color: var(--pine); }
img { max-width: 100%; }
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: white;
  padding: 0.5rem 0.8rem;
  z-index: 20;
}
.skip:focus { top: 1rem; }

.topnote {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.2rem 1.15rem;
  background: var(--pine);
  color: #f3efe4;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 0.45rem 1rem;
}
.topnote .fresh { color: #f3e2b0; font-weight: 650; }
.topnote .fresh::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #95d5b2;
  box-shadow: 0 0 0 3px rgba(149, 213, 178, 0.28);
  vertical-align: 0.05em;
}
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 239, 230, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner, .wrap { width: min(var(--max), calc(100% - 2rem)); margin: 0 auto; }
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 4.2rem; }
.brand { font-family: var(--serif); font-weight: 620; font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.brand span { color: var(--gold); }
nav { display: flex; gap: 0.9rem; margin-left: auto; align-items: center; }
.header-inner > .countries { margin-left: auto; }
nav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; }
nav a:hover { color: var(--pine); }
nav a[aria-current="page"] { color: var(--pine); font-weight: 650; }
.lang { border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.7rem; text-decoration: none; color: var(--ink); background: #fffdf8; }
.lang:hover { border-color: var(--pine); color: var(--pine); }
.menu-btn {
  display: none;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font: inherit;
}

.hero { padding: 3.5rem 0 2rem; }
.hero h1, .page-head h1, .prose h2, .card h2, .result h2 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.hero h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); margin: 0 0 1rem; max-width: 14ch; }
.page-head h1::after, .home h1::after {
  content: "";
  display: block;
  width: 3.4rem;
  height: 3px;
  margin-top: 0.75rem;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #e7c98a);
}
.lede { font-size: 1.2rem; color: var(--muted); max-width: 42rem; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1.5rem; align-items: start; }
.calc-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.home { padding-top: 2.8rem; }
.home h1 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; line-height: 1.08; font-size: clamp(2.6rem, 5vw, 4.6rem); margin: 0 0 0.8rem; max-width: 18ch; }
.home .lede { max-width: 46rem; }
.countries-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.8rem 0 2.8rem; }
.country-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.flag { display: block; width: 3.4rem; height: 2.25rem; object-fit: cover; border-radius: 6px; border: 1px solid rgba(28, 25, 21, 0.14); box-shadow: 0 6px 14px rgba(48, 36, 16, 0.12); margin-bottom: 0.85rem; }
.flagline { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.45rem; color: var(--pine); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.flagline .flag { width: 1.7rem; height: 1.12rem; margin: 0; border-radius: 3px; box-shadow: none; }
.country-card h2 { font-family: var(--serif); font-weight: 560; font-size: 1.8rem; margin: 0 0 0.35rem; letter-spacing: -0.03em; }
.country-card p { margin: 0; color: var(--muted); flex: 1; }
.country-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.country-links a {
  text-decoration: none;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 650;
  font-size: 0.92rem;
  background: var(--pine);
  color: #f6f1e7;
}
.country-links a:last-child { background: transparent; color: var(--pine); border: 1px solid #b7c9be; }
.country-links a:hover { background: var(--pine-soft); color: #fff; }
.country-links a:last-child:hover { background: #eef5f0; color: var(--pine); }
.stack > * + * { margin-top: 1rem; }
.card, .result, .prose, .tool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card, .result { padding: 1.25rem; }
.card h2, .result h2 { margin: 0 0 0.8rem; font-size: 1.45rem; }
label { display: block; font-size: 0.92rem; font-weight: 600; margin: 0.8rem 0 0.3rem; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 0.72rem 0.8rem;
  border-radius: 10px;
  border: 1px solid #cfc6b6;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--pine-soft);
  outline-offset: 1px;
  border-color: var(--pine-soft);
}
textarea { min-height: 8rem; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.check { display: flex; gap: 0.55rem; align-items: center; margin-top: 0.9rem; font-weight: 600; }
.check input { width: auto; }
.hint { color: var(--pine-soft); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; margin: 0.15rem 0 0; }
.net { font-family: var(--serif); font-size: clamp(2.3rem, 4vw, 3.3rem); margin: 0.15rem 0 0.2rem; color: var(--pine); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.lines { list-style: none; padding: 0; margin: 0.7rem 0 0; }
.lines li { display: flex; justify-content: space-between; gap: 0.6rem 1rem; padding: 0.5rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.lines li span { flex: 1 1 9rem; min-width: 0; }
.lines li strong { flex: 0 0 auto; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tax { color: var(--tax); }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; padding-bottom: 3rem; }
.tool { position: relative; overflow: hidden; padding: 1.15rem 2.4rem 1.2rem 1.15rem; text-decoration: none; color: inherit; display: block; transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease; }
.tool::before { content: ""; display: block; height: 4px; margin: -1.15rem -2.4rem 0.9rem -1.15rem; background: linear-gradient(90deg, var(--pine), var(--gold)); }
.tool::after { content: "→"; position: absolute; right: 1rem; top: 1.35rem; color: var(--gold); }
.tool:hover { border-color: var(--pine-soft); transform: translateY(-3px); box-shadow: 0 18px 36px rgba(27, 67, 50, 0.12); }
.tool strong { display: block; font-family: var(--serif); font-size: 1.35rem; font-weight: 560; margin-bottom: 0.35rem; }
.tool span { color: var(--muted); }
.page-head { padding: 2.2rem 0 0.4rem; }
.page-head h1 { font-size: clamp(2rem, 4vw, 3.3rem); margin: 0 0 0.6rem; max-width: 18ch; }
.calc-layout { padding-bottom: 1rem; }
.result {
  position: sticky;
  top: 5.4rem;
  background: linear-gradient(180deg, #e7f2eb 0%, var(--card) 7.2rem);
  border-color: #c5d5cb;
}
.page-copy {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem 1.6rem;
  margin-top: 1.2rem;
  margin-bottom: 2.5rem;
}
.page-copy h2, .page-copy h3 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose { padding: 1.4rem 1.5rem 1.6rem; margin-top: 1.2rem; margin-bottom: 2.5rem; }
.prose h2 { font-size: 1.7rem; margin: 1.4rem 0 0.4rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin: 1.1rem 0 0.3rem; }
.sources { font-size: 0.92rem; }
.note {
  background: #f7f1e2;
  border-left: 4px solid var(--gold);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
footer { border-top: 3px solid var(--pine); padding: 2.2rem 0 2.8rem; color: var(--muted); font-size: 0.92rem; background: #ebe4d6; }
.footer-grid { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-grid a { color: var(--muted); }
.banner[hidden] { display: none !important; }
.banner {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  background: var(--ink);
  color: #f6f1e7;
  padding: 0.9rem 1.2rem;
  z-index: 15;
}
.banner p { margin: 0; max-width: 46rem; }
.banner a { color: #f6f1e7; }
.banner button, button.primary {
  font: inherit;
  background: #f3efe4;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
}
button.primary { background: var(--pine); color: #f6f1e7; }
button.primary:hover { background: var(--pine-soft); }
button.ghost { background: transparent; color: #f6f1e7; border: 1px solid #8a8172; }
.adslot { margin: 1rem 0; text-align: center; }
.error { color: var(--tax); font-size: 0.9rem; min-height: 1.2rem; }

@media (max-width: 1100px) {
  .countries-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 861px) {
  .calc { display: grid; grid-template-columns: minmax(17rem, 23rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
  .tools { grid-template-columns: repeat(6, 1fr); }
  .tool { grid-column: span 2; }
  .tool:nth-child(1):nth-last-child(4),
  .tool:nth-child(2):nth-last-child(3),
  .tool:nth-child(3):nth-last-child(2),
  .tool:nth-child(4):nth-last-child(1),
  .tool:nth-child(1):nth-last-child(2),
  .tool:nth-child(2):nth-last-child(1),
  .tool:nth-child(4):nth-last-child(2),
  .tool:nth-child(5):nth-last-child(1) { grid-column: span 3; }
  .tool:only-child { grid-column: span 6; }
  .card:has(> [data-result-for]) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
    align-items: start;
  }
  .card > [data-result-for] { padding-left: 1.25rem; border-left: 1px solid var(--line); }
  .card:has(> [data-result-for]) > :not([data-result-for]) { grid-column: 1; }
  .card:has(> [data-result-for]) > [data-result-for] { grid-column: 2; grid-row: 1 / span 8; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-block; }
  nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: flex-start;
    padding: 0.8rem 1rem 1rem;
  }
  nav.open { display: flex; }
  .hero-grid, .calc-layout, .tools, .row, .countries-grid { grid-template-columns: 1fr; }
  .tool { grid-column: auto; }
  .result { position: static; }
  .banner {
    flex-direction: column;
    align-items: stretch;
    max-height: 46vh;
    overflow: auto;
  }
  .banner div { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; background: var(--ink); padding-top: 0.35rem; }
}
