/* ============================================
   PolicyEase 保單易 - iOS-like Mobile-First Styles
   ============================================ */

:root {
    --primary-color: #007AFF;
    --primary-dark: #0051D5;
    --background: #F2F2F7;
    --card-bg: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #6E6E73;
    --border-color: #C6C6C8;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --error-color: #FF3B30;
    --overlay-bg: rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 100vh;
}

/* ============================================
   Header
   ============================================ */

.app-header {
    background-color: var(--card-bg);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.title-zh {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-restore {
    padding: 0.5rem 1rem;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background-color: transparent;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-restore:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.btn-restore:active {
    transform: translateY(0);
}

#languageSelect {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
    min-height: 36px;
}

#languageSelect:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

#languageSelect:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* ============================================
   Benchmark Info
   ============================================ */

.benchmark-info {
    display: block;
    background-color: #FFF9E6;
    color: #856404;
    padding: 0.75rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    border-bottom: 1px solid #FFE69C;
}

/* ============================================
   Container & Cards
   ============================================ */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    position: relative;
    transition: box-shadow 0.2s ease;
    min-height: 200px;
    display: block;
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: block;
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: block;
}

/* ============================================
   Disclaimer
   ============================================ */

.disclaimer {
    background-color: #FFF3CD;
    border: 1px solid #FFE69C;
    border-radius: var(--border-radius);
    padding: 1rem;
    color: #856404;
}

.disclaimer strong {
    display: block;
    margin-bottom: 0.5rem;
}

/* ============================================
   Form Styles
   ============================================ */

.form-group {
    margin-bottom: 1.25rem;
    min-height: 50px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    min-height: 20px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.2s;
    min-height: 44px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.disabled-input {
    background-color: var(--background);
    color: var(--text-secondary);
    cursor: not-allowed;
}

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

.input-with-prefix .prefix {
    position: absolute;
    left: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    pointer-events: none;
}

.input-with-prefix input {
    padding-left: 3rem;
}

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

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: linear-gradient(135deg, #007AFF 0%, #0066DD 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
    font-weight: 700;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #0066DD 0%, #0055CC 100%);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
    transform: translateY(-1px);
}

.btn-unlock {
    background: linear-gradient(135deg, #FF9500 0%, #FF8000 100%);
    color: white;
    font-size: 0.9375rem;
    padding: 0.875rem 1.75rem;
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.25);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.btn-unlock:hover {
    background: linear-gradient(135deg, #FF8A00 0%, #FF7000 100%);
    box-shadow: 0 6px 16px rgba(255, 149, 0, 0.35);
    transform: translateY(-1px);
}

.btn-large {
    padding: 1.125rem 2rem;
    font-size: 1.125rem;
    min-height: 56px;
}

.btn-featured {
    background: linear-gradient(135deg, #FF9500 0%, #FF6B00 100%);
    position: relative;
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.4);
    transform: scale(1.02);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-featured:hover {
    box-shadow: 0 8px 24px rgba(255, 149, 0, 0.5);
    transform: scale(1.03) translateY(-1px);
}

.btn-featured::before {
    content: '⭐ BEST VALUE';
    position: absolute;
    top: -10px;
    right: 10px;
    background: linear-gradient(135deg, #FF3B30 0%, #E61E14 100%);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
    z-index: 1;
    white-space: nowrap;
}

.pricing-options {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
    padding: 0.5rem;
}

@media (min-width: 640px) {
    .pricing-options {
        flex-direction: row;
        justify-content: center;
        gap: 1.5rem;
    }

    .pricing-options .btn {
        flex: 1;
        max-width: 280px;
    }
}

/* ============================================
   Results Section
   ============================================ */

.results-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: var(--background);
    border-radius: 8px;
}

.result-item.locked {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.08) 0%, rgba(255, 149, 0, 0.04) 100%);
    border: 2px dashed rgba(255, 149, 0, 0.3);
    padding: 1.5rem;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

.result-item.locked .locked-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.result-item.locked .locked-content span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.result-item.locked .btn-unlock {
    width: 100%;
    max-width: 400px;
    padding: 1rem 2rem;
    font-size: 1rem;
    box-shadow: 0 4px 16px rgba(255, 149, 0, 0.3);
}

.result-item.locked .btn-unlock:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 149, 0, 0.4);
}

.result-value {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.comment {
    margin-top: 0.75rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border-left: 3px solid var(--primary-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   Locked Content
   ============================================ */

.locked {
    position: relative;
    overflow: hidden;
}

.locked-overlay {
    text-align: center;
    padding: 2.5rem 1.5rem;
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 249, 251, 0.98) 100%);
    border-radius: var(--border-radius);
}

.locked-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

.locked-overlay h3 {
    position: relative;
    z-index: 1;
    color: #000000;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.locked-overlay p {
    position: relative;
    z-index: 1;
    color: #3C3C43;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    font-weight: 500;
}

.locked-overlay button {
    position: relative;
    z-index: 10;
    filter: none;
}

/* ============================================
   Currency Conversion Section
   ============================================ */

.currency-conversion-section {
    margin-top: 1.5rem;
    padding: 0;
    background: transparent;
    border-radius: var(--border-radius);
    border: none;
}

.conversion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.conversion-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.conversion-header h4 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.currency-conversion-section .locked-content {
    text-align: center;
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(0, 122, 255, 0.02) 100%);
    border-radius: var(--border-radius);
    border: 2px dashed rgba(0, 122, 255, 0.2);
    box-shadow: 0 2px 12px rgba(0, 122, 255, 0.08);
}

.currency-conversion-section .locked-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.currency-conversion-section .unlocked-content {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(0, 122, 255, 0.02) 100%);
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 122, 255, 0.1);
}

