:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.tool-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.tool-topbar-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.tool-topbar-link {
    color: var(--primary-color);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.tool-topbar-text {
    color: var(--secondary-color);
    font-size: 0.86rem;
}

.tool-topbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

header p {
    color: var(--secondary-color);
}

.page-alert {
    margin-bottom: 24px;
    padding: 18px 20px;
    border-radius: 18px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 55%, #ffffff 100%);
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.12);
}

.page-alert-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.page-alert-title {
    margin-top: 12px;
    font-size: 1.08rem;
    font-weight: 800;
    color: #9a3412;
}

.page-alert-text {
    margin-top: 10px;
    color: #7c2d12;
    font-size: 0.95rem;
    line-height: 1.75;
}

.page-alert-tip {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
    color: #b45309;
    font-size: 0.88rem;
    font-weight: 700;
}

.runtime-notice {
    margin-bottom: 24px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
}

.runtime-notice-title {
    color: #b91c1c;
    font-size: 0.95rem;
    font-weight: 800;
}

.runtime-notice-text {
    margin-top: 6px;
    color: #991b1b;
    font-size: 0.86rem;
    line-height: 1.6;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.city-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.form-group--wide {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--secondary-color);
}

.form-group input,
.form-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.section-gap {
    margin-top: 16px;
}

.form-helper {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--secondary-color);
    font-size: 0.86rem;
}

.search-group {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.92rem;
    border-bottom: 1px solid #f1f5f9;
}

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

.dropdown-item:hover {
    background-color: #f8fafc;
}

.dropdown-item small {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
}

