/* ============================================================
   E-計算！ Math — 原価率・利益率の計算（cost-ratio.html）だけで使う見た目
   共通（../assets/css/ek.css・css/math.css）の上に重ねる。色は変数だけを使う。
   ============================================================ */

/* ページ上部の要点 */
.cr-quick { margin: 4px 0 20px; }
.cr-quick ul { margin: 2px 0 0; }
.cr-quick li { margin: 2px 0; }

/* 知りたいこと（6つ。共通CSSで4つ以上はチップになる）：狭い画面でも1つの名前の途中で折り返さない */
html[data-ui="v2"] form .radio-row.cr-modes > label { white-space: nowrap; }
@media (max-width: 400px) {
  html[data-ui="v2"] form .radio-row.cr-modes > label { padding-left: 10px; padding-right: 10px; font-size: 13px; }
}

/* 数と単位（円・%）または選択（原価率／粗利率、掛け／%）を横に並べる */
html[data-ui="v2"] .field { min-width: 0; }
.cr-vu { display: flex; gap: 8px; align-items: center; min-width: 0; }
.cr-vu > input { flex: 1 1 auto; min-width: 0; }
.cr-unit { flex: none; min-width: 1.5em; font-size: 14px; color: var(--ink-2); }
.cr-unit:empty { display: none; }
html[data-ui="v2"] .field .cr-vu select { flex: 0 0 7.5em; width: 7.5em; min-width: 0; max-width: 100%; padding-left: 8px; padding-right: 28px; }
html[data-ui="v2"] .cr-vu input[type="text"] {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px; font-size: 15px; font-variant-numeric: tabular-nums; text-align: right;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
}
html[data-ui="v2"] .cr-vu input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
@media (max-width: 560px) { html[data-ui="v2"] .cr-vu input[type="text"] { font-size: 16px; } }   /* iOS で入力時に拡大されないように */
/* 入力の誤り（math.css の .vp-row input.bad と同じ見た目） */
html[data-ui="v2"] .cr-vu input.bad { border-color: var(--s2, #B4442C); border-width: 2px; }
html[data-ui="v2"] .cr-vu input::placeholder { color: var(--muted); }

/* 売価の端数（単位と丸め方の2つの選択） */
.cr-round { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
html[data-ui="v2"] .field .cr-round select { flex: 1 1 8em; width: auto; min-width: 0; max-width: 100%; }

/* くわしい条件（入力の中の折りたたみ） */
html[data-ui="v2"] details.why.cr-more { margin-top: 6px; }
html[data-ui="v2"] .cr-more > summary { margin-bottom: 0; }
html[data-ui="v2"] .cr-more[open] > summary { margin-bottom: 14px; }
.cr-more-hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.cr-more .field:last-child { margin-bottom: 4px; }

/* 結果の大きな数字は狭い画面で縮める。数字の途中では折り返さない（ページの script が桁区切りのカンマのあとに <wbr> を入れる） */
html[data-ui="v2"] .cr-out .res-hero .big b { font-size: clamp(28px, 8.5vw, 44px); overflow-wrap: normal; }
html[data-ui="v2"] .cr-out .res-mini .v { overflow-wrap: normal; word-break: normal; }
html[data-ui="v2"] .cr-out .res-mini .v small { white-space: nowrap; }
html[data-ui="v2"] .cr-out .res-mini .s { overflow-wrap: anywhere; }
html[data-ui="v2"] .cr-out .res-mini .k { overflow-wrap: anywhere; }
@media (max-width: 400px) {   /* 320px の画面で小さな箱の中は約70px */
  html[data-ui="v2"] .cr-out .res-mini .v { font-size: 15px; }
  html[data-ui="v2"] .cr-out .res-mini .v.long { font-size: 14px; }
}
/* それでも欄からはみ出す数がある行は、3つの箱を縦に並べる（ページの script の fitMinis が付ける） */
html[data-ui="v2"] .cr-out .res-mini.cr-stack { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
html[data-ui="v2"] .cr-out .res-mini.cr-stack > div { padding: 0; }
html[data-ui="v2"] .cr-out .res-mini.cr-stack > div + div { border-left: 0; padding: 10px 0 0; border-top: 1px solid var(--grid); }
/* 結果の欄の高さを先に確保する（読み込み直後の計算で下の要素が動かないように）。calc が最初に .cr-pending を外す */
#result { min-height: 220px; }
#resultPanel.cr-pending { min-height: 480px; }
.cr-out .verdict { margin-top: 12px; line-height: 1.8; overflow-wrap: anywhere; }
#resultPanel [hidden] { display: none !important; }

/* ---- 売価の内わけの帯（名前と値は HTML、棒だけ SVG） ---- */
.cr-fig { margin: 16px 0 0; padding: 14px 16px 10px; border: 1px solid var(--grid); border-radius: var(--r); background: var(--surface); min-width: 0; }
.cr-fig figcaption { font-size: 13.5px; font-weight: 700; color: var(--ink); margin-bottom: 6px; line-height: 1.6; }
.cr-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.cr-legend li { display: flex; align-items: center; gap: 6px; }
.cr-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.cr-legend i.cr-k-cost { background: color-mix(in srgb, var(--ink) 28%, var(--surface)); }
.cr-legend i.cr-k-prof { background: var(--accent); }
.cr-row + .cr-row { margin-top: 10px; }
.cr-row-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.cr-row-h .cr-lab { min-width: 0; overflow-wrap: anywhere; }
.cr-row-h .cr-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.cr-row.sel .cr-lab { font-weight: 700; }
.cr-fig svg.cr-bar { display: block; width: 100%; height: 14px; margin-top: 2px; }
.cr-bar .cr-track { fill: var(--page); }
.cr-bar .cr-cost { fill: color-mix(in srgb, var(--ink) 28%, var(--surface)); }
.cr-bar .cr-prof { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.cr-row.sel .cr-bar .cr-prof { fill: var(--accent); }
.cr-row-s { margin: 3px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-2); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---- 計算式と内訳 ---- */
.cr-fl { display: block; margin: 0 0 6px; overflow-wrap: anywhere; }

/* ---- 解説の表 ---- */
table.cr-wrap td, table.cr-wrap th { white-space: normal; }
table.cr-wrap td.n { white-space: nowrap; }
table.data.cr-conv { width: auto; min-width: 14em; }
