/* Cards */
.card {
    background: var(--surface-1);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

.btn-success {
    background: var(--lender-primary);
    color: white;
}

.btn-warning {
    background: var(--borrower-primary);
    color: white;
}

.btn-danger {
    background: #DC2626;
    color: white;
}

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    min-width: 36px;
    justify-content: center;
}

/* Escrow Verification */
.escrow-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(46, 204, 113, 0.12);
    color: var(--success, #2ecc71);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.escrow-verify-card {
    background: var(--surface-2, #f5f5f5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
}

.escrow-verify-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.form-input:read-only {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-calculated {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface-1);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.25rem;
    color: var(--text-primary);
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-card-clickable {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

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

.clickable-cell {
    cursor: pointer;
    transition: background-color 0.15s;
}

.clickable-cell:hover {
    background-color: rgba(0,0,0,0.04);
}

.info-icon {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-left: 0.25rem;
}

.tooltip-trigger {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
}

.tooltip-trigger .tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 250px;
    z-index: 100;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: opacity 0.2s, visibility 0.2s;
    text-align: left;
    line-height: 1.4;
}

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

.tooltip-trigger:hover .tooltip-text,
.tooltip-trigger:focus .tooltip-text,
.tooltip-trigger.active .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.cost-breakdown-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.cost-breakdown-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cost-breakdown-title {
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.cost-breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.cost-breakdown-row.total {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 600;
}

.cost-breakdown-close {
    margin-top: 1rem;
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

.cost-breakdown-close:hover {
    background: var(--border-color);
}

/* LTV Badges */
.ltv-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.ltv-safe {
    background: rgba(5, 150, 105, 0.12);
    color: var(--ltv-safe);
}

.ltv-caution {
    background: rgba(217, 119, 6, 0.12);
    color: var(--ltv-caution);
}

.ltv-warning {
    background: rgba(234, 88, 12, 0.12);
    color: var(--ltv-warning);
}

.ltv-danger {
    background: rgba(220, 38, 38, 0.12);
    color: var(--ltv-danger);
}

/* Role Badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    min-width: 80px;
    text-align: center;
}

.role-lender {
    background: var(--lender-light);
    color: var(--lender-dark);
}

.role-borrower {
    background: var(--borrower-light);
    color: var(--borrower-dark);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    min-width: 85px;
    text-align: center;
    text-transform: uppercase;
}

.status-active {
    background: rgba(58, 79, 192, 0.1);
    color: var(--primary);
}

.status-completed {
    background: rgba(5, 150, 105, 0.1);
    color: var(--ltv-safe);
}

.status-liquidated {
    background: rgba(220, 38, 38, 0.1);
    color: var(--ltv-danger);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(4px);
    background: rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 0.75rem;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-warning {
    background: rgba(217, 119, 6, 0.1);
    color: #B45309;
    border: 1px solid rgba(217, 119, 6, 0.25);
}

.alert-danger {
    background: rgba(220, 38, 38, 0.1);
    color: #B91C1C;
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.alert-success {
    background: rgba(5, 150, 105, 0.1);
    color: #047857;
    border: 1px solid rgba(5, 150, 105, 0.25);
}

.alert-info {
    background: rgba(58, 79, 192, 0.08);
    color: #2E3FA0;
    border: 1px solid rgba(58, 79, 192, 0.2);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* Utility Classes */
.text-success { color: var(--lender-primary); }
.text-warning { color: var(--borrower-primary); }
.text-danger { color: var(--ltv-danger); }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    margin-bottom: 1rem;
}

.back-btn:hover {
    color: var(--text-primary);
}

/* Refresh button animation */
.refreshing {
    animation: spin 1s linear infinite;
}

/* Form Wizard */
.form-wizard-progress {
    display: flex;
    gap: 0.25rem;
    padding: 0 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.wizard-step {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color 0.2s ease;
}
.wizard-step:hover {
    color: var(--primary);
}
.wizard-step.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.wizard-step.completed { color: var(--ltv-safe); border-bottom-color: var(--ltv-safe); }
.wizard-step span.step-num {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    align-items: center;
    flex-shrink: 0;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--surface-2);
    margin-right: 0.25rem;
}
.wizard-step.active span.step-num { background: var(--primary); color: #fff; }
.wizard-step.completed span.step-num { background: var(--ltv-safe); color: #fff; }
.form-step { display: none; }
.form-step.active { display: block; }

/* Section divider */
.form-section {
    border-top: 1px solid var(--border-color);
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

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

/* File upload button */
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.file-upload-btn.has-file {
    border-style: solid;
    border-color: var(--lender-primary);
    color: var(--lender-primary);
}

/* Skeleton shimmer */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-1) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Tab Bar */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.tab-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Secondary Tab Bar (sub-tabs inside a tab) */
.tab-bar-secondary {
    margin-bottom: 1rem;
}
.tab-bar-secondary .tab-btn {
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
}

/* Health Dot */
.health-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}
.health-dot.safe { background: var(--ltv-safe); }
.health-dot.caution { background: var(--ltv-caution); }
.health-dot.warning { background: var(--ltv-warning); }
.health-dot.danger { background: var(--ltv-danger); }
.health-dot.critical { background: var(--ltv-danger); animation: pulse 1.5s ease infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* Help Tip / Glossary Tooltip */
.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    cursor: help;
    margin-left: 0.25rem;
    position: relative;
    vertical-align: middle;
}
.help-tip:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-tip:focus::after,
.help-tip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 250px;
    z-index: 1000;
    line-height: 1.4;
    box-shadow: var(--shadow-md);
}
.help-tip:focus::before,
.help-tip:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
    z-index: 1000;
}

/* Nav Badge */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--ltv-danger);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.25rem;
    animation: badgePop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes badgePop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* CSV Dropdown Menu */
.csv-menu-wrapper {
    position: relative;
    display: inline-block;
}

.csv-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 50;
    min-width: 220px;
    padding: 0.25rem 0;
}

