
:root {
    --fs-2xl: 30px;
    --fs-xl: 26px;
    --fs-lg: 20px;
    --fs-md: 16px;
    --fs-sm: 14px;
    --fs-xs: 12px;
    --serif: "Zen Kaku Gothic New", sans-serif;
    --sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    --mono: "JetBrains Mono", monospace;
    --ink: #1C2B33;
    --ink-soft: #56707A;
    --ink-faint: #8CA3AB;
    --paper: #F5FAFC;
    --panel-2: #EAF4F7;
    --line: #D8E8ED;
    --accent: #2B6CA3;
    --accent-strong: #184C73;
    --accent-soft: #EAF2FA;
    --positive: #237A4E;
    --positive-soft: #DEF3E6;
    --danger: #B8362A;
    --danger-soft: #FCE4E1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--fs-md);
    line-height: 1.6;
}

.container {
    width: 95%;
    max-width: 1500px;
    margin: 0 auto;
}

.seo-intro {
    max-width: 800px;
    margin: 20px auto 0;
    padding: 0 4px;
    font-size: var(--fs-sm);
    line-height: 1.8;
    color: var(--ink-soft);
    text-align: center;
}

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

.hero-banner {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    line-height: 0;
}

.hero-banner img {
    width: 100%;
    height: auto;
    display: block;
}

.rocket-banner {
    display: block;
    background: var(--accent-soft);
    color: var(--accent-strong);
    text-decoration: none;
    text-align: center;
    padding: 12px 20px;
    font-size: var(--fs-sm);
    font-weight: bold;
    border-bottom: 1px solid var(--line);
}

.rocket-banner:hover {
    background: var(--accent-soft);
    filter: brightness(0.95);
}

.app-install-banner {
    background: var(--accent-soft);
    text-align: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.app-install-banner .lede {
    margin: 0 0 8px;
    font-size: var(--fs-sm);
    font-weight: bold;
    color: var(--accent-strong);
}

.app-install-btn {
    background: var(--accent-strong);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 10px 24px;
    font-weight: bold;
    font-size: var(--fs-sm);
    cursor: pointer;
    margin: 0;
}

.app-install-btn:hover {
    filter: brightness(0.95);
}

.ios-install-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.ios-install-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 43, 51, 0.5);
}

.ios-install-modal-card {
    position: relative;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 24px 24px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}

.ios-install-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 4px 8px;
    margin: 0;
}

.ios-install-steps {
    padding-left: 20px;
    margin: 14px 0;
    font-size: var(--fs-sm);
    line-height: 1.9;
}

.ios-share-icon {
    font-size: var(--fs-md);
    margin-left: 4px;
}

.line-add-banner {
    background: var(--positive-soft);
    text-align: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.line-add-banner .lede {
    margin: 0 0 8px;
    font-size: var(--fs-sm);
    font-weight: bold;
    color: var(--ink);
}

.line-share-banner {
    background: var(--panel-2);
    text-align: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.line-share-banner .lede {
    margin: 0 0 8px;
    font-size: var(--fs-sm);
    font-weight: bold;
    color: var(--ink);
}

.line-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #06C755;
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: var(--fs-sm);
    padding: 10px 20px;
    border-radius: 24px;
}

.line-share-btn:hover {
    background: #05a648;
}

section {
    background: white;
    margin: 24px 0;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--line);
    box-shadow: none;
}

h2 {
    margin: 0 0 20px;
    font-family: var(--sans);
    font-weight: 700;
    font-size: var(--fs-lg);
    color: var(--ink);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent-strong);
    display: block;
}

