:root {
    --bg: #f6f8fb;
    --bg-grad-a: #eef3ff;
    --bg-grad-b: #f9f4ee;
    --text: #1f2430;
    --muted: #5c667a;
    --line: #d8deeb;
    --surface: #ffffff;
    --surface-soft: #f8fafe;
    --primary: #0f6fdc;
    --primary-rgb: 15, 111, 220;
    --primary-ink: #ffffff;

    /* Map our tokens onto Bootstrap's CSS variables so .card,
     * .alert, .badge, .btn-outline-*, .text-muted, .bg-light, etc.
     * follow the active theme instead of staying white. Doing this
     * in :root and not per-theme means the theme classes on <body>
     * just need to override our tokens — Bootstrap re-reads the
     * cascade automatically. */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-secondary-color: var(--muted);
    --bs-tertiary-color: var(--muted);
    --bs-tertiary-bg: var(--surface-soft);
    --bs-border-color: var(--line);
    --bs-emphasis-color: var(--text);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary);
    /* Bootstrap reads --bs-primary-rgb literally inside rgba(...);
     * a chained var(--primary-rgb) substitution doesn't always
     * propagate cleanly when overridden per-theme on <body>, so
     * each theme below redeclares --bs-primary-rgb with the same
     * literal value as --primary-rgb. */
    --bs-primary: var(--primary);
    --bs-primary-rgb: 15, 111, 220;
    /* Bootstrap card: use --surface-soft (off-white) so all
     * Bootstrap-driven cards on /, /business/, /articles/ etc. match
     * the look of our custom .inputs-card / .options-card / .pension-card
     * on the calculator pages. The site-header above stays at
     * --surface (pure white) so it visually separates from cards. */
    --bs-card-bg: var(--surface-soft);
    --bs-card-border-color: var(--line);
    --bs-card-color: var(--text);
}

body.theme-slate {
    --bg: #f7f7f5;
    --bg-grad-a: #f2f2ed;
    --bg-grad-b: #f9f3e7;
    --text: #22252d;
    --muted: #60656f;
    --line: #ddd8cf;
    --surface: #ffffff;
    --surface-soft: #fbf9f5;
    --primary: #9a6a1f;
    --primary-rgb: 154, 106, 31;
    --primary-ink: #ffffff;
    --bs-primary-rgb: 154, 106, 31;
}

body.theme-graphite {
    --bg: #eef2f3;
    --bg-grad-a: #e4ecef;
    --bg-grad-b: #eef4f3;
    --text: #1c2329;
    --muted: #54616a;
    --line: #cfd8df;
    --surface: #ffffff;
    --surface-soft: #f4f8f9;
    --primary: #00756b;
    --primary-rgb: 0, 117, 107;
    --primary-ink: #ffffff;
    --bs-primary-rgb: 0, 117, 107;
}

body {
    margin: 0;
    padding: 0;
    color: var(--text);
    font-family: "Trebuchet MS", "Gill Sans", "Noto Sans", sans-serif;
    background:
        radial-gradient(1200px 500px at 0% 0%, var(--bg-grad-a), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, var(--bg-grad-b), transparent 58%),
        var(--bg);
}

/* Embed body opt-out — when the page is iframed (embed.html) we
 * strip the site header / footer chrome via {% block site_header %}
 * and {% block site_chrome %}, so no extra spacing needed there. */

.container.mt-3.mb-5 {
    max-width: 1120px;
}

/* a11y: skip-link for keyboard users.
 *
 * Hidden state uses the modern clip-path pattern — the element is
 * 1×1 px and visually erased; *not* `display: none` because that
 * would also remove it from the focus order, which defeats the
 * purpose. Mouse users never see it.
 *
 * Focused state slides in from the top-left as a card-styled
 * button matching the rest of the chrome (theme primary, soft
 * surface, rounded), so a keyboard user hitting Tab gets a clean
 * affordance instead of "broken-looking" raw link. */
