/* ======================================================================
 *  房贷计算器 /tools/mortgage-calc
 *  依赖 home.css 全局变量 + tool-detail.css 公共类，支持黑夜模式
 * ====================================================================== */

[hidden] { display: none !important; }

.mc-layout {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}
.mc-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}
.mc-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}

/* ---------- 表单 ---------- */
.mc-field { margin-bottom: 14px; min-width: 0; }
.mc-field > label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-sub);
    margin-bottom: 7px;
}
.mc-input-wrap { position: relative; display: flex; align-items: center; }
.mc-input {
    width: 100%;
    height: 43px;
    padding: 0 64px 0 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
    -moz-appearance: textfield;
}
.mc-input::-webkit-outer-spin-button,
.mc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mc-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.mc-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 36px;
    font-size: 13.5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a8' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}
.mc-suffix {
    position: absolute;
    right: 14px;
    font-size: 12px;
    color: var(--c-text-muted);
    pointer-events: none;
}
.mc-help {
    font-size: 11.5px;
    line-height: 1.65;
    color: var(--c-text-muted);
    margin-top: 6px;
}
.mc-help b { color: var(--c-text-sub); }
.mc-row2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.mc-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 13px;
    font-size: 12px;
    font-weight: 700;
    color: var(--c-text-muted);
}
.mc-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--c-border);
}

.btn-block { width: 100%; margin-top: 8px; }

/* ---------- 结果区 ---------- */
.mc-result-card { min-height: 340px; }
.mc-result-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 320px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 13.5px;
    line-height: 1.8;
}
.mc-result-empty .emoji { font-size: 46px; opacity: 0.75; }

.mc-result-body { animation: mcFade 0.28s ease; }
@keyframes mcFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.mc-hero {
    padding: 22px 24px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.09), rgba(120, 90, 255, 0.07));
    border: 1px solid rgba(0, 102, 255, 0.2);
    margin-bottom: 14px;
}
.mc-hero-label { font-size: 12.5px; color: var(--c-text-sub); margin-bottom: 6px; }
.mc-hero-num {
    display: flex;
    align-items: baseline;
    gap: 4px;
    line-height: 1.1;
    color: var(--c-primary);
}
.mc-hero-num .cur { font-size: 20px; font-weight: 700; }
.mc-hero-num b { font-size: 38px; font-weight: 800; letter-spacing: -0.035em; }
.mc-hero-sub { font-size: 12.5px; color: var(--c-text-sub); margin-top: 8px; }

.mc-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.mc-split-item {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
}
.mc-split-num {
    font-size: 18px;
    font-weight: 800;
    color: var(--c-text);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.mc-split-key { font-size: 11.5px; color: var(--c-text-muted); }

/* 明细账单 */
.mc-bill {
    list-style: none;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}
.mc-bill li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--c-border);
}
.mc-bill li:last-child { border-bottom: none; }
.mc-bill .k { color: var(--c-text-sub); }
.mc-bill .v { font-weight: 700; color: var(--c-text); white-space: nowrap; }
.mc-bill li.total { background: var(--c-surface-soft); }
.mc-bill li.total .v { color: var(--c-primary); font-size: 14.5px; }

