* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
    padding: 20px;
}

.calculator-container {
    max-width: 960px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 24px 28px;
}

.calc-header {
    text-align: center;
    margin-bottom: 20px;
}

.title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 2px;
}

.logo-link {
    display: inline-block;
}

.logo-img {
    height: 28px;
    width: auto;
}

.calc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
    max-width: 480px;
}

.calc-layout.has-results {
    grid-template-columns: 1fr 1fr;
    max-width: none;
}

.calc-form {
    min-width: 0;
}

.calc-results {
    min-width: 0;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
}

.form-row > * {
    min-width: 0;
    width: 100%;
}

.toggle-group {
    display: flex;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e5e7eb;
}

.toggle-group.compact {
    flex: 1 1 0;
}

.toggle-btn {
    flex: 1;
    padding: 12px 10px;
    border: none;
    background: #f9fafb;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-btn:first-child {
    border-right: 1px solid #e5e7eb;
}

.toggle-btn.active {
    background: #dc2626;
    color: white;
}

.toggle-btn:hover:not(.active) {
    background: #f3f4f6;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.form-select {
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    color: #1a1a2e;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-select.compact {
    flex: 1;
    min-width: 0;
    height: 100%;
}

.form-select:focus {
    outline: none;
    border-color: #dc2626;
}

.social-deduction-info {
    padding: 8px 12px;
    background: #f3f4f6;
    border: 2px solid #dc2626;
    border-radius: 8px;
    font-size: 12px;
    color: #374151;
}

.sub-options {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.sub-option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sub-option-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.form-checkbox-sm {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.form-checkbox-sm:checked {
    background: #dc2626;
    border-color: #dc2626;
}

.form-checkbox-sm:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 1px;
    width: 5px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.vosms-other-wrapper {
    width: 110px;
    flex-shrink: 0;
}

.vosms-other-wrapper .form-input {
    font-size: 12px;
    padding: 4px 24px 4px 8px;
    font-weight: 500;
}

.vosms-other-wrapper .input-suffix {
    font-size: 12px;
    right: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper.compact {
    flex: 1;
    min-width: 0;
    height: 100%;
}

.form-input {
    width: 100%;
    padding: 12px 36px 12px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #dc2626;
}

.form-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.input-suffix {
    position: absolute;
    right: 12px;
    color: #6b7280;
    font-size: 16px;
    font-weight: 600;
    pointer-events: none;
}

.calculate-btn {
    padding: 10px 20px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}

.calculate-btn:hover:not(:disabled) {
    background: #b91c1c;
    transform: translateY(-1px);
}

.calculate-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.error-block {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 14px;
    margin-bottom: 10px;
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-card {
    padding: 10px 14px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    overflow: visible;
}

.result-card.highlight {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.result-card.highlight-green {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.result-card.highlight-amber {
    background: #fef2f2;
    border-color: #fecaca;
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.result-row {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.result-row:not(:last-child) {
    border-bottom: 1px solid #e5e7eb;
}

.result-row.main-row {
    padding: 3px 0;
}

.result-label {
    font-size: 13px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-label-muted {
    font-size: 11px;
    color: #9ca3af;
    padding-left: 10px;
}

.vosms-other-info {
    margin-top: -2px;
}

.info-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    font-weight: 700;
    font-style: italic;
    cursor: help;
    font-family: Georgia, serif;
    user-select: none;
}

.info-icon-wrap:hover .info-icon {
    background: #dc2626;
    color: white;
}

.info-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #f3f4f6;
    border: 2px solid #dc2626;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 400;
    font-style: normal;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #374151;
    white-space: normal;
    width: 220px;
    line-height: 1.4;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #dc2626;
}

.info-icon-wrap:hover .info-tooltip {
    display: block;
}

.result-value-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    transition: all 0.15s ease;
    color: #6b7280;
}

.copy-btn:hover {
    color: #374151;
}

.copy-btn:active {
    transform: scale(0.92);
}

.copy-svg {
    width: 14px;
    height: 14px;
    color: #6b7280;
}

.copy-check-svg {
    width: 14px;
    height: 14px;
    color: #16a34a;
}

.result-value {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a2e;
    white-space: nowrap;
}

.result-value.deduction {
    color: #1a1a2e;
}

.result-value.employer {
    color: #1a1a2e;
}

.main-row .result-label {
    font-size: 13px;
    font-weight: 600;
}

.main-row .result-value {
    font-size: 16px;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: #ffffff;
    color: #dc2626;
    border: 1.5px solid #dc2626;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.download-btn svg {
    flex-shrink: 0;
}

.download-btn:hover:not(:disabled) {
    background: #dc2626;
    color: white;
}

.download-btn:hover:not(:disabled) svg {
    stroke: white;
}

@media (max-width: 768px) {
    .calc-layout,
    .calc-layout.has-results {
        grid-template-columns: 1fr;
        max-width: none;
        gap: 20px;
    }

    .calc-results {
        border-top: 1px solid #e5e7eb;
        padding-top: 16px;
    }

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

    .sub-options {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .calculator-container {
        padding: 16px 14px;
        border-radius: 12px;
    }

    .title {
        font-size: 18px;
    }

    .toggle-btn {
        font-size: 13px;
        padding: 10px 8px;
    }

    .form-input {
        font-size: 16px;
    }

    .vosms-inline {
        flex-direction: column;
        align-items: flex-start;
    }
}

body.embed {
    background: transparent;
    padding: 0;
    min-height: auto;
}

body.embed .calculator-container {
    max-width: none;
    border-radius: 0;
    box-shadow: none;
}

body.embed .calc-header {
    display: none;
}

@media (max-width: 480px) {
    body.embed {
        padding: 0;
    }

    body.embed .calculator-container {
        border-radius: 0;
    }
}
