/*
 * TaxCalc.pl - own stylesheet. No external resources, no build step,
 * no url() anywhere: every ornament here is a gradient, a border or a shape.
 *
 * The system in one paragraph: a warm paper canvas, near-black ink, white
 * surfaces with large radii, and a single teal accent - the logo's - that is
 * reserved for the one thing the user should do next. Hierarchy comes from type weight,
 * space and elevation - never from a wall of colour. Reference material lives
 * inside a <details>; the next step never does.
 *
 * Colour contract:
 *   --ink      body text, headings                (>= 12:1 on the canvas)
 *   --ink-2    secondary prose, labels, captions  (>= 6:1  on the canvas)
 *   --ink-3    hairline emphasis, dots, markers   (~3.4:1 - never words)
 *   --accent   links and small accented text      (>= 5.9:1 on canvas and tint)
 *   --brand    filled actions, only with --on-accent ink on top (>= 4.5:1)
 *
 * Light and dark: every token that differs is one light-dark(light, dark) pair,
 * so the palette has a single source and the mode is chosen by `color-scheme`
 * alone. The root follows the operating system; `data-theme` on <html> (set by
 * js/theme.js from the user's pick) pins one mode, and print.css pins paper to
 * light. Never add a second, media-gated copy of the palette.
 */

:root {
    color-scheme: light dark;

    /* Canvas and surfaces ------------------------------------------------- */
    --canvas: light-dark(#f7f5f0, #0c0e0b);
    --canvas-deep: light-dark(#efece3, #090b08);
    --surface: light-dark(#ffffff, #171a14);
    --surface-sunken: light-dark(#f2efe7, #11140e);
    --surface-raised: light-dark(#ffffff, #1d211a);
    /* The lettering of the broker logos: as shipped, or white on dark. */
    --logo-ink-ibkr: light-dark(#222222, #ffffff);
    --logo-ink-degiro: light-dark(#111111, #ffffff);

    /* Ink ----------------------------------------------------------------- */
    --ink: light-dark(#101410, #f1f3e9);
    --ink-2: light-dark(#5a5d55, #a9ada0);
    --ink-3: light-dark(#84867c, #767a6d);
    --on-accent: light-dark(#ffffff, #032120);

    /* Accent -------------------------------------------------------------- */
    /* Teal from the logo (#029F9D), darkened where it carries white text. */
    --brand: light-dark(#087F7C, #35CFC9);
    --brand-deep: light-dark(#06716E, #5BD6D0);
    --brand-soft: light-dark(#D9F1EF, #123634);
    --accent: light-dark(#0A6361, #7FE0DA);
    --accent-strong: light-dark(#074F4D, #A6EBE6);
    --accent-fill: var(--brand);
    --accent-fill-hover: var(--brand-deep);
    --accent-tint: light-dark(#E1F3F1, #10302E);
    --accent-tint-strong: light-dark(#C8E9E6, #154440);

    /* Lines and elevation -------------------------------------------------- */
    --hairline: light-dark(rgba(16, 20, 16, 0.10), rgba(241, 243, 233, 0.11));
    --hairline-strong: light-dark(rgba(16, 20, 16, 0.22), rgba(241, 243, 233, 0.24));
    --shadow-1: 0 1px 2px light-dark(rgba(16, 20, 16, 0.05), rgba(0, 0, 0, 0.5));
    --shadow-2:
        0 2px 6px light-dark(rgba(16, 20, 16, 0.05), rgba(0, 0, 0, 0.45)),
        0 12px 28px -18px light-dark(rgba(16, 20, 16, 0.30), rgba(0, 0, 0, 0.8));
    --shadow-3:
        0 4px 12px light-dark(rgba(16, 20, 16, 0.06), rgba(0, 0, 0, 0.5)),
        0 26px 56px -30px light-dark(rgba(16, 20, 16, 0.40), rgba(0, 0, 0, 0.9));

    /* Decorative glow behind the top of every page ------------------------- */
    --glow-a: light-dark(rgba(2, 159, 157, 0.20), rgba(53, 207, 201, 0.10));
    --glow-b: light-dark(rgba(8, 127, 124, 0.08), rgba(53, 207, 201, 0.05));

    /* Status -------------------------------------------------------------- */
    --error: light-dark(#9f2d20, #ff9d92);
    --error-bg: light-dark(#fbeae7, #2f1512);
    --warning: light-dark(#7a4a06, #f0c579);
    --warning-bg: light-dark(#fbf1dc, #2e2410);
    --info: light-dark(#25505f, #a8d2df);
    --info-bg: light-dark(#e6f0f3, #14262c);
    --negative: light-dark(#9f2d20, #ff9d92);

    /* Shape --------------------------------------------------------------- */
    --r-1: 12px;
    --r-2: 18px;
    --r-3: 26px;
    --r-4: 34px;
    --r-pill: 980px;

    --page: 62rem;
    --page-wide: 78rem;

    --tap: 44px;

    --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* The user's pick beats the operating system; no pick means "follow it". */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

/*
 * `hidden` is how the markup ships a control that only makes sense with
 * JavaScript. The attribute has to beat the layout rules below - `.button` sets
 * `display: inline-flex`, and an author rule outranks the browser's own
 * `[hidden] { display: none }`, which would leave a "hidden" button on screen.
 */
[hidden] { display: none !important; }

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
}

/*
 * The two radial washes are the only page-level ornament: no image, no extra
 * element, and they scroll away with the top of the document instead of
 * following the reader down a long table.
 */
body {
    margin: 0;
    background-color: var(--canvas);
    background-image:
        radial-gradient(58rem 32rem at 8% -10%, var(--glow-a), transparent 60%),
        radial-gradient(44rem 28rem at 96% -4%, var(--glow-b), transparent 58%);
    background-repeat: no-repeat;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.55;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Layout ------------------------------------------------------------------ */

.container {
    width: 100%;
    max-width: var(--page);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container--wide { max-width: var(--page-wide); }
.container--workbench { max-width: 112rem; }

/* Specificity has to match `.container`, which owns the horizontal padding. */
main.container {
    display: block;
    padding-top: 2.75rem;
    padding-bottom: 4.5rem;
}

.section { margin-top: 4.5rem; }
.section--tight { margin-top: 2.25rem; }
.section:first-child { margin-top: 0; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 20;
    padding: 0.875rem 1.375rem;
    border-radius: 0 0 var(--r-2) 0;
    background: var(--brand);
    color: var(--on-accent);
    font-weight: 650;
    text-decoration: none;
}

.skip-link:focus { left: 0; }

/* Typography -------------------------------------------------------------- */

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.028em;
    text-wrap: balance;
}

h1 {
    margin: 0 0 0.875rem;
    font-size: clamp(2.1rem, 5.6vw, 3.1rem);
    line-height: 1.05;
}

h2 {
    margin: 0 0 0.625rem;
    font-size: clamp(1.4rem, 3vw, 1.875rem);
    line-height: 1.15;
}

h3 {
    margin: 0 0 0.375rem;
    font-size: 1.0625rem;
    font-weight: 650;
    letter-spacing: -0.018em;
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

.lead {
    max-width: 44rem;
    color: var(--ink-2);
    font-size: 1.1875rem;
    line-height: 1.5;
    letter-spacing: -0.014em;
}

.note {
    color: var(--ink-2);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.muted { color: var(--ink-2); }

.quiet {
    color: var(--ink-2);
    font-size: 0.875rem;
}

/*
 * A small all-caps kicker above a section title. It carries a teal tick drawn
 * with a border, so the eye finds the start of a section without a heavier rule.
 */
.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    color: var(--ink-2);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 1.375rem;
    height: 0;
    border-top: 3px solid var(--brand);
    border-radius: 3px;
}

a {
    color: var(--accent);
    font-weight: 500;
    text-decoration-color: color-mix(in srgb, currentColor 38%, transparent);
    text-decoration-thickness: from-font;
    text-underline-offset: 0.16em;
    transition: color 0.15s var(--ease), text-decoration-color 0.15s var(--ease);
}

a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

/*
 * One ring for everything. Ink is the only colour that keeps contrast on the
 * canvas, on white, and next to a filled brand button at the same time.
 */
:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
    border-radius: 6px;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
    background: var(--surface-sunken);
    padding: 0.12em 0.4em;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px var(--hairline);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Header ------------------------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    /* Vertical padding lives here: `.container` owns the inner element's. */
    padding-block: 0.5rem;
    background: color-mix(in srgb, var(--canvas) 82%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--hairline);
}

/*
 * Brand on the left, navigation and the theme switch packed on the right. On a
 * phone whatever does not fit wraps to a second row instead of overflowing.
 */
.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem 1.25rem;
    min-height: 2.5rem;
}

.site-header__brand {
    margin-right: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5625rem;
    color: var(--ink);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
}

/* The mark: the logo's calculator icon, a local PNG drawn at 26px. */
.brand-mark {
    flex: none;
    width: 1.625rem;
    height: 1.625rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.125rem;
    padding: 0 0.75rem;
    border-radius: var(--r-pill);
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 550;
    text-decoration: none;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.site-nav a:hover {
    background: color-mix(in srgb, var(--ink-3) 16%, transparent);
    color: var(--ink);
}

.site-nav a[aria-current="page"] {
    background: var(--accent-tint);
    color: var(--accent);
}

/*
 * Theme toggle: one round button. The markup ships it hidden and js/theme.js
 * reveals it - without script there is nothing to remember a pick with, and
 * the page follows the operating system anyway. The icon names the current
 * state: half a circle for the system theme, then a sun or a moon.
 */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--ink-3) 14%, transparent);
    color: var(--ink-2);
    cursor: pointer;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.theme-toggle:hover {
    background: color-mix(in srgb, var(--ink-3) 24%, transparent);
    color: var(--ink);
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.theme-toggle svg { display: none; width: 1.125rem; height: 1.125rem; }

.theme-toggle[data-theme-state="auto"] [data-icon="auto"],
.theme-toggle[data-theme-state="light"] [data-icon="light"],
.theme-toggle[data-theme-state="dark"] [data-icon="dark"] { display: block; }

/* On a phone the header wraps to three rows; pinned, it would eat a fifth of the screen. */
@media (max-width: 34rem) {
    .site-header { position: static; }
    /* The toggle joins the brand's row; the navigation takes the next one whole. */
    .theme-toggle { order: 1; width: var(--tap); height: var(--tap); }
    .site-header__inner > nav { order: 2; flex-basis: 100%; }
    .site-nav a { padding: 0 0.5rem; white-space: nowrap; }
}

/* Progress steps ---------------------------------------------------------- */

.progress { margin-bottom: 2.5rem; }

.progress__list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
}

.progress__step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3125rem 0.75rem 0.3125rem 0.3125rem;
    border-radius: var(--r-pill);
    color: var(--ink-2);
}

.progress__step + .progress__step::before {
    content: "";
    width: 1.5rem;
    height: 0;
    margin: 0 0.375rem 0 0;
    border-top: 2px solid var(--hairline-strong);
    border-radius: 2px;
}

.progress__num {
    display: grid;
    place-items: center;
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--ink-3) 20%, transparent);
    color: var(--ink-2);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.progress__step.is-current {
    background: var(--surface);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
    color: var(--ink);
}

.progress__step.is-current .progress__num {
    background: var(--brand);
    color: var(--on-accent);
    box-shadow: 0 0 0 4px var(--accent-tint);
}

.progress__step.is-current .progress__label { font-weight: 650; }

.progress__step.is-done { color: var(--ink-2); }

.progress__step.is-done .progress__num {
    background: var(--accent-tint);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.progress__step.is-done + .progress__step::before { border-top-color: var(--brand-deep); }

/* Surfaces ---------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border-radius: var(--r-4);
    padding: 2.25rem;
    box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline);
}

.panel--flush { padding: 1.75rem; }

/* Landing ----------------------------------------------------------------- */

.hero {
    display: grid;
    gap: 2.5rem;
    align-items: center;
    padding: 3rem 0 0.5rem;
}

@media (min-width: 58rem) {
    .hero {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
        gap: 3.5rem;
        padding-top: 4rem;
    }
}

.hero__text { max-width: 34rem; }

.hero h1 { font-size: clamp(2.35rem, 6.2vw, 3.75rem); }

.hero__lead { margin-bottom: 1.75rem; }

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

/*
 * Decorative only, and marked aria-hidden in the markup: a settled statement
 * turning into one number. Bars, not text, so it can never be mistaken for a
 * real figure.
 */
.hero__art {
    position: relative;
    display: none;
    padding: 1.5rem 0.75rem 1.5rem 1.5rem;
}

@media (min-width: 58rem) {
    .hero__art { display: block; }
}

.hero__art-card {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.875rem;
    padding: 1.75rem;
    border-radius: var(--r-3);
    background: var(--surface);
    box-shadow: var(--shadow-3), 0 0 0 1px var(--hairline);
}

.hero__art-card::before {
    content: "";
    position: absolute;
    inset: -1px -1px auto;
    height: 5px;
    border-radius: var(--r-3) var(--r-3) 0 0;
    background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 25%, transparent));
}

.hero__art-row {
    height: 0.625rem;
    border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--ink-3) 26%, transparent);
}

.hero__art-row:nth-child(2) { width: 82%; }
.hero__art-row:nth-child(3) { width: 64%; }
.hero__art-row:nth-child(4) { width: 74%; }

.hero__art-total {
    height: 2.5rem;
    margin-top: 0.5rem;
    border-radius: var(--r-2);
    background: linear-gradient(120deg, var(--brand), var(--brand-deep));
}

.hero__art-back {
    position: absolute;
    inset: 0 2.5rem 2.5rem 0;
    border-radius: var(--r-3);
    background: var(--accent-tint);
    box-shadow: 0 0 0 1px var(--hairline);
    transform: rotate(-4deg);
}

/*
 * Supported brokers: the heading keeps the left edge of every section, the
 * logos sit in a strip drawn in the language of the FAQ list below it -
 * hairlines above and below, one between the cells - each centred in its own
 * half. The two marks differ in build (IBKR's symbol rises above its letters,
 * DEGIRO's caps are heavier), so their heights are set to match optically.
 */
.broker-logos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 1.5rem 0 0;
    padding: 0;
    border-block: 1px solid var(--hairline);
    list-style: none;
}

.broker-logos li {
    display: grid;
    place-items: center;
    min-height: 6rem;
    padding: 1.25rem 1.5rem;
}

.broker-logos li + li { border-left: 1px solid var(--hairline); }

/*
 * Third-party logos as their owners draw them; only the lettering follows the
 * theme (currentColor) - dark as shipped on the light canvas, white on the
 * dark one, the inverse variant IBKR itself publishes.
 */
.broker-logo { display: block; width: auto; max-width: 100%; height: 2.25rem; }
.broker-logo--ibkr { color: var(--logo-ink-ibkr); }
.broker-logo--degiro { height: 1.625rem; color: var(--logo-ink-degiro); }

@media (max-width: 34rem) {
    .broker-logos { grid-template-columns: minmax(0, 1fr); }
    .broker-logos li { min-height: 4.5rem; padding: 1rem; }
    .broker-logos li + li { border-left: 0; border-top: 1px solid var(--hairline); }
    .broker-logo { height: 2rem; }
    .broker-logo--degiro { height: 1.375rem; }
}

/*
 * Closing call to action. The teal wash is a background, so the ink on top is
 * still --ink and the contrast is the same as anywhere else on the page.
 */
.cta-band {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem 2rem;
    margin-top: 4.5rem;
    padding: 2rem 2.25rem;
    border-radius: var(--r-4);
    background:
        radial-gradient(24rem 14rem at 96% 120%, color-mix(in srgb, var(--brand) 45%, transparent), transparent 70%),
        var(--accent-tint);
    box-shadow: 0 0 0 1px var(--hairline);
}

.cta-band__text { max-width: 34rem; }
.cta-band h2 { margin-bottom: 0.25rem; }
.cta-band p { margin: 0; color: var(--ink-2); }
.cta-band .actions { margin: 0; }

/* Disclosures ------------------------------------------------------------- */

.disclosure-group { margin-top: 1.5rem; }

.disclosure { border-top: 1px solid var(--hairline); }

.disclosure-group > .disclosure:last-child { border-bottom: 1px solid var(--hairline); }

.disclosure > summary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: var(--tap);
    padding: 0.75rem 0;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.018em;
    cursor: pointer;
    list-style: none;
}

.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::marker { content: ""; }

/*
 * The affordance is a circle (::after, a flex item) with a chevron on top
 * (::before, taken out of flow and centred over it). Two borders on a rotated
 * box - no glyph, no image, and it flips when the section opens.
 */
.disclosure > summary::after {
    content: "";
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--surface-sunken);
    box-shadow: inset 0 0 0 1px var(--hairline);
    transition: background-color 0.15s var(--ease);
}

.disclosure > summary::before {
    content: "";
    position: absolute;
    right: 0.65rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.32rem;
    border-right: 2px solid var(--ink-2);
    border-bottom: 2px solid var(--ink-2);
    border-radius: 0 0 2px 0;
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease), border-color 0.15s var(--ease), margin-top 0.25s var(--ease);
}

.disclosure[open] > summary::before {
    margin-top: -0.14rem;
    transform: rotate(-135deg);
}

.disclosure > summary:hover { color: var(--accent); }
.disclosure > summary:hover::after { background: var(--accent-tint); }
.disclosure > summary:hover::before { border-color: var(--accent); }

.disclosure__body {
    padding: 0.25rem 0 1.75rem;
    max-width: 48rem;
    color: var(--ink-2);
    font-size: 0.9375rem;
}

.disclosure__body > :last-child { margin-bottom: 0; }
.container--workbench .disclosure__body { max-width: none; }
.disclosure__body h3 { color: var(--ink); margin-top: 1.75rem; }
.disclosure__body h3:first-child { margin-top: 0; }
.disclosure__body strong { color: var(--ink); font-weight: 650; }

.disclosure--card {
    border: 0;
    background: var(--surface);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
    padding: 0 1.5rem;
    transition: box-shadow 0.2s var(--ease);
}

.disclosure--card:hover { box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline); }
.disclosure--card + .disclosure--card { margin-top: 0.625rem; }
.disclosure--card .disclosure__body { padding-bottom: 1.5rem; }

/* A teal tick appears on the open card, so the reader keeps their place. */
.disclosure--card[open] { box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline); }
.disclosure--card[open] > summary { color: var(--ink); }

.list-plain {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.list-plain > li {
    position: relative;
    padding: 0.5rem 0 0.5rem 1.125rem;
    border-top: 1px solid var(--hairline);
}

.list-plain > li:first-child { border-top: 0; }

.list-plain > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.0625rem;
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: var(--ink-3);
}

/* Forms ------------------------------------------------------------------- */

.field { margin-bottom: 1.75rem; }
.field:last-child { margin-bottom: 0; }

.field > label {
    display: block;
    margin-bottom: 0.4375rem;
    font-size: 0.9375rem;
    font-weight: 650;
}

.field__hint {
    margin: 0.625rem 0 0;
    color: var(--ink-2);
    font-size: 0.875rem;
    line-height: 1.45;
}

input[type="text"],
input[type="date"],
input[type="number"],
select {
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-1);
    padding: 0.5rem 0.6875rem;
    max-width: 100%;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input[type="text"]:hover,
input[type="date"]:hover,
select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline-strong)); }

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-tint);
    outline: none;
}

/* The ring stays visible for keyboard users on top of the tinted glow. */
input[type="text"]:focus-visible,
input[type="date"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

select {
    padding-right: 2rem;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink-2) 50%, var(--ink-2) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
        linear-gradient(-45deg, transparent 50%, var(--ink-2) 50%, var(--ink-2) calc(50% + 1.5px), transparent calc(50% + 1.5px));
    background-position: right 1.05rem top 55%, right 0.65rem top 55%;
    background-size: 0.4rem 0.4rem;
    background-repeat: no-repeat;
}

.field__hint + .quiet { margin-top: 0.5rem; }

.field--inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0;
}

.field--inline > label { margin-bottom: 0; }

/* File area */

.dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 0.625rem;
    padding: 2.75rem 1.5rem;
    border: 2px dashed color-mix(in srgb, var(--accent) 32%, var(--hairline-strong));
    border-radius: var(--r-3);
    background:
        radial-gradient(20rem 10rem at 50% -10%, var(--accent-tint), transparent 70%),
        var(--surface-sunken);
    text-align: center;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.2s var(--ease);
}

/* A tray with an arrow dropping into it, drawn from borders alone. */
.dropzone__icon {
    position: relative;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.25rem;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--hairline), var(--shadow-1);
}

/* Stem and head of an upward arrow: a file going out of the machine, not in. */
.dropzone__icon::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0.75rem;
    width: 2px;
    height: 1.5rem;
    margin-left: -1px;
    border-radius: 2px;
    background: var(--accent);
}

.dropzone__icon::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 0.9375rem;
    width: 0.625rem;
    height: 0.625rem;
    margin-left: -0.3125rem;
    border-left: 2px solid var(--accent);
    border-top: 2px solid var(--accent);
    border-radius: 3px 0 0 0;
    transform: rotate(45deg);
}

.dropzone__label {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 650;
    letter-spacing: -0.016em;
    cursor: pointer;
}

.dropzone input[type="file"] {
    font: inherit;
    font-size: 0.9375rem;
    max-width: 100%;
    color: var(--ink-2);
}

.dropzone input[type="file"]::file-selector-button {
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 650;
    min-height: 2.5rem;
    margin-right: 0.75rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 0 0 1px var(--hairline-strong);
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.dropzone input[type="file"]::file-selector-button:hover { background: var(--accent-tint); }

.dropzone__hint {
    margin: 0;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.dropzone__status {
    margin: 0;
    min-height: 1.375rem;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 650;
}

.dropzone.is-dragover {
    border-color: var(--accent);
    border-style: solid;
    background: var(--accent-tint);
    transform: scale(1.005);
}

.dropzone.is-filled {
    border-style: solid;
    border-color: var(--accent);
    background: var(--surface);
}

.dropzone:focus-within {
    border-color: var(--accent);
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

/* Buttons ----------------------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--tap);
    padding: 0 1.5rem;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--hairline-strong), var(--shadow-1);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.014em;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), box-shadow 0.2s var(--ease), transform 0.12s var(--ease), color 0.15s var(--ease);
}

.button:hover {
    background: var(--accent-tint);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow-1);
    transform: translateY(-1px);
}

.button:active { transform: translateY(0); }

.button--primary {
    background: var(--brand);
    box-shadow: 0 1px 2px rgba(16, 20, 16, 0.10), 0 10px 22px -14px rgba(16, 20, 16, 0.55);
    color: var(--on-accent);
}

.button--primary:hover {
    background: var(--brand-deep);
    color: var(--on-accent);
    box-shadow: 0 2px 4px rgba(16, 20, 16, 0.12), 0 16px 30px -16px rgba(16, 20, 16, 0.55);
}

.button--quiet {
    background: color-mix(in srgb, var(--ink-3) 15%, transparent);
    box-shadow: none;
    color: var(--ink);
}

.button--quiet:hover {
    background: color-mix(in srgb, var(--ink-3) 24%, transparent);
    box-shadow: none;
    color: var(--ink);
}

.button--plain,
.button--link {
    background: none;
    box-shadow: none;
    padding: 0 0.625rem;
    color: var(--accent);
}

.button--plain:hover,
.button--link:hover {
    background: none;
    box-shadow: none;
    color: var(--accent-strong);
    text-decoration: underline;
    transform: none;
}

.button--large {
    min-height: 3.25rem;
    padding: 0 2rem;
    font-size: 1.0625rem;
}

/* A chevron that nudges forward on hover: the affordance of "next step". */
.button--next::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    border-radius: 0 2px 0 0;
    transform: rotate(45deg);
    transition: transform 0.2s var(--ease);
}

.button--next:hover::after { transform: rotate(45deg) translate(2px, -2px); }

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 1.75rem 0 0;
}

.actions--start { margin-top: 0; }

/* The guide link under the upload button: clear of the button, not a hint glued to it. */
.upload-help { margin-top: 1.5rem; }

/* Sticky action bar (review screen) */

.action-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding: 0.875rem 0;
    border-top: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--canvas) 90%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
}

.action-bar__spacer { flex: 1 1 auto; }

@media (max-width: 34rem) {
    .action-bar { padding: 0.75rem 0; }
    .action-bar .button--primary { flex: 1 1 100%; }
    .action-bar .button--quiet,
    .action-bar .button--plain { flex: 1 1 40%; }
    .action-bar__spacer { display: none; }
}

/* Messages ---------------------------------------------------------------- */

.messages {
    max-width: 58rem;
    margin: 0 0 1.75rem;
}

.messages--after { margin-top: 1.75rem; }

.message {
    position: relative;
    margin: 0 0 0.5rem;
    padding: 0.8125rem 1.125rem 0.8125rem 1.125rem;
    border-radius: var(--r-2);
    border-left: 4px solid currentColor;
    font-size: 0.9375rem;
    line-height: 1.45;
}

.message:last-child { margin-bottom: 0; }

.message--error { background: var(--error-bg); color: var(--error); }
.message--warning { background: var(--warning-bg); color: var(--warning); }
.message--info { background: var(--info-bg); color: var(--info); }

.message strong { font-weight: 700; }

.message-group {
    margin: 0 0 0.5rem;
    border-radius: var(--r-2);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--hairline);
}

.message-group > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.875rem;
    padding: 0 1.125rem;
    color: var(--ink-2);
    font-size: 0.9375rem;
    font-weight: 550;
    cursor: pointer;
    list-style: none;
}

