:root {
    color-scheme: light;
    --ink: #20223b;
    --muted: #555874;
    --paper: #f5f4fc;
    --line: #dedbed;
    --accent: #5341ca;
    --night: #252052;
    --lime: #ddfa9c;
    font-family: system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 3px solid #8065ed; outline-offset: 4px; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 2rem, 66rem); margin-inline: auto; }
.top { border-bottom: 1px solid var(--line); background: #fff; }
.bar, nav, .brand { display: flex; align-items: center; gap: 1rem; }
.bar { justify-content: space-between; min-height: 4.25rem; flex-wrap: wrap; padding-block: .6rem; }
.brand { font-weight: 750; text-decoration: none; gap: .55rem; }
.brand span { background: var(--accent); color: white; border-radius: .55rem; display: grid; place-items: center; width: 2rem; height: 2rem; }
nav a { color: var(--muted); text-underline-offset: .25em; }
.intro { padding: clamp(2.5rem, 7vw, 5.5rem) 0 2rem; }
h1 { font-size: clamp(2.5rem, 8vw, 5.75rem); line-height: .99; letter-spacing: -.065em; margin: 0; }
h1 span { color: var(--accent); }
.intro p { max-width: 37rem; color: var(--muted); font-size: 1.12rem; margin: 1.25rem 0 0; }
.desk { display: grid; grid-template-columns: 1.08fr 1fr; border: 1px solid var(--line); border-radius: 1.4rem; overflow: hidden; background: white; }
.inputs, .result { min-width: 0; padding: clamp(1.15rem, 4vw, 2.6rem); }
.inputs { display: grid; gap: 1.3rem; align-content: start; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend, .field > label { font-weight: 700; margin-bottom: .5rem; padding: 0; display: block; }
.options, .rate-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.directions label { display: flex; align-items: center; gap: .35rem; }
.options label, .options button, .input-box { border: 1px solid var(--line); background: var(--paper); border-radius: .65rem; padding: .55rem .65rem; }
input[type="radio"] { accent-color: var(--accent); margin: 0; }
.options label:has(:checked), .options button[aria-pressed="true"] { color: #3926aa; border-color: #8e7de2; background: #ede8ff; }
.options button { color: var(--ink); font-weight: 650; }
.input-box { display: flex; align-items: center; gap: .4rem; }
.input-box input { border: 0; padding: 0; background: transparent; color: inherit; min-width: 0; width: 100%; font-weight: 650; }
.input-box span, .field small { color: var(--muted); }
.rate-row .input-box { width: 6rem; }
.field small { display: block; margin-top: .38rem; }
.field .error { color: #a4253b; }
.error:empty { display: none; }
.action, #copy, [data-example] { border: 1px solid transparent; border-radius: .65rem; padding: .55rem .85rem; font-weight: 650; }
.action { background: var(--accent); color: white; justify-self: start; }
.result { background: var(--night); color: white; }
.result h2 { margin: 0 0 1.3rem; font-size: 1.15rem; }
.total { padding: 1rem; background: #372f6d; border-radius: .8rem; }
.total p { margin: 0; }
.total strong { color: var(--lime); display: block; font-size: clamp(1.35rem, 3.3vw, 2.9rem); line-height: 1.25; letter-spacing: -.035em; overflow-wrap: anywhere; }
dl { margin: .7rem 0 1rem; }
dl div { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem .6rem; border-bottom: 1px solid #514875; padding: .5rem 0; }
dd { margin: 0; font-weight: 700; }
dd, .total strong { font-variant-numeric: tabular-nums; }
#copy { background: var(--lime); color: #252044; }
#copy-status { display: block; margin-top: .4rem; }
.guide { padding-block: 2.5rem; }
.guide h2 { font-size: clamp(1.45rem, 4vw, 2rem); }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
article { background: white; border: 1px solid var(--line); border-radius: 1rem; padding: 1.25rem; }
article h3 { margin-top: 0; }
article p, .source, .footer { color: var(--muted); }
.example { background: var(--paper); border-radius: .45rem; padding: .55rem .7rem; color: var(--ink); }
[data-example] { background: #ede8ff; color: #3926aa; }
.footer { border-top: 1px solid var(--line); padding-block: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 43rem) { .desk, .examples { grid-template-columns: 1fr; } }
select {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: .65rem;
    background: var(--paper);
    padding: .55rem .65rem;
    color: var(--ink);
    font: inherit;
}
.table-wrap { overflow-x: auto; max-height: 26rem; border: 1px solid var(--line); border-radius: .8rem; }
table { width: 100%; border-collapse: collapse; background: white; text-align: left; }
th, td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
thead { position: sticky; top: 0; background: #ede8ff; }
details { border-bottom: 1px solid var(--line); padding: .7rem 0; }
summary { cursor: pointer; font-weight: 700; }
details p { margin-bottom: .3rem; }
.calculation-steps {
    margin: 1.25rem 0;
    border-top: 1px solid #625888;
    padding-top: .85rem;
}
.calculation-steps h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.calculation-steps ol { margin: 0; padding-left: 1.35rem; }
.calculation-steps li + li { margin-top: .75rem; }
.calculation-steps li p { margin: .2rem 0; color: var(--lime); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calculation-steps small { color: #eee9ff; }
#steps-rounding { margin: .6rem 0 0; }
.calculation-steps summary { margin-bottom: .5rem; }
.calculation-steps[open] > summary { margin-bottom: .75rem; }
.history-card { margin-block: 1rem; }
.history-chart svg { width: 100%; height: auto; display: block; }
.history-grid line { stroke: var(--line); }
.history-grid text { fill: var(--muted); font-size: 13px; }
.history-standard { color: var(--accent); }
.history-reduced { color: #1e774f; }
.history-chart path { fill: none; stroke: currentColor; stroke-width: 2.5; }
.history-chart circle { fill: currentColor; }
.history-chart .history-upper { stroke-dasharray: 5 4; }
.history-legend { display: flex; gap: .4rem 1.2rem; flex-wrap: wrap; font-size: .9rem; }
.history-legend span::before { content: ''; display: inline-block; width: 1em; height: .2em; vertical-align: middle; margin-right: .4em; background: var(--accent); }
.history-legend span + span::before { background: #1e774f; }
.pdf-options label, .pdf-options textarea, .pdf-options small { display: block; }
.pdf-options textarea {
    width: 100%;
    padding: .55rem .65rem;
    margin: .35rem 0;
    border: 1px solid var(--line);
    border-radius: .65rem;
    color: var(--ink);
    font: inherit;
    resize: vertical;
}
.pdf-options .action { margin-top: .65rem; background: var(--lime); color: var(--night); }
.country-flag { display: inline-block; min-width: 1.55em; }
.result-basis {
    margin: 0 0 .8rem;
    color: #eee9ff;
    font-size: .93rem;
    font-variant-numeric: tabular-nums;
}

nav { flex-wrap: wrap; }

@media (min-width: 75rem) {
    .wrap {
        width: min(100% - 6rem, 84rem);
    }
    .intro {
        display: grid;
        grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr);
        align-items: end;
        gap: 2.5rem;
        padding-block: clamp(3rem, 5vw, 5rem) 2.25rem;
    }
    .intro h1 {
        font-size: clamp(4rem, 6vw, 5.5rem);
    }
    .intro p {
        max-width: 27rem;
        margin: 0 0 .35rem;
        font-size: 1.2rem;
    }
    .desk {
        grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr);
    }
    .inputs, .result {
        padding: clamp(2.5rem, 3vw, 3.5rem);
    }
    .inputs {
        gap: 1.55rem;
    }
    .total {
        padding: 1.15rem 1.35rem;
    }
    .total strong {
        font-size: clamp(2.9rem, 3.8vw, 3.8rem);
    }
    .examples {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .guide > p, .faq details p {
        max-width: 70ch;
    }
}

.nav-menu { position: relative; padding: 0; border: 0; }
.nav-menu ul {
    position: absolute;
    z-index: 2;
    inset-inline-end: 0;
    width: max-content;
    max-width: min(16rem, calc(100vw - 2rem));
    margin: .5rem 0 0;
    padding: .65rem .8rem;
    list-style: none;
    background: white;
    border: 1px solid var(--line);
    border-radius: .65rem;
    box-shadow: 0 .5rem 1.5rem #2520521c;
}
.tax-topics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.tax-topics h3 { margin-bottom: .45rem; }
.tax-topics p { margin-top: 0; }
.tax-topics a { color: #3926aa; }
@media (max-width: 43rem) {
    .nav-menu ul { position: static; margin-block: .5rem; }
    .tax-topics { grid-template-columns: 1fr; }
}

.theme-toggle {
    border: 1px solid var(--line);
    border-radius: .65rem;
    padding: .35rem .65rem;
    color: var(--ink);
    background: var(--paper);
}
.theme-toggle[aria-pressed="true"] { border-color: var(--accent); }
.copy-actions label { display: block; margin-bottom: .4rem; font-weight: 650; }
.copy-controls { display: flex; flex-wrap: wrap; gap: .55rem; }
.copy-actions select { min-width: 0; }
#copy-preview {
    display: block;
    width: 100%;
    margin-block: .5rem;
    border: 1px solid var(--line);
    border-radius: .55rem;
    padding: .5rem;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
}
#copy-preview-label { margin-top: .65rem; }

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #f0edf9;
    --muted: #c6bfd9;
    --paper: #171426;
    --line: #48405c;
    --accent: #b6a5ff;
    --night: #241e47;
    --lime: #ddfa9c;
}
[data-theme="dark"] :is(.top, .desk, article, table, .nav-menu ul) { background: #211b34; }
[data-theme="dark"] .brand span,
[data-theme="dark"] .inputs .action { color: #211b34; }
[data-theme="dark"] :is(thead, [data-example], .options label:has(:checked), .options button[aria-pressed="true"]) {
    background: #382d58;
    color: #e5dcff;
}
[data-theme="dark"] :is(.source a, .tax-topics a) { color: var(--accent); }
[data-theme="dark"] .history-reduced { color: #78dfad; }
[data-theme="dark"] .history-legend span + span::before { background: #78dfad; }
[data-theme="dark"] .field .error { color: #ffafbf; }
[data-theme="dark"] .pdf-options textarea { background: var(--paper); }

.nav-menu li + li { margin-top: .45rem; }
.position-row {
    display: grid;
    grid-template-columns: minmax(10rem, 2fr) minmax(5rem, .65fr) minmax(9rem, 1fr) minmax(7rem, .8fr) auto;
    align-items: end;
    gap: .65rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
    padding: .7rem;
    margin-bottom: .75rem;
}
.position-row label { display: grid; gap: .25rem; min-width: 0; }
.position-row input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: .55rem;
    background: var(--paper);
    color: var(--ink);
    padding: .45rem .55rem;
}
.position-rounding { margin-top: 1rem; }
.position-exports { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
#position-summary tfoot { font-weight: 700; }
[data-theme="dark"] #positions-form .action { color: #211b34; }
@media (max-width: 52rem) {
    .position-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .position-row label:first-of-type { grid-column: 1 / -1; }
}

.language-menu summary { white-space: nowrap; }
.language-menu a { padding: .25rem .4rem; border-radius: .35rem; text-decoration: none; }
.language-menu a[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 700; }
.brand img { flex: none; }
.intro h1 { overflow-wrap: anywhere; }

.result { --result-glow: #ddfa9c99; }
.result dd { border-radius: .3rem; }
#position-summary tfoot { --result-glow: #7054dc85; }
[data-theme="dark"] #position-summary tfoot { --result-glow: #b6a5ff99; }
