/* 総眞設備 月次明細の担当者入れ
   考え方: 事務の帳票。1列・左そろえ。色は「状態」にだけ使う。
   黄＝候補つきの要確認 / 橙＝候補なしの要確認（保存するエクセルの下書きと同じ色）/ 緑＝確定。
   TimeTree の色（青・黄・緑・紫・赤・サンゴ）は、候補の予定に付ける小さな丸でそのまま見せる。 */

:root {
  color-scheme: light;
  --ground: #EEF1F4;
  --paper: #FFFFFF;
  --ink: #1B2733;
  --muted: #5B6875;
  --line: #D3DAE1;
  --navy: #1F3A5F;
  --navy-deep: #162B48;
  --ok: #1E7B4F;
  --ok-soft: #E3F2EA;
  --cand: #FFF2A8;
  --none: #FFD3A6;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --tt-blue: #47B2F7; --tt-green: #2ECC87; --tt-yellow: #FDC02D; --tt-purple: #B38BDC;
  --tt-red: #E73B3B; --tt-coral: #FB7F77; --tt-black: #212121;
  --font: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font); line-height: 1.65;
  padding-bottom: 6.5rem; /* 下に固定した帯のぶん */
}
.wrap { max-width: 68rem; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.hide-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* 上の帯 */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-in { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-end; justify-content: space-between; padding-top: 1.5rem; padding-bottom: 1.25rem; }
.top h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.01em; }
.top-sub { color: var(--muted); font-size: 0.9375rem; margin-top: 0.25rem; max-width: 40rem; }
.top-tools { display: flex; gap: 0.5rem; flex-wrap: wrap; }