.rate-info {
    font-size: var(--fs-sm);
    color: var(--ink-soft);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

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

.form-item label {
    font-weight: 600;
    font-size: var(--fs-sm);
    margin-bottom: 8px;
    color: var(--ink);
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: var(--fs-md);
    font-family: var(--sans);
    text-align: right;
    background-color: white;
    color: var(--ink);
    transition: border-color 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(43, 108, 163, 0.1);
}

.unit {
    font-size: var(--fs-xs);
    color: #333;
    margin-top: 4px;
    font-weight: 500;
}

.inline-flag {
    display: block;
    font-size: var(--fs-xs);
    margin-top: 5px;
    color: var(--accent-strong);
}

.inline-flag.info {
    color: var(--ink-soft);
}

button {
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s ease;
}

.btn-main {
    background: var(--accent-strong);
    color: white;
}

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

.btn-pdf {
    background: white;
    color: var(--accent-strong);
    border: 1px solid var(--accent-strong);
}

.btn-pdf:hover {
    background: var(--accent-soft);
}

.btn-add {
    background: white;
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-add:hover {
    background: var(--panel-2);
}

.goal-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: var(--fs-md);
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
    margin: 0;
}

/* ==================================================
   積立シミュレーション：寒色系に統一（暖色禁止ルール遵守）
================================================== */
#tab-savings h2 {
    border-bottom-color: var(--accent-strong);
}

#tab-savings .savings-lede {
    font-size: var(--fs-sm);
    color: var(--ink-soft);
    margin: -10px 0 18px;
}

#tab-savings .savings-3way-tabs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

#tab-savings .savings-3way-tab {
    flex: 1 1 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 10px;
    padding: 14px 10px;
    margin: 0;
    cursor: pointer;
    font-family: var(--sans);
    transition: all 0.2s ease;
}

#tab-savings .savings-3way-tab:hover {
    border-color: var(--accent);
}

#tab-savings .savings-3way-tab img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

#tab-savings .savings-3way-tab span {
    font-size: var(--fs-sm);
    font-weight: bold;
    color: var(--ink);
    text-align: center;
}

#tab-savings .savings-3way-tab.active {
    border-color: var(--accent-strong);
    background: var(--accent-soft);
}

#tab-savings .savings-btn {
    background: var(--accent-strong);
    color: #fff;
}

#tab-savings .savings-btn:hover {
    filter: brightness(0.95);
}

#tab-savings .savings-banner {
    margin-top: 24px;
    padding: 20px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--line);
}

#tab-savings .savings-banner-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    background: transparent;
    border-radius: 0;
    padding: 0;
    flex-wrap: wrap;
}

#tab-savings .savings-mascot {
    width: 48px;
    height: 48px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tab-savings .savings-mascot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#tab-savings .savings-banner-text {
    text-align: left;
}

#tab-savings .savings-banner-label {
    font-size: var(--fs-xs);
    font-weight: bold;
    color: var(--ink-soft);
    text-transform: none;
}

#tab-savings .savings-banner-value {
    margin-top: 4px;
    font-family: var(--mono);
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--accent-strong);
}

#tab-savings .savings-banner-value .unit {
    margin-left: 8px;
    font-size: var(--fs-sm);
    font-weight: bold;
    color: var(--ink-soft);
}

#tab-savings .savings-chart-wrap {
    margin-top: 18px;
    overflow-x: auto;
}

#tab-savings .savings-chart-legend {
    display: flex;
    gap: 18px;
    font-size: var(--fs-xs);
    color: var(--ink-soft);
    margin-bottom: 6px;
}

#tab-savings .savings-chart-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: middle;
}

#tab-savings .savings-chart-legend .dot.principal { background: var(--accent); }
#tab-savings .savings-chart-legend .dot.profit { background: var(--positive); }
#tab-savings .savings-chart-legend .dot.balance { background: var(--accent); }

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--line);
}

.tab-btn {
    margin: 0;
    padding: 12px 18px;
    font-size: var(--fs-sm);
    font-weight: 600;
    border-radius: 0;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    border: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--ink);
}

