:root {
    --ink: #17324b;
    --muted: #60758a;
    --canvas: #f3f8fc;
    --paper: #ffffff;
    --line: #d7e3ed;
    --blue: #2468a9;
    --blue-dark: #174d7f;
    --blue-soft: #e8f4ff;
    --blue-border: #b9dcf7;
    --green: #218263;
    --green-dark: #176448;
    --green-soft: #e8f7f0;
    --green-border: #b8e4d0;
    --red: #c94c58;
    --red-dark: #96323d;
    --red-soft: #ffedf0;
    --red-border: #f1bdc3;
    --yellow-soft: #fff7d9;
    --shadow: 0 18px 48px rgba(31, 70, 105, 0.1);
}

* { box-sizing: border-box; }

html {
    color: var(--ink);
    background: var(--canvas);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        radial-gradient(circle at 4% 4%, rgba(184, 220, 247, 0.58), transparent 27rem),
        radial-gradient(circle at 96% 18%, rgba(184, 228, 208, 0.42), transparent 24rem),
        var(--canvas);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(36, 104, 169, 0.25);
    outline-offset: 2px;
}

.shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.topbar {
    color: #fff;
    background: linear-gradient(115deg, var(--blue-dark), var(--blue) 72%, #2b7fb5);
    box-shadow: 0 8px 28px rgba(23, 77, 127, 0.18);
}

.topbar-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-mark,
.print-logo {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    color: var(--blue-dark);
    background: #d9f4e7;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: -0.04em;
    box-shadow: inset 0 0 0 1px rgba(23, 77, 127, 0.12);
}

.brand > div { display: grid; gap: 1px; }
.brand strong { font-size: 16px; }
.brand div span { color: rgba(255, 255, 255, 0.72); font-size: 12px; }

.connection-status {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 12px;
    font-weight: 750;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.connection-status.is-online .status-dot {
    background: #8ee2b9;
    box-shadow: 0 0 0 4px rgba(142, 226, 185, 0.18);
}

.connection-status.is-offline .status-dot {
    background: #ff9ca6;
    box-shadow: 0 0 0 4px rgba(255, 156, 166, 0.18);
}

.connection-status.is-unknown .status-dot {
    background: #ffd98a;
    box-shadow: 0 0 0 4px rgba(255, 217, 138, 0.18);
}

.page-shell { padding: 32px 0 46px; }

.tabs {
    display: inline-flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 8px 24px rgba(31, 70, 105, 0.05);
}

.tabs button {
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
    font-weight: 750;
}

.tabs button:hover { color: var(--blue-dark); background: var(--blue-soft); }
.tabs button.is-active { color: #fff; background: var(--blue); box-shadow: 0 6px 15px rgba(36, 104, 169, 0.23); }

.hero-copy { max-width: 790px; margin: 42px 0 25px; }
.eyebrow {
    display: block;
    margin: 0 0 9px;
    color: var(--red);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero-copy h1,
.setup-card h1 {
    margin: 0;
    font-size: clamp(34px, 4vw, 52px);
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.hero-copy p {
    max-width: 760px;
    margin: 15px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.7;
}

.alert {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 22px;
    padding: 14px 16px;
    border: 1px solid;
    border-radius: 15px;
}

.alert > div:last-child { display: grid; gap: 2px; }
.alert strong { font-size: 13px; }
.alert span { font-size: 12px; }

.alert-icon {
    flex: 0 0 auto;
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 15px;
    font-weight: 900;
}

.alert-online { color: var(--green-dark); border-color: var(--green-border); background: var(--green-soft); }
.alert-online .alert-icon { color: #fff; background: var(--green); }
.alert-offline { color: var(--red-dark); border-color: var(--red-border); background: var(--red-soft); }
.alert-offline .alert-icon { color: #fff; background: var(--red); }
.alert-neutral { color: var(--blue-dark); border-color: var(--blue-border); background: var(--blue-soft); }
.alert-neutral .alert-icon { color: #fff; background: var(--blue); }
.alert-warning { color: #765915; border-color: #ead28f; background: var(--yellow-soft); }
.alert-warning .alert-icon { color: #fff; background: #bd8a18; }

.calculator-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(390px, 0.96fr);
    align-items: start;
    gap: 24px;
}

.card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.card-heading,
.comparison-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.card-heading { min-height: 76px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-heading-blue { background: var(--blue-soft); border-bottom-color: var(--blue-border); }
.card-heading > div { display: flex; align-items: center; gap: 12px; }
.card-heading h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }

.step-number {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 11px;
    color: var(--blue-dark);
    background: #cfe9fb;
    font-size: 11px;
    font-weight: 850;
}

.step-green { color: var(--green-dark); background: #cfefdf; }
.text-button { padding: 7px 0; border: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 750; }
.text-button:hover { text-decoration: underline; }

.form-section { padding: 23px 22px 25px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.section-blue { background: linear-gradient(180deg, rgba(232, 244, 255, 0.55), rgba(255, 255, 255, 0)); }
.section-green { background: linear-gradient(180deg, rgba(232, 247, 240, 0.65), rgba(255, 255, 255, 0)); }
.form-section h3 { margin: 0 0 17px; font-size: 13px; font-weight: 800; }
.form-section > .field + .field { margin-top: 17px; }

.field { min-width: 0; }
.field label { display: block; margin-bottom: 7px; color: #3f566a; font-size: 12px; font-weight: 720; }
.field input,
.field select {
    width: 100%;
    height: 47px;
    border: 1px solid #bfd0de;
    border-radius: 11px;
    color: var(--ink);
    background: #fff;
    font-size: 14px;
    font-weight: 650;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input { padding: 0 14px; }
.field select { padding: 0 36px 0 13px; }
.field input:hover, .field select:hover { border-color: #92adc1; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36, 104, 169, 0.1); outline: 0; }
.field select:disabled { color: #8b9aa7; cursor: not-allowed; background: #f2f5f7; }
.field input::placeholder { color: #99a8b4; font-weight: 450; }
.field-hint, .sync-note { display: block; margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.sync-note { display: grid; gap: 3px; line-height: 1.55; }
.sync-note strong { color: var(--blue-dark); font-weight: 750; }

.input-with-suffix { position: relative; }
.input-with-suffix input { padding-right: 78px; }
.input-with-suffix > span {
    position: absolute;
    top: 50%;
    right: 13px;
    min-width: 40px;
    padding-left: 10px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-align: right;
    transform: translateY(-50%);
}

.field-grid { display: grid; gap: 12px; margin-top: 17px; }
.field-grid-three { grid-template-columns: 0.72fr 1.22fr 0.72fr; }

.rate-strip {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 1px;
    margin-top: 17px;
    overflow: hidden;
    border: 1px solid var(--green-border);
    border-radius: 13px;
    background: var(--green-border);
}

.rate-strip > div { min-width: 0; display: grid; gap: 3px; padding: 13px 14px; background: var(--green-soft); }
.rate-strip span { color: var(--green-dark); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; }
.rate-strip strong { overflow-wrap: anywhere; font-size: 13px; }

.button {
    min-height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 11px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.7; transform: none; }
.button-blue { width: 100%; margin-top: 14px; background: var(--blue); box-shadow: 0 8px 18px rgba(36, 104, 169, 0.2); }
.button-green { background: var(--green); box-shadow: 0 8px 18px rgba(33, 130, 99, 0.18); }
.button-outline { border: 1px solid var(--blue-border); color: var(--blue-dark); background: #fff; box-shadow: 0 8px 18px rgba(36, 104, 169, 0.08); }
.button-red { background: var(--red); box-shadow: 0 8px 18px rgba(201, 76, 88, 0.18); }
.button.is-loading .button-label::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 8px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; vertical-align: -2px; animation: spin .75s linear infinite; }
.button-outline.is-loading .button-label::before { border-color: rgba(36, 104, 169, .25); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-actions {
    display: grid;
    grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
    gap: 10px;
    margin-top: 14px;
}

.result-stack { display: grid; gap: 18px; }
.result-hero {
    overflow: hidden;
    padding: 24px;
    border: 1px solid #9ed6bd;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--green-dark), var(--green) 58%, #359a75);
    box-shadow: 0 20px 46px rgba(33, 130, 99, 0.2);
}

.result-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: rgba(255,255,255,.8); font-size: 12px; font-weight: 700; }
.calculated-badge { padding: 5px 9px; border-radius: 999px; color: var(--green-dark); background: #c9f0dc; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.tax-total { display: block; margin: 12px 0 19px; font-size: clamp(41px, 6vw, 58px); line-height: 1; letter-spacing: -.045em; }
.hero-metrics { display: grid; grid-template-columns: 1fr .58fr; gap: 12px; }
.hero-metrics > div { display: grid; gap: 3px; padding: 12px 13px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.08); }
.hero-metrics span, .basis-note span { color: rgba(255,255,255,.68); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.hero-metrics strong { font-size: 14px; }
.basis-note { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 13px; padding-top: 13px; border-top: 1px solid rgba(255,255,255,.15); }
.basis-note strong { font-size: 12px; }

.compact-heading { min-height: 68px; padding: 15px 18px; background: #f8fbfd; }
.accent-blue { border-top: 4px solid #8fc7ee; }
.accent-green { border-top: 4px solid #92d6b8; }
.source-tag { padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .05em; }
.source-blue { color: var(--blue-dark); background: var(--blue-soft); }
.source-green { color: var(--green-dark); background: var(--green-soft); }

.result-table { padding: 6px 18px 12px; }
.result-table > div,
.comparison-results > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 0;
    border-bottom: 1px solid #e7eef3;
    font-size: 12px;
}
.result-table > div:last-child, .comparison-results > div:last-child { border-bottom: 0; }
.result-table span, .comparison-results span { color: var(--muted); }
.result-table strong, .comparison-results strong { text-align: right; }
.result-table .negative strong { color: var(--red); }
.result-table .strong { margin-top: 2px; padding-top: 11px; }
.result-table .strong strong { color: var(--ink); font-size: 14px; }

.result-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.result-actions > span { color: var(--muted); font-size: 11px; text-align: right; }

.comparison-intro { max-width: 850px; }
.comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.comparison-card { padding: 22px; }
.comparison-heading { margin-bottom: 20px; }
.comparison-heading > div { display: grid; gap: 2px; }
.comparison-heading span { color: var(--muted); font-size: 11px; }
.comparison-heading strong { font-size: 28px; letter-spacing: -.035em; }
.rate-chip { padding: 7px 10px; border-radius: 999px; color: var(--blue-dark) !important; background: var(--blue-soft); font-size: 11px !important; font-weight: 850; }
.comparison-inputs { display: grid; gap: 15px; }
.comparison-results { margin-top: 18px; padding: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.difference-callout { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 17px; padding: 14px; border: 1px solid var(--red-border); border-radius: 13px; color: var(--red-dark); background: var(--red-soft); }
.difference-callout span { font-size: 11px; font-weight: 750; }
.difference-callout strong { font-size: 16px; }

footer { margin-top: 34px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.setup-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.setup-card { width: min(650px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.setup-card .brand-mark { margin-bottom: 20px; }
.setup-card h1 { font-size: clamp(30px, 5vw, 45px); }
.setup-card > p:not(.eyebrow) { color: var(--muted); }
.setup-card .alert { margin: 22px 0 0; align-items: flex-start; }
.setup-note { font-size: 12px; }
.noscript { position: fixed; inset: auto 16px 16px; z-index: 20; padding: 12px 16px; border-radius: 12px; color: #fff; background: var(--red-dark); }

.print-report { display: none; }

@media (max-width: 900px) {
    .calculator-grid { grid-template-columns: 1fr; }
    .result-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .result-hero, .result-actions { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
    .shell { width: min(100% - 24px, 1180px); }
    .topbar-inner { min-height: 70px; }
    .brand div span { display: none; }
    .connection-status { padding: 7px 9px; }
    .hero-copy { margin-top: 32px; }
    .hero-copy h1 { font-size: 35px; }
    .field-grid-three, .comparison-grid, .result-stack { grid-template-columns: 1fr; }
    .result-hero, .result-actions { grid-column: auto; }
    .rate-strip { grid-template-columns: 1fr; }
    .result-actions { align-items: stretch; flex-direction: column; }
    .result-actions .button { width: 100%; }
    .result-actions > span { text-align: left; }
}

@media (max-width: 430px) {
    .tabs { width: 100%; }
    .tabs button { flex: 1; padding: 0 10px; }
    .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
    .brand strong { font-size: 14px; }
    .connection-status { font-size: 10px; }
    .card-heading, .form-section, .comparison-card { padding-left: 16px; padding-right: 16px; }
    .result-hero { padding: 20px; }
    .tax-total { font-size: 40px; }
    .sync-actions { grid-template-columns: 1fr; }
}

@page { size: A4 portrait; margin: 9mm; }

@media print {
    html, body {
        width: auto;
        min-width: 0;
        margin: 0;
        padding: 0;
        color: #17283a;
        background: #fff !important;
        font-family: Arial, Helvetica, sans-serif;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .no-print, .noscript { display: none !important; }
    .print-report {
        display: block !important;
        width: 100%;
        max-width: 192mm;
        margin: 0 auto;
        font-size: 9pt;
        line-height: 1.28;
    }

    .print-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 18mm;
        padding-bottom: 4mm;
        border-bottom: 1.2mm solid #2468a9;
    }
    .print-header h1 { margin: 1mm 0 0; font-size: 21pt; line-height: 1; letter-spacing: -.5pt; }
    .print-kicker { color: #2468a9; font-size: 7.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: .8pt; }
    .print-logo { width: 13mm; height: 13mm; border-radius: 3mm; color: #174d7f; background: #d9f4e7 !important; font-size: 9pt; }

    .print-offline {
        margin-top: 4mm;
        padding: 2.5mm 3mm;
        border: .4mm solid #c94c58;
        border-radius: 2mm;
        color: #96323d;
        background: #ffedf0 !important;
        font-size: 8pt;
        font-weight: 700;
    }

    .print-summary {
        display: grid;
        grid-template-columns: 1fr .58fr 1.12fr;
        gap: 2.5mm;
        margin-top: 4mm;
    }
    .print-summary > div {
        min-height: 22mm;
        display: grid;
        align-content: center;
        gap: 2mm;
        padding: 3mm;
        border: .35mm solid #b9dcf7;
        border-radius: 2.5mm;
        background: #e8f4ff !important;
    }
    .print-summary span, .print-footer span { color: #60758a; font-size: 7pt; text-transform: uppercase; letter-spacing: .5pt; }
    .print-summary strong { font-size: 14pt; }
    .print-summary .print-total { color: #fff; border-color: #218263; background: #218263 !important; }
    .print-summary .print-total span { color: rgba(255,255,255,.78); }
    .print-summary .print-total strong { font-size: 18pt; }

    .print-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; margin-top: 4mm; }
    .print-card { overflow: hidden; border: .35mm solid #d7e3ed; border-radius: 2.5mm; break-inside: avoid; }
    .print-card h2 { margin: 0; padding: 3mm; font-size: 10pt; }
    .print-blue h2 { color: #174d7f; background: #e8f4ff !important; }
    .print-green h2 { color: #176448; background: #e8f7f0 !important; }
    .print-card dl { margin: 0; padding: 1.5mm 3mm 2mm; }
    .print-card dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 4mm; padding: 2.1mm 0; border-bottom: .2mm solid #e2eaf0; }
    .print-card dl > div:last-child { border-bottom: 0; }
    .print-card dt { color: #60758a; }
    .print-card dd { margin: 0; font-weight: 700; text-align: right; }
    .print-card .print-strong { padding-top: 2.7mm; }
    .print-card .print-strong dd { font-size: 10pt; }

    .print-basis {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 4mm;
        padding: 3.5mm 4mm;
        border: .5mm solid #c94c58;
        border-radius: 2.5mm;
        color: #96323d;
        background: #ffedf0 !important;
    }
    .print-basis span { font-size: 8pt; font-weight: 700; text-transform: uppercase; letter-spacing: .5pt; }
    .print-basis strong { font-size: 12pt; }

    .print-footer {
        display: grid;
        grid-template-columns: 1.4fr .8fr .8fr;
        gap: 3mm;
        margin-top: 5mm;
        padding-top: 4mm;
        border-top: .35mm solid #d7e3ed;
    }
    .print-footer > div { display: grid; gap: 1.2mm; }
    .print-footer strong { font-size: 8.5pt; }
}