.exchange-rate-info {
    padding: 1rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 3px solid var(--success-color);
}

.exchange-rate-info span {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.converted-amounts {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.converted-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.converted-item:last-child {
    border-bottom: none;
}

.converted-item span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.converted-item strong {
    color: var(--primary-color);
    font-size: 1.125rem;
}

/* FX Impact Analysis - Scenario Styling */

.fx-current-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

.fx-info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.fx-info-item span {
    font-size: 1.5rem;
}

.fx-info-item div {
    flex: 1;
}

.fx-info-item strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.fx-info-item small {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.btn-analyze {
    width: 100%;
    margin: 1rem 0;
}

.fx-scenarios {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.fx-scenarios h4 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.125rem;
}

.scenario-item {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid;
    background-color: var(--card-bg);
}

.scenario-pessimistic {
    border-color: var(--error-color);
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.05) 0%, rgba(255, 59, 48, 0.02) 100%);
}

.scenario-realistic {
    border-color: var(--warning-color);
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.05) 0%, rgba(255, 149, 0, 0.02) 100%);
}

.scenario-optimistic {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.05) 0%, rgba(52, 199, 89, 0.02) 100%);
}

.scenario-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.scenario-icon {
    font-size: 1.25rem;
}

.scenario-header strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.scenario-details {
    display: grid;
    gap: 0.5rem;
}

.scenario-rate {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.scenario-irr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.scenario-irr span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.scenario-irr strong {
    font-size: 1.25rem;
    font-weight: 700;
}

.scenario-pessimistic .scenario-irr strong {
    color: var(--error-color);
}

.scenario-realistic .scenario-irr strong {
    color: var(--warning-color);
}

.scenario-optimistic .scenario-irr strong {
    color: var(--success-color);
}

.scenario-impact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem;
    border-radius: 6px;
    background-color: rgba(0, 0, 0, 0.03);
}

.scenario-pessimistic .scenario-impact {
    color: var(--error-color);
}

.scenario-realistic .scenario-impact {
    color: var(--warning-color);
}

.scenario-optimistic .scenario-impact {
    color: var(--success-color);
}

.fx-disclaimer {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: rgba(0, 122, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    display: flex;
    gap: 0.75rem;
}

.fx-disclaimer strong {
    font-size: 1.25rem;
    line-height: 1;
}

.fx-disclaimer p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .fx-current-info {
        grid-template-columns: 1fr;
    }
}

.locked-content .btn-unlock {
    margin-left: auto;
}

/* ============================================
   Comparison Table
   ============================================ */

.comparison-table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.comparison-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    vertical-align: middle;
}

.comparison-table th small {
    font-size: 0.7rem;
    font-weight: 500;
    display: block;
    opacity: 0.95;
    line-height: 1.3;
}

.comparison-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    vertical-align: middle;
}

.comparison-table td:first-child {
    text-align: left;
}

.comparison-table td:last-child {
    white-space: nowrap;
}

.comparison-table tr:hover {
    background-color: var(--background);
}

