:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1f0eb;
  --ink: #15171a;
  --ink-2: #3d4147;
  --muted: #73777d;
  --line: #e4e2db;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ee;
  --c-net: #0f766e;
  --c-tax: #d9734a;
  --c-social: #5b6fd6;
  --c-other: #a68a3d;
  --focus: #0f766e55;
  --shadow: 0 1px 2px rgb(20 20 15 / .04), 0 8px 24px -12px rgb(20 20 15 / .10);
  --radius: 18px;
  --radius-sm: 11px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113; --surface: #171a1d; --surface-2: #1e2226; --ink: #eef0f1; --ink-2: #c9cdd1;
    --muted: #8d9399; --line: #2a2f34; --accent: #2bb3a3; --accent-ink: #06201d; --accent-soft: #143a36;
    --c-net: #2bb3a3; --c-tax: #e88a62; --c-social: #8394ee; --c-other: #c9aa58; --focus: #2bb3a366;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1113; --surface: #171a1d; --surface-2: #1e2226; --ink: #eef0f1; --ink-2: #c9cdd1;
  --muted: #8d9399; --line: #2a2f34; --accent: #2bb3a3; --accent-ink: #06201d; --accent-soft: #143a36;
  --c-net: #2bb3a3; --c-tax: #e88a62; --c-social: #8394ee; --c-other: #c9aa58; --focus: #2bb3a366;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px -14px rgb(0 0 0 / .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: -.01em; font-size: 17px; }
.brand-mark svg { width: 28px; height: 28px; display: block; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { stroke: var(--accent-ink); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.7; stroke-linecap: round; }
.icon-btn .i-moon { display: none; }
:root[data-theme="dark"] .icon-btn .i-sun { display: none; }
:root[data-theme="dark"] .icon-btn .i-moon { display: block; }

/* hero */
.hero { padding: 48px 0 24px; max-width: 760px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.07; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 700; text-wrap: balance; }
.lede { font-size: clamp(16px, 2vw, 18px); color: var(--ink-2); margin: 0; text-wrap: pretty; }

/* countries */
.countries { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 20px; }
.country-btn { display: inline-flex; align-items: center; gap: 9px; padding: 9px 15px 9px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; font-size: 15px;
  transition: border-color .15s, background .15s, transform .15s; }
.country-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.country-btn .code { font-size: 11px; font-weight: 700; letter-spacing: .04em; width: 30px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.country-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.country-btn[aria-pressed="true"] .code { background: var(--accent); color: var(--accent-ink); }

/* layout */
.calc { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 20px; align-items: start; padding-bottom: 56px; }
@media (max-width: 880px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.inputs { min-width: 0; position: sticky; top: 80px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 880px) { .inputs { position: static; } }
.results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.help { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.4; }
select, .text-input, .mini-num {
  width: 100%; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
  padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2373777d' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.mini-num { width: 64px; height: 30px; padding: 0 8px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
select:focus, .text-input:focus, .mini-num:focus, .money-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }

.money-input { display: flex; align-items: center; height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; gap: 10px; transition: border-color .15s, box-shadow .15s; }
.money-input .cur { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .05em; }
.money-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-align: right; }
.money-sm { height: 46px; flex: 1; }
.money-sm input { font-size: 18px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { min-width: 0; overflow: hidden; text-overflow: ellipsis; border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 550; font-size: 14px; color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 1px var(--line); }
.seg-full { display: flex; } .seg-full button { flex: 1; }
.seg-sm button { padding: 5px 10px; font-size: 13px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-2) var(--p, 50%)); outline: none; margin: 8px 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgb(0 0 0 / .2); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--focus); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; min-height: 32px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .sw { flex: none; width: 42px; height: 25px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s; }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { transform: translateX(17px); }
.toggle input:focus-visible + .sw { box-shadow: 0 0 0 4px var(--focus); }

#countryFields, #advancedFields { display: flex; flex-direction: column; gap: 18px; }
#advancedFields { padding-top: 4px; border-top: 1px dashed var(--line); padding-top: 18px; }
.link-btn { align-self: flex-start; border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; }
.link-btn::after { content: " ↓"; } .link-btn[aria-expanded="true"]::after { content: " ↑"; }

/* results */
.result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--muted); }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { border-radius: 14px; padding: 16px; background: var(--surface-2); min-width: 0; }
.tile.primary { background: var(--accent); color: var(--accent-ink); }
.tile .t-label { font-size: 12.5px; font-weight: 600; opacity: .75; }
.tile .t-net { font-size: clamp(19px, 3.2vw, 30px); font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; }
.tile .t-gross { font-size: 12.5px; opacity: .72; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile.primary { grid-column: 1 / -1; }
}
.bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; margin: 18px 0 10px; background: var(--surface-2); gap: 2px; }
.bar span { display: block; height: 100%; transition: flex-basis .35s ease; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.legend b { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink); }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; font-weight: 650; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; vertical-align: top; }
.breakdown td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.breakdown .rate { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.breakdown .note { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.breakdown .grp td { text-align: left; padding-top: 16px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); border-bottom: 0; }
.breakdown .grp i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; }
.breakdown .sum td { font-weight: 650; border-bottom: 0; }
.breakdown .gross td { font-weight: 600; }
.breakdown .netrow td { font-weight: 700; font-size: 17px; border-bottom: 0; padding-top: 14px; color: var(--accent); }
.minus::before { content: "− "; color: var(--muted); }