.dropdown-empty {
    padding: 12px;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.down-payment-display {
    background: #eff6ff;
    border: 1px dashed var(--primary-color);
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
}

.down-payment-display strong {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.btn-container {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.btn-container .btn-secondary {
    width: 100%;
}

.btn-container-tip {
    color: var(--secondary-color);
    font-size: 0.84rem;
    text-align: center;
}

.btn-reset-draft {
    padding: 12px 18px;
    border: 1px solid rgba(239, 68, 68, 0.24);
    border-radius: 12px;
    background: #fff;
    color: var(--danger-color);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reset-draft:disabled {
    border-color: var(--border-color);
    color: var(--secondary-color);
    opacity: 0.68;
    cursor: not-allowed;
}

.btn-reset-draft:not(:disabled):hover {
    border-color: var(--danger-color);
    background: #fff5f5;
}

.btn-reset-draft:not(:disabled):focus-visible {
    outline: none;
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgb(239 68 68 / 0.12);
}

.btn-calculate {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: background 0.2s;
}

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

.btn-progress {
    position: absolute;
    inset: 0 auto 0 -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.22);
    transition: left 0.8s linear;
}

.report-export-bar {
    display: none;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px 16px;
    margin-top: 4px;
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fbff 100%);
}

.report-export-copy {
    min-width: 0;
}

.report-export-title {
    color: var(--text-main);
    font-size: 0.98rem;
    font-weight: 700;
}

.report-export-text {
    margin-top: 4px;
    color: var(--secondary-color);
    font-size: 0.88rem;
    line-height: 1.7;
}

.report-export-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.report-export-btn {
    white-space: nowrap;
}

.report-export-mobile-tip {
    grid-column: 1 / -1;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.86);
    color: #1d4ed8;
    font-size: 0.88rem;
    line-height: 1.7;
}

.print-report-header {
    display: none;
}

.result-formula-note {
    margin-top: 4px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.result-highlight-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.result-highlight-card {
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.result-highlight-card--profit {
    border-color: rgba(16, 185, 129, 0.2);
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}

.result-highlight-card--cash {
    border-color: rgba(37, 99, 235, 0.2);
    background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
}

.result-highlight-card span {
    display: block;
    color: var(--secondary-color);
    font-size: 0.84rem;
}

.result-highlight-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.result-highlight-card small {
    display: block;
    margin-top: 8px;
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.5;
}

.result-basis {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.result-basis-item {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
}

.result-basis-item span {
    display: block;
    margin-bottom: 6px;
    color: var(--secondary-color);
    font-size: 0.82rem;
}

.result-basis-item strong {
    display: block;
    color: var(--text-main);
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.result-breakdown {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}

.result-group-title {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 700;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.result-row-label {
    font-size: 0.95rem;
    color: var(--text-main);
}

.result-row-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.result-row-plus .result-row-label,
.result-row-plus .result-row-value {
    color: var(--success-color);
}

.result-row-minus .result-row-label,
.result-row-minus .result-row-value {
    color: #b45309;
}

.result-row-subtotal {
    background: #fffbeb;
}

.result-row-subtotal .result-row-label,
.result-row-subtotal .result-row-value {
    color: #92400e;
    font-weight: 700;
}

.result-row-total {
    background: #f8fafc;
}

.result-row-total .result-row-label {
    font-size: 1rem;
    font-weight: 700;
}

.result-row-total .result-row-value {
    font-size: 1.35rem;
}

.result-extra {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #eef2ff;
}

.result-extra-label {
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.result-extra-note {
    margin-top: 4px;
    color: #64748b;
    font-size: 0.82rem;
}

.result-extra-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.result-extra-value.is-positive {
    color: var(--primary-color);
}

.result-extra-value.is-negative {
    color: var(--danger-color);
}

.value.profit {
    color: var(--success-color);
}

.value.loss {
    color: var(--danger-color);
}

.table-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
}

.table-toolbar-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
}

.table-toolbar-note {
    color: var(--secondary-color);
    font-size: 0.82rem;
    line-height: 1.6;
}

.table-container {
    overflow-x: auto;
    margin-top: 20px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    background: #f8fafc;
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border-color);
    color: var(--secondary-color);
    white-space: nowrap;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.lpr-change-row {
    background-color: #fffbeb;
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-down {
    background: #dcfce7;
    color: #166534;
}

body.drawer-open {
    overflow: hidden;
}

.segmented-control {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
}

.segment-option,
.choice-card {
    position: relative;
    cursor: pointer;
}

.segment-option input,
.choice-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segment-option span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--secondary-color);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.segment-option.is-active span {
    border-color: var(--primary-color);
    background: #eff6ff;
    color: var(--primary-color);
}

.btn-secondary {
    padding: 12px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-calculate--inline {
    width: auto;
    min-width: 160px;
    padding: 14px 20px;
    font-size: 1rem;
}

.prepay-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.prepay-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.prepay-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.prepay-panel-note {
    margin-top: 4px;
    color: var(--secondary-color);
    font-size: 0.86rem;
}

.prepay-plan-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.prepay-plan-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.prepay-plan-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.prepay-plan-head h4 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.prepay-plan-meta {
    margin-top: 8px;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.prepay-plan-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.text-btn {
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.text-btn-danger {
    color: var(--danger-color);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.tag-muted {
    background: #e2e8f0;
    color: #334155;
}

.prepay-empty {
    padding: 18px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    color: var(--secondary-color);
    font-size: 0.92rem;
    background: #f8fafc;
}

.prepay-impact {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
}

.prepay-impact-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.prepay-impact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.prepay-impact-item {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(191, 219, 254, 0.9);
}

.prepay-impact-item span {
    display: block;
    margin-bottom: 6px;
    color: var(--secondary-color);
    font-size: 0.82rem;
}

.prepay-impact-item strong {
    font-size: 1rem;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

.compare-panel {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
}

.compare-panel summary {
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-main);
    list-style: none;
}

.compare-panel summary::-webkit-details-marker {
    display: none;
}

.compare-list {
    border-top: 1px solid var(--border-color);
}

.compare-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.compare-row span {
    color: var(--secondary-color);
}

.compare-row strong {
    font-variant-numeric: tabular-nums;
}

.metric-positive {
    color: var(--success-color);
}

.metric-negative {
    color: var(--danger-color);
}

.prepay-event-row {
    background: #eff6ff;
}

.special-event-cell {
    min-width: 260px;
    white-space: normal;
    color: var(--text-main);
    line-height: 1.5;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 999;
}

.drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(460px, 100vw);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.2);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1000;
}

.drawer.is-open {
    transform: translateX(0);
}

.drawer-header,
.drawer-footer {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    border-bottom: none;
}

.drawer-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.drawer-subtitle {
    margin-top: 4px;
    color: var(--secondary-color);
    font-size: 0.86rem;
}

.drawer-close {
    border: none;
    background: transparent;
    color: var(--secondary-color);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 24px;
}

.drawer-section + .drawer-section {
    margin-top: 20px;
}

.drawer-section-title {
    margin-bottom: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

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

.choice-card-content {
    display: block;
    height: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    transition: all 0.2s ease;
}

.choice-card-content strong {
    display: block;
    color: var(--text-main);
    font-size: 0.95rem;
}

.choice-card-content small {
    display: block;
    margin-top: 6px;
    color: var(--secondary-color);
    font-size: 0.82rem;
    line-height: 1.5;
}

.choice-card.is-active .choice-card-content {
    border-color: var(--primary-color);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.08);
}

.choice-card.is-disabled {
    cursor: not-allowed;
}

.choice-card.is-disabled .choice-card-content {
    background: #f8fafc;
    color: #94a3b8;
    opacity: 0.65;
}

.drawer-summary {
    margin-top: 20px;
    padding: 16px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
}

.drawer-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.drawer-summary-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.drawer-summary-item span {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.drawer-summary-item strong {
    text-align: right;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

@media print {
    @page {
        size: auto;
        margin: 12mm;
    }

    body {
        padding: 0;
        background: #fff;
        color: #000;
    }

    body.print-mode-active .container {
        max-width: none;
    }

    body.print-mode-active .container > :not(#resultsSection),
    body.print-mode-active .drawer,
    body.print-mode-active .drawer-backdrop {
        display: none !important;
    }

    body.print-mode-active #resultsSection {
        display: block !important;
    }

    body.print-mode-active #resultsSection > .card {
        margin-bottom: 14px;
        padding: 18px;
        border: 1px solid #dbe3ee;
        border-radius: 12px;
        box-shadow: none;
        break-inside: avoid;
    }

    body.print-mode-active #repayScheduleCard {
        break-inside: auto;
    }

    body.print-mode-active .report-export-bar {
        display: none !important;
    }

    body.print-mode-active .print-report-header {
        display: block;
        margin-bottom: 14px;
        padding-bottom: 14px;
        border-bottom: 1px solid #dbe3ee;
    }

    body.print-mode-active .print-report-title-row {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 20px;
    }

    body.print-mode-active .print-report-eyebrow {
        color: #2563eb;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    body.print-mode-active .print-report-header h2 {
        margin-top: 6px;
        font-size: 22px;
        line-height: 1.35;
        color: #0f172a;
    }

    body.print-mode-active .print-report-meta {
        min-width: 240px;
        display: grid;
        gap: 8px;
    }

    body.print-mode-active .print-report-meta div {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        color: #475569;
        font-size: 12px;
    }

    body.print-mode-active .print-report-meta strong {
        color: #0f172a;
        font-size: 12px;
    }

    body.print-mode-active .print-report-tip {
        margin-top: 10px;
        color: #475569;
        font-size: 12px;
        line-height: 1.6;
    }

    body.print-mode-active .result-highlight-grid,
    body.print-mode-active .result-basis,
    body.print-mode-active .prepay-impact-grid {
        gap: 10px;
    }

    body.print-mode-active .result-highlight-card,
    body.print-mode-active .result-basis-item,
    body.print-mode-active .prepay-impact-item,
    body.print-mode-active .compare-panel,
    body.print-mode-active .result-breakdown,
    body.print-mode-active .result-extra {
        box-shadow: none;
        break-inside: avoid;
    }

    body.print-mode-active .compare-panel summary {
        cursor: default;
        padding: 12px 16px;
        background: #f8fafc;
        border-bottom: 1px solid #dbe3ee;
    }

    body.print-mode-active .compare-panel[open] .compare-list {
        display: block !important;
    }

    body.print-mode-summary #repayScheduleCard {
        display: none !important;
    }

    body.print-mode-full #repayScheduleCard {
        display: block !important;
    }

    body.print-mode-active .table-container {
        margin-top: 14px;
        overflow: visible;
    }

    body.print-mode-active table {
        min-width: 0;
        font-size: 11px;
    }

    body.print-mode-active #repayTable thead {
        display: table-header-group !important;
    }

    body.print-mode-active #repayBody {
        display: table-row-group !important;
    }

    body.print-mode-active #repayBody tr {
        display: table-row !important;
        break-inside: avoid;
        background: transparent !important;
    }

    body.print-mode-active #repayBody td {
        display: table-cell !important;
        padding: 8px 10px;
        white-space: normal;
        border-bottom: 1px solid #dbe3ee;
    }

    body.print-mode-active #repayBody td::before {
        content: none !important;
    }

    body.print-mode-active .special-event-cell {
        min-width: 0;
    }
}

