/* 消費税計算
   色は Bootstrap 5.3 の変数で組み、ライト／ダークで自動的に切り替える。 */

#app-tax {
    max-width: 900px;
}

/* ---------- モード切替（2択を等幅で並べる） ---------- */
#app-tax .tx-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

#app-tax .tx-tabs .btn {
    white-space: nowrap;
    font-weight: 700;
    min-width: 0;
}

/* 狭い画面では「（インボイス）」を隠す。出したままだと、字の幅でボタンが枠からはみ出す
   （2026-09-23 実 Safari で発覚。枠 378px に対しボタン 142＋238＋すき間8＝388px） */
@media (max-width: 575.98px) {
    #app-tax .tx-tab-sub {
        display: none;
    }
}

/* ---------- パネル（見出しに面を敷いて役割を分ける） ---------- */
#app-tax .tx-panel {
    border: 1px solid var(--bs-border-color);
    border-radius: 4px;
    overflow: hidden;
    background: var(--bs-body-bg);
}

#app-tax .tx-panel-head {
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
    padding: .55rem 1rem;
    font-weight: 700;
}

#app-tax .tx-panel-body {
    padding: 1rem;
}

/* ---------- 選択肢の行 ---------- */
#app-tax .tx-optrow {
    display: grid;
    grid-template-columns: 6.5em 1fr;
    align-items: center;
    gap: .5rem;
}

#app-tax .tx-optrow + .tx-optrow {
    margin-top: .75rem;
}

#app-tax .tx-optlabel {
    font-weight: 700;
    font-size: .95rem;
}

#app-tax .tx-opts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
}

#app-tax .tx-opts-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#app-tax .tx-opts .btn {
    white-space: nowrap;
    padding-inline: .25rem;
}

@media (max-width: 575.98px) {
    #app-tax .tx-optrow {
        grid-template-columns: 1fr;
        gap: .3rem;
    }
}

#app-tax .tx-swapmark {
    color: var(--bs-secondary-color);
    padding-bottom: .6rem;
}

@media (max-width: 767.98px) {
    #app-tax .tx-swapmark {
        padding-bottom: 0;
        margin-block: -.5rem;
    }
}

/* ---------- 結果 ---------- */
#app-tax .tx-result {
    border-left: 4px solid var(--bs-primary);
    background: var(--bs-tertiary-bg);
    padding: .9rem 1rem;
}

#app-tax .tx-result-cells {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

#app-tax .tx-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#app-tax .tx-cell-label {
    font-size: .8rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

#app-tax .tx-cell-val {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    /* 金額はカンマの位置で折らない。入りきらないときは main.js の fitCells が縦1列に並べ替える */
    white-space: nowrap;
}

#app-tax .tx-result-cells.tx-stack { grid-template-columns: minmax(0, 1fr); }
#app-tax .tx-result-cells.tx-stack .tx-cell {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
}

#app-tax .tx-cell-main .tx-cell-val {
    font-size: 1.6rem;
}

@media (max-width: 575.98px) {
    #app-tax .tx-cell-val { font-size: 1.1rem; }
    #app-tax .tx-cell-main .tx-cell-val { font-size: 1.25rem; }
}

#app-tax .tx-formula {
    margin-top: .5rem;
}

#app-tax .tx-formula:empty {
    display: none;
}

/* ---------- 明細 ---------- */
#app-tax .tx-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9rem 6.5rem 2.6rem;
    gap: .4rem;
    align-items: center;
}

#app-tax .tx-row-head {
    font-size: .8rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    margin-bottom: .3rem;
}

#app-tax .tx-del {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* スマホ: 品名を1行目、金額・税率・削除を2行目 */
@media (max-width: 767.98px) {
    #app-tax .tx-row {
        grid-template-columns: minmax(0, 1fr) 6rem 2.75rem;
        padding-bottom: .5rem;
        border-bottom: 1px dashed var(--bs-border-color);
    }
    #app-tax .tx-row .tx-name {
        grid-column: 1 / -1;
    }
    #app-tax .tx-del {
        min-height: 38px;
    }
}

#app-tax .tx-sumtable th,
#app-tax .tx-sumtable td {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#app-tax .tx-sumtable thead th {
    font-size: .8rem;
    line-height: 1.25;
    background: var(--bs-tertiary-bg);
}

#app-tax .tx-sumtable tfoot th,
#app-tax .tx-sumtable tfoot td {
    border-top: 2px solid var(--bs-border-color);
}

#app-tax .tx-sumtable .tx-grand th,
#app-tax .tx-sumtable .tx-grand td {
    border-top: 0;
    font-size: 1.05rem;
}

/* ずれがある行の差（色文字にせず、面で示す） */
#app-tax .tx-diff {
    font-weight: 700;
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}