.csv-menu.open {
    display: block;
}

.csv-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}

.csv-menu-item:hover,
.csv-menu-item:focus {
    background: var(--surface-2);
    outline: none;
}

.csv-menu-item small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Manual BTC Price Input */
.manual-price-input {
    width: 140px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

/* Stress Test Card */
.stress-test-body {
    padding: 0 1rem 1rem;
}

.stress-test-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stress-slider {
    flex: 1;
}

.stress-value {
    min-width: 80px;
    text-align: right;
    font-size: 1.1rem;
    font-weight: 600;
}

.stress-sim-price {
    font-size: 1.1rem;
}

/* Preference Labels */
.pref-label {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

/* Keyboard Shortcuts Panel */
.shortcut-group { }
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}
.shortcut-row:last-child { border-bottom: none; }
kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Onboarding Checklist */
.checklist-progress {
    height: 4px;
    background: var(--surface-2);
    border-radius: 2px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.checklist-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.checklist-item {
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item.completed { color: var(--ltv-safe); text-decoration: line-through; opacity: 0.7; }

/* Gauge Tooltip (click-triggered popover) */
.gauge-tooltip {
    position: fixed;
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.15s ease;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Tooltip Viewport Repositioning */
/* Tooltip shown below (for elements near top of viewport / under sticky header) */
.help-tip.tip-down:hover::after,
.help-tip.tip-down:focus::after {
    bottom: auto;
    top: calc(100% + 8px);
}
.help-tip.tip-down:hover::before,
.help-tip.tip-down:focus::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--text-primary);
}

.help-tip.tip-right:hover::after,
.help-tip.tip-right:focus::after {
    left: auto;
    right: 0;
    transform: none;
}
/* Segmented Control */
.segmented-control {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.seg-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    background: var(--surface-1);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid var(--border-color);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active { background: var(--primary); color: #fff; }

/* View Mode Badge */
.view-mode-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-height: 1em;
}

.help-tip.tip-left:hover::after,
.help-tip.tip-left:focus::after {
    left: 0;
    transform: none;
}

/* ========================================
   Escrow Recovery Wizard
   ======================================== */
/* ===== Recovery Wizard ===== */
.recovery-wizard {
    max-width: 100%;
}

/* Security Notice - thin collapsible bar */
.security-notice-bar {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 6px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.security-notice-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.4rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: #B45309;
    font-weight: 500;
}
[data-theme="dark"] .security-notice-toggle { color: #FBBF24; }
.security-notice-toggle svg { flex-shrink: 0; color: inherit; }
.security-notice-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}
.security-notice-bar.expanded .security-notice-chevron {
    transform: rotate(180deg);
}
.security-notice-body {
    padding: 0 0.75rem 0.5rem 2rem;
}
.security-notice-body p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* Legacy security notice (used elsewhere) */
.security-notice {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.security-notice svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #F59E0B;
}
.security-notice p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Wizard Progress Stepper */
.recovery-wizard-progress {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.recovery-wizard-step {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
}
.recovery-wizard-step:hover { color: var(--primary); }
.recovery-wizard-step.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.recovery-wizard-step.completed {
    color: var(--ltv-safe);
    border-bottom-color: var(--ltv-safe);
}
.recovery-wizard-step .step-num {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--surface-2);
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease;
}
.recovery-wizard-step.active .step-num { background: var(--primary); color: #fff; }
.recovery-wizard-step.completed .step-num { background: var(--ltv-safe); color: #fff; }

/* Step transitions */
.recovery-step {
    display: none;
    animation: recoveryFadeIn 0.25s ease;
}
.recovery-step.active { display: block; }
@keyframes recoveryFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Step card spacing */
.recovery-step .omv-card { margin-bottom: 0; }
.recovery-step .form-group { margin-bottom: 1rem; }

/* Recovery-specific form styling */
.recovery-loan-select-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.recovery-loan-select-row .form-select { flex: 1; }
.recovery-manual-hint { margin-bottom: 0.75rem; }
.recovery-password-group { margin-top: 1.25rem; }
.recovery-password-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.recovery-password-row .form-input { flex: 1; }
.recovery-role-desc { margin-bottom: 1rem; }

/* Role Cards */
.role-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.25rem 0;
}
.role-card {
    background: var(--surface-1);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem 1.25rem;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    text-align: center;
    position: relative;
}
.role-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.role-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.role-card.selected {
    border-color: var(--primary);
    background: rgba(58, 79, 192, 0.06);
    box-shadow: 0 0 0 3px rgba(58, 79, 192, 0.15);
}
.role-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    background: var(--surface-2);
    transition: background 0.2s ease, color 0.2s ease;
}
.role-card.selected .role-card-icon {
    background: var(--primary);
    color: #fff;
}
.role-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.role-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.5rem;
}
.role-card-steps {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    text-align: left;
}

/* Fee Tier Buttons */
.fee-tiers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 0.75rem 0;
}
.fee-tier-btn {
    background: var(--surface-1);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    position: relative;
}
.fee-tier-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}
.fee-tier-btn.active {
    border-color: var(--primary);
    background: rgba(58, 79, 192, 0.06);
    box-shadow: 0 0 0 2px rgba(58, 79, 192, 0.12);
}
.fee-tier-label {
    font-size: 0.8rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.2rem;
}
.fee-tier-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
}
.fee-rate-value {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    display: block;
}
.fee-recommended {
    display: none;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary);
    margin-top: 0.25rem;
}
.fee-tier-btn.active .fee-recommended { display: block; }