main.wrap { padding-top: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
#result { display: flex; flex-direction: column; gap: 1.25rem; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: 0.9375rem; font-weight: 700; line-height: 1.2; cursor: pointer;
  padding: 0.65rem 1rem; border-radius: 6px; border: 1px solid var(--navy);
  background: var(--paper); color: var(--navy); text-decoration: none;
}
.btn:hover { background: #F3F6FA; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-deep); }
.btn.quiet { border-color: var(--line); color: var(--ink); font-weight: 400; }
.btn.small { padding: 0.4rem 0.7rem; font-size: 0.875rem; }
.btn.big { padding: 0.9rem 1.6rem; font-size: 1.0625rem; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; background: #E3E7EC; border-color: #E3E7EC; color: #8A95A1; }
.btn:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .hide-input:focus-visible + .btn, .hide-input:focus-visible ~ label { outline: 3px solid #7DB3F0; outline-offset: 2px; }

/* お知らせ（失敗したとき） */
.notice { background: var(--danger-soft); color: var(--danger); border: 1px solid #F3B8B1; border-radius: 6px; padding: 0.8rem 1rem; font-weight: 700; white-space: pre-line; }
.notice.info { background: var(--ok-soft); color: var(--ok); border-color: #B5DCC5; }

/* 3つの手順 */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.step { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.step h2 { font-size: 1.125rem; font-weight: 700; display: flex; align-items: center; gap: 0.6rem; }
.step-no { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.9375rem; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.step.done .step-no { background: var(--ok); }
.step-state { font-weight: 700; overflow-wrap: anywhere; }
.step.done .step-state { color: var(--ok); }
.step.warn .step-state { color: #8A4B00; }
.step-help { color: var(--muted); font-size: 0.875rem; }
.step-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem; }
.step.drag { outline: 3px dashed var(--navy); outline-offset: -3px; background: #F3F6FA; }

/* 件数のまとめ */
.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.count { padding: 0.9rem 1.2rem; border-right: 1px solid var(--line); min-width: 0; }
.count:last-child { border-right: 0; }
.count dt { color: var(--muted); font-size: 0.875rem; }
.count dd { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.count dd small { font-size: 0.875rem; font-weight: 400; color: var(--muted); margin-left: 0.3rem; }
.count.cand dd { box-shadow: inset 0 -0.6em 0 var(--cand); display: inline-block; }
.count.none dd { box-shadow: inset 0 -0.6em 0 var(--none); display: inline-block; }
dl.counts { margin: 0; }

/* かたまり */
.block { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem; }
.block-head, .block > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1rem; }
.block h2 { font-size: 1.1875rem; font-weight: 700; }
.block-note { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.block-help { color: var(--muted); font-size: 0.875rem; margin-top: 0.4rem; }
.block > summary { cursor: pointer; list-style: none; }
.block > summary::-webkit-details-marker { display: none; }
.block > summary::before { content: "＋"; font-weight: 700; color: var(--navy); width: 1.2rem; }
.block[open] > summary::before { content: "－"; }
.empty { color: var(--muted); margin-top: 0.6rem; }

/* 確認が要る行 */
.check-list { display: flex; flex-direction: column; margin-top: 0.8rem; border-top: 1px solid var(--line); }
.row { border-bottom: 1px solid var(--line); padding: 1rem 0 1rem 0.9rem; border-left: 0.45rem solid var(--cand); display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
.row.none { border-left-color: var(--none); }
.row.done { border-left-color: var(--ok); padding-top: 0.6rem; padding-bottom: 0.6rem; }
.row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1rem; }
.row-memo { font-size: 1.0625rem; font-weight: 700; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.row-why { font-size: 0.875rem; color: var(--muted); }
.cands { display: flex; flex-direction: column; gap: 0.4rem; }
.cand-btn {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.2rem 0.8rem; text-align: left;
  font: inherit; cursor: pointer; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 0.55rem 0.8rem; color: var(--ink);
}
.cand-btn:hover { border-color: var(--navy); background: #F3F6FA; }
.cand-who { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.cand-who small { font-weight: 400; color: var(--navy); margin-left: 0.35rem; }
.cand-ev { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 0.1rem 0.5rem; align-items: center; }
.dot { flex: none; width: 0.7rem; height: 0.7rem; border-radius: 50%; display: inline-block; background: var(--line); }
.dot.c3 { background: var(--tt-blue); } .dot.c1 { background: var(--tt-green); } .dot.c9 { background: var(--tt-yellow); }
.dot.c10 { background: var(--tt-purple); } .dot.c6 { background: var(--tt-red); } .dot.c8 { background: var(--tt-coral); } .dot.c5 { background: var(--tt-black); }
.pick { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pick label { font-size: 0.875rem; color: var(--muted); }
select, input[type="text"] { font: inherit; font-size: 1rem; padding: 0.5rem 0.6rem; border: 1px solid #9AA5B1; border-radius: 6px; background: var(--paper); color: var(--ink); min-width: 0; }
input[type="text"] { width: 11rem; }
.done-line { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: center; }
.done-name { font-weight: 700; color: var(--ok); }
.done-name::before { content: "✓ "; }
.link { font: inherit; font-size: 0.875rem; background: none; border: 0; padding: 0.2rem 0; color: var(--navy); text-decoration: underline; cursor: pointer; }

/* 自動で入れた工事 */
.auto-list { margin-top: 0.8rem; border-top: 1px solid var(--line); }
.auto-row { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: 0.2rem 1rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.auto-name { font-weight: 700; }
.auto-body { min-width: 0; }
.auto-memo { overflow-wrap: anywhere; }
.auto-ev { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 0.1rem 0.5rem; align-items: center; }

/* 集計 */
.table-scroll { overflow-x: auto; margin-top: 0.8rem; }
table.sum { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.sum th, .sum td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.sum thead th { font-size: 0.875rem; color: var(--muted); font-weight: 400; border-bottom: 2px solid var(--ink); }
.sum .num { text-align: right; }
.sum tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.sum tr.pending td { background: #FFF8E0; }
.sum tr.skip td { color: var(--muted); }

/* 下に固定した帯：あと何件で保存できるか */
.bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 2px solid var(--ink); z-index: 5; }
.bar-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(6rem, 14rem) auto; gap: 1rem 1.5rem; align-items: center; padding-top: 0.8rem; padding-bottom: 0.8rem; }
.bar-text { display: flex; flex-direction: column; min-width: 0; }
.bar-text strong { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.bar-text span { font-size: 0.875rem; color: var(--muted); }
.meter { height: 0.6rem; background: #E3E7EC; border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.25s ease; }
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }

@media (max-width: 52rem) {
  .steps { grid-template-columns: minmax(0, 1fr); }
  .count { border-right: 0; border-bottom: 1px solid var(--line); }
  .bar-in { grid-template-columns: minmax(0, 1fr) auto; }
  .meter { display: none; }
  .auto-row { grid-template-columns: minmax(0, 1fr) auto; }
  .auto-name { grid-column: 1 / -1; }
}
