:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --line: #d9e3f3;
    --ink: #1f2a3d;
    --muted: #61708a;
    --primary: #1063ff;
    --primary-strong: #0c4ecc;
    --ok: #14804a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(800px 400px at 90% -10%, #d9e8ff 0%, transparent 60%),
        radial-gradient(700px 350px at -10% 5%, #e4f8ef 0%, transparent 60%),
        var(--bg);
}

.new-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 16px 42px;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-switch {
    display: inline-flex;
    border: 1px solid #c8d9ff;
    border-radius: 999px;
    background: #edf3ff;
    padding: 2px;
}

.lang-link {
    text-decoration: none;
    color: #43649c;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    padding: 7px 10px;
    border-radius: 999px;
}

.lang-link.active {
    background: #fff;
    color: #173f92;
    box-shadow: 0 2px 6px rgba(22, 63, 146, 0.2);
}

.brand h1 {
    margin: 0;
    font-size: 29px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.brand p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.legacy-link {
    text-decoration: none;
    color: var(--primary-strong);
    border: 1px solid #c8d9ff;
    background: #edf3ff;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 13px;
}

.grid {
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    gap: 16px;
    align-items: start;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 25px rgba(25, 52, 96, 0.08);
}

.form-card {
    padding: 18px;
}

.form-card h2,
.result-card h2 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 800;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.form-switch-group {
    margin-top: 2px;
}

.switch-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.switch-label-row > span:first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.switch-control {
    position: relative;
    width: 46px;
    height: 26px;
    flex: 0 0 auto;
}

.switch-control input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d4deef;
    transition: background-color 0.18s ease;
}

.switch-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(24, 39, 75, 0.22);
    transition: transform 0.18s ease;
}

.switch-control input:checked + .switch-slider {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.switch-control input:checked + .switch-slider::before {
    transform: translateX(20px);
}

.diety-amount-group {
    display: none;
}

.diety-amount-group.visible {
    display: flex;
}

label {
    font-size: 13px;
    font-weight: 700;
}

label small {
    color: var(--muted);
    font-weight: 500;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
}

input:focus {
    outline: 2px solid rgba(16, 99, 255, 0.18);
    border-color: var(--primary);
}

.info {
    margin-top: 6px;
    border: 1px solid #cddfff;
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    color: #2a4b7d;
}

.quick-legend {
    margin-top: 8px;
    border: 1px solid #cfe0ff;
    background: linear-gradient(180deg, #f6f9ff 0%, #eef4ff 100%);
    border-radius: 12px;
    padding: 10px 12px;
}

.quick-legend strong {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #214a86;
}

.quick-legend ul {
    margin: 0;
    padding-left: 18px;
}

.quick-legend li {
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.35;
    color: #2a4b7d;
}

.btn {
    width: 100%;
    border: none;
    border-radius: 11px;
    padding: 12px 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
}

.result-card {
    padding: 18px;
}

.summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.summary-item {
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 10px;
    background: #fbfdff;
    transition: box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.summary-item span {
    font-size: 12px;
    color: var(--muted);
    display: block;
}

.summary-item strong {
    font-size: 16px;
}

.summary-item.summary-total {
    position: relative;
    border: none;
    background: linear-gradient(90deg, #176a3f 0%, #1d7b4b 28%, #258b56 62%, #31a66a 100%);
    color: #fff;
    overflow: visible;
    box-shadow: 0 8px 20px rgba(20, 108, 66, 0.22);
    animation: totalPulse 2.1s ease-in-out infinite;
}

.summary-item.summary-total::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 14px;
    background: radial-gradient(circle at 50% 50%, rgba(49, 166, 106, 0.45) 0%, rgba(49, 166, 106, 0.12) 55%, rgba(49, 166, 106, 0) 78%);
    z-index: -1;
    animation: totalPulseRing 2.1s ease-in-out infinite;
}

.summary-item.summary-total span {
    color: rgba(255, 255, 255, 0.85);
}

.summary-item.summary-total strong {
    color: #fff;
}

@keyframes totalPulse {
    0%,
    100% {
        box-shadow: 0 8px 20px rgba(20, 108, 66, 0.22);
        transform: translateY(0) scale(1);
    }

    50% {
        box-shadow: 0 14px 32px rgba(20, 108, 66, 0.45);
        transform: translateY(-1px) scale(1.015);
    }
}

@keyframes totalPulseRing {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.98);
    }

    50% {
        opacity: 0.9;
        transform: scale(1.04);
    }
}

@media (prefers-reduced-motion: reduce) {
    .summary-item.summary-total {
        animation: none;
    }

    .summary-item.summary-total::after {
        animation: none;
        opacity: 0.3;
    }
}

.bvg-threshold-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid #ffd7a1;
    background:
        linear-gradient(180deg, #fff9ef 0%, #fff4df 100%),
        radial-gradient(200px 80px at 100% 0%, rgba(255, 214, 143, 0.28) 0%, transparent 70%);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 20px rgba(150, 93, 15, 0.08);
}

.bvg-threshold-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9a5d00;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    margin-top: 2px;
}