/* Custom fee input */
.recovery-custom-fee {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.recovery-custom-fee-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.recovery-custom-fee-input {
    width: 100px;
    font-size: 0.78rem !important;
    padding: 0.35rem 0.5rem !important;
}

/* Role card keyboard focus */
.role-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Recovery action button (full-width) */
.recovery-action-btn {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
}

/* Signing Progress (inline) */
.recovery-progress-container {
    margin-top: 1rem;
}
.signing-progress {
    margin: 1rem 0;
}
.signing-progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}
.signing-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}
.signing-progress-fill.partial {
    background: #F59E0B;
    width: 50%;
}
.signing-progress-fill.complete {
    background: var(--ltv-safe);
    width: 100%;
}
.signing-progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

/* Progress steps during signing */
.recovery-signing-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface-2);
    border-radius: 8px;
    margin-top: 0.75rem;
}
.recovery-signing-status .signing-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.recovery-signing-status p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.recovery-signing-bar {
    height: 4px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.recovery-signing-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Next Steps Checklist (Step 4 Creator) */
.recovery-next-steps {
    margin: 1rem 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.recovery-next-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.recovery-step-bullet {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text-muted);
    flex-shrink: 0;
}
.recovery-step-bullet.done {
    background: var(--ltv-safe);
    color: #fff;
}

/* Recovery Output (PSBT textarea) */
.recovery-output {
    position: relative;
    margin: 1rem 0;
}
.recovery-output textarea {
    width: 100%;
    min-height: 90px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.73rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    resize: vertical;
    line-height: 1.5;
}
.recovery-output-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.recovery-output-actions .btn { flex: 1; min-width: 0; justify-content: center; }

/* Platform Badge in Recovery */
.recovery-platform-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(58, 79, 192, 0.1);
    color: var(--primary);
    white-space: nowrap;
}

