:root {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #0f172a;
    background-color: #f5f6f8;
    line-height: 1.4;
}

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

:root {
    --header-height: 96px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #ffffff;
    color: #0f172a;
}

.site-header {
    position: relative;
    padding: 1.75rem clamp(1rem, 4vw, 2.5rem) 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--header-height);
}

.header-logo-block {
    position: absolute;
    left: clamp(1rem, 4vw, 2.5rem);
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.header-logo-block:focus-visible {
    outline: 2px solid #6366f1;
    border-radius: 999px;
}

.header-logo {
    width: 62px;
    height: 62px;
    max-width: 62px;
    max-height: 62px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
    display: inline-block;
}

.header-title {
    text-align: center;
    line-height: 1.2;
    width: 100%;
    padding-left: 0.5rem;
}

.header-burger {
    position: absolute;
    right: calc(clamp(1rem, 4vw, 2.5rem) + 54px);
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.auth-user .header-burger {
    display: inline-flex;
}
.header-burger:hover {
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.2);
    transform: translateY(-50%) translateY(-2px);
}

.header-auth {
    position: absolute;
    right: clamp(1rem, 4vw, 2.5rem);
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.header-auth svg {
    width: 22px;
    height: 22px;
}

.header-auth:hover {
    box-shadow: 0 6px 15px rgba(79, 70, 229, 0.2);
    transform: translateY(-50%) translateY(-2px);
}

.eyebrow {
    margin: 0 0 0.5rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4c51bf;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.75rem);
}



.layout {
    padding: 0 clamp(1rem, 4vw, 2.5rem) 2rem;
    display: grid;
    gap: 1.5rem;
}

.layout.single-column {
    max-width: 960px;
    margin: 0 auto 2rem;
    grid-template-columns: 1fr;
    justify-items: center;
}
.page-history .layout.single-column {
    margin: 0 auto 2rem !important;
    padding-left: clamp(1rem, 4vw, 2.5rem);
    padding-right: clamp(1rem, 4vw, 2.5rem);
}

.card {
    background: transparent;
    border-radius: 0;
    padding: 1rem 0;
    box-shadow: none;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: center;
    align-items: center;
    width: 100%;
    max-width: 960px;
}
.page-history .card {
    max-width: 100%;
}

.card-header h2 {
    margin: 0.25rem 0 0;
    font-size: 1.65rem;
}

.card-header p {
    margin: 0.25rem 0 0;
    color: #475467;
}

.card-header.stacked {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.back-button {
    align-self: flex-start;
}

.selection-card h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    text-align: center;
}

.zero-step,
.income-step {
    border: none;
    border-radius: 0;
    padding: 1rem 0;
    background: transparent;
    width: 100%;
}

.zero-year {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.zero-year input {
    width: 160px;
    border: 1px solid #d0d5dd;
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
}

.zero-search {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.zero-search input {
    flex: 1;
    min-width: 240px;
    border: 1px solid #d0d5dd;
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
}

.step-actions,
.success-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    width: 100%;
}

.step-actions.split {
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
}

.step-actions.split button {
    flex: 1 1 50%;
}

.prefill-summary {
    line-height: 1.5;
    color: #334155;
    width: 100%;
}

.prefill-intro {
    margin: 0 0 0.5rem;
    color: #475467;
}

.prefill-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e2e8f0;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.prefill-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 0.25rem;
    align-items: center;
    padding: 0.07rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.prefill-row:last-child {
    border-bottom: none;
}

.prefill-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: #1f2937;
    margin: 0;
    white-space: nowrap;
    text-align: left;
}

.prefill-value {
    font-size: 0.85rem;
    color: #0f172a;
    margin: 0;
    text-align: right;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    width: min(420px, 90vw);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0;
}

.auth-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin-top: 0.5rem;
    width: 100%;
}

.auth-actions button {
    flex: 1 1 0;
    width: 100%;
}

.auth-feedback {
    min-height: 1.25rem;
    margin-top: 0.5rem;
    color: #b91c1c;
    font-size: 0.95rem;
}

.auth-secondary {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.75rem;
    width: 100%;
}

.auth-secondary .ghost.subtle {
    opacity: 0.8;
    font-weight: 500;
    width: 100%;
}