.fold { padding: 0; }
.fold summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: ""; width: 9px; height: 9px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
.fold[open] summary::after { transform: rotate(-135deg) translateX(-3px); }
.fold > table { margin: 0 22px 18px; width: calc(100% - 44px); }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv tr:last-child td { border-bottom: 0; font-weight: 650; }
.kv td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }

.target-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.target-out { margin: 12px 0 0; font-size: 15px; color: var(--ink-2); min-height: 1.5em; }
.target-out b { color: var(--ink); font-variant-numeric: tabular-nums; }

.meta { font-size: 13.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 0; }
.meta h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.meta ul { margin: 0; padding-left: 18px; } .meta li { margin: 3px 0; }
.meta a { color: var(--accent); text-underline-offset: 2px; }
.ghost-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 550; font-size: 14px; }
.ghost-btn:hover { border-color: var(--accent); }

.footer { border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: 13px; color: var(--ink-2); }
.footer p { max-width: 760px; margin: 0 0 8px; }

.loading { opacity: .5; transition: opacity .2s; }
button:focus-visible, .country-btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 520px) { .card { padding: 18px; } .card-head .seg button { padding: 5px 8px; } .money-input input { font-size: 22px; } .tile { padding: 14px; } .tile .t-gross { font-size: 12px; } }

/* links styled as segmented buttons / country pills */
.seg a { padding: 5px 10px; border-radius: 9px; font-weight: 550; font-size: 13px; color: var(--ink-2); text-decoration: none; }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 1px var(--line); }
a.country-btn { color: var(--ink); text-decoration: none; }
.country-btn[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.country-btn[aria-current="page"] .code { background: var(--accent); color: var(--accent-ink); }

/* explainer + legal */
.explainer, .legal { max-width: 760px; padding-bottom: 56px; color: var(--ink-2); }
.explainer h2, .legal h2 { font-size: 22px; letter-spacing: -.02em; color: var(--ink); margin: 32px 0 10px; }
.legal h1 { font-size: 34px; letter-spacing: -.03em; margin: 40px 0 16px; color: var(--ink); }
.explainer p, .explainer li, .legal p, .legal li { font-size: 16px; line-height: 1.65; }
.explainer ul, .legal ul { padding-left: 20px; }
.explainer li, .legal li { margin: 6px 0; }
.explainer strong { color: var(--ink); }
.explainer a, .legal a { color: var(--accent); text-underline-offset: 2px; }
.legal .todo { background: #fde68a; color: #111; padding: 0 4px; border-radius: 4px; }

.footer-links { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 14px 0; }
.fl-group { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.fl-group b { color: var(--ink); font-weight: 650; }
.footer-links a { color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }
