/* 计算器系列（calc/*.html）共用样式。通用组件见 ../common.css，这里只放本系列特有的部分。 */

/* 布局：.tb-split 里的卡片是并排的两列，取消 common.css 中相邻卡片的上间距 */
.tb-split > .tb-card,
.calc-result > .tb-card,
.tb-stack > .tb-card { margin-top: 0; }

.calc-form { display: grid; gap: 0.875rem; }
.calc-form .tb-tabs { display: flex; }
.calc-form .tb-tabs .tb-tab { flex: 1; }
.calc-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.calc-actions .tb-btn { flex: 1 1 auto; }
.calc-result { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.is-stale .tb-stats,
.is-stale .tb-table-wrap,
.is-stale .calc-fade { opacity: 0.4; }

input[aria-invalid="true"] { border-color: var(--color-danger); }

/* 统计块：主结果占整行并放大；数字不在中间折行 */
.tb-stats { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.tb-stat { min-width: 0; }
.tb-stat-value { font-size: 1.3rem; overflow-wrap: normal; word-break: keep-all; }
.tb-stat--main { grid-column: 1 / -1; background: var(--color-primary-soft); }
.tb-stat--main .tb-stat-value { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.25rem); }
.tb-stat-value small { font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600; color: var(--color-text-muted); margin-left: 3px; }
.tb-stat-value.is-cost { color: var(--color-hot); }
.tb-stat-value.is-plain { color: var(--color-text); }
.tb-stat-value.is-text { font-size: 1.125rem; }
.tb-stat-sub { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; }

/* 数字表格：右对齐、等宽数字，长表格纵向滚动并固定表头 */
.calc-table th, .calc-table td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table tr.is-active td { background: var(--color-primary-soft); font-weight: 600; color: var(--color-primary); }
.calc-table tfoot td { background: var(--color-surface); font-weight: 700; border-top: 1px solid var(--color-border); border-bottom: 0; }
.calc-scroll { max-height: 440px; overflow: auto; }
.calc-scroll thead th { position: sticky; top: 0; z-index: 1; }
.calc-table input[type="number"] { width: 5.25rem; min-height: 34px; padding: 0.25rem 0.5rem; text-align: right; }

.calc-note { font-size: 0.8125rem; color: var(--color-text-muted); line-height: 1.7; }
.calc-note strong { color: var(--color-text-secondary); }
.calc-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.875rem; }
.calc-head .tb-card-title { margin-bottom: 0; }

/* 占比条 */
.calc-bar { display: flex; height: 10px; border-radius: var(--radius-full); overflow: hidden; background: var(--color-surface); }
.calc-bar > span { display: block; height: 100%; background: var(--color-primary); transition: width var(--transition-normal); }
.calc-bar > span + span { background: var(--color-hot); }
.calc-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8125rem; color: var(--color-text-secondary); margin-top: 0.5rem; }
.calc-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--color-primary); margin-right: 6px; }
.calc-legend span + span i { background: var(--color-hot); }

@media (max-width: 480px) {
    .calc-actions .tb-btn { flex: 1 1 40%; }
    .tb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tb-stat { padding: 0.75rem; }
}
