/* 画面ごとの部品。土台と共通部品は app.css。
   末尾の「移行中」は、まだ差し替えていない画面が使っている旧クラス。
   その画面を作り直した時点で、対応するブロックごと消す。 */

/* ── タブ ───────────────────────────────── */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 10px 14px; min-height: 40px; font-weight: 700; font-size: 13.5px;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* 3つの段を順に踏む画面なので、タブに番号を振って現在地を示す。
   「済み」は data-state、「いま見ている段」は aria-selected。
   1つの色に2つの意味を載せないよう、済みより選択中を優先して塗る（下の順序が効く） */
.tabs .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-right: 7px; border-radius: 50%;
  background: var(--neutral-bg); color: var(--muted);
  font-family: var(--font-num); font-size: 11px; font-weight: 700;
}
.tabs button[data-state="done"] .step-num { background: var(--ok-bg); color: var(--ok); }
.tabs button[aria-selected="true"] .step-num { background: var(--primary); color: #fff; }

.head-actions { display: flex; gap: 8px; align-items: center; flex: none; }

/* ── 資料の登録 ─────────────────────────── */

.drop {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 30px 24px; text-align: center;
  transition: border-color .18s, background .18s;
}
.drop.over { border-color: var(--primary); background: var(--primary-weak); }
.drop > svg { width: 30px; height: 30px; color: var(--subtle); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drop p { margin: 10px 0 4px; font-weight: 600; }
.drop .hint { color: var(--subtle); font-size: 12.5px; font-weight: 400; }
.drop .buttons { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* 種別 / 名前 / 用途 / サイズ / 取り消し。列を固定して取り消しボタンの位置を揃える */
.file-row {
  display: grid; grid-template-columns: 88px minmax(0, 1fr) auto auto 30px;
  align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  animation: rowIn .28s ease both;
}
.file-row:last-child { border-bottom: 0; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.file-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-use { color: var(--subtle); font-size: 12.5px; }
.file-size { color: var(--muted); font-size: 12.5px; }
.file-row.pending .file-name { color: var(--muted); }
.up-track { display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--neutral-bg); overflow: hidden; margin-top: 5px; }
.up-track i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .35s linear; }

/* 次にやることを常に画面に残す。押す前に何が起きるかを添える */
.runbar {
  position: sticky; bottom: 0; z-index: 20; margin-top: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.runbar .why { color: var(--muted); font-size: 13px; }

/* ── 解析の進捗 ─────────────────────────── */

.run-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.run-side { display: flex; align-items: center; gap: 12px; flex: none; }
.run-side svg { fill: none; stroke: currentColor; stroke-width: 2; }
.bigbar { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.bigbar i { display: block; height: 100%; border-radius: 4px; background: var(--primary); transition: width .6s cubic-bezier(.4, 0, .2, 1); }

/* 進んでいる間は縞を流す。1案件が36〜542秒（実測）かかるので、
   数字が変わらない時間が長い。止まっていないことを見せる必要がある */
.bigbar i.moving {
  background-image: linear-gradient(115deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%,
                    rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
  background-size: 22px 22px;
  animation: slide 1s linear infinite;
}
@keyframes slide { to { background-position: 22px 0; } }

.stages { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stages li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 6px; transition: background .2s;
}
.stages .mark { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.stages .label { color: var(--text); }
.stages .detail { color: var(--muted); font-size: 12.5px; }
.stages li.todo { color: var(--subtle); }
.stages li.done { color: var(--ok); }
.stages li.active { background: var(--primary-weak); color: var(--primary); }
.stages li.active .label { font-weight: 700; }
.stages li.active .detail { color: var(--primary); }
.spin { animation: spin 1.1s linear infinite; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 解析結果 ───────────────────────────── */

/* 行頭の帯。文字を読まなくても「要確認の塊」が見える */
td.stripe { position: relative; padding-left: 18px; }
td.stripe::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stripe, transparent); }
tr.s-ok { --stripe: var(--ok); }
tr.s-check { --stripe: var(--accent-fill); }
tr.s-unknown { --stripe: var(--danger); }
/* 人が直した行。AIの判定（緑）と区別する（青＝人の入力） */
tr.s-fixed { --stripe: var(--primary); }
tr.s-excluded { --stripe: var(--border-strong); color: var(--muted); }
/* 工種と数量の確認で使う。s-plain は印を付けない行（帯を出さない） */
tr.s-plain { --stripe: transparent; }

/* 数量セルに添える一言（桁の疑い）。数量そのものへの注意なので、
   独立した「状態」の列を作らず、値のすぐ下に置く */
.cell-warn { color: var(--warn); font-weight: 700; }

/* 行の右端の「修正」。行そのものは押せるようにしていないので、
   押せる場所をここで明示する（case_works.js / case_result.js の同趣旨のコメント）。

   **表示は table-cell のままにする。** `display: flex` などを当てると td が
   列のモデルから外れ、ブラウザが匿名セルで包むため、ボタンが隣の列（信頼度・
   記載箇所）に重なって見える。実際に、適合表マスタ用の
   `.row-actions { display: flex }` が同じ名前でぶつかって重なりが起きた
   （マスタ側は使われなくなっても残っていた）。名前を共有しない。 */
.row-actions { text-align: right; white-space: nowrap; width: 1%; }
.row-edit > svg { width: 14px; height: 14px; }

/* 信頼度。数字だけだと大小が読み取れないので細いバーを添える */
.conf { display: flex; align-items: center; gap: 8px; }
.conf-bar { width: 46px; height: 5px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; flex: none; }
.conf-bar i { display: block; height: 100%; border-radius: 3px; background: var(--fill, var(--subtle)); }
.conf-high { --fill: var(--ok); }
.conf-mid { --fill: var(--accent-fill); }
.conf-low { --fill: var(--danger); }

/* ── 重ねる層 ───────────────────────────── */

.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.42); animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 32px));
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-3); padding: 24px;
  animation: pop .2s cubic-bezier(.34, 1.4, .64, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { font-size: 17px; margin-bottom: 4px; }
.modal .lead { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
/* 確認は「何が起きるか」を先に読ませ、問いを見出しにする（app.js の confirmDialog）*/
.modal .lead-above { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.modal .lead-above + h2 { margin-bottom: 0; }

/* 編集か削除かを選ばせる並び。入力欄の下に削除ボタンを置くと、
   名前を直しに来ただけの人の指の先に取り返しのつかない操作が並ぶ */
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  justify-content: flex-start; text-align: left; white-space: normal;
  background: var(--surface); color: var(--text); font-weight: 400;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px 16px;
}
.choice:hover { background: var(--surface-2); border-color: var(--subtle); }
.choice > svg {
  width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--subtle);
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.choice strong { display: block; font-size: 14px; }
.choice .sub { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.choice-danger { color: var(--danger); border-color: #fca5a5; }
.choice-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.choice-danger > svg { color: var(--danger); }
.choice-danger .sub { color: #991b1b; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.drawer {
  position: fixed; z-index: 50; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw); overflow-y: auto;
  background: var(--surface); box-shadow: var(--shadow-3); padding: 24px;
  animation: slidein .24s cubic-bezier(.4, 0, .2, 1) both;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.drawer h2 { font-size: 18px; }
.drawer dl { margin: 20px 0 0; display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 11px 14px; font-size: 13.5px; }
.drawer dt { color: var(--subtle); font-weight: 700; font-size: 12.5px; }
.drawer dd { margin: 0; }
.reason { margin-top: 20px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; line-height: 1.75; }
.reason h3 { margin: 0 0 7px; font-size: 12px; letter-spacing: .05em; color: var(--subtle); }

/* 数量と単位は一緒に読むものなので横に並べる。狭い画面では縦に落とす */
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; }

/* ── ログイン ───────────────────────────── */

/* 入力欄が2つだけの画面なので、中央に寄せて視線を集める */
.login-card { max-width: 420px; margin: 8vh auto 0; padding: 28px; }
/* 見出しの上に置く小さな肩書き。h1 と同じ大きさで出ると2つ見出しがあるように読める */
.login-card .eyebrow {
  margin: 0 0 6px; color: var(--subtle);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
}
/* 見出しはヘッダーと同じシステム名。420px幅では2行になるので、
   折り返しを「工事資料解析・」の後（＝記号の位置）に寄せる。
   既定のままだと「工事資料解析・コニ／シ製品選定システム」と社名の途中で切れる。
   keep-all で入り切らない狭い画面では anywhere が受け止める。 */
.login-card h1 {
  font-size: 22px; margin-bottom: 6px;
  word-break: keep-all; overflow-wrap: anywhere;
}

/* 表示/非表示のボタンを入力欄の中に重ねる。文字が下に潜らないよう右に余白を取る */
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; min-height: 34px; padding: 7px; border-radius: 5px;
  background: transparent; border: 0; color: var(--subtle);
}
.password-toggle:hover { background: var(--surface-2); color: var(--text); }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

@media (max-width: 720px) {
  .file-row { grid-template-columns: 76px minmax(0, 1fr) 30px; }
  .file-size, .file-use { display: none; }
  .runbar { flex-direction: column; align-items: stretch; }
  .runbar button { width: 100%; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  /* タブは4つある。狭い画面では折り返さず横スクロールさせる
     （折り返すと下線の位置が段でずれて、どこを見ているか分からなくなる） */
  .tabs { overflow-x: auto; }
}

/* ── 適合表マスタ ───────────────────────── */

/* 行をそのまま編集する適合表。候補/除外は別の塊にして、解析へ入る行を明確にする。 */
#search { width: min(320px, 100%); }
#rows tr { cursor: pointer; }
#rows td small, .excluded-row small { display: block; color: var(--muted); margin-top: 3px; white-space: pre-line; }
#rows tr.group-row { cursor: default; }
#rows tr.group-row:hover, #rows tr.group-row:focus-visible { background: var(--surface-2); }
tr.group-row td { background: var(--surface-2); padding: 8px 18px; }
tr.group-row .gname { font-weight: 700; font-size: 13.5px; }
tr.group-row .gcount { margin-left: 8px; font-size: 11.5px; color: var(--subtle); font-weight: 600; }
td.indent { padding-left: 30px; }
td.edit-col { width: 90px; text-align: right; white-space: nowrap; color: var(--subtle); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--subtle); margin-top: 2px; white-space: pre-line; }
.edit-hint { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600;
  color: var(--primary); opacity: 0; transition: opacity .15s; }
#rows tr:hover .edit-hint, #rows tr:focus-visible .edit-hint { opacity: 1; }
td.edit-col svg.chev { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
  color: var(--border-strong); vertical-align: -5px; margin-left: 6px; }
#excluded { margin: 14px 0; border-top: 1px solid var(--border); padding-top: 12px; }
#excluded summary { cursor: pointer; font-weight: 700; }
.excluded-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 4px; }
.drawer-body { padding: 4px 0 16px; }
.drawer-body h3 { margin: 20px 0 10px; font-size: 14px; }
.drawer-foot { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; }

/* 編集できない行の詳細ビュー。値そのものを読ませる画面なので、入力欄は使わない。
   組みは既存の .drawer dl/dt/dd（案件詳細と同じ）を流用しているため、
   ここに足すのは見出しの製品名と「表示のみ」の印だけ。 */
.lead-product { font-size: 16px; font-weight: 700; margin: 10px 0 0; }
.lead-sub { font-size: 12.5px; color: var(--subtle); font-family: var(--font-num); margin: 2px 0 0; }
.view-only { display: inline-block; font-size: 11.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 99px; padding: 1px 9px; color: var(--muted); }
/* 判断基準は箇条書きで改行を含む。pre-line は詳細ビューの中だけに効かせる
   （.drawer dd は案件詳細でも使っており、そちらの見た目を変えないため） */
.drawer dl.detail dd { white-space: pre-line; }
.drawer .cond .value { font-size: 13px; padding-bottom: 10px; }
.drawer-foot .foot-note { font-size: 12px; color: var(--subtle); }
.drawer-foot .grow { flex: 1; }
.link-button { border: 0; background: none; color: var(--primary); padding: 0; min-height: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.cond { border: 1px solid var(--border); border-radius: 6px; padding: 12px 12px 2px; margin-bottom: 10px; position: relative; background: var(--surface-2); }
.cond .kind { font-size: 11.5px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.cond .remove { position: absolute; top: 6px; right: 6px; background: none; border: none; color: var(--subtle); padding: 6px; min-height: 0; }
.cond .remove:hover { color: var(--danger); background: var(--surface); }
.cond .remove svg, .add-buttons button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.add-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.add-buttons button { display: inline-flex; align-items: center; gap: 5px; background: var(--surface); color: var(--primary); border: 1px dashed var(--border-strong); font-size: 12.5px; font-weight: 600; min-height: 32px; padding: 5px 12px; }
.add-buttons button:hover { background: var(--primary-weak); }

/* この画面で何ができないかの但し書き。表と地続きに見えないよう離す */
.page-foot { margin: 16px 2px 0; font-size: 12.5px; line-height: 1.7; max-width: 68ch; }