.tab-btn.active {
    background: transparent;
    color: var(--accent-strong);
    border-bottom-color: var(--accent-strong);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.result-card {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.result-card .title {
    font-weight: 600;
    font-size: var(--fs-xs);
    color: var(--ink-soft);
    margin-bottom: 8px;
}

.result-card .value {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--accent-strong);
    font-family: var(--mono);
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    font-size: var(--fs-sm);
}

th,
td {
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: right;
    white-space: nowrap;
    font-family: var(--mono);
}

th {
    background: transparent;
    color: var(--ink);
    text-align: center;
    font-size: var(--fs-xs);
    font-family: var(--sans);
    font-weight: 700;
    border-bottom: 2px solid var(--accent-strong);
    padding: 12px 14px 14px;
}

th:first-child {
    text-align: left;
}

td:first-child {
    text-align: left;
    font-weight: 600;
    font-size: var(--fs-sm);
    font-family: var(--sans);
    color: var(--ink);
}

td:nth-child(2) {
    text-align: center;
}

.compare-table {
    min-width: 1000px;
}

.compare-table td:first-child {
    font-weight: bold;
    text-align: left;
    font-size: var(--fs-md);
    font-family: var(--sans);
}

.bonus-note {
    display: block;
    font-size: var(--fs-xs);
    font-weight: normal;
    color: var(--ink-soft);
    margin-top: 3px;
}

#goalTable td input {
    width: 80px;
    display: inline-block;
    padding: 8px;
}

#goalTable td input[type="text"] {
    width: 130px;
    text-align: left;
}

.gain {
    color: var(--positive);
    font-weight: bold;
}

.loss {
    color: var(--danger);
    font-weight: bold;
}

.highlight {
    background: var(--accent-soft);
}

.future-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.future-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    background: var(--panel-2);
}

.future-card .number {
    font-size: var(--fs-xl);
    font-weight: bold;
    margin-top: 8px;
}

.search-row {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.search-row .form-item {
    width: 220px;
}

.remaining-result {
    margin-top: 20px;
    padding: 20px;
    background: var(--accent-soft);
    border-radius: 10px;
    font-size: var(--fs-xl);
    font-weight: bold;
}

footer {
    background: var(--panel-2);
    color: var(--ink-soft);
    text-align: center;
    padding: 25px;
    margin-top: 30px;
    font-size: var(--fs-sm);
}

.admin-link {
    margin-top: 10px;
}

.admin-link a {
    font-size: var(--fs-xs);
    color: var(--ink-faint);
    text-decoration: none;
}

.admin-link a:hover {
    text-decoration: underline;
}

.small {
    font-size: var(--fs-xs);
    color: #333;
    font-weight: 500;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1000px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .future-box {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .form-grid,
    .result-grid,
    .future-box {
        grid-template-columns: 1fr;
    }

    section {
        padding: 18px;
    }

    button {
        width: 100%;
    }

    .search-row .form-item {
        width: 100%;
    }

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

    .tab-btn {
        padding: 10px 8px;
        font-size: var(--fs-xs);
    }

    /* 住宅ローン比較表・積立表：横スクロールではなく、縦カードに切り替える */
    .compare-table, #goalTable, #forwardTable {
        min-width: 0;
        width: 100%;
    }

    .compare-table thead, #goalTable thead, #forwardTable thead {
        display: none;
    }

    .compare-table, .compare-table tbody,
    #goalTable, #goalTable tbody,
    #forwardTable, #forwardTable tbody {
        display: block;
        width: 100%;
    }

    .compare-table tr, #goalTable tr, #forwardTable tr {
        display: block;
        margin-bottom: 14px;
        border: 1px solid var(--line);
        border-radius: 10px;
        overflow: hidden;
        background: var(--panel-2, #fff);
    }

    .compare-table td, #goalTable td, #forwardTable td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        border: none;
        border-bottom: 1px solid var(--line);
        text-align: right;
        white-space: normal;
        padding: 10px 14px;
    }

    .compare-table tr td:last-child, #goalTable tr td:last-child, #forwardTable tr td:last-child {
        border-bottom: none;
    }

    .compare-table td::before, #goalTable td::before, #forwardTable td::before {
        content: attr(data-label);
        color: var(--ink-soft);
        font-family: var(--sans);
        font-size: var(--fs-xs);
        text-align: left;
        margin-right: 10px;
        flex-shrink: 0;
    }

    #goalTable td input, #goalTable td select {
        width: auto;
        max-width: 140px;
        text-align: right;
    }

    .compare-table td:first-child, #forwardTable td:first-child {
        background: var(--accent-strong);
        color: white;
        font-size: var(--fs-md);
        justify-content: flex-start;
    }

    .compare-table td:first-child::before, #forwardTable td:first-child::before {
        content: "";
        margin: 0;
    }

    #goalTable td:first-child {
        background: var(--accent-soft);
    }

    #goalTable td:first-child input {
        max-width: none;
        width: 100%;
        text-align: left;
        font-weight: bold;
        background: transparent;
        border: none;
    }
}

