/* ゆうとぴあデイケア 利用者管理。事務所の Windows パソコン（ブラウザ）を主に、読みやすさを優先 */
:root {
  --ink: #1f2933; --sub: #52606d; --line: #cbd2d9; --soft: #f4f6f8; --bg: #fbfcfc; --card: #ffffff;
  --brand: #2f6f6a; --brand-ink: #ffffff; --brand-soft: #e6f0ee;
  --warn: #8a5a00; --warn-soft: #fff4dc; --error: #b42318; --error-soft: #fdecea; --ok-soft: #e8f5ec;
  --add: #1f6f43; --upd: #1d4f91; --chk: #8a5a00; --err: #b42318;
  --radius: 8px;
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h2 { font-size: 1.12rem; margin: 1.6rem 0 .5rem; }
h2 small { font-weight: 400; color: var(--sub); margin-left: .4em; font-size: .9rem; }
.hint { color: var(--sub); font-size: .88rem; }
.muted { color: var(--sub); }
.spacer { flex: 1; }

/* 上の帯とタブ */
.top { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.brand strong { font-size: 1.15rem; letter-spacing: .04em; }
.logo { width: .9rem; height: .9rem; border-radius: 3px; background: #9fd3c9; align-self: center; }
.facility { font-size: .92rem; opacity: .92; }
.who { margin-left: auto; font-size: .9rem; opacity: .95; }
.tabs { display: flex; gap: .25rem; padding: 0 1rem; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .75rem 1rem; cursor: pointer; color: var(--sub); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
main { max-width: 1440px; margin: 0 auto; padding: 1rem 1.25rem 4rem; }
.loading { color: var(--sub); }
.loading.error { color: var(--error); font-weight: 700; }
.banner { background: var(--warn-soft); color: var(--warn); padding: .6rem 1.25rem; border-bottom: 1px solid #f0d9a8; font-size: .92rem; }

/* ボタン */
button.primary, button.ghost, button.danger { border-radius: 6px; padding: .5rem 1.1rem; cursor: pointer; border: 1px solid transparent; }
button.primary { background: var(--brand); color: #fff; font-weight: 700; }
button.primary:hover { background: #255a56; }
button.ghost { background: var(--card); border-color: var(--line); }
button.ghost:hover { background: var(--soft); }
button.danger { background: var(--error); color: #fff; font-weight: 700; }
button.small { padding: .25rem .7rem; font-size: .88rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #7cc4b8; outline-offset: 1px; }
button.name { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 700; text-align: left; }
button.name:hover { color: #183f3c; }

/* 曜日・人数 */
.bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.days { display: flex; gap: .35rem; flex-wrap: wrap; }
.day { min-width: 4.2rem; padding: .45rem .7rem; border: 1px solid var(--line); background: var(--card); border-radius: 6px; cursor: pointer; font-size: 1.1rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.day small { font-size: .78rem; font-weight: 400; color: var(--sub); }
.day.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day.on small { color: #d9efea; }
.cards { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem 1rem; min-width: 7.2rem; display: flex; flex-direction: column; line-height: 1.3; text-align: left; }
.card span { color: var(--sub); font-size: .85rem; }
.card b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.card small { color: var(--sub); font-size: .82rem; }
.card.warn { background: var(--warn-soft); border-color: #f0d9a8; }
button.card { cursor: pointer; }
button.card.on { outline: 3px solid var(--brand); }

/* 表 */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.grid th, table.grid td { border-bottom: 1px solid #e4e7eb; padding: .45rem .6rem; text-align: left; vertical-align: top; }
table.grid thead th { background: var(--soft); font-size: .84rem; color: var(--sub); white-space: nowrap; position: sticky; top: 0; }
table.grid tbody tr:nth-child(even) { background: #fafbfc; }
table.grid tbody tr:hover { background: var(--brand-soft); }
td.name, th.name { white-space: nowrap; }
td.time, th.time, td.mark, th.mark { white-space: nowrap; text-align: center; }
td.number, th.number { white-space: nowrap; text-align: right; }
td.long { min-width: 12rem; white-space: pre-wrap; }
td.list { min-width: 7rem; }
table.counts td, table.counts th { text-align: right; font-variant-numeric: tabular-nums; }
table.counts td:first-child, table.counts th:first-child { text-align: left; }
table.counts tr.now { background: var(--brand-soft) !important; font-weight: 700; }
.empty { color: var(--sub); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0; }
.count { color: var(--sub); margin: 0 0 .4rem; }
table.people td.dayc, table.people th.dayc { text-align: center; white-space: nowrap; }
table.people tr.off td { color: var(--sub); }
.slot { font-size: .86rem; }
.tag { display: inline-block; margin-left: .25rem; padding: 0 .3rem; border-radius: 4px; font-size: .76rem; }
.tag.bath { background: #dbeafe; color: #1d4f91; }
.meta { color: var(--sub); font-size: .82rem; }
.notice { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.notice h2 { margin-top: 0; }
.notice.ok { background: var(--ok-soft); border-color: #b9dfc6; }

/* 検索・ツールバー */
.search input { width: 22rem; max-width: 70vw; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 6px; }
.bar select { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.chip { background: var(--brand-soft); color: var(--brand); padding: .2rem .7rem; border-radius: 999px; font-weight: 700; }

/* ダイアログ */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(1080px, 96vw); max-height: 94vh; box-shadow: 0 18px 50px rgba(15, 30, 40, .28); }
dialog::backdrop { background: rgba(20, 30, 40, .45); }
#printDlg, #confirmDlg { width: min(520px, 94vw); }
dialog form { display: flex; flex-direction: column; max-height: 94vh; }
.dlg-head { display: flex; align-items: center; padding: .8rem 1.2rem; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 1.2rem; }
.dlg-head .icon { margin-left: auto; border: 0; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--sub); padding: .2rem .5rem; }
.dlg-body { padding: 1rem 1.2rem; overflow-y: auto; }
.dlg-body.narrow fieldset { border: 0; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .35rem; }
.dlg-body.narrow legend { font-weight: 700; margin-bottom: .3rem; }
.dlg-foot { display: flex; align-items: center; gap: .6rem; padding: .8rem 1.2rem; border-top: 1px solid var(--line); background: var(--soft); border-radius: 0 0 10px 10px; flex-wrap: wrap; }
fieldset.grp { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem 1rem 1rem; margin: 0 0 1rem; }
fieldset.grp legend { font-weight: 700; padding: 0 .4rem; color: var(--brand); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .7rem 1rem; }
.f { display: flex; flex-direction: column; gap: .2rem; }
.f.wide { grid-column: 1 / -1; }
.f label { font-size: .86rem; color: var(--sub); }
.f input, .f select, .f textarea, table.plan input.time { padding: .42rem .6rem; border: 1px solid #b6c0ca; border-radius: 6px; background: #fff; width: 100%; }
.f textarea { resize: vertical; }
.f input:disabled, .f select:disabled, .f textarea:disabled, table.plan input:disabled { background: var(--soft); color: var(--ink); border-color: #dfe3e8; }
.unit { display: flex; align-items: center; gap: .4rem; }
.unit span { color: var(--sub); }
.ferr { color: var(--error); font-size: .84rem; }
[aria-invalid="true"] { border-color: var(--error) !important; background: var(--error-soft) !important; }
table.plan { border-collapse: collapse; }
table.plan th, table.plan td { padding: .3rem .6rem; text-align: center; border-bottom: 1px solid #e4e7eb; }
table.plan thead th { font-size: .84rem; color: var(--sub); }
table.plan tbody th { font-size: 1.05rem; }
table.plan input[type=checkbox] { width: 1.3rem; height: 1.3rem; cursor: pointer; }
table.plan input.time { width: 6.5rem; text-align: center; }
td.slotc { min-width: 3.5rem; color: var(--brand); font-weight: 700; }
.errors { background: var(--error-soft); border: 1px solid #f5c2bd; color: var(--error); border-radius: var(--radius); padding: .6rem 1rem; margin-bottom: 1rem; }
.errors p, .errors ul { margin: .2rem 0; }
.warnings { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: .5rem 1rem; margin-bottom: 1rem; }
.warnings p { margin: .1rem 0; }

/* 取り込み */
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.2rem; margin: 1rem 0; }
.block h2 { margin-top: 0; }
details.block summary { cursor: pointer; font-weight: 700; }
.imp-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.alert { border-radius: var(--radius); padding: .7rem 1rem; margin: .8rem 0; }
.alert.error { background: var(--error-soft); color: var(--error); border: 1px solid #f5c2bd; }
.alert.error h2 { margin-top: 0; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; background: var(--soft); color: var(--sub); }
.badge.cat-追加 { background: var(--ok-soft); color: var(--add); }
.badge.cat-更新 { background: #e3edfb; color: var(--upd); }
.badge.cat-要確認 { background: var(--warn-soft); color: var(--chk); }
.badge.cat-エラー { background: var(--error-soft); color: var(--err); }
.card.cat-追加 b { color: var(--add); } .card.cat-更新 b { color: var(--upd); } .card.cat-要確認 b { color: var(--chk); } .card.cat-エラー b { color: var(--err); }
table.imp td:nth-child(4) { min-width: 26rem; }
table.imp tr.cat-要確認 { background: #fffaf0 !important; }
table.imp select { max-width: 100%; padding: .35rem .5rem; border: 1px solid #b6c0ca; border-radius: 6px; margin: .2rem 0; }
ul.issues, ul.diff, ul.xdiff { margin: .2rem 0; padding-left: 1.1rem; font-size: .9rem; }
ul.issues li.error { color: var(--error); }
ul.issues li.warn { color: var(--warn); }
.reason { margin: 0 0 .2rem; color: var(--warn); font-weight: 700; font-size: .9rem; }
.note { margin: .2rem 0; color: var(--sub); font-size: .88rem; }
.apply label.check { display: flex; gap: .5rem; align-items: center; font-size: 1rem; }
.apply input[type=checkbox] { width: 1.2rem; height: 1.2rem; }

/* 設定 */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .8rem 1rem; }
.choices label { display: flex; flex-direction: column; font-size: .88rem; color: var(--sub); gap: .2rem; }
.choices textarea { padding: .4rem .5rem; border: 1px solid #b6c0ca; border-radius: 6px; color: var(--ink); }

/* お知らせ */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: #1f2933; color: #fff; padding: .7rem 1.2rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; z-index: 10; }
.toast.error { background: var(--error); }

/* 印刷：画面は隠して、印刷用の表だけ出す。利用者一覧・入浴表は A4 横 */
.print-area { display: none; }
@page { size: A4 portrait; margin: 10mm; }
@page land { size: A4 landscape; margin: 9mm; }
@media print {
  :root { font-size: 10.5pt; background: #fff; }
  body { background: #fff; }
  .app, dialog, .toast { display: none !important; }
  .print-area { display: block; }
  .sheet { break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet.land { page: land; }
  .sheet header { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid #000; margin-bottom: 3mm; }
  .sheet h1 { font-size: 15pt; margin: 0 0 1mm; }
  .sheet header p { margin: 0; font-size: 9pt; }
  .tbl-wrap { border: 0; overflow: visible; }
  table.grid { font-size: 9.5pt; }
  table.grid th, table.grid td { border: 1px solid #555; padding: 1.4mm 1.6mm; }
  table.grid thead th { background: #e8e8e8 !important; color: #000; position: static; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.grid tbody tr { break-inside: avoid; background: #fff !important; }
  td.blank { min-width: 55mm; }
  .sheet.bath tbody td { height: 10mm; }
  td.long { min-width: 35mm; }
  .empty { border: 1px solid #555; }
}

/* 狭い画面（タブレット・スマホでの確認用） */
@media (max-width: 700px) {
  :root { font-size: 14px; }
  .top { padding: .6rem 1rem; flex-wrap: wrap; }
  .who { margin-left: 0; width: 100%; }
  main { padding: .8rem 1rem 3rem; }
  .card { min-width: 5.6rem; padding: .45rem .7rem; }
  .card b { font-size: 1.4rem; }
  .day { min-width: 3.3rem; }
  .search input { width: 100%; max-width: none; }
  .search { flex: 1 1 100%; }
  table.grid td:not(.long) { white-space: nowrap; }
}