.message-group > summary::-webkit-details-marker { display: none; }
.message-group > summary::marker { content: ""; }
.message-group > summary:hover { color: var(--ink); }

.message-group > summary::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid var(--ink-3);
    border-bottom: 2px solid var(--ink-3);
    border-radius: 0 0 2px 0;
    transform: rotate(45deg) translateY(-0.1rem);
    transition: transform 0.2s var(--ease);
}

.message-group[open] > summary::after { transform: rotate(-135deg); }

.message-group__body { padding: 0 0.625rem 0.625rem; }

/* Tables ------------------------------------------------------------------ */

.table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--r-2);
    box-shadow: 0 0 0 1px var(--hairline);
    scrollbar-width: thin;
    scrollbar-color: var(--ink-3) transparent;
    overscroll-behavior-x: contain;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.table caption {
    caption-side: top;
    text-align: left;
    padding: 0.875rem 1.125rem 0.25rem;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.6875rem 1rem;
    border-top: 1px solid var(--hairline);
    text-align: left;
    vertical-align: middle;
}

.table thead th {
    position: relative;
    border-top: 0;
    background: var(--surface-sunken);
    color: var(--ink-2);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table thead th:first-child { border-radius: var(--r-2) 0 0 0; }
.table thead th:last-child { border-radius: 0 var(--r-2) 0 0; }

.table tbody tr:first-child th,
.table tbody tr:first-child td { border-top: 1px solid var(--hairline); }

.table tbody tr:hover { background: color-mix(in srgb, var(--accent-tint) 55%, transparent); }

.table td { font-variant-numeric: tabular-nums; }
.table tbody th { font-weight: 650; }

.table--detail { font-size: 0.875rem; }
.table--detail td, .table--detail th { white-space: nowrap; }

.table--compact th,
.table--compact td { padding: 0.5rem 1rem; }

/* Editable review tables */

.table--editable input[type="text"],
.table--editable input[type="date"],
.table--editable select {
    font-size: 0.9375rem;
    padding: 0.4375rem 0.5625rem;
}

.table--editable td { vertical-align: top; }
.table--editable tbody tr:hover { background: none; }

.cell-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}