.print-only { display: none; }

@media print {
    body.schedule-print-mode .hero-banner,
    body.schedule-print-mode .app-install-banner,
    body.schedule-print-mode .rocket-banner,
    body.schedule-print-mode .line-add-banner,
    body.schedule-print-mode .line-share-banner,
    body.schedule-print-mode .seo-intro,
    body.schedule-print-mode #loanFormSection,
    body.schedule-print-mode .tabs,
    body.schedule-print-mode footer,
    body.schedule-print-mode .no-print {
        display: none !important;
    }
    body.schedule-print-mode .tab-panel {
        display: none !important;
    }
    body.schedule-print-mode #tab-schedule {
        display: block !important;
    }
    body.schedule-print-mode .print-only {
        display: block !important;
        margin-bottom: 16px;
    }
    body.schedule-print-mode .print-only .facts {
        display: flex;
        gap: 24px;
        flex-wrap: wrap;
        font-size: 13px;
        border: 1px solid #D8E8ED;
        border-radius: 8px;
        padding: 10px 14px;
        margin-top: 6px;
    }
    body.schedule-print-mode #scheduleTable {
        min-width: 0;
        font-size: 11px;
    }
}

.ref-grid-2col{grid-template-columns:1fr 1fr;}
@media (max-width:600px){.ref-grid-2col{grid-template-columns:1fr;}}
.ref-line{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:4px 0;border-bottom:1px dashed var(--line);font-size:var(--fs-sm);}
.ref-line .k{text-align:left;}
.ref-line .v{font-family:var(--mono);white-space:nowrap;}
.ref-line.total{font-weight:bold;border-bottom:none;border-top:1px solid var(--line);margin-top:4px;padding-top:8px;}
.ref-line.sub .k{padding-left:20px;color:var(--ink-soft);font-size:var(--fs-xs);}
.ref-line.sub .v{color:var(--ink-soft);font-size:var(--fs-xs);}
.ref-line.sub2 .k{padding-left:32px;color:var(--ink-soft);font-size:var(--fs-xs);}
.ref-line.sub2 .v{color:var(--ink-soft);font-size:var(--fs-xs);}
.ref-line.deficit{font-weight:bold;color:var(--danger);}

.retire-table {
    min-width: 1700px;
}
.retire-table th:first-child,
.retire-table td:first-child {
    position: sticky;
    left: 0;
    text-align: left;
    font-family: var(--sans);
    background: var(--panel-2);
    z-index: 2;
    min-width: 190px;
    border-right: 2px solid var(--line);
}
.retire-table th:first-child { background: var(--accent-strong); z-index: 3; }
.retire-table tr.retire-section td { background: var(--accent-soft); font-weight: bold; }
.retire-table tr.retire-section td:first-child { background: var(--accent-soft); }
.retire-table tr.retire-sub td:first-child { color: var(--ink-soft); font-size: var(--fs-xs); padding-left: 22px; }
.retire-table tr.retire-total td { font-weight: bold; background: var(--panel-2); }
.retire-table tr.retire-total td:first-child { background: var(--panel-2); }
.retire-table td.neg { color: var(--danger); }
.retire-table tr.retire-grand td { font-weight: bold; background: var(--accent-soft); }
.retire-table tr.retire-grand td:first-child { background: var(--accent-soft); color: var(--accent-strong); }

