* { box-sizing: border-box; }
body { font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; margin: 0; color: #222; background: #f6f6f4; }
header.top { background: #2f3b52; color: #fff; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
header.top h1 { font-size: 16px; margin: 0 8px 0 0; }
header.top .user { margin-left: auto; font-size: 13px; }
button { cursor: pointer; border: 1px solid #b9bdc7; background: #fff; border-radius: 6px; padding: 5px 10px; font-size: 13px; }
button.primary { background: #2f6fd0; border-color: #2f6fd0; color: #fff; }
button.danger { background: #c0392b; border-color: #c0392b; color: #fff; }
button:disabled { opacity: .45; cursor: default; }
nav.tabs { display: flex; gap: 4px; padding: 8px 12px 0; flex-wrap: wrap; }
nav.tabs button.active { background: #2f3b52; color: #fff; border-color: #2f3b52; }
main { padding: 12px; }
.card { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.login-wrap { max-width: 360px; margin: 60px auto; }
label { display: block; font-size: 13px; margin: 8px 0 3px; color: #444; }
input, select, textarea { width: 100%; padding: 7px; border: 1px solid #c4c8d0; border-radius: 6px; font-size: 14px; }
textarea { min-height: 60px; }
.error { color: #c0392b; font-size: 13px; margin: 8px 0; }
.notice { background: #fff7e0; border: 1px solid #e5cf8a; border-radius: 6px; padding: 8px; font-size: 13px; margin: 8px 0; }
.warn-strong { background: #fdecea; border: 1px solid #e0a49e; border-radius: 6px; padding: 8px; font-size: 13px; margin: 6px 0; color: #7c1d12; }
.warn-info { background: #eef3fb; border: 1px solid #b6c8e8; border-radius: 6px; padding: 8px; font-size: 13px; margin: 6px 0; }

/* 月間表 */
.month-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.month-scroll { overflow: auto; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); background: #fff; border: 1px solid #ddd; border-radius: 8px; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; line-height: 1.3; }
table.grid th, table.grid td { border-right: 1px solid #e3e3e3; border-bottom: 1px solid #e3e3e3; padding: 3px; vertical-align: top; min-width: 46px; }
/* 日付のヘッダー行はスクロールしても上に固定する */
table.grid thead th { position: sticky; top: 0; background: #f0f1f4; z-index: 3; }
table.grid thead th.name { z-index: 5; }
table.grid th.name, table.grid td.name { position: sticky; left: 0; background: #f0f1f4; min-width: 84px; max-width: 84px; z-index: 2; font-weight: 600; overflow-wrap: break-word; }
table.grid th.total, table.grid td.total { background: #fbf7ea; min-width: 44px; text-align: right; }
table.grid.hide-totals th.total, table.grid.hide-totals td.total { display: none; }
table.grid td.today { background: #fff3cd; }
table.grid td.cell { cursor: pointer; }
table.grid td.cell:hover { background: #eef3fb; }
/* ログインユーザー本人の行 */
table.grid tr.myrow td { background: #fff6cf; }
table.grid tr.myrow td.name { background: #ffdf6b; }
table.grid tr.myrow td.today { background: #ffe082; }
/* セル内チップ: 省略せず折り返して全文表示する。メーカーは文字色＋背景色で判別 */
.cell-item { display: block; line-height: 1.3; white-space: normal; overflow-wrap: break-word; word-break: break-all; padding: 1px 3px; border-radius: 3px; margin-bottom: 2px; }
.cell-item:last-child { margin-bottom: 0; }
.cell-item.swap-link { cursor: pointer; }
.cell-item.swap-link:hover { outline: 1px solid #888; }
.cell-item.detail-link { cursor: pointer; }
.cell-item.detail-link:hover { outline: 1px solid #888; }
/* 車両チップ（種別で色分けし、名前は折り返さない） */
.veh-chip { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 12px; white-space: nowrap; }
.veh-chip.u-kyoyo { color: #0d47a1; background: #e2edfb; }
.veh-chip.u-senyou { color: #1b5e20; background: #e2f1e5; }
.veh-chip.u-jika { color: #444; background: #efefec; }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-scroll table.list { min-width: 560px; }
/* 共用車の予約カレンダー */
table.grid.veh-grid th, table.grid.veh-grid td { min-width: 74px; }
table.grid.veh-grid th.name, table.grid.veh-grid td.name { min-width: 128px; max-width: 128px; }
table.grid td.veh-cell { cursor: pointer; }
table.grid td.veh-cell:hover { background: #eef3fb; }
.veh-book { display: block; background: #e2edfb; color: #0d47a1; border-radius: 4px; padding: 1px 3px; margin-bottom: 2px; font-size: 11px; line-height: 1.3; overflow-wrap: break-word; cursor: pointer; }
.mk-sanki { color: #1b5e20; background: #e2f1e5; }
.mk-okamura { color: #b71c1c; background: #fde9e9; }
.mk-itoki { color: #0d47a1; background: #e2edfb; }
.mk-other { color: #222; background: #efefec; }
.duty-chip { color: #4a148c; background: #efe6f7; }
.legend { font-size: 12px; color: #555; margin: 4px 0 8px; }
.legend .mk-sanki, .legend .mk-okamura, .legend .mk-itoki, .legend .duty-chip { padding: 0 4px; border-radius: 3px; }

/* 日別・案件 */
.asg-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.asg-head .site { font-weight: 700; font-size: 15px; }
.crew-line { font-size: 13px; margin: 2px 0; }
.badge { display: inline-block; font-size: 11px; border-radius: 8px; padding: 0 6px; background: #eee; margin-left: 4px; }
.badge.leader { background: #ffe9a8; } .badge.gentai { background: #d7e9f7; }
.crew-row { display: grid; grid-template-columns: 1.4fr .7fr .7fr auto auto auto; gap: 6px; align-items: end; margin-bottom: 6px; }
.crew-row label { margin: 0; font-size: 11px; }
.checkline { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.checkline input { width: auto; }
table.list { border-collapse: collapse; width: 100%; font-size: 13px; }
table.list th, table.list td { border-bottom: 1px solid #e3e3e3; padding: 5px 6px; text-align: left; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; z-index: 10; }
.modal { background: #fff; border-radius: 10px; padding: 16px; margin: 24px 8px; width: 640px; max-width: 96vw; }
.modal h3 { margin-top: 0; }
.row-flex { display: flex; gap: 8px; flex-wrap: wrap; }
.row-flex > * { flex: 1; min-width: 140px; }
.swap-before-after { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swap-before-after h4 { margin: 4px 0; font-size: 13px; }
.kv { font-size: 13px; }
.loading { padding: 24px; }
@media (max-width: 640px) {
  .swap-before-after { grid-template-columns: 1fr; }
  .crew-row { grid-template-columns: 1fr 1fr; }
  /* スマホ: 列を詰めて表示日数を増やし、チップは小さい文字で折り返す */
  main { padding: 8px; }
  table.grid { font-size: 11px; }
  table.grid th, table.grid td { min-width: 42px; padding: 2px; }
  table.grid th.name, table.grid td.name { min-width: 64px; max-width: 64px; font-size: 11px; }
  table.grid th.total, table.grid td.total { min-width: 36px; }
  .cell-item { padding: 1px 2px; margin-bottom: 2px; }
}