.cell-group--pair { flex-wrap: nowrap; }

.input--name { width: 100%; min-width: 8rem; font-weight: 550; }
.input--currency { width: 4.75rem; text-transform: uppercase; }
.input--amount { width: 6.25rem; font-variant-numeric: tabular-nums; }
.input--quantity { width: 5.25rem; font-variant-numeric: tabular-nums; }
.input--date { width: 8.25rem; }

.row-ordinal {
    display: inline-block;
    min-width: 1.25rem;
    padding-top: 0.5rem;
    color: var(--ink-3);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    vertical-align: top;
}

.cell--instrument { min-width: 12rem; }
.cell--instrument .cell-group { align-items: flex-start; }
.cell--instrument .cell-group > .input--name { flex: 1 1 8rem; }

.cell--country select { width: 100%; max-width: 12rem; }

.cell--remove { text-align: center; }

/*
 * The label, not the box, is the target. At desktop density it hugs the
 * checkbox; the mobile block below grows it to the 44x44 minimum without
 * inflating the box itself, which would look out of scale next to the inputs.
 */
.remove-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.4375rem 0 0;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.remove-toggle:hover { background: color-mix(in srgb, var(--error) 12%, transparent); }

/* "Usuń" in the dividend and fee editors: a button that takes the row off at once. */
.row-remove {
    min-height: 2rem;
    padding-inline: 0;
    color: var(--error);
    font-size: 0.875rem;
}