.bvg-threshold-content {
    min-width: 0;
}

.bvg-threshold-notice strong {
    display: block;
    color: #7c4a00;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 3px;
}

.bvg-threshold-notice span {
    display: block;
    color: #8f5c0d;
    font-size: 12px;
    font-weight: 600;
}

.legend {
    border: 1px solid var(--line);
    background: #f7faff;
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 12px;
}

.legend strong {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
}

.legend ul {
    margin: 0;
    padding-left: 18px;
}

.legend li {
    font-size: 12px;
    color: var(--ink);
    margin-bottom: 4px;
}

.costs-highlight {
    border: 1px solid #bcd3f7;
    background:
        linear-gradient(180deg, #f3f8ff 0%, #eaf3ff 100%),
        radial-gradient(280px 120px at 100% 0%, rgba(116, 165, 255, 0.18) 0%, transparent 72%);
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 12px;
    box-shadow: 0 8px 20px rgba(35, 76, 145, 0.1);
}

.costs-highlight strong {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #1d437f;
}

.costs-highlight ul {
    margin: 0;
    padding-left: 18px;
}

.costs-highlight li {
    font-size: 13px;
    color: #243856;
    margin-bottom: 4px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.payroll-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: visible;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.payroll-table thead {
    background: linear-gradient(180deg, #edf4ff 0%, #e7f0ff 100%);
}

.payroll-table thead td {
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 800;
    color: #203a65;
}

.payroll-table tbody td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #eaf0fb;
}

.payroll-table tbody tr:last-child td {
    border-bottom: none;
}

.payroll-table tbody tr:hover td {
    background-color: #f4f8ff;
}

.payroll-table .calc-row-final-brutto td {
    background: #ffffff;
    font-size: 14px;
}

thead {
    background: #eef4ff;
}

thead td {
    font-size: 12px;
    font-weight: 800;
    padding: 8px;
}

tbody td {
    padding: 8px;
    font-size: 12px;
}

.metric-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.help-tip {
    position: relative;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e8f0ff;
    border: 1px solid #b7ccf8;
    color: #1c55c5;
    font-size: 11px;
    font-weight: 800;
    line-height: 14px;
    text-align: center;
    cursor: help;
    display: inline-block;
    user-select: none;
}

.tip-box {
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    transform: translateX(-50%);
    width: 300px;
    max-width: 70vw;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #cfe0ff;
    background: #f7faff;
    color: #20324f;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: 0 10px 22px rgba(20, 44, 84, 0.14);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 40;
}

.tip-box strong {
    display: block;
    margin-bottom: 4px;
    color: #1e3d73;
    font-size: 12px;
}

.tip-box span {
    display: block;
}

.tip-note {
    margin-top: 4px;
    color: #4f6282;
    font-size: 11px;
}

.help-tip:hover .tip-box,
.help-tip:focus .tip-box {
    opacity: 1;
    visibility: visible;
}

.help-tip:focus {
    outline: 2px solid rgba(16, 99, 255, 0.35);
    outline-offset: 2px;
}

.bvg-popup-trigger {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #b7ccf8;
    background: #e8f0ff;
    color: #1c55c5;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.bvg-popup-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 24, 40, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    z-index: 1300;
}

.bvg-popup-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.bvg-popup-card {
    position: relative;
    width: min(560px, 92vw);
    border-radius: 16px;
    border: 1px solid #cfe0ff;
    background: #f7faff;
    box-shadow: 0 18px 42px rgba(20, 44, 84, 0.24);
    padding: 16px 16px 14px;
}

.bvg-popup-card strong {
    display: block;
    color: #1e3d73;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 8px;
    padding-right: 26px;
}

.bvg-popup-card span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #20324f;
    margin-bottom: 5px;
    line-height: 1.4;
}

.bvg-popup-close {
    position: absolute;
    right: 10px;
    top: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #c3d6ff;
    background: #eef4ff;
    color: #214a86;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 24, 40, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1200;
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.loading-card {
    min-width: 220px;
    max-width: 92vw;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(238, 245, 255, 0.72));
    box-shadow: 0 18px 44px rgba(18, 35, 72, 0.28);
    padding: 16px 18px;
    text-align: center;
}

.loading-card strong {
    display: block;
    color: #1a335f;
    font-size: 15px;
    font-weight: 800;
    margin-top: 2px;
}

.loading-card span {
    display: block;
    color: #39527a;
    font-size: 12px;
    margin-top: 4px;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 8px;
    border-radius: 50%;
    border: 3px solid rgba(16, 99, 255, 0.22);
    border-top-color: var(--primary);
    animation: loaderSpin 0.8s linear infinite;
}

@keyframes loaderSpin {
    to {
        transform: rotate(360deg);
    }
}

tbody tr:nth-child(even) {
    background: #f9fbff;
}

.payroll-table tbody tr:nth-child(even) {
    background: #f9fbff;
}

.calc-costs-start td {
    border-top: 3px solid #9cb9ea;
    background: linear-gradient(180deg, #eef4ff 0%, #e8f0ff 100%);
}



.payroll-table .calc-costs-row td {
    background-color: #f7faff;
}

.payroll-table .calc-costs-row:hover td {
    background-color: #eef4ff;
}

.payroll-table .calc-row-odvody td:first-child {
    box-shadow: inset 4px 0 0 #4d8dff;
}

.payroll-table .calc-row-dan td:first-child {
    box-shadow: inset 4px 0 0 #2fad73;
}

.payroll-table .calc-row-qst.row-highlight td:first-child,
.payroll-table .calc-row-dan.row-highlight td:first-child {
    box-shadow: inset 4px 0 0 #2fad73;
}

.payroll-table .calc-row-admin td:first-child {
    box-shadow: inset 4px 0 0 #f2a63a;
}

.payroll-table .calc-row-admin.row-highlight td:first-child {
    box-shadow: inset 4px 0 0 #f2a63a;
}

.payroll-table .calc-row-krankenkasse td {
    background-color: #fff5f5;
}

.payroll-table .calc-row-krankenkasse td:first-child {
    box-shadow: inset 4px 0 0 #e24a4a;
    color: #8f2020;
    font-weight: 700;
}

.payroll-table .calc-row-krankenkasse:hover td {
    background-color: #ffeaea;
}

.payroll-table .calc-row-krankenkasse.row-highlight td:first-child {
    box-shadow: inset 4px 0 0 #e24a4a;
}

.payroll-table .calc-row-diety td {
    background-color: #f2f8ff;
}

.payroll-table .calc-row-diety td:first-child {
    box-shadow: inset 4px 0 0 #2b73e0;
    color: #1c4f9f;
    font-weight: 700;
}

.payroll-table .calc-row-diety:hover td {
    background-color: #e9f2ff;
}

.row-highlight td {
    background-color: #edf5ff !important;
    transition: background-color 0.15s ease;
}

.source-rate-row.row-highlight td:first-child,
.source-qst-row.row-highlight td:first-child,
.summary-netto.row-highlight {
    box-shadow: inset 3px 0 0 #6da0ff;
}

.calc-row-final-brutto.row-highlight td:first-child {
    box-shadow: inset 4px 0 0 #6da0ff;
}

.summary-netto.row-highlight {
    border-color: #5e96ff;
    background: linear-gradient(180deg, #f2f7ff 0%, #e5efff 100%);
    box-shadow:
        inset 3px 0 0 #3d84ff,
        0 0 0 2px rgba(61, 132, 255, 0.22),
        0 10px 22px rgba(45, 108, 224, 0.2);
    transform: translateY(-1px);
}

.summary-netto.row-highlight span,
.summary-netto.row-highlight strong {
    color: #0e3a8c;
}

.source-qst-row.row-highlight td:first-child {
    box-shadow: inset 3px 0 0 #51b885;
}

.total-row {
    background: transparent;
}

.total-row td {
    font-weight: 800;
    color: #fff;
}

.total-row td:nth-child(1) {
    background: #176a3f !important;
}

.total-row td:nth-child(2) {
    background: #1d7b4b !important;
}

.total-row td:nth-child(3) {
    background: #258b56 !important;
}

.total-row td:nth-child(4) {
    background: #31a66a !important;
}

.app-version {
    margin-top: 10px;
    text-align: right;
    color: #7a8ba8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

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

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

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

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