/* Transaction Summary Card */
.recovery-summary {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}
.recovery-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.85rem;
}
.recovery-summary-row.total {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 600;
}
.recovery-summary-label {
    color: var(--text-secondary);
}
.recovery-summary-value {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

/* Recovery intro help text */
.recovery-intro-help {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: -0.25rem;
    margin-bottom: 1rem;
}

/* Recovery nav buttons */
.recovery-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.recovery-nav-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Address validation hint */
.recovery-address-hint {
    min-height: 1.2em;
    transition: color 0.2s;
}

/* Broadcast button */
.recovery-broadcast-btn {
    background: var(--ltv-safe);
    border-color: var(--ltv-safe);
}
.recovery-broadcast-btn:hover {
    filter: brightness(1.08);
}
.recovery-broadcast-secondary {
    text-align: center;
    margin-top: 0.75rem;
}

/* Broadcast success result */
.recovery-broadcast-result {
    margin-top: 1.25rem;
}
.recovery-success-card {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}
.recovery-success-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ltv-safe);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}
.recovery-success-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}
.recovery-success-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.recovery-txid {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.recovery-txid-link {
    font-size: 0.73rem;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-all;
    color: var(--primary);
    text-decoration: none;
}
.recovery-txid-link:hover { text-decoration: underline; }
.recovery-done-btn {
    margin-top: 1rem;
}

/* Info bar (non-warning) */
.recovery-info-bar {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(58, 79, 192, 0.06);
    border: 1px solid rgba(58, 79, 192, 0.15);
    border-radius: 8px;
}
.recovery-info-bar svg { flex-shrink: 0; margin-top: 1px; }
.recovery-info-bar p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* PSBT textarea in signer path */
.recovery-psbt-textarea {
    font-size: 0.78rem;
    line-height: 1.5;
}

/* File upload styled */
.recovery-file-upload {
    position: relative;
    display: flex;
    align-items: center;
}
.recovery-file-upload input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.8rem;
    background: var(--surface-1);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}
.recovery-file-upload svg {
    position: absolute;
    right: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Start Recovery button in loan detail */
.btn-recovery {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    white-space: nowrap;
}
.btn-recovery:hover {
    background: rgba(58, 79, 192, 0.08);
    transform: translateY(-1px);
}
.btn-recovery svg { flex-shrink: 0; }

/* Mobile: role cards stack, fee full-width, copy prominent */
@media (max-width: 600px) {
    .role-cards {
        grid-template-columns: 1fr;
    }
    .fee-tiers {
        grid-template-columns: 1fr;
    }
    .recovery-output-actions {
        flex-direction: column;
    }
    .recovery-output-actions .btn { width: 100%; }
    .recovery-password-row {
        flex-direction: column;
    }
    .recovery-password-row .btn { width: 100%; }
}
@media (max-width: 480px) {
    .recovery-wizard-step {
        font-size: 0.65rem;
        padding: 0.3rem 0.15rem;
        flex-direction: column;
        gap: 0.2rem;
    }
    .recovery-wizard-step .step-label {
        display: block;
        line-height: 1.2;
    }
    .role-card { padding: 1rem; }
    .role-card-steps { font-size: 0.65rem; }
    .recovery-action-btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}
@media (max-width: 360px) {
    .recovery-wizard-step .step-label { display: none; }
    .recovery-wizard-step .step-num { width: 26px; height: 26px; font-size: 0.75rem; }
}

/* Testnet Banner */
.testnet-banner {
    background: #fdf5d0;
    color: #8a7a20;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1001;
    letter-spacing: 0.02em;
}
.testnet-banner a {
    font-weight: 500;
}
[data-theme="dark"] .testnet-banner {
    background: #3a3520;
    color: #c8b44a;
}
[data-theme="dark"] .testnet-nav-badge {
    background: #3a3520 !important;
    color: #c8b44a !important;
}