.row-remove:hover { color: var(--error); }

.cell--source {
    color: var(--ink-2);
    font-size: 0.8125rem;
    max-width: 14rem;
    white-space: normal;
}

.row--needs-attention .cell--country select {
    border-color: color-mix(in srgb, var(--warning) 60%, transparent);
    background-color: var(--warning-bg);
}


/* Technical columns, revealed by the review toggle (works without JS) */

.cell--tech { display: none; }

/*
 * The toggle is a real checkbox next to a real label, so the technical columns
 * can be revealed with the keyboard and with JavaScript switched off. Both
 * elements are siblings of `.review-body` on purpose - that is what lets plain
 * CSS reach the cells inside it.
 */
.tech-toggle__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.tech-toggle__label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    margin: 0 0 1rem auto;
    min-height: 2.5rem;
    padding: 0 1rem;
    border-radius: var(--r-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--hairline-strong);
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 550;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

/*
 * A miniature switch: a pill track with the knob painted by a radial gradient,
 * moved to the other end when the box is checked. No extra element, no image.
 */
.tech-toggle__label::before {
    content: "";
    flex: none;
    width: 1.875rem;
    height: 1.0625rem;
    border-radius: var(--r-pill);
    background-color: color-mix(in srgb, var(--ink-3) 55%, transparent);
    background-image: radial-gradient(circle 0.34375rem at 0.53125rem 50%, var(--surface) 98%, transparent 100%);
    transition: background-color 0.2s var(--ease);
}

