:root {
    color-scheme: light;
    --bg: #eef4f5;
    --surface: #ffffff;
    --surface-muted: #f5f8f8;
    --ink: #1c2b2f;
    --muted: #5f6f73;
    --line: #cfdadc;
    --strong-line: #aabbbf;
    --accent: #0f4c5c;
    --accent-2: #2d6a4f;
    --accent-soft: #e3f1ec;
    --warn: #9a4d00;
    --danger: #9b1c1c;
    --danger-soft: #fff1f1;
    --ok: #1f6f43;
    --shadow: 0 18px 50px rgba(17, 48, 57, 0.12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(15, 76, 92, 0.08), rgba(15, 76, 92, 0) 310px),
        var(--bg);
    font-size: 16px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: var(--accent);
}

.masthead,
.layout,
.footer-note {
    width: min(1220px, calc(100% - 32px));
    margin-inline: auto;
}

.masthead {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: flex-end;
    padding: 34px 0 22px;
}

.masthead h1 {
    margin: 0;
    font-size: clamp(2.1rem, 5vw, 4.4rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.intro {
    max-width: 760px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-2);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.privacy-note {
    min-width: 230px;
    border-left: 4px solid var(--accent-2);
    padding: 12px 0 12px 16px;
    color: var(--muted);
}

.privacy-note strong,
.privacy-note span {
    display: block;
}

.privacy-note strong {
    color: var(--ink);
}

.layout {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: clip;
}

.summary-band {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #123b46;
    color: #fff;
}

.profile-bar {
    display: grid;
    grid-template-columns: minmax(220px, 320px) auto 1fr;
    gap: 14px;
    align-items: end;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: #f7faf9;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.db-status {
    align-self: center;
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.db-status.ok {
    color: var(--ok);
}

.db-status.error {
    color: var(--danger);
}

.summary-item {
    padding: 18px 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.summary-item:last-child {
    border-right: 0;
}

.summary-item span,
.summary-item strong {
    display: block;
}

.summary-item span {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.88rem;
}

.summary-item strong {
    margin-top: 4px;
    font-size: clamp(1.05rem, 2vw, 1.45rem);
    line-height: 1.2;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
    overflow-x: auto;
}

.tab {
    border: 0;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    min-height: 52px;
    padding: 0 22px;
    font-weight: 750;
    white-space: nowrap;
}

.tab:hover,
.tab:focus-visible {
    background: #eaf2f3;
    color: var(--ink);
}

.tab.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: inset 0 -3px 0 var(--accent-2);
}

.view {
    display: none;
    padding: 26px;
}

.view.active {
    display: block;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
}

.section-heading h2,
.deduction-section h3,
.result-column h3,
.tips-section h3,
.sources-section h3 {
    margin: 0;
}

.section-heading h2 {
    font-size: clamp(1.45rem, 3vw, 2.1rem);
    line-height: 1.1;
}

.form-grid,
.tool-strip {
    display: grid;
    gap: 14px;
}

.context-grid {
    grid-template-columns: 1.5fr 0.8fr 1fr;
}

.form-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

label,
.textarea-label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--strong-line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 9px 11px;
}

textarea {
    resize: vertical;
    min-height: 240px;
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: 0.92rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    outline: 3px solid rgba(45, 106, 79, 0.24);
    outline-offset: 1px;
}

.notice {
    margin: 18px 0;
    border-left: 4px solid var(--accent);
    background: #eef7f7;
    padding: 13px 16px;
    color: #31555c;
}

.tool-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
    align-items: end;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.primary-button,
.ghost-button,
.danger-button,
.small-button {
    min-height: 42px;
    border-radius: 6px;
    padding: 9px 14px;
    border: 1px solid transparent;
    font-weight: 800;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: #0b3e4b;
}

.ghost-button {
    background: #fff;
    color: var(--accent);
    border-color: var(--strong-line);
}

.ghost-button:hover {
    background: #edf6f4;
}

.danger-button {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f0b7b7;
}

.small-button {
    min-height: 36px;
    background: transparent;
    color: var(--danger);
    border-color: #e7b7b7;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
}

.data-table caption {
    text-align: left;
    padding: 12px 14px;
    font-weight: 800;
    background: #f0f5f5;
}

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

.data-table thead th {
    background: #f7faf9;
    color: #37565c;
    font-size: 0.9rem;
}

.data-table input {
    min-width: 130px;
}

.data-table tfoot th,
.data-table tfoot td {
    background: #f0f5f5;
    font-weight: 850;
}

.exclusive-box {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px 16px;
}

.exclusive-box summary {
    cursor: pointer;
    font-weight: 850;
    color: var(--accent);
}

.exclusive-box .form-grid {
    margin-top: 16px;
}

.help-text,
.section-copy {
    color: var(--muted);
}

.help-text {
    margin: 12px 0 0;
    font-size: 0.92rem;
}

.section-copy {
    margin: 8px 0 16px;
}

.deduction-layout {
    display: grid;
    gap: 18px;
}

.deduction-section,
.result-column,
.tips-section,
.sources-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.deduction-section h3,
.result-column h3,
.tips-section h3,
.sources-section h3 {
    font-size: 1.18rem;
}

.section-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.compact-list,
.result-list {
    margin: 16px 0 0;
}

.compact-list div,
.result-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.compact-list dt,
.result-list dt {
    color: var(--muted);
    font-weight: 700;
}

.compact-list dd,
.result-list dd {
    margin: 0;
    font-weight: 850;
    text-align: right;
}

.row-stack {
    display: grid;
    gap: 12px;
}

.entry-row {
    display: grid;
    grid-template-columns: 1.3fr 1fr 0.8fr auto;
    gap: 12px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.medical-row {
    grid-template-columns: 1.3fr 1fr 0.8fr 0.8fr auto;
}

.extra-row {
    grid-template-columns: 1.4fr 0.8fr 1fr 0.8fr 0.8fr 0.8fr auto;
}

.vacation-row {
    grid-template-columns: 1fr 1.3fr repeat(5, 0.8fr) auto;
}

.row-note {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.88rem;
}

.row-note.warn {
    color: var(--warn);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.tips-section,
.sources-section {
    margin-top: 18px;
}

.tips-list {
    display: grid;
    gap: 10px;
    padding-left: 20px;
    margin: 14px 0 0;
}

.tips-list li::marker {
    color: var(--accent-2);
}

.sources-section ul {
    margin-bottom: 0;
}

.split-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 28px;
}

.data-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.footer-note {
    color: var(--muted);
    padding: 18px 0 34px;
    font-size: 0.92rem;
}

.positive {
    color: var(--ok);
}

.negative {
    color: var(--danger);
}

.neutral {
    color: var(--ink);
}

@media (max-width: 920px) {
    .masthead {
        align-items: flex-start;
        flex-direction: column;
    }

    .privacy-note {
        width: 100%;
    }

    .summary-band,
    .profile-bar,
    .context-grid,
    .form-grid,
    .result-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tool-strip {
        grid-template-columns: 1fr 1fr;
    }

    .entry-row,
    .medical-row,
    .extra-row,
    .vacation-row {
        grid-template-columns: 1fr 1fr;
    }

    .entry-row .small-button,
    .medical-row .small-button,
    .extra-row .small-button,
    .vacation-row .small-button {
        width: fit-content;
    }
}

@media (max-width: 620px) {
    .masthead,
    .layout,
    .footer-note {
        width: min(100% - 20px, 1220px);
    }

    .masthead {
        padding-top: 22px;
    }

    .summary-band,
    .profile-bar,
    .context-grid,
    .form-grid,
    .tool-strip,
    .result-grid,
    .entry-row,
    .medical-row,
    .extra-row,
    .vacation-row,
    .split-list {
        grid-template-columns: 1fr;
    }

    .summary-item {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    }

    .summary-item:last-child {
        border-bottom: 0;
    }

    .view {
        padding: 18px;
    }

    .section-heading,
    .section-line {
        align-items: flex-start;
        flex-direction: column;
    }

    .tab {
        min-width: 145px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .masthead,
    .profile-bar,
    .tabs,
    #tab-months,
    #tab-extras,
    #tab-vacations,
    #tab-deductions,
    #tab-data,
    .footer-note,
    #printSummary {
        display: none !important;
    }

    .layout {
        width: 100%;
        border: 0;
        box-shadow: none;
    }

    .view {
        display: block !important;
        padding: 0;
    }
}