/* 构成条 */
.mc-meter { margin-bottom: 14px; }
.mc-meter-label { font-size: 12px; color: var(--c-text-muted); margin-bottom: 8px; }
.mc-meter-bar {
    display: flex;
    height: 12px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--c-surface-soft);
}
.mc-meter-bar .seg { height: 100%; transition: width 0.3s ease; }
.mc-meter-bar .seg-loan { background: linear-gradient(90deg, #0066ff, #5b8cff); }
.mc-meter-bar .seg-interest { background: linear-gradient(90deg, #ff8f1f, #ffb347); }
.mc-meter-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 9px;
    font-size: 12px;
    color: var(--c-text-muted);
}
.mc-meter-legend b { color: var(--c-text-sub); }
.mc-meter-legend .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}
.mc-meter-legend .dot-loan { background: #0066ff; }
.mc-meter-legend .dot-interest { background: #ff8f1f; }

/* 压力评估 */
.mc-pressure {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    margin-bottom: 14px;
}
.mc-pressure-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--c-text-sub);
    margin-bottom: 9px;
}
.mc-pressure-head b { font-size: 14px; font-weight: 800; color: var(--c-text); }
.mc-pressure-bar {
    height: 10px;
    border-radius: 99px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    overflow: hidden;
}
.mc-pressure-fill {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: #10b981;
    transition: width 0.3s ease, background 0.3s ease;
}
.mc-pressure-fill.is-green { background: linear-gradient(90deg, #10b981, #34d399); }
.mc-pressure-fill.is-blue { background: linear-gradient(90deg, #0066ff, #5b8cff); }
.mc-pressure-fill.is-orange { background: linear-gradient(90deg, #f0851c, #ffb347); }
.mc-pressure-fill.is-red { background: linear-gradient(90deg, #ef4444, #f87171); }
.mc-pressure-tip {
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--c-text-muted);
    margin-top: 9px;
}

/* 方式对比 */
.mc-compare {
    border: 1px solid var(--c-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--c-surface-soft);
}
.mc-cmp-head {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--c-text-sub);
    margin-bottom: 10px;
}
.mc-cmp-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.mc-cmp-item {
    padding: 11px 13px;
    border-radius: 11px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
}
.mc-cmp-item .k { display: block; font-size: 11.5px; color: var(--c-text-muted); margin-bottom: 4px; }
.mc-cmp-item .v { display: block; font-size: 17px; font-weight: 800; color: var(--c-text); letter-spacing: -0.02em; }
.mc-cmp-item small { display: block; font-size: 10.5px; color: var(--c-text-muted); margin-top: 4px; line-height: 1.5; }
.mc-cmp-item.is-active { border-color: rgba(0, 102, 255, 0.4); background: var(--c-primary-soft); }
.mc-cmp-item.is-active .v { color: var(--c-primary); }
.mc-cmp-tip {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--c-text-sub);
    line-height: 1.7;
}
.mc-cmp-tip b { color: var(--c-accent-green); }

.mc-note {
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--c-text-sub);
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--c-primary-soft);
    border: 1px dashed rgba(0, 102, 255, 0.28);
}
.mc-note b { color: var(--c-text); }

/* ---------- 还款计划表 ---------- */
.mc-table-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
}
.mc-table-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.mc-table-head .mc-title { margin-bottom: 4px; }
.mc-table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.mc-seg {
    display: inline-flex;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--c-surface-soft);
}
.mc-seg button {
    border: none;
    background: transparent;
    color: var(--c-text-sub);
    font-size: 12.5px;
    font-weight: 700;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
    font-family: inherit;
}
.mc-seg button.active { background: var(--c-primary); color: #fff; }
.mc-mini {
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    color: var(--c-text-sub);
    font-size: 12.5px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.16s ease, color 0.16s ease;
}
.mc-mini:hover { border-color: var(--c-primary); color: var(--c-primary); }
.mc-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
    max-height: 560px;
    overflow-y: auto;
}
.mc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 520px;
}
.mc-table thead th {
    text-align: right;
    padding: 12px 16px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-text-sub);
    background: var(--c-surface-soft);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.mc-table thead th:first-child { text-align: center; }
.mc-table tbody td {
    padding: 10px 16px;
    text-align: right;
    color: var(--c-text-sub);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.mc-table tbody td:first-child { text-align: center; font-weight: 700; color: var(--c-text); }
.mc-table tbody tr:last-child td { border-bottom: none; }
.mc-table tbody td.c-interest { color: #f0851c; font-weight: 700; }
.mc-table-empty {
    text-align: center !important;
    color: var(--c-text-muted) !important;
    padding: 30px 16px !important;
    font-weight: 400 !important;
}

.mc-disclaim {
    font-size: 12px;
    line-height: 1.85;
    color: var(--c-text-muted);
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 26px;
}
.mc-disclaim b { color: var(--c-text-sub); }
.mc-info { margin-bottom: 26px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
    .mc-layout { grid-template-columns: 1fr; }
    .mc-result-card { min-height: auto; }
    .mc-result-empty { min-height: 180px; }
}
@media (max-width: 620px) {
    .mc-card, .mc-table-card { padding: 18px; }
    .mc-hero-num b { font-size: 30px; }
    .mc-split { grid-template-columns: 1fr; }
    .mc-cmp-grid { grid-template-columns: 1fr; }
    .mc-bill li { flex-direction: column; align-items: flex-start; gap: 4px; }
    .mc-row2 { grid-template-columns: 1fr; }
    .mc-table-scroll { max-height: none; }
}

/* ============ 黑夜模式 ============ */
[data-theme="dark"] .mc-input { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .mc-input option { background: #131c31; color: #e5e9f0; }
[data-theme="dark"] .mc-hero {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(120, 90, 255, 0.14));
    border-color: rgba(59, 130, 246, 0.28);
}
[data-theme="dark"] .mc-hero-num { color: #6ea8ff; }
[data-theme="dark"] .mc-note {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.32);
}
[data-theme="dark"] .mc-split-item,
[data-theme="dark"] .mc-pressure,
[data-theme="dark"] .mc-compare,
[data-theme="dark"] .mc-bill li.total,
[data-theme="dark"] .mc-table thead th,
[data-theme="dark"] .mc-disclaim,
[data-theme="dark"] .mc-seg,
[data-theme="dark"] .mc-mini { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .mc-cmp-item { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .mc-cmp-item.is-active {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.4);
}
[data-theme="dark"] .mc-bill li.total .v,
[data-theme="dark"] .mc-cmp-item.is-active .v { color: #6ea8ff; }
[data-theme="dark"] .mc-cmp-tip b { color: #34d399; }
[data-theme="dark"] .mc-table tbody td.c-interest { color: #fbbf24; }
[data-theme="dark"] .mc-pressure-bar { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .mc-meter-bar { background: rgba(255, 255, 255, 0.06); }