.tech-toggle__input:hover + .tech-toggle__label { color: var(--ink); }

.tech-toggle__input:focus-visible + .tech-toggle__label {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.tech-toggle__input:checked + .tech-toggle__label {
    background: var(--accent-tint);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--accent);
}

.tech-toggle__input:checked + .tech-toggle__label::before {
    background-color: var(--accent);
    background-image: radial-gradient(circle 0.34375rem at calc(100% - 0.53125rem) 50%, var(--surface) 98%, transparent 100%);
}

.tech-toggle__input:checked ~ .review-body .cell--tech { display: table-cell; }

/* Review summary bar ------------------------------------------------------ */

.review-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2rem;
    margin-bottom: 1.75rem;
    padding: 1.25rem 1.75rem;
    background: var(--surface);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}

.review-bar__counts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 0;
    color: var(--ink-2);
    font-size: 0.9375rem;
}

.review-bar__counts > span {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4375rem;
    padding: 0.25rem 0.875rem;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
}

.review-bar__counts b {
    color: var(--ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Pushed to the far end of the bar; drops below the counts when they wrap. */
.review-bar__privacy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0 auto;
    color: var(--ink-2);
    font-size: 0.8125rem;
}

.review-bar__privacy::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--brand-deep);
    box-shadow: 0 0 0 3px var(--accent-tint);
}

.review-section { margin-top: 2.75rem; }
.review-body > .review-section:first-child { margin-top: 0.5rem; }
.review-section > h2 { font-size: 1.25rem; margin-bottom: 0.875rem; }

/* Result ------------------------------------------------------------------ */

.verdict {
    position: relative;
    overflow: hidden;
    margin: 0 0 1.25rem;
    padding: 2.25rem;
    background:
        radial-gradient(30rem 18rem at 100% 0%, var(--accent-tint), transparent 68%),
        var(--surface);
    border-radius: var(--r-4);
    box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline);
}

/* One teal rule across the top: the page's single loudest signal. */
.verdict::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 20%, transparent));
}

.verdict > h2 { margin-top: 0.25rem; }

.verdict__caption {
    margin: 0 0 1.5rem;
    max-width: 46rem;
    color: var(--ink-2);
    font-size: 0.9375rem;
}

.verdict__pair {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 40rem) {
    .verdict__pair {
        grid-template-columns: 1fr 1fr;
        gap: 2.5rem;
    }

    .verdict__pair > div + div {
        padding-left: 2.5rem;
        border-left: 1px solid var(--hairline);
    }
}

.verdict__label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.375rem;
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.verdict__label::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--brand-deep);
}

.verdict__pair > div + div .verdict__label::before { background: var(--ink-3); }

.verdict__amount {
    display: block;
    font-size: clamp(2.25rem, 6.4vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.038em;
    line-height: 1.02;
    font-variant-numeric: tabular-nums;
}

.verdict__unit {
    font-size: 0.4em;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--ink-2);
    margin-left: 0.3em;
}

.verdict__sub {
    margin: 0.5rem 0 0;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.verdict__note {
    margin: 1.75rem 0 0;
    padding-top: 1.375rem;
    border-top: 1px solid var(--hairline);
    color: var(--ink-2);
    font-size: 0.9375rem;
}

.figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
    gap: 0.75rem;
    margin: 0 0 1.5rem;
}

.figure {
    position: relative;
    overflow: hidden;
    padding: 1.25rem 1.375rem;
    background: var(--surface);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}

.figure::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent-tint-strong);
}

.figure__label {
    display: block;
    margin-bottom: 0.3125rem;
    color: var(--ink-2);
    font-size: 0.8125rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.figure__value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.028em;
    font-variant-numeric: tabular-nums;
}

.figure--negative .figure__value { color: var(--negative); }
.figure--negative { color: var(--negative); }
.figure--negative::before { background: color-mix(in srgb, var(--negative) 45%, transparent); }
.figure--total { font-weight: 700; }

.figures { margin: 0 0 1rem; }
.figures dt { color: var(--ink); font-weight: 650; margin-top: 1rem; }
.figures dt:first-child { margin-top: 0; }
.figures dd { margin: 0.1875rem 0 0; color: var(--ink-2); }

.download-band {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    padding: 1.5rem 1.75rem;
    border-radius: var(--r-3);
    background: var(--surface-sunken);
    box-shadow: 0 0 0 1px var(--hairline);
}

.download-band__text { max-width: 28rem; }
.download-band__text h2 { font-size: 1.125rem; margin-bottom: 0.25rem; }

.download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 0;
}

.download-note { margin: 0.5rem 0 0; }

@media (max-width: 34rem) {
    .download-actions { flex-direction: column; align-items: stretch; }
    .download-actions .button { width: 100%; }
}

/* Error page -------------------------------------------------------------- */

.error-page {
    max-width: 36rem;
    margin: 3rem auto 0;
    padding: 2.5rem;
    border-radius: var(--r-4);
    background: var(--surface);
    box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline);
    text-align: left;
}

.error-page__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding: 0.375rem 0.9375rem 0.375rem 0.75rem;
    border-radius: var(--r-pill);
    background: var(--accent-tint);
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.error-page__badge::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
}

.error-page > .quiet {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--hairline);
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
    margin-top: 5rem;
    padding: 2.5rem 0 3rem;
    border-top: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--canvas-deep) 70%, transparent);
    color: var(--ink-2);
    font-size: 0.8125rem;
    line-height: 1.55;
}