.skip-link {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link:focus,
.skip-link:focus-visible {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    z-index: 10000;
    padding: 0.55rem 1rem;
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(27, 46, 94, 0.12);
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.12s ease;
}

.skip-link:hover:focus {
    transform: translateY(-1px);
}

/* a11y: visible focus ring for every interactive element. Bootstrap
 * applies its own focus rules but they fade against our themes;
 * this gives a consistent ring tinted with the active theme's
 * primary colour. Only :focus-visible — keyboard / programmatic
 * focus — never on plain mouse click. */
:focus-visible {
    outline: 3px solid rgba(var(--bs-primary-rgb), 0.45);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-check-input:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid rgba(var(--bs-primary-rgb), 0.55);
    outline-offset: 2px;
}

/* Sticky site header (polish item) — brand on the left, theme cycle
 * button on the right. Sits above scroll on every page; ~56 px tall
 * so it doesn't dominate the viewport. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 4px rgba(27, 46, 94, 0.04);
}

.site-header-inner {
    max-width: 1120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.75rem;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.05rem;
}

.site-brand:hover {
    color: var(--primary);
}

.site-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: var(--primary-ink);
    font-weight: 800;
    font-size: 0.95rem;
    line-height: 1;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--text);
    background: var(--surface-soft);
}

.theme-toggle-icon {
    flex-shrink: 0;
}

/* 404 / 500 error pages — large oversized number above a friendly
 * heading + recovery links. Same visual language as the landing
 * hero: rounded surface card, muted secondary text. */
.error-page {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.error-code {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.top-controls {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 0.9rem;
}

.top-controls .nav-tabs {
    margin-bottom: 0;
}

.theme-switch {
    max-width: 260px;
    min-width: 220px;
}

.footer-meta {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.footer-meta a {
    color: var(--muted);
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 3px;
    font-weight: 600;
}

.footer-meta a:hover,
.footer-meta a:focus-visible {
    color: var(--primary);
    text-decoration-color: var(--primary);
}

.footer-spec {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 400;
}

.card {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(27, 46, 94, 0.06);
    overflow: hidden;
}

.card-title {
    font-size: clamp(1.4rem, 2.4vw, 1.9rem);
    font-weight: 800;
    letter-spacing: 0.01em;
    margin-bottom: 1.25rem;
}

.nav-tabs {
    border-bottom: 1px solid var(--line);
    gap: 0.4rem;
}

.nav-tabs .nav-link {
    border: 1px solid transparent;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    color: var(--muted);
    font-weight: 700;
}

.nav-tabs .nav-link.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line) var(--line) var(--surface);
}

.alert {
    border-radius: 12px;
    border: 1px solid #f1d7a2;
}

.form-label {
    font-weight: 700;
    color: #283047;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid #cfd8ea;
    min-height: 42px;
}

.form-control:focus,
.form-select:focus {
    border-color: #8fb7f0;
    box-shadow: 0 0 0 0.2rem rgba(15, 111, 220, 0.15);
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.45rem;
}

.form-check-input {
    margin-right: 0.5rem;
}

/* Shared "soft surface" card — used for inputs, options, pension,
 * student loan, other-income sections. Original three classes
 * (.options-card, .inputs-card, .pension-card) had identical
 * declarations; kept as comma-grouped selectors for HTML stability. */
.options-card,
.inputs-card,
.pension-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 0.75rem;
}

.more-deductions {
    margin-top: 0.6rem;
}

.more-deductions > summary {
    cursor: pointer;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    font-weight: 500;
    color: var(--text);
    list-style: none;
    user-select: none;
    transition: background 0.12s, border-color 0.12s;
}

.more-deductions > summary::-webkit-details-marker {
    display: none;
}

.more-deductions > summary::before {
    content: "▶";
    display: inline-block;
    margin-right: 0.55rem;
    font-size: 0.75em;
    color: var(--muted);
    transition: transform 0.15s;
}

.more-deductions[open] > summary::before {
    transform: rotate(90deg);
}

.mode-tabs {
    border-bottom: 1px solid var(--line);
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.mode-tabs .nav-link {
    color: var(--muted);
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 0.55rem 1rem;
    margin-bottom: -1px;
    font-weight: 500;
}

.mode-tabs .nav-link:hover {
    color: var(--text);
    border-color: transparent;
}

.mode-tabs .nav-link.active {
    color: var(--text);
    background: transparent;
    border-bottom-color: var(--accent, var(--text));
}

/* Embed (iframe) layout — see templates/calculator/embed.html.
 * Strips the gradient background and outer chrome so the calculator
 * card sits flush in the customer's iframe. Theme classes still
 * apply via body[class*="theme-..."]. */
.embed-body {
    background: transparent;
}

.embed-body > .container {
    padding-top: 0;
    padding-bottom: 0;
}

.embed-poweredby {
    padding: 0.5rem 0 1rem;
}

.embed-poweredby a {
    color: var(--text);
}

/* Info-tooltip dot used in result tables (e.g. dividend tax row).
 * Native title= tooltip on hover/focus; visually it's a small ⓘ
 * with muted colour so it doesn't compete with the row label. */
.info-tip {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--muted);
    font-size: 0.85em;
    cursor: help;
    user-select: none;
}

.info-tip:hover,
.info-tip:focus {
    color: var(--text);
    outline: none;
}

/* /business/ sales landing — hero, use-case grid, demo iframe,
 * pricing tiers, contact. Reuses Bootstrap card + the existing
 * landing-hero box style for the hero. */
.business-hero {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.business-hero .lead {
    color: var(--muted);
}

.business-callout {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    background: var(--surface-soft);
}

.business-demo-frame {
    margin-top: 0.75rem;
}

/* Lead paragraph max-width — used to be inline `style="max-width:
 * 720px"` on hero leads. Pull out so all themed pages share one
 * rule. */
/* Constrained-width readable text — used on hero leads, error
 * pages, articles index intro. Replaces ad-hoc inline
 * `style="max-width: …"` we kept introducing in new templates. */
.measure-text {
    max-width: 60ch;
}

.measure-text-narrow {
    max-width: 50ch;
}

.lead.hero-lead {
    max-width: 720px;
}

.lead.hero-lead-wide {
    max-width: 760px;
}

/* Embedded iframe used for the live preview / demo. Themed border
 * + surface; sizing comes from inline width/height on the element
 * (height differs per use-case). */
.demo-iframe {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

/* Article footer CTA card (links to all 5 calculators). Same
 * dashed-box style as the landing-page B2B callout. */
.article-cta {
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

/* Snippet block in /business/embed/ generator — wraps long URLs
 * cleanly and guarantees a minimum height so the layout doesn't
 * jump as the URL grows or shrinks. */
.snippet-block {
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 7rem;
}

/* Site-wide footer rendered from base.html. Four-column nav + a
 * meta strip with attribution and the HMRC-spec note. Collapses
 * to a single column on narrow screens. */
.site-footer {
    margin-top: 2.5rem;
    padding: 1.75rem 1.5rem 1.25rem;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.footer-cols {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem 2rem;
    margin-bottom: 1rem;
}

.footer-col h6 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.06em;
    margin: 0 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
}

.footer-col ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.footer-col li {
    padding: 0.25rem 0;
}

.footer-col a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted transparent;
    transition: border-color 0.12s ease, color 0.12s ease;
}

.footer-col a:hover,
.footer-col a:focus-visible {
    color: var(--text);
    border-bottom-color: var(--primary);
}

@media (max-width: 768px) {
    .site-footer {
        padding: 1.25rem 1.1rem 0.85rem;
    }

    .footer-cols {
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem 1rem;
    }
}

@media (max-width: 480px) {
    .footer-cols {
        grid-template-columns: 1fr;
    }
}

/* Markdown-rendered content pages (/help/, /privacy/, /terms/,
 * /changelog/, /about/, /faq/) — light typography polish. */
.markdown-body {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    margin-top: 0.5rem;
    line-height: 1.55;
}

.markdown-body h1 {
    margin-top: 0;
    font-weight: 800;
}

.markdown-body h2 {
    margin-top: 1.5rem;
    font-weight: 700;
}

.markdown-body h3 {
    margin-top: 1.2rem;
    font-weight: 700;
    font-size: 1.05rem;
}

.markdown-body code {
    background: var(--surface-soft);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.92em;
}

.markdown-body pre {
    background: var(--surface-soft);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.markdown-body th,
.markdown-body td {
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

/* Landing page (/) — hero, calculator cards, trust signals.
 * Cards reuse Bootstrap's .card; only hero typography and trust-list
 * spacing live here. */
/* --- Landing hero --------------------------------------------------------
   Two-tone gradient banner with a year-pill, accent title, three trust
   chips and a CTA row. Decorative SVGs sit absolutely in the top-left
   and bottom-right corners at low opacity — they add visual texture
   without competing with the content. All colours pull from existing
   palette variables so theme tweaks propagate. */
.landing-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(135deg,
                var(--bg-grad-a) 0%,
                var(--surface) 55%,
                var(--bg-grad-b) 100%);
    padding: 3.25rem 1.5rem 3rem;
    margin-bottom: 1.75rem;
    isolation: isolate;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
}

.hero-decor {
    position: absolute;
    color: var(--primary);
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
}

.hero-decor-tl {
    top: -36px;
    left: -36px;
    width: 180px;
    height: 180px;
}

.hero-decor-br {
    bottom: -28px;
    right: -28px;
    width: 220px;
    height: 220px;
    color: var(--bg-grad-b);
    filter: hue-rotate(-20deg);
    opacity: 0.65;
}

.hero-year-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hero-year-badge svg {
    width: 12px;
    height: 12px;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.1rem);
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.hero-title-accent {
    background: linear-gradient(135deg, var(--primary) 0%, #1f9bb0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.hero-lead {
    font-size: 1.08rem;
    line-height: 1.55;
    color: var(--muted);
    max-width: 560px;
    margin: 0 auto 1.4rem;
    /* Left-aligned inside its centred max-width column. Pure
       centre-alignment broke reading rhythm on a 3-line paragraph —
       each line started at a different x-coord. */
    text-align: left;
}

.hero-lead strong {
    color: var(--text);
    font-weight: 600;
}

.hero-trust {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1.6rem;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.hero-chip svg {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.hero-chip-spec svg { color: #2f7a55; }
.hero-chip-precision svg { color: var(--primary); }
.hero-chip-os svg { color: #1f2937; }

.hero-cta-row {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.4rem;
}

.hero-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.6rem;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.25),
                0 6px 16px rgba(var(--primary-rgb), 0.18);
    transition: transform 0.12s, box-shadow 0.12s;
}

.hero-cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3),
                0 10px 24px rgba(var(--primary-rgb), 0.22);
}

.hero-cta-btn svg {
    width: 14px;
    height: 14px;
}

.hero-cta-meta {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}

@media (max-width: 600px) {
    .landing-hero { padding: 2.25rem 1rem 2rem; }
    .hero-decor-tl { width: 120px; height: 120px; top: -24px; left: -24px; }
    .hero-decor-br { width: 140px; height: 140px; bottom: -20px; right: -20px; }
}

.trust-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.trust-list li {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line);
}

.trust-list li:last-child {
    border-bottom: 0;
}

.lc-optimal-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 0.85rem 1rem;
}

.lc-optimal-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.lc-optimal-title .badge {
    margin-right: 0.4rem;
}

.lc-optimal-numbers {
    color: var(--muted);
    font-size: 0.95rem;
}

.lc-optimal-numbers strong {
    color: var(--text);
}

.more-deductions > summary:hover {
    border-color: var(--accent, var(--text));
}

.more-deductions > summary .text-muted {
    font-weight: 400;
    font-size: 0.85em;
}

/* "Continue in Self Assessment estimator" CTA shown below the result
   panels of single-source calculators. Visually it's a soft tinted
   panel with the explanatory text on the left and the action button
   on the right — distinct from the dense results table just above. */
.continue-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg,
                rgba(31, 90, 166, 0.06) 0%,
                rgba(31, 90, 166, 0.02) 100%);
}

.continue-cta-text {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
    flex: 1 1 280px;
    min-width: 0;
}

.continue-cta-text strong {
    color: var(--text);
    display: block;
    margin-bottom: 0.15rem;
}

.continue-cta-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.continue-cta-btn .btn-icon {
    width: 14px;
    height: 14px;
}

.hint-list {
    margin-top: 0.4rem;
    color: var(--muted, #6c757d);
    font-size: 0.85rem;
    line-height: 1.45;
}

.hint-list p,
.hint-list ul {
    margin: 0;
}

.hint-list ul {
    padding-left: 1.1rem;
    list-style: disc;
}

.hint-list ul + .hint-list-trail,
.hint-list .hint-list-lead + ul {
    margin-top: 0.35rem;
}

.hint-list .hint-list-trail {
    margin-top: 0.35rem;
}

.hint-list strong {
    color: var(--text, #212529);
    font-weight: 600;
}


.options-title {
    font-weight: 700;
    color: #283047;
    margin-bottom: 0.55rem;
}

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

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 0.5rem 0.65rem;
    min-height: 44px;
}

.option-item .form-check-label {
    margin: 0;
    font-weight: 600;
    cursor: pointer;
}

.option-item .form-check-input {
    margin: 0;
    cursor: pointer;
}

button[type="submit"].btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
    border-radius: 10px;
    font-weight: 700;
    padding: 0.68rem 0.9rem;
}

button[type="submit"].btn-primary:hover {
    filter: brightness(0.95);
}

/* Force every Bootstrap primary button (filled and outline) to
 * follow our --primary token directly. Without these explicit
 * overrides, Bootstrap's chain
 *   --bs-btn-bg: var(--bs-primary)
 *   .btn-primary { background-color: var(--bs-btn-bg); }
 * doesn't always pick up theme switches at the body level (the
 * substitution chain has more than one indirection). One-step
 * substitution from .btn-primary directly to --primary is robust
 * across all browsers and theme states. */
.btn-primary,
.btn-primary:focus {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
}

.btn-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
    filter: brightness(0.92);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    background-color: transparent;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
}