.auth-secondary button {
    width: 100%;
}

.menu-button {
    display: block;
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 0.9rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #0f172a;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.menu-button:hover {
    border-color: #4f46e5;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.2);
    transform: translateY(-2px);
}

.history-title {
    margin: 0 0 0.5rem;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
}
.page-history .layout.single-column {
    width: 100%;
}
.page-history .side-panel {
    display: none !important;
}
.page-history.panel-open .layout.single-column {
    margin-left: 0;
}

.history-card {
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
    background: #fff;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.history-meta {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
}

.history-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.97rem;
}

.history-row.muted {
    color: #64748b;
    font-size: 0.9rem;
}

.history-label {
    font-weight: 600;
    color: #1f2937;
}

.history-value {
    text-align: right;
    font-weight: 500;
    color: #0f172a;
}

.history-actions {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    text-align: center;
}

@media (max-width: 767px) {
    .history-actions {
        grid-template-columns: 1fr;
    }
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
    font-size: 0.85rem;
}

.pill.light {
    background: #f1f5f9;
    color: #334155;
}

.side-panel {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: 260px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    padding: 1.25rem 1rem;
    display: none;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    z-index: 900;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.side-panel .side-section h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: #1f2937;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.history-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.35rem 0;
    font-size: 0.95rem;
}

.history-list li span {
    max-width: 60%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.history-list li button {
    border: none;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 0.6rem;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
}

@media (min-width: 1024px) {
    .side-panel {
        display: flex;
        transform: translateX(-100%);
    }
    .panel-open .side-panel {
        transform: translateX(0);
    }
    .layout.single-column {
        margin-left: 0;
        padding-left: clamp(1rem, 4vw, 2.5rem);
        transition: margin-left 0.25s ease;
    }
    .panel-open .layout.single-column {
        margin-left: 260px;
        padding-left: clamp(1rem, 4vw, 2.5rem);
    }
    .site-header {
        padding-left: clamp(1rem, 4vw, 2.5rem);
        padding-right: clamp(1rem, 4vw, 2.5rem);
    }
    .header-burger {
        display: none;
    }
}

@media (max-width: 1023px) {
    .side-panel {
        width: min(320px, 80vw);
        box-shadow: 8px 0 24px rgba(15, 23, 42, 0.2);
        display: flex;
    }
    .side-panel.open {
        transform: translateX(0);
    }
}

.prefill-meta {
    margin-top: 0.75rem;
    font-size: 0.82rem;
    color: #94a3b8;
}

.icon-button {
    border: none;
    background: transparent;
    color: #4f46e5;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.icon-button:hover {
    color: #312e81;
}

.ready-text h3 {
    margin: 0 0 0.5rem;
}

.ready-text p {
    margin: 0;
    color: #475467;
}

.option-grid {
    display: grid;
    gap: 1rem;
}

.option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem 1.25rem;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(14, 165, 233, 0.08));
    transition: background 0.25s ease, transform 0.2s ease, border-color 0.2s ease;
}

.option:hover {
    transform: translateY(-2px);
    border-color: #4f46e5;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(14, 165, 233, 0.15));
}

.option strong {
    font-size: 1.05rem;
}

.option small {
    color: #475467;
}

.option-icon {
    font-size: 1.5rem;
}

.option small {
    display: block;
    color: #475467;
    font-size: 0.9rem;
}

.form-card.hidden {
    display: none;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #4f46e5;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.form-grid.column {
    flex-direction: column;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    max-width: 520px;
    text-align: center;
}

.field label {
    font-weight: 600;
    font-size: 0.92rem;
}

.field input,
.field select {
    border: 1px solid #d0d5dd;
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    text-align: center;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-actions input {
    width: 100%;
}

.button-stack {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: 100%;
    position: relative;
}

.button-stack button {
    flex: 1;
}

.button-stack.loading button {
    opacity: 0.6;
    pointer-events: none;
}

.button-stack.loading::after {
    content: "";
    position: absolute;
    right: 0.75rem;
    top: 50%;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(79, 70, 229, 0.2);
    border-top-color: #4f46e5;
    border-radius: 50%;
    transform: translateY(-50%);
    animation: spin 0.8s linear infinite;
}

.primary,
.ghost {
    cursor: pointer;
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.25);
}