.site-footer p { margin: 0 0 0.625rem; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { color: var(--ink-2); font-weight: 550; }
.site-footer a:hover { color: var(--ink); }

.site-footer__grid {
    display: grid;
    gap: 1.25rem 3rem;
}

@media (min-width: 46rem) {
    .site-footer__grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

.disclaimer {
    color: var(--ink-2);
    padding-left: 0.875rem;
    border-left: 3px solid var(--brand-deep);
}

/* Print helpers used on the printable report page ------------------------- */

.printable .disclosure__body { max-width: none; }

.print-header {
    margin-bottom: 2.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hairline);
}

.print-header__brand {
    display: flex;
    align-items: center;
    gap: 0.5625rem;
    margin-bottom: 1rem;
    color: var(--ink-2);
    font-size: 0.8125rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.print-footer { margin-top: 2.5rem; color: var(--ink-2); font-size: 0.875rem; }

/*
 * Shown only when JavaScript is off, in place of the print button - see the
 * comment in report/print.html.twig.
 */
.print-hint {
    flex: 1 1 18rem;
    color: var(--ink-2);
    font-size: 0.9375rem;
    line-height: 1.45;
}

kbd {
    font-family: inherit;
    font-size: 0.9375em;
    font-weight: 650;
    padding: 0.08em 0.4em;
    border-radius: 6px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--hairline-strong), 0 1px 0 var(--hairline-strong);
    color: var(--ink);
    white-space: nowrap;
}

/* Narrow screens: review tables become stacked cards --------------------- */

@media (max-width: 47.99rem) {
    main.container { padding-top: 2rem; }

    .panel { padding: 1.5rem; border-radius: var(--r-3); }
    .hero { padding-top: 2rem; }
    .dropzone { padding: 2rem 1rem; }
    .verdict { padding: 1.5rem; }
    .cta-band { padding: 1.75rem 1.5rem; }
    .review-bar { padding: 1.125rem 1.25rem; }
    .download-band { padding: 1.25rem; }
    .error-page { padding: 1.75rem; }

    .table-wrapper--editable {
        background: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    .table--editable { display: block; }
    .table--editable caption { padding: 0 0 0.75rem; }
    .table--editable thead { display: none; }
    .table--editable tbody { display: block; }

    .table--editable tr {
        display: block;
        margin-bottom: 0.75rem;
        padding: 1rem 1.125rem;
        background: var(--surface);
        border-radius: var(--r-2);
        box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
    }

    .table--editable td {
        display: grid;
        grid-template-columns: 6.5rem 1fr;
        align-items: center;
        gap: 0.75rem;
        padding: 0.375rem 0;
        border: 0;
    }

    .table--editable td::before {
        content: attr(data-label);
        color: var(--ink-2);
        font-size: 0.75rem;
        font-weight: 650;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    .table--editable .cell--instrument {
        padding-bottom: 0.625rem;
        border-bottom: 1px solid var(--hairline);
        margin-bottom: 0.375rem;
    }

    .table--editable .cell--remove { text-align: left; }
    .table--editable .row-ordinal { display: none; }
    .table--editable tbody tr:first-child td { border-top: 0; }
    .table--editable .cell-group--pair { flex-wrap: wrap; }
    .table--editable .input--name,
    .table--editable .input--date,
    .table--editable .input--amount { width: 100%; }

    .table--editable td.cell--tech { display: none; }
    .tech-toggle__input:checked ~ .review-body td.cell--tech { display: grid; }
    .tech-toggle__input:checked ~ .review-body th.cell--tech { display: none; }

    /*
     * Touch targets. A pointer on glass is roughly 44 CSS pixels wide, so every
     * control the review screen asks a finger to hit gets at least that much -
     * the compact editable fields, the delete toggle and the technical-details
     * switch. Confined to this block on purpose: at desktop density the same
     * sizes would spread one row of the table over two screens.
     *
     * The 1rem font size is part of the target, not decoration: iOS zooms the
     * page in on any focused field below 16px, which throws the layout off.
     */
    .table--editable input[type="text"],
    .table--editable input[type="date"],
    .table--editable select {
        min-height: var(--tap);
        padding: 0.5rem 0.6875rem;
        font-size: 1rem;
    }

    .table--editable .row-remove { min-height: var(--tap); font-size: 1rem; }

    .tech-toggle__label {
        min-height: var(--tap);
        padding: 0 1.125rem;
        margin-right: 0;
    }

    /* Reference tables stay readable by scrolling, never by shrinking. */
    .table--detail { font-size: 0.8125rem; }
}

/* Very narrow: the step rail wraps rather than clipping. */
@media (max-width: 26rem) {
    .container { padding: 0 1.125rem; }
    .progress__step + .progress__step::before { width: 0.75rem; margin-right: 0.25rem; }
    .progress__step { padding-right: 0.5rem; }
    .hero h1 { font-size: 2.15rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    /* Movement, not just its duration: nothing here may shift under the pointer. */
    .button:hover,
    .dropzone.is-dragover { transform: none; }
}

/* Higher contrast: drop the decorative washes and firm up every line. */
@media (prefers-contrast: more) {
    :root {
        --ink-2: light-dark(#43463f, #c9ccbf);
        --hairline: light-dark(rgba(16, 20, 16, 0.28), rgba(241, 243, 233, 0.32));
        --hairline-strong: light-dark(rgba(16, 20, 16, 0.55), rgba(241, 243, 233, 0.60));
        --glow-a: transparent;
        --glow-b: transparent;
    }

    .verdict,
    .figure,
    .panel,
    .disclosure--card { box-shadow: 0 0 0 1.5px var(--hairline-strong); }
}

/*
 * Printing any page: disclosures must not swallow content. JavaScript opens
 * every <details> before printing; these rules cover the case where it is off.
 */
@media print {
    .site-header,
    .site-footer,
    .skip-link,
    .progress,
    .no-print,
    .hero__art,
    .cta-band,
    .tech-toggle__label,
    .action-bar { display: none !important; }

    body { background: #fff; color: #000; }

    .disclosure > summary::after,
    .message-group > summary::after { display: none; }

    details > summary { list-style: none; }
    details::details-content { content-visibility: visible !important; }
    details:not([open]) > *:not(summary) { display: block !important; }

    .cell--tech { display: table-cell !important; }
}

/* Unified calculator workbench ------------------------------------------- */

.workbench-heading,
.panel-heading,
.workbench-bar,
.tablist {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.workbench-heading { margin-bottom: 1.25rem; }
.workbench-heading__privacy {
    margin: 0;
    color: var(--ink-2);
    font-size: 0.875rem;
}

.workbench-bar {
    position: sticky;
    top: 4rem;
    z-index: 8;
    margin-bottom: 1.25rem;
    padding: 0.875rem 1rem;
    border-radius: var(--r-2);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow-2), 0 0 0 1px var(--hairline);
    backdrop-filter: blur(16px);
}

.workbench-counts {
    display: flex;
    flex: 1 1 22rem;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0;
}

.workbench-counts span {
    padding: 0.2rem 0.65rem;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    color: var(--ink-2);
    font-size: 0.8125rem;
}

.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.tablist {
    justify-content: flex-start;
    gap: 0.25rem;
    padding: 0.375rem;
    border-radius: var(--r-2);
    background: var(--surface-sunken);
}

.tablist [role="tab"] {
    min-height: var(--tap);
    padding: 0.55rem 1rem;
    border: 0;
    border-radius: calc(var(--r-2) - 4px);
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 650;
    cursor: pointer;
}

.tablist [role="tab"][aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}

.workbench-panel {
    width: 100%;
    margin-top: 1rem;
    padding: 1.5rem;
    border-radius: var(--r-3);
    background: var(--surface);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}

.workbench-panel > .table-wrapper,
.workbench-panel [data-fragment] > .table-wrapper,
.workbench-panel .disclosure__body > .table-wrapper { width: 100%; }
.panel-heading { margin-bottom: 1rem; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }

.result-unavailable {
    padding: 2rem;
    border: 1px dashed var(--hairline-strong);
    border-radius: var(--r-2);
    background: var(--surface-sunken);
}

.pit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.dividend-summary { margin-bottom: 1.25rem; }
.dividend-summary .pit-fields dd .cell-note { margin-top: 0.125rem; }

.dividend-countries caption {
    margin-bottom: 0.5rem;
    text-align: left;
    caption-side: top;
}

.settings-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
}

.settings-grid .field--inline { margin-bottom: 0.75rem; }

.settings-help { display: grid; gap: 0.625rem; margin: 0 0 0.75rem; }

.settings-help dt {
    color: var(--ink);
    font-weight: 650;
}

.settings-help dd {
    margin: 0.125rem 0 0;
    color: var(--ink-2);
}

/* One text size across the settings cards: labels, choices, help and notes. */
.settings-grid .field--inline > label,
.settings-grid select,
.settings-help dt,
.settings-help dd,
.settings-grid .note { font-size: 0.9375rem; line-height: 1.5; }
.settings-grid .field--inline > label { font-weight: 650; }

.pit-card {
    padding: 1.25rem;
    border-radius: var(--r-2);
    background: var(--surface-sunken);
    box-shadow: inset 0 0 0 1px var(--hairline);
}
.pit-card--wide { margin-bottom: 1rem; }
.pit-fields { display: grid; gap: 0; margin: 0; }
.pit-fields > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    padding: 0.625rem 0;
    border-top: 1px solid var(--hairline);
}
.pit-fields > div:first-child { border-top: 0; }
.pit-fields dt { color: var(--ink-2); }
.pit-fields dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.reconciliation {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--hairline-strong);
    font-size: 0.875rem;
}

.table--editable input:not([type="hidden"]),
.table--editable select {
    max-width: 18rem;
    margin: 0.1rem;
    padding: 0.4rem 0.5rem;
    font: inherit;
    font-size: 0.875rem;
}
.cell-note { display: block; color: var(--ink-2); font-size: 0.72rem; }

/*
 * Step-by-step broker help with screenshots. The numbers are a CSS counter in
 * the style of a small numbered badge; the screenshots are local files, framed so a
 * dark broker UI still reads as a picture on the light canvas.
 */
.tutorial {
    counter-reset: tutorial;
    display: grid;
    gap: 1.25rem;
    margin: 1rem 0 1.5rem;
    padding: 0;
    list-style: none;
}

.tutorial__step {
    counter-increment: tutorial;
    position: relative;
    padding-left: 2.75rem;
}

.tutorial__step::before {
    content: counter(tutorial);
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 10px;
    background: var(--accent-tint);
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tutorial__step > p { margin: 0.25rem 0 0.625rem; }

.tutorial__shot { margin: 0; }

.tutorial__shot img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--r-1);
    box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline);
}

/* Marks an option position in the FIFO table; a written one is the case people misread. */
.position-kind { font-weight: 650; color: var(--accent); }
.position-kind--short { color: var(--warning); }
.toggle-label { display: inline-flex; align-items: center; gap: 0.35rem; min-height: var(--tap); }

.attention-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--ink-3) 18%, transparent);
    color: var(--ink-2);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.attention-count--blocking {
    background: var(--error-bg);
    color: var(--error);
}