.comparison-table button {
    padding: 0.5rem;
    background-color: var(--error-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.modal-actions .btn {
    flex: 1;
}

/* ============================================
   Upgrade Modal
   ============================================ */

.upgrade-modal {
    max-width: 600px;
}

.upgrade-badge {
    position: absolute;
    top: -10px;
    right: 20px;
    background: linear-gradient(135deg, #FF9500 0%, #FF6B00 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.upgrade-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background-color: var(--background);
    border-radius: 8px;
}

.upgrade-current,
.upgrade-new {
    padding: 1rem;
}

.upgrade-current {
    border-right: 2px solid var(--border-color);
}

.upgrade-current h4 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.upgrade-new h4 {
    color: var(--primary-color);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.upgrade-comparison ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.upgrade-comparison li {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.upgrade-comparison li::before {
    content: '✓';
    color: var(--success-color);
    font-weight: bold;
}

.upgrade-arrow {
    display: flex;
    align-items: center;
    font-size: 2rem;
    color: var(--primary-color);
}

.upgrade-price {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

@media (max-width: 640px) {
    .upgrade-comparison {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .upgrade-current {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }

    .upgrade-arrow {
        transform: rotate(90deg);
        justify-content: center;
        margin: 0.5rem 0;
    }
}

/* ============================================
   Loading Overlay
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

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

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1rem;
}

/* ============================================
   Footer
   ============================================ */

.app-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.footer-separator {
    color: var(--border-color);
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .app-title {
        font-size: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .comparison-table {
        font-size: 0.75rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem;
    }
}

/* Dark mode disabled by default - uncomment to enable */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --background: #000000;
        --card-bg: #1C1C1E;
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --border-color: #38383A;
    }
}
*/

/* ============================================
   Legal Pages (Privacy & Terms) Enhancements
   ============================================ */

/* Legal pages now use the main app structure with .card */
.card h2 {
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.card h3 {
    margin-top: 1.5rem;
    font-size: 1.125rem;
}

.card p,
.card li {
    line-height: 1.8;
}

.card code {
    background-color: var(--background);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

/* Style links in card content, but not buttons */
.card a:not(.btn) {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 122, 255, 0.3);
    transition: all 0.2s;
}

.card a:not(.btn):hover {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-dark);
}

/* Ensure buttons maintain their styling */
.card .btn-primary {
    color: white !important;
    border-bottom: none !important;
}

.disclaimer-box {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.1) 0%, rgba(255, 149, 0, 0.05) 100%);
    border-left: 4px solid var(--warning-color);
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.1);
}

.disclaimer-box strong {
    color: var(--warning-color);
    font-weight: 700;
    font-size: 1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.disclaimer-box p {
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
}

/* Enhanced dark mode for legal pages - disabled */
/*
@media (prefers-color-scheme: dark) {
    .disclaimer-box {
        background: linear-gradient(135deg, rgba(255, 149, 0, 0.2) 0%, rgba(255, 149, 0, 0.1) 100%);
    }

    .disclaimer-box strong {
        color: #FFC940;
    }
}
*/

/* ============================================
   Enhanced Accessibility & Focus States
   ============================================ */

/* Better focus indicators */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Ensure minimum tap targets on mobile */
@media (pointer: coarse) {
    .btn,
    button,
    a {
        min-height: 44px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Fix placeholder color for dark mode */
.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-group select option {
    background-color: var(--card-bg);
    color: var(--text-primary);
}

/* Remove number input spinners for cleaner look */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Ensure number inputs look like text inputs */
.form-group input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

/* Age-based calculation indicators */
.age-indicator {
    color: #2196F3;
    font-size: 0.8rem;
    display: block;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Age-based section title */
.age-section-title {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.age-section-title h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Comparison table action buttons */
.comparison-table button {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: opacity 0.2s;
}

.comparison-table button:hover {
    opacity: 0.9;
}

.btn-edit {
    background-color: #2196F3;
    color: white;
    margin-right: 0.5rem;
}

.btn-delete {
    background-color: #f44336;
    color: white;
}

/* Fulfillment Rate Analysis Styles */
.fulfillment-analysis-results {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 2px solid var(--primary-color);
}

.fulfillment-analysis-results h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.fulfillment-analysis-results h4 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.fulfillment-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
    table-layout: fixed;
}

/* Column widths for scenarios comparison table */
.scenarios-comparison .fulfillment-table th:nth-child(1),
.scenarios-comparison .fulfillment-table td:nth-child(1) {
    width: 18%;
}

.scenarios-comparison .fulfillment-table th:nth-child(2),
.scenarios-comparison .fulfillment-table td:nth-child(2) {
    width: 10%;
    text-align: center;
}

.scenarios-comparison .fulfillment-table th:nth-child(3),
.scenarios-comparison .fulfillment-table td:nth-child(3) {
    width: 22%;
    text-align: right;
}

.scenarios-comparison .fulfillment-table th:nth-child(4),
.scenarios-comparison .fulfillment-table td:nth-child(4) {
    width: 18%;
    text-align: right;
}

.scenarios-comparison .fulfillment-table th:nth-child(5),
.scenarios-comparison .fulfillment-table td:nth-child(5) {
    width: 18%;
    text-align: center;
}

.scenarios-comparison .fulfillment-table th:nth-child(6),
.scenarios-comparison .fulfillment-table td:nth-child(6) {
    width: 14%;
    text-align: center;
}

.fulfillment-table th,
.fulfillment-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.fulfillment-table th {
    background-color: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: normal;
    line-height: 1.3;
}

.fulfillment-table tr:hover {
    background-color: var(--background);
}

.fulfillment-table .total-row {
    font-weight: 600;
    border-top: 2px solid var(--border-color);
}

.fulfillment-table .highlight-row {
    background-color: rgba(0, 122, 255, 0.08);
    font-weight: 500;
    border-left: 3px solid var(--primary-color);
}

/* Impact severity color coding */
.fulfillment-table .impact-mild {
    color: var(--success-color);
    font-weight: 600;
}

.fulfillment-table .impact-moderate {
    color: var(--warning-color);
    font-weight: 600;
}

.fulfillment-table .impact-serious {
    color: #FF6B35;
    font-weight: 600;
}

.fulfillment-table .impact-severe {
    color: var(--error-color);
    font-weight: 700;
    background-color: rgba(255, 59, 48, 0.05);
}

/* Breakeven period color coding */
.fulfillment-table .breakeven-good {
    color: var(--success-color);
    font-weight: 600;
}

.fulfillment-table .breakeven-moderate {
    color: var(--warning-color);
    font-weight: 600;
}

.fulfillment-table .breakeven-long {
    color: var(--error-color);
    font-weight: 600;
}

/* Enhanced cell styling */
.fulfillment-table .amount-cell {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.95em;
}

.fulfillment-table .irr-cell {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.95em;
}

/* Legacy support */
.fulfillment-table .negative-impact {
    color: #f44336;
    font-weight: 600;
}

/* Fulfillment insights cards */
.fulfillment-insights {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(88, 86, 214, 0.05) 100%);
    border-radius: var(--border-radius);
}

.fulfillment-insights h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.insight-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.insight-card {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.insight-card.insight-warning {
    border-left-color: var(--warning-color);
}

.insight-card.insight-danger {
    border-left-color: var(--error-color);
}

.insight-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.insight-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.insight-card.insight-warning .insight-value {
    color: var(--warning-color);
}

.insight-card.insight-danger .insight-value {
    color: var(--error-color);
}

.insight-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Responsive table for mobile */
@media (max-width: 768px) {
    .fulfillment-table {
        font-size: 0.75rem;
    }

    .fulfillment-table th,
    .fulfillment-table td {
        padding: 0.5rem 0.25rem;
    }

    .fulfillment-table th {
        font-size: 0.7rem;
    }

    /* Adjust column widths for mobile */
    .scenarios-comparison .fulfillment-table th:nth-child(1),
    .scenarios-comparison .fulfillment-table td:nth-child(1) {
        width: 20%;
    }

    .scenarios-comparison .fulfillment-table th:nth-child(2),
    .scenarios-comparison .fulfillment-table td:nth-child(2) {
        width: 12%;
    }

    .scenarios-comparison .fulfillment-table th:nth-child(3),
    .scenarios-comparison .fulfillment-table td:nth-child(3) {
        width: 20%;
    }

    .scenarios-comparison .fulfillment-table th:nth-child(4),
    .scenarios-comparison .fulfillment-table td:nth-child(4) {
        width: 16%;
    }

    .scenarios-comparison .fulfillment-table th:nth-child(5),
    .scenarios-comparison .fulfillment-table td:nth-child(5) {
        width: 18%;
    }

    .scenarios-comparison .fulfillment-table th:nth-child(6),
    .scenarios-comparison .fulfillment-table td:nth-child(6) {
        width: 14%;
    }

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

    .insight-value {
        font-size: 1.5rem;
    }
}

.key-insights ul,
.recommendation ul {
    margin-left: 1.5rem;
    line-height: 1.8;
}

.key-insights li,
.recommendation li {
    margin-bottom: 0.5rem;
}

.payout-breakdown,
.irr-breakdown,
.scenarios-comparison {
    margin-bottom: 1.5rem;
}