/* 老後資金シミュレーション PDF保存（A3横・1枚に収める） */
.retire-unit-warn { display: none; color: var(--danger); font-weight: bold; }
.retire-print-header { display: none; }
@media print {
    body.retire-print-mode .hero-banner,
    body.retire-print-mode .app-install-banner,
    body.retire-print-mode .rocket-banner,
    body.retire-print-mode .line-add-banner,
    body.retire-print-mode .line-share-banner,
    body.retire-print-mode .seo-intro,
    body.retire-print-mode #loanFormSection,
    body.retire-print-mode .tabs,
    body.retire-print-mode footer,
    body.retire-print-mode .tab-panel {
        display: none !important;
    }
    body.retire-print-mode { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body.retire-print-mode { background: #fff; }
    body.retire-print-mode .container { max-width: none; padding: 0; margin: 0; }
    body.retire-print-mode section { padding: 0; margin: 0; border: none; box-shadow: none; background: none; }
    body.retire-print-mode #tab-retirement { display: block !important; }
    body.retire-print-mode #tab-retirement > *:not(.retire-print-keep) { display: none !important; }
    body.retire-print-mode .retire-print-header { display: block !important; margin-bottom: 8px; }
    body.retire-print-mode .retire-print-header h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 6px; }
    body.retire-print-mode .retire-print-header .meta { font-size: 11px; color: var(--ink); margin-bottom: 6px; }
    body.retire-print-mode .retire-print-header .facts {
        display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px 14px;
        font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px;
    }
    body.retire-print-mode .retire-print-header .facts b { font-family: var(--mono); }
    body.retire-print-mode #retireShortNote { font-size: 13px; margin: 6px 0 !important; }
    body.retire-print-mode #retireLogicNote { font-size: 13px; line-height: 1.6; margin: 6px 0 !important; color: var(--ink); }
    body.retire-print-mode .retire-chart-wrap { margin-top: 4px !important; overflow: visible !important; }
    body.retire-print-mode #retireChart { min-width: 0 !important; width: 100% !important; height: 230px !important; }
    body.retire-print-mode .table-wrap { overflow: visible !important; margin-top: 6px !important; }
    body.retire-print-mode .retire-table {
        min-width: 0 !important; width: 100%; table-layout: fixed;
        font-size: var(--retire-print-font, 10px);
    }
    body.retire-print-mode .retire-table th,
    body.retire-print-mode .retire-table td {
        padding: 3px 2px; font-size: var(--retire-print-font, 10px); text-align: right;
    }
    body.retire-print-mode .retire-table th { text-align: center; }
    body.retire-print-mode .retire-table th:first-child,
    body.retire-print-mode .retire-table td:first-child {
        position: static; min-width: 0; width: 150px; text-align: left; padding-left: 6px; font-size: 10px;
    }
    body.retire-print-mode .retire-table tr.retire-sub td:first-child { padding-left: 14px; font-size: 9.5px; color: var(--ink); }
    body.retire-print-mode .retire-table tr { break-inside: avoid; }
}

@media print {
    body.lifeplan-print-mode .hero-banner,
    body.lifeplan-print-mode .app-install-banner,
    body.lifeplan-print-mode .rocket-banner,
    body.lifeplan-print-mode .line-add-banner,
    body.lifeplan-print-mode .line-share-banner,
    body.lifeplan-print-mode .seo-intro,
    body.lifeplan-print-mode #loanFormSection,
    body.lifeplan-print-mode .tabs,
    body.lifeplan-print-mode footer,
    body.lifeplan-print-mode .tab-panel {
        display: none !important;
    }
    body.lifeplan-print-mode { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body.lifeplan-print-mode { background: #fff; }
    body.lifeplan-print-mode .container { max-width: none; padding: 0; margin: 0; }
    body.lifeplan-print-mode section { padding: 0; margin: 0; border: none; box-shadow: none; background: none; }
    body.lifeplan-print-mode #tab-lifeplan { display: block !important; }
    body.lifeplan-print-mode #lpx_summary { display: block !important; margin-bottom: 12px; }
    body.lifeplan-print-mode .table-wrap { overflow: visible !important; margin-top: 8px !important; }
    body.lifeplan-print-mode .retire-table {
        min-width: 0 !important; width: 100%; table-layout: fixed;
        font-size: 9px;
    }
    body.lifeplan-print-mode .retire-table th,
    body.lifeplan-print-mode .retire-table td {
        padding: 3px 2px; font-size: 9px; text-align: right;
    }
    body.lifeplan-print-mode .retire-table th { text-align: center; }
    body.lifeplan-print-mode .retire-table th:first-child,
    body.lifeplan-print-mode .retire-table td:first-child {
        position: static; min-width: 0; width: 80px; text-align: left; padding-left: 4px; font-size: 9px;
    }
    body.lifeplan-print-mode .retire-table tr { break-inside: avoid; }
}

/* 年を横、家計項目を縦に並べるキャッシュフロー表 */
.cashflow-table { width:max-content; min-width:100%; font-size:12px; }
.cashflow-table th, .cashflow-table td { min-width:104px; white-space:nowrap; padding:6px 8px; }
.cashflow-table th:first-child { position:sticky; left:0; z-index:2; min-width:180px; text-align:left; background:var(--panel-2); }
.cashflow-table thead th:first-child { background:var(--accent-strong); z-index:3; }
.cashflow-table .retire-section th, .cashflow-table .retire-section td { background:var(--accent-soft); font-weight:bold; }
.cashflow-table .retire-total th { background:var(--panel-2); }
.cashflow-table .cashflow-spacer td { height:16px; padding:0; background:white; border:0; }
.cashflow-table .cashflow-edit { background:#fff8d9; }
.cashflow-table .cashflow-edit input { width:72px; font-size:12px; padding:4px; }
.cashflow-table .cashflow-edit button { padding:0; margin:0; font-size:12px; color:var(--accent-strong); background:transparent; text-decoration:underline; }
#lpx_print_pages { display:none; }
@media print {
    body.lifeplan-print-mode #tab-lifeplan > *:not(#lpx_print_pages) { display:none !important; }
    body.lifeplan-print-mode #lpx_print_pages { display:block !important; }
    body.lifeplan-print-mode .cashflow-print-page { break-after:page; }
    body.lifeplan-print-mode .cashflow-print-page:last-child { break-after:auto; }
    body.lifeplan-print-mode .cashflow-print-page h2 { font-size:14px; margin:0 0 4px; }
    body.lifeplan-print-mode .cashflow-print-page p { font-size:10px; margin:0 0 4px; }
    body.lifeplan-print-mode .cashflow-table { width:100%; min-width:0; table-layout:fixed; }
    body.lifeplan-print-mode .cashflow-table th, body.lifeplan-print-mode .cashflow-table td { min-width:0; padding:2px 3px; font-size:9px; white-space:normal; }
    body.lifeplan-print-mode .cashflow-table th:first-child { position:static; width:120px; }
    body.lifeplan-print-mode .cashflow-spacer td { height:7px; }
}

#tab-lifeplan [hidden] { display:none !important; }
#tab-lifeplan .lifeplan-section-title { color:#23649b; font-size:22px; font-weight:750; border-top:2px solid #9dbedb; border-bottom:1px solid #d8e5f0; padding:14px 12px; margin:30px 0 18px; background:#edf5fb; border-radius:8px; }
#tab-lifeplan > h3 { color:#23649b !important; font-size:17px !important; border-bottom:1px solid #d8e5f0; padding-bottom:8px; }
#tab-lifeplan .form-grid { padding:14px; background:#fbfcff; border:1px solid #e0e8f1; border-radius:10px; }
#tab-lifeplan .form-item label { color:#30465d; }
#tab-lifeplan table thead th { background:#fae5ec; color:#334b64; }
#tab-lifeplan table thead th:first-child { background:#fae5ec; color:#334b64; }
#tab-lifeplan .cashflow-table th:first-child { background:#fff1bd; color:#334b64; border-color:#e1d69d; }
#tab-lifeplan .cashflow-table thead th:first-child { background:#fae5ec; color:#334b64; }
#tab-lifeplan .cashflow-table .retire-section th, #tab-lifeplan .cashflow-table .retire-section td { background:#f8dfe8; color:#334b64; }
#tab-lifeplan .cashflow-table .retire-total th, #tab-lifeplan .cashflow-table .retire-total td { background:#e7f2ec; color:#30465d; }
#tab-lifeplan .cashflow-table .cashflow-spacer td { background:white; }
@media print {
    body.lifeplan-print-mode .cashflow-print-page { break-after:auto; break-inside:avoid; }
    body.lifeplan-print-mode .cashflow-print-page h2 { font-size:12px; }
    body.lifeplan-print-mode .cashflow-print-page p { font-size:8px; }
    body.lifeplan-print-mode .cashflow-print-page .cashflow-table th,
    body.lifeplan-print-mode .cashflow-print-page .cashflow-table td { padding:2px 1px; font-size:5.5px; line-height:1.4; white-space:normal; overflow-wrap:anywhere; }
    body.lifeplan-print-mode .cashflow-print-page .cashflow-table th:first-child { width:78px; font-size:6.5px; padding-left:3px; }
}

@media print {
    body.lifeplan-print-mode .cashflow-print-page .cashflow-table td.cashflow-number { white-space:nowrap; font-size:4.8px; letter-spacing:-0.15px; }
}

#tab-lifeplan .lifeplan-monthly-payment { margin-top:12px; color:#23649b; font-size:18px; line-height:1.6; }
#tab-lifeplan .lifeplan-monthly-payment strong { display:block; font-size:25px; font-weight:750; }
#tab-lifeplan .lifeplan-term-limit { display:block; margin-top:8px; color:#30465d; font-size:16px; line-height:1.5; }

#tab-lifeplan .form-grid { grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:16px 20px; padding:12px; }
#tab-lifeplan .form-item { min-width:0; }
#tab-lifeplan .form-item label { font-size:15px; margin-bottom:6px; }
#tab-lifeplan input[type="number"] { width:138px; max-width:100%; padding:7px 9px; font-size:16px; line-height:1.3; }
#tab-lifeplan input[id*="age"], #tab-lifeplan input[id*="years"], #tab-lifeplan input[id*="rate"] { width:96px; }
#tab-lifeplan .form-item select { width:180px; max-width:100%; padding:7px 9px; font-size:16px; }
#tab-lifeplan .form-item > .unit { display:inline; margin-left:6px; font-size:14px; }
#tab-lifeplan .lifeplan-monthly-payment { margin-top:10px; font-size:17px; }
#tab-lifeplan .lifeplan-monthly-payment strong { font-size:25px; }
#tab-lifeplan .lifeplan-term-limit { font-size:16px; }
#tab-lifeplan .cashflow-table input[type="number"] { width:74px; font-size:12px; padding:4px; }
#tab-lifeplan .lifeplan-section-title { padding:10px 12px; margin:24px 0 14px; font-size:20px; }
@media(max-width:520px) { #tab-lifeplan .form-grid { grid-template-columns:1fr; } }

/* 全タブの入力幅。入力可能な金額・計算条件は変更しない。 */
input[type="number"], input[type="text"] { width:138px; max-width:100%; min-width:0; box-sizing:border-box; }
.form-item select { width:180px; max-width:100%; min-width:0; box-sizing:border-box; }
.form-item { min-width:0; }

/* 目的別の入力表は支払額までコンパクトに表示する */
#tab-lifeplan #purpose-investment-table { min-width:0; width:auto; max-width:100%; }
#tab-lifeplan #purpose-investment-table th,
#tab-lifeplan #purpose-investment-table td { padding:8px 6px; }
#tab-lifeplan #purpose-investment-table th:first-child,
#tab-lifeplan #purpose-investment-table td:first-child { min-width:0; position:static; padding-right:12px; }
#tab-lifeplan #purpose-investment-table input[id^="pur_target_"] { width:94px; }
#tab-lifeplan #purpose-investment-table input[id^="pur_years_"] { width:54px; }
#tab-lifeplan #purpose-investment-table input[id^="pur_rate_"] { width:64px; }
#tab-lifeplan #purpose-investment-table select { width:90px; min-width:0; padding:7px 6px; box-sizing:border-box; font-size:16px; }
#tab-lifeplan #purpose-investment-table td:last-child { color:var(--accent-strong); font-weight:700; }


.education-child-card { display:grid; grid-template-columns:minmax(0,1fr) 260px; gap:20px; align-items:start; }
.education-child-estimate { padding:12px 14px; background:#eef5fc; border-radius:8px; color:#245b94; line-height:1.7; }
@media(max-width:760px) { .education-child-card { grid-template-columns:1fr; gap:12px; } }

/* お子様の年齢・進路は選択肢に合わせた幅にする */
#tab-lifeplan .education-child-inputs .form-grid { display:flex; flex-wrap:wrap; gap:8px 10px; padding:8px; }
#tab-lifeplan .education-child-inputs .form-item { flex:0 0 auto; }
#tab-lifeplan .education-child-inputs .form-item select { width:76px; padding:6px; }
#tab-lifeplan .education-child-inputs select[id$="_uni"] { width:196px; }
#tab-lifeplan .education-child-inputs input[id$="_age"] { width:64px; padding:6px; }
#tab-lifeplan .education-child-inputs .form-item label { font-size:16px; margin-bottom:4px; }

#tab-lifeplan .cashflow-table tr[data-key="annualBalance"] th,
#tab-lifeplan .cashflow-table tr[data-key="annualBalance"] td { background:#173e59 !important; color:#fff !important; font-size:17px; font-weight:800; padding-top:14px; padding-bottom:14px; border-color:#51738a; }
#tab-lifeplan .cashflow-table tr[data-key="annualBalance"] td.neg { background:#a03938 !important; }
#tab-lifeplan .plan-balance-focus { border-left:6px solid #218b91; padding:20px 24px; background:#173e59; color:white; margin:18px 0 0; }
#tab-lifeplan .plan-balance-focus p { margin:4px 0 10px; }
#tab-lifeplan .plan-balance-focus strong { display:block; font-size:32px; line-height:1.4; font-variant-numeric:tabular-nums; }
#tab-lifeplan .plan-balance-focus span { display:block; font-size:17px; }
#tab-lifeplan .plan-allocation { display:flex; flex-wrap:wrap; gap:14px 36px; border:1px solid #c5d9e2; padding:12px 24px; background:#edf5f8; }
#tab-lifeplan .plan-allocation p { flex:1 1 220px; margin:4px 0; line-height:1.8; }

.tabs a.tab-btn { display:inline-block; text-decoration:none; text-align:center; }

/* 住宅ローン計算セクションはコンパクトに（2026-11-09） */
#loanFormSection .form-grid { gap: 12px 16px; }
#loanFormSection .form-item input[type="number"] { width: 150px; max-width: 100%; padding: 7px 9px; }
#loanFormSection #loanAmount { width: 170px; }
#loanFormSection #husbandAgeLoan, #loanFormSection #wifeAgeLoan,
#loanFormSection #loanYears, #loanFormSection #completionAge,
#loanFormSection #examYears, #loanFormSection #repayRatioLimit { width: 84px; }
#loanFormSection #examRate { width: 100px; }
#loanFormSection #otherDebtMonthly { width: 120px; }

/* 銀行タブ（借入上限の審査基準の切り替え） */
#loanFormSection .bank-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 8px; margin-top: 16px; }
#loanFormSection .bank-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-family: inherit; text-align: left; }
#loanFormSection .bank-tab .bt-name { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
#loanFormSection .bank-tab .bt-limit { font-size: 17px; font-weight: 700; color: var(--accent-strong); }
#loanFormSection .bank-tab .bt-rate { font-size: 11px; color: var(--ink-faint); }
#loanFormSection .bank-tab.active { border-color: var(--accent); background: var(--accent-soft); }
#loanFormSection .bank-tab.active .bt-name { color: var(--accent-strong); }