.attention-empty {
    padding: 2rem;
    border: 1px dashed var(--hairline-strong);
    border-radius: var(--r-2);
    background: var(--surface-sunken);
}

.attention-empty h2,
.attention-empty p { margin-bottom: 0.4rem; }

.attention-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.attention-item {
    padding: 1rem 1.125rem;
    border-left: 4px solid var(--warning);
    border-radius: var(--r-2);
    background: var(--warning-bg);
}

.attention-item--blocking {
    border-left-color: var(--error);
    background: var(--error-bg);
}

.attention-action {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attention-action select {
    max-width: 18rem;
    padding: 0.4rem 0.5rem;
    font: inherit;
    font-size: 0.875rem;
}

.attention-action .button--link {
    min-height: 2rem;
    padding-inline: 0;
    font-size: 0.8125rem;
}

.attention-item__level {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--ink-2);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.attention-item p { margin: 0 0 0.45rem; }
.attention-item a { font-size: 0.875rem; font-weight: 650; }

/*
 * Transakcje: a read-only ledger. One table per FIFO queue, one <tbody> per
 * trade - its summary row, then a row holding the "Szczegóły" and "Edytuj"
 * disclosures. Without JavaScript their <summary> elements are the toggles;
 * with it (.is-enhanced) the buttons in the summary row are, and the panels
 * row exists only while one of them is open.
 */
.trade-ledger { display: grid; gap: 2rem; }

/* Clear the sticky header and workbench bar when a hash brings a row up. */
.trade,
.attention-item { scroll-margin-top: 13rem; }

.ledger-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--r-1);
    background: var(--warning-bg);
    color: var(--warning);
    font-size: 0.875rem;
}

.ledger-notice p { margin: 0; }
.ledger-notice .button--link { padding-inline: 0; color: inherit; font-weight: 650; }

.ledger-section { display: grid; gap: 1.25rem; }
.ledger-section > h3 { margin: 0; font-size: 1.125rem; }
.ledger-section--new > .note { margin: 0; }

.instrument { display: grid; gap: 0.5rem; min-width: 0; }

.instrument__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
}

.instrument__title { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.instrument__symbol { color: var(--ink-2); font-weight: 500; }

.instrument__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.875rem;
    margin: 0;
    color: var(--ink-2);
    font-size: 0.8125rem;
}

.ledger-table th,
.ledger-table td { vertical-align: top; }
.ledger-table tbody tr:hover { background: none; }
.ledger-table .cell--number { text-align: right; white-space: nowrap; }
.ledger-table .trade__summary > td { border-top: 1px solid var(--hairline); }
.ledger-table .trade:hover > .trade__summary { background: color-mix(in srgb, var(--accent-tint) 55%, transparent); }

/*
 * With JavaScript the summary row opens the details. An open trade keeps the
 * hover colour on both its rows, and the visually hidden details button shows
 * its keyboard focus on the row it stands for.
 */