/* Show + Clear button row used at the bottom of every calculator
 * tab. Bootstrap's default <a class="btn"> and our customised
 * button[type="submit"].btn-primary had different paddings (0.375
 * vs 0.68 rem), making the two buttons visibly different heights
 * and their text baselines drift. .form-actions normalises both
 * sides to the same padding, weight, radius, and inline-flex
 * centering, so labels (and icons) line up cleanly. */
.form-actions {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.form-actions .btn {
    padding: 0.68rem 0.9rem;
    font-weight: 700;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    line-height: 1.2;
}

.form-actions .btn .btn-icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

.table {
    margin-bottom: 0;
    border-color: #d8deeb;
}

.table thead th {
    background: linear-gradient(180deg, #f8faff 0%, #f1f5fe 100%);
    color: #2f3a56;
    font-weight: 700;
    border-bottom-width: 1px;
}

.table td,
.table th {
    vertical-align: middle;
}

.table tbody tr:nth-child(odd) td {
    background-color: var(--surface-soft);
}

.tab-pane .card-body.bg-light {
    background: linear-gradient(180deg, #f7f8fc 0%, #f2f5fb 100%) !important;
}

pre.bg-light {
    border: 1px solid #d8deeb;
    border-radius: 10px;
    background: #ffffff !important;
}

@media (min-width: 992px) {
    .form-layout > [class*="col-"] {
        display: flex;
    }

    .form-layout .inputs-card,
    .form-layout .options-card {
        width: 100%;
        height: 100%;
    }

    .form-layout .inputs-card {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    /* iOS Safari auto-zooms when an input has font-size < 16px on
     * focus. Pin to 16px on mobile to suppress that — the user's
     * pinch-zoom is unaffected, only the focus-driven zoom. */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"] {
        font-size: 16px;
    }

    .container.mt-3.mb-5 {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .top-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-switch {
        max-width: none;
        min-width: 0;
    }

    .footer-meta {
        text-align: left;
    }

    .card {
        border-radius: 14px;
    }

    .card-body {
        padding: 1rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 576px) {
    .results-table thead {
        display: none;
    }

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

    .results-table tbody tr {
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        margin-bottom: 0.75rem;
        overflow: hidden;
    }

    .results-table tbody tr:nth-child(odd) td {
        background: transparent;
    }

    .results-table tbody td {
        padding: 0.5rem 0.75rem;
        border: 0;
        border-bottom: 1px solid var(--line);
        font-size: 0.9rem;
        white-space: normal;
    }

    .results-table tbody td:first-child {
        font-weight: 700;
        color: #283047;
        background: var(--surface-soft);
    }

    .results-table tbody td:last-child {
        border-bottom: 0;
    }

    .results-table tbody td:nth-child(n + 2) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .results-table tbody td:nth-child(2)::before {
        content: "Yearly";
        color: var(--muted);
        font-weight: 700;
    }

    .results-table tbody td:nth-child(3)::before {
        content: "Monthly";
        color: var(--muted);
        font-weight: 700;
    }

    .results-table tbody td:nth-child(4)::before {
        content: "Weekly";
        color: var(--muted);
        font-weight: 700;
    }

    .results-table tbody td:nth-child(5)::before {
        content: "Hourly";
        color: var(--muted);
        font-weight: 700;
    }

    .results-table tbody td:empty::after {
        content: "-";
        color: var(--muted);
    }
}