.primary:disabled {
    opacity: 0.6;
    cursor: wait;
    box-shadow: none;
    transform: none;
}

.primary.success {
    background: linear-gradient(135deg, #0f9d58, #34a853);
    box-shadow: 0 15px 30px rgba(15, 157, 88, 0.25);
}

.ghost {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.ghost.subtle {
    background: transparent;
    border: 1px dashed #c7d2fe;
    color: #4f46e5;
}

.primary:hover:not(:disabled),
.ghost:hover {
    transform: translateY(-1px);
}

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #f8fafc;
    border-radius: 999px;
    padding: 0.35rem;
}

.pill-group label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.pill-group label span {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pill-group input {
    display: none;
}

.pill-group input:checked + span {
    background: #fff;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.quarter-grid {
    display: grid;
    gap: 0.6rem;
}

.quarter-grid.column {
    grid-template-columns: 1fr;
}

.form-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
}

.help {
    margin: 0;
    color: #475467;
    font-size: 0.95rem;
}

.help-small {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: #94a3b8;
}

.prefill-feedback {
    min-height: 1.25rem;
    color: #0f172a;
    font-size: 0.9rem;
}

.prefill-feedback.success {
    color: #047857;
}

.prefill-feedback.error {
    color: #b91c1c;
}

.hidden {
    display: none !important;
}

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 999;
}

.toast {
    background: #0f172a;
    color: #fff;
    padding: 0.85rem 1.1rem;
    border-radius: 0.75rem;
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.35);
    min-width: 220px;
    animation: toast-in 0.3s ease forwards;
    font-size: 0.9rem;
}

.toast.success {
    background: #0f9d58;
}

.toast.error {
    background: #dc2626;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

@media (max-width: 768px) {
    .option {
        flex-direction: row;
    }

    .header-brand {
        gap: 0.4rem;
    }

    .header-logo {
        width: 42px;
        height: 42px;
        max-width: 42px;
        max-height: 42px;
        flex-shrink: 0;
    }
}
.field.hidden-field {
    display: none;
}
.year-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 420px;
    margin-bottom: 1rem;
}

.year-button {
    border: 1px solid #d0d5dd;
    border-radius: 0.9rem;
    padding: 0.9rem 0;
    font-size: 1rem;
    font-weight: 600;
    background: #f8fafc;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.year-button.active {
    border-color: #4f46e5;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(14, 165, 233, 0.15));
    color: #1f2667;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.2);
}

.year-button:hover {
    transform: translateY(-1px);
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.75rem;
    width: 100%;
    max-width: 420px;
}

.choice-grid.vertical {
    grid-template-columns: 1fr;
    max-width: 360px;
    margin: 0 auto;
}

.choice-grid label {
    display: block;
}

.choice-grid input {
    display: none;
}

.choice-grid span {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #d0d5dd;
    border-radius: 0.9rem;
    padding: 0.9rem 0;
    font-weight: 600;
    background: #f8fafc;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.choice-grid input:checked + span {
    border-color: #4f46e5;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(14, 165, 233, 0.15));
    color: #1f2667;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.2);
}

.choice-grid span:hover {
    transform: translateY(-1px);
}
.choice-grid.correction input:checked + span {
    border-color: #0f9d58;
    background: linear-gradient(135deg, rgba(15, 157, 88, 0.15), rgba(52, 168, 83, 0.15));
    color: #0f5132;
    box-shadow: 0 8px 18px rgba(15, 157, 88, 0.22);
}

.choice-grid.vertical + .field,
.choice-grid.vertical + .field.hidden {
    width: 100%;
}

.field[data-section="variable-income"] {
    width: 100%;
    max-width: 360px;
    align-self: center;
}

.field[data-section="variable-income"] input {
    width: 100%;
}
.no-underline {
    text-decoration: none;
}

.ghost.danger {
    color: #b91c1c;
    border-color: #fecdd3;
    background: #fff1f2;
}

.ghost.danger:hover {
    background: #ffe4e6;
    border-color: #fda4af;
}