.trade-ledger.is-enhanced .trade__summary { cursor: pointer; }
.ledger-table .trade.is-open:not(.is-editing) > tr { background: color-mix(in srgb, var(--accent-tint) 55%, transparent); }
.trade__actions .button.visually-hidden { min-height: 0; }
.trade:has([data-trade-toggle="details"]:focus-visible) > .trade__summary {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Seven data columns share the width evenly; "Edytuj" sits at the right edge. */
@media (min-width: 48rem) {
    .ledger-table { table-layout: fixed; min-width: 52rem; }
    .ledger-table__actions { width: 6rem; }
}

.trade__side { font-weight: 650; }
.trade__side--sell { color: var(--accent); }
.trade__result { white-space: nowrap; }
/* .table td would otherwise win and leave "Edytuj" at the cell's left. */
.ledger-table .trade__actions { text-align: right; white-space: nowrap; }
.trade__actions .button { min-height: 2rem; padding-right: 0; font-size: 0.875rem; }
.ledger-table .trade__panels > td { padding-top: 0; border-top: 0; }
.trade__panel + .trade__panel { margin-top: 0.5rem; }

.trade__panel > summary {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 650;
    cursor: pointer;
}

.trade-ledger.is-enhanced .trade__panel > summary { display: none; }
.trade-ledger.is-enhanced .trade__panels:not(:has(details[open])) { display: none; }

.trade.is-editing > tr { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
.ledger-table .trade.is-editing:hover > .trade__summary { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
.trade.is-editing > tr > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.trade.is-removed .trade__summary > td:not(.trade__actions) { opacity: 0.5; text-decoration: line-through; }

.flag {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    color: var(--warning);
    font-size: 0.75rem;
    font-weight: 650;
}

.flag::before {
    content: "";
    flex: none;
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background: currentColor;
}

.flag--warning { color: var(--warning); }
.flag--error { color: var(--error); }
a.flag { text-decoration: underline; }

.trade-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.trade-form__field { display: grid; align-content: start; gap: 0.25rem; min-width: 0; }
.trade-form__field--wide { grid-column: span 2; }
.trade-form__field label { color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; }

.trade-form__field input,
.trade-form__field select { width: 100%; font-size: 0.9375rem; padding: 0.4375rem 0.5625rem; }

.trade-form__field input[type="time"] {
    font: inherit;
    font-size: 0.9375rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-1);
}

.trade-form__messages { display: grid; gap: 0.25rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.trade-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }

.remove-toggle--labelled {
    gap: 0.5rem;
    margin: 0;
    padding: 0.25rem 0.625rem;
    color: var(--error);
    font-size: 0.875rem;
    font-weight: 600;
}

.remove-toggle--labelled input { accent-color: var(--error); }

.trade-details { display: grid; gap: 1rem; padding: 0.5rem 0 0.75rem; }

.trade-details__facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.5rem 1.25rem;
    margin: 0;
}

.trade-details__facts dt { color: var(--ink-2); font-size: 0.75rem; font-weight: 650; }
.trade-details__facts dd { margin: 0; overflow-wrap: anywhere; }

.trade-details__notice,
.trade-details__total,
.trade-details__open,
.trade-details > .note { margin: 0; }

.trade-details__notice { align-items: flex-start; font-size: 0.8125rem; }
.trade-details__notice::before { margin-top: 0.45em; }

.trade-details__matches caption { padding-inline: 1rem; color: var(--ink); font-weight: 650; }
.trade-details__unavailable { color: var(--warning); white-space: normal; }

@media (max-width: 47.99rem) {
    /* One card per trade; the labels the header row carried move inline. */
    .ledger-table { display: block; }
    .ledger-table thead { display: none; }
    .ledger-table tbody,
    .ledger-table tr { display: block; }
    .ledger-table .trade { padding: 0.5rem 1rem; border-top: 1px solid var(--hairline); }
    .ledger-table .trade:first-of-type { border-top: 0; }
    .ledger-table .trade__summary > td,
    .ledger-table .trade__panels > td { display: block; padding: 0.25rem 0; border: 0; }

    .ledger-table .trade__summary > td[data-label] {
        display: grid;
        grid-template-columns: 6rem minmax(0, 1fr);
        align-items: baseline;
        gap: 0.125rem 0.75rem;
        text-align: left;
    }

    /* Notes (the time, the tax year) sit under the value, not the label. */
    .ledger-table .trade__summary > td[data-label] > * { grid-column: 2; }

    .ledger-table .trade__summary > td[data-label]::before {
        content: attr(data-label);
        grid-column: 1;
        color: var(--ink-2);
        font-size: 0.75rem;
        font-weight: 650;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    /* A card has padding of its own: tint the card, not just its rows. */
    .ledger-table .trade.is-open:not(.is-editing) { background: color-mix(in srgb, var(--accent-tint) 55%, transparent); }
    .ledger-table .trade.is-open:not(.is-editing) > tr { background: none; }
    .trade.is-editing > tr > td:first-child { box-shadow: none; }
    .trade.is-editing { box-shadow: inset 3px 0 0 var(--brand); }
    .trade__result { white-space: normal; }
    .trade__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; text-align: left; }

    .trade__actions .button,
    .trade__panel > summary,
    .trade-form__actions .button,
    .remove-toggle--labelled { min-height: var(--tap); font-size: 1rem; }
    .trade__actions .button.visually-hidden { min-height: 0; }

    .trade-form { grid-template-columns: minmax(0, 1fr); }
    .trade-form__field--wide { grid-column: auto; }

    .trade-form__field input,
    .trade-form__field select { min-height: var(--tap); font-size: 1rem; }

    .trade-details__facts { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 54rem) {
    .container--workbench { padding-inline: 0.75rem; }
    .workbench-bar { position: static; }
    .pit-grid { grid-template-columns: 1fr; }
    .workbench-panel { padding: 1rem; }
    .tablist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .trade,
    .attention-item { scroll-margin-top: 4.5rem; }
    .table--editable input:not([type="hidden"]),
    .table--editable select,
    .attention-action select,
    .attention-action .button--link { min-height: var(--tap); font-size: 1rem; }
}

/*
 * FIFO tab: the lot map. One disclosure per FIFO queue, openings (lots) on
 * the left and the closings that consumed them on the right; side by side
 * once there is room, stacked below that. Lot references are links between
 * the two panes.
 */
.lot-board { display: grid; gap: 1rem; margin-bottom: 2rem; }
.lot-board__intro h3 { margin: 0 0 0.25rem; font-size: 1.125rem; }
.lot-board__intro .note,
.lot-board__reset { margin: 0; }
.lot-board__reset .button--link { padding-inline: 0; }
.lot-pairs-title { margin: 0 0 0.75rem; font-size: 1.125rem; }

/* The FIFO tab's formulas and legal notes, collapsed below the pairs table. */
.calc-notes { margin-top: 2rem; }

.lot-queue {
    border: 1px solid var(--hairline);
    border-radius: var(--r-1);
    background: var(--surface);
}

.lot-queue > summary {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
    min-height: var(--tap);
    padding: 0.75rem 2.75rem 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
}

.lot-queue > summary::-webkit-details-marker { display: none; }
.lot-queue > summary::marker { content: ""; }

/* The same border-drawn chevron as .disclosure, flipped while open. */
.lot-queue > summary::after {
    content: "";
    position: absolute;
    right: 1.25rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.32rem;
    border-right: 2px solid var(--ink-2);
    border-bottom: 2px solid var(--ink-2);
    border-radius: 0 0 2px 0;
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease), margin-top 0.25s var(--ease);
}

.lot-queue[open] > summary::after { margin-top: -0.14rem; transform: rotate(-135deg); }
.lot-queue > summary:hover .lot-queue__title { color: var(--accent); }
.lot-queue > summary:hover::after { border-color: var(--accent); }
.lot-queue__title { font-weight: 650; overflow-wrap: anywhere; }
.lot-queue__meta { color: var(--ink-2); font-size: 0.8125rem; }

.lot-panes {
    display: grid;
    gap: 1rem;
    padding: 0 1rem 1rem;
}

@media (min-width: 46rem) {
    .lot-panes { grid-template-columns: 1fr 1fr; }
}

.lot-pane { min-width: 0; }

.lot-pane__title {
    margin: 0 0 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--hairline);
    color: var(--ink-2);
    font-size: 0.8125rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lot-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }

.lot {
    scroll-margin-top: 13rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--r-1) - 4px);
    background: var(--canvas);
    font-size: 0.875rem;
}

.lot:target { box-shadow: inset 3px 0 0 var(--brand); }
.lot--editing { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); box-shadow: inset 3px 0 0 var(--brand); }
.lot--problem { box-shadow: inset 3px 0 0 var(--error); }

.lot__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin: 0;
}

.lot__label { font-weight: 700; }
.lot__date { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lot__qty { font-variant-numeric: tabular-nums; }
.lot__trade { margin-left: auto; font-size: 0.8125rem; }

.lot__links,
.lot__problems { display: grid; gap: 0.125rem; margin: 0.375rem 0 0; padding: 0; list-style: none; }
.lot__links li { font-variant-numeric: tabular-nums; }
.lot__problems { color: var(--error); font-size: 0.8125rem; }
.lot__open { margin: 0.375rem 0 0; color: var(--ink-2); font-size: 0.8125rem; }
.lot__open.flag { color: var(--warning); }
.lot__actions { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.375rem 0 0; }
.lot__actions .button--link { min-height: 2rem; padding-inline: 0; font-size: 0.875rem; }

.lot-ref { font-weight: 650; }
.lot-ref--specific { color: var(--accent-strong); }

.lot-method {
    padding: 0.0625rem 0.5rem;
    border-radius: var(--r-pill);
    background: var(--accent-tint);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 650;
}

.lot-method--specific { background: var(--brand); color: var(--on-accent); }

.lot-editor { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
.lot-editor__intro,
.lot-editor__actions { margin: 0; }
.lot-editor__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.lot-editor__table input { width: 7rem; padding: 0.375rem 0.5rem; font-size: 0.9375rem; text-align: right; }

@media print {
    .workbench-bar,
    .attention-action,
    #panel-settings,
    .tablist,
    .panel-heading .button,
    .table--editable,
    [data-row-template],
    [data-new-trades],
    .trade__panel--edit,
    .trade__panel > summary,
    .trade__actions,
    .ledger-notice .button,
    .lot-editor,
    .lot__actions,
    .lot-board__reset { display: none !important; }
    .trade-ledger.is-enhanced .trade__panels { display: table-row; }
    .workbench-panel,
    .workbench-panel[hidden] {
        display: block !important;
        margin: 0 0 5mm;
        padding: 0;
        border: 0;
        box-shadow: none;
    }
    .pit-grid { grid-template-columns: repeat(2, 1fr); }
}