@media (max-width: 900px) {
    .city-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-group--wide {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    body {
        padding: 12px;
    }

    .container {
        max-width: 100%;
    }

    .tool-topbar,
    .tool-topbar-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-topbar-badge {
        width: 100%;
        justify-content: center;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.55rem;
    }

    header p {
        font-size: 0.92rem;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 14px;
    }

    .card-title {
        margin-bottom: 16px;
        font-size: 1.05rem;
    }

    .grid,
    .city-grid,
    .result-basis,
    .result-highlight-grid {
        grid-template-columns: 1fr;
    }

    .form-group--wide {
        grid-column: span 1;
    }

    .form-group input,
    .form-group select,
    .btn-calculate {
        min-height: 44px;
        font-size: 16px;
    }

    .dropdown-content {
        max-height: 220px;
    }

    .prepay-panel-header,
    .prepay-plan-head,
    .compare-row,
    .drawer-footer,
    .drawer-summary-item,
    .table-toolbar,
    .report-export-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .prepay-plan-actions,
    .drawer-footer,
    .report-export-actions {
        width: 100%;
        justify-content: space-between;
    }

    .report-export-bar {
        grid-template-columns: 1fr;
    }

    .btn-secondary,
    .btn-calculate--inline {
        width: 100%;
    }

    .choice-grid,
    .prepay-impact-grid {
        grid-template-columns: 1fr;
    }

    .drawer {
        top: auto;
        right: 0;
        bottom: 0;
        width: 100%;
        height: min(86vh, 760px);
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .drawer.is-open {
        transform: translateY(0);
    }

    .drawer-header,
    .drawer-footer {
        padding: 16px;
    }

    .drawer-body {
        padding: 16px 16px 22px;
    }

    .table-container {
        margin-top: 14px;
        border: none;
        border-radius: 0;
        overflow-x: visible;
    }

    table {
        min-width: 0;
        width: 100%;
    }

    #repayTable thead {
        display: none;
    }

    #repayBody {
        display: grid;
        gap: 12px;
    }

    #repayBody tr {
        display: grid;
        gap: 0;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        overflow: hidden;
        background: #fff;
    }

    #repayBody tr.lpr-change-row {
        background: #fffbeb;
        border-color: #fcd34d;
    }

    #repayBody tr.prepay-event-row {
        background: #eff6ff;
        border-color: #93c5fd;
    }

    #repayBody tr.lpr-change-row.prepay-event-row {
        background: linear-gradient(180deg, #eff6ff 0%, #fffbeb 100%);
    }

    #repayBody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 16px;
        padding: 10px 12px;
        white-space: normal;
        border-bottom: 1px dashed var(--border-color);
    }

    #repayBody td:last-child {
        border-bottom: none;
    }

    #repayBody td::before {
        content: attr(data-label);
        flex: 0 0 92px;
        color: var(--secondary-color);
        font-size: 0.78rem;
        font-weight: 700;
        line-height: 1.5;
    }

    .special-event-cell {
        min-width: 0;
    }

    th,
    td {
        padding: 10px;
        font-size: 0.82rem;
    }

    .result-extra,
    .result-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-row-value,
    .result-extra-value,
    .drawer-summary-item strong {
        text-align: left;
    }

    .result-highlight-card strong,
    .result-row-total .result-row-value {
        font-size: 1.2rem;
    }
}

@media (max-width: 420px) {
    header h1 {
        font-size: 1.4rem;
    }

    .card {
        padding: 14px;
    }

    .btn-calculate {
        padding: 14px;
    }
}
