* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif; background: #f2f4f7; color: #1f2937; font-size: 15px; }

/* ===== サイドバーレイアウト ===== */
#layout { display: flex; min-height: 100vh; }
#sidebar { width: 195px; flex-shrink: 0; background: #1e3a8a; color: #fff; padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; line-height: 1.5; text-align: center; margin-bottom: 6px; }
#termLabel { font-size: 12px; color: #c7d2fe; text-align: center; margin-bottom: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px; background: rgba(255,255,255,.08); }
#termLabel:hover { background: rgba(255,255,255,.18); }
#sideNav { display: flex; flex-direction: column; gap: 4px; }
button.side { display: block; width: 100%; text-align: left; border: none; background: transparent; color: #dbe4ff; padding: 11px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; line-height: 1.4; white-space: nowrap; }
button.side:hover { background: #3b5bb5; }
button.side.active { background: #fff; color: #1e3a8a; font-weight: 700; }
#saveStatus { margin-top: auto; font-size: 11px; color: #c7d2fe; text-align: center; }
main { flex: 1; min-width: 0; padding: 16px; max-width: 1500px; }
.pane { display: none; }
.pane.active { display: block; }
.pageHead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.pageHead h2 { font-size: 19px; margin: 0; }
.pageHead .right { margin-left: auto; }

@media (max-width: 840px) {
  #layout { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; }
  .brand { margin: 0; font-size: 13px; line-height: 1.3; }
  #sideNav { flex-direction: row; flex-wrap: wrap; }
  button.side { width: auto; padding: 8px 10px; }
  #saveStatus { margin: 0 0 0 auto; }
}

h2 { font-size: 16px; margin: 14px 0 8px; }
h3 { font-size: 14px; margin: 12px 0 6px; color: #374151; }

.courseTabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.courseTabs button { border: 1px solid #cbd5e1; background: #fff; padding: 7px 18px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.courseTabs button.active { background: #1e3a8a; color: #fff; border-color: #1e3a8a; font-weight: 700; }

.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
button.primary { background: #1e3a8a; color: #fff; border: none; padding: 9px 18px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 700; }
button.ghost { background: #fff; color: #334155; border: 1px solid #cbd5e1; padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }
button.danger { background: #fff; color: #b91c1c; border: 1px solid #fca5a5; padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }
button.mini { background: #fff; color: #334155; border: 1px solid #cbd5e1; padding: 2px 8px; border-radius: 6px; font-size: 11px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }

/* ===== ホーム ===== */
.homeGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.homeCard h3 { margin-top: 0; font-size: 16px; color: #1e3a8a; }
.homeCard .stat { font-size: 13px; line-height: 2; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 700; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }

/* ===== 警告 ===== */
.warnBox { border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; line-height: 1.7; }
.warnBox.red { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.warnBox.yellow { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.warnBox.ok { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }

/* ===== 時間割 ===== */
.assignTableWrap { overflow-x: auto; }
table.assign { border-collapse: collapse; width: 100%; }
table.assign th, table.assign td { border: 1px solid #cbd5e1; padding: 5px 6px; text-align: center; vertical-align: top; }
table.assign th { background: #eef2ff; font-size: 13px; }
table.assign td.slotHead { background: #f8fafc; text-align: left; font-size: 12px; white-space: nowrap; }
table.assign td.slotHead .lbl { font-size: 16px; font-weight: 700; }
.posRow { display: flex; align-items: center; gap: 3px; margin: 3px 0; }
.posRow select { flex: 1; min-width: 90px; padding: 5px 4px; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; }
.posRow select.locked { border-color: #1e3a8a; background: #eef2ff; font-weight: 700; }
.posRow select.bad { border-color: #dc2626; background: #fef2f2; color: #b91c1c; font-weight: 700; }
.posRow select.warn2 { border-color: #d97706; background: #fffbeb; }
.posRow .lockBtn { border: none; background: none; cursor: pointer; font-size: 13px; padding: 2px; opacity: .55; }
.posRow .lockBtn.on { opacity: 1; }

table.counter { border-collapse: collapse; font-size: 13px; }
table.counter th, table.counter td { border: 1px solid #d1d5db; padding: 4px 8px; text-align: center; }
table.counter th { background: #f1f5f9; }
table.counter td.name { text-align: left; font-weight: 700; white-space: nowrap; }
table.counter td.cnt { font-weight: 700; }
table.counter tr.uneven td.cnt { color: #b45309; }

/* ===== 講師ページ ===== */
.teacherLayout { display: flex; gap: 14px; align-items: flex-start; }
.tListCard { width: 210px; flex-shrink: 0; }
.tRow { display: flex; align-items: center; gap: 3px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.tRow:hover { background: #f1f5f9; }
.tRow.sel { background: #dbeafe; font-weight: 700; }
.tRow .nm { flex: 1; }
.tDetail { flex: 1; min-width: 0; }
.dragHandle { cursor: grab; color: #94a3b8; font-size: 16px; padding: 0 4px; user-select: none; }
.tRow.dragOver { border-top: 3px solid #1e3a8a; }
button.updown { padding: 2px 6px; font-size: 10px; border: 1px solid #cbd5e1; background: #fff; border-radius: 5px; cursor: pointer; }

table.avail { border-collapse: collapse; font-size: 14px; margin-top: 4px; }
table.avail th, table.avail td { border: 1px solid #d1d5db; padding: 3px 5px; text-align: center; }
table.avail th { background: #f1f5f9; font-size: 12px; }
table.avail th .mini { margin: 2px 1px 0; }
table.avail td.dateCol { text-align: left; font-weight: 700; white-space: nowrap; padding-right: 8px; font-size: 13px; }
table.avail td.tg { cursor: pointer; width: 46px; height: 36px; font-size: 15px; user-select: none; }
table.avail td.tg.on { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
table.avail td.tg.off { color: #cbd5e1; }
.courseHead { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.courseHead h3 { margin: 0; font-size: 15px; color: #1e3a8a; }

/* ===== 配置一覧（画面用・バトンリレー縦読み） ===== */
table.overviewTbl { border-collapse: collapse; width: 100%; table-layout: fixed; }
table.overviewTbl th, table.overviewTbl td { border: 1px solid #94a3b8; text-align: center; vertical-align: middle; }
table.overviewTbl th { background: #eef2ff; font-size: 13px; padding: 6px 2px; }
table.overviewTbl .placeCol { width: 48px; font-size: 12px; }
table.overviewTbl .timeCol { width: 92px; font-size: 12px; line-height: 1.4; white-space: pre-line; }
table.overviewTbl td.names { font-size: 15px; font-weight: 700; padding: 8px 2px 22px; position: relative; }
table.overviewTbl td.names.dateStart { border-left: 2px solid #475569; }
table.overviewTbl th.dateHead { border-left: 2px solid #475569; }
table.overviewTbl td.laneEmpty { background: #f1f5f9; }
table.overviewTbl td.names .nm { display: block; white-space: nowrap; }
.nm.empty { color: #9ca3af; font-weight: 400; }
.baton { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 11px; line-height: 1.2; color: #a8b3c1; font-weight: 400; text-align: center; }
/* 翌日への引き継ぎ: ↓ + 翌日最初の担当者名（2行縦） */
.baton.nextday { position: static; display: block; margin-top: 4px; }
.baton.nextday .nda { display: block; color: #a8b3c1; font-size: 11px; line-height: 1.2; }
.baton.nextday .nextName { display: block; color: #c2712a; font-weight: 700; font-size: 12px; line-height: 1.3; }

/* ===== 設定 ===== */
.cfgRow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.cfgRow input[type=text], .cfgRow input[type=date], .cfgRow input[type=number] { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.cfgRow input[type=number] { width: 60px; }
.cfgRow .tag { font-size: 12px; color: #64748b; }
.hint { font-size: 12px; color: #64748b; line-height: 1.7; }

/* ===== 印刷 (1講座=A3横1枚) ===== */
#printArea { display: none; }
.sheet { background: #fff; }
.sheetTitle { text-align: center; font-size: 34px; font-weight: 700; letter-spacing: .2em; margin-bottom: 8mm; }
.courseBlock { width: 100%; }
table.printTbl { border-collapse: collapse; width: 100%; table-layout: fixed; }
table.printTbl th, table.printTbl td { border: 1.4pt solid #000; text-align: center; vertical-align: middle; }
table.printTbl th { font-size: 24pt; padding: 4mm 1mm; }
table.printTbl .placeCol { width: 20mm; font-size: 19pt; }
table.printTbl .timeCol { width: 36mm; font-size: 17pt; line-height: 1.5; white-space: pre-line; }
table.printTbl td.names { font-size: 26pt; font-weight: 700; padding: 4mm .5mm 9mm; overflow: hidden; position: relative; }
table.printTbl td.names.dateStart, table.printTbl th.dateHead { border-left: 2.5pt solid #000; }
table.printTbl td.laneEmpty { background: #eee; }
table.printTbl td.names .nm { display: block; white-space: nowrap; }
table.printTbl .baton { position: absolute; left: 0; right: 0; bottom: 1.2mm; font-size: 12pt; line-height: 1.2; color: #777; font-weight: 400; text-align: center; }
table.printTbl .baton.nextday { position: static; display: block; margin-top: 1.5mm; }
table.printTbl .baton.nextday .nda { display: block; color: #777; font-size: 12pt; line-height: 1.2; }
table.printTbl .baton.nextday .nextName { display: block; color: #000; font-weight: 700; font-size: 16pt; line-height: 1.3; }
/* 3レーン以上（1講座12列など）は文字をやや詰める */
table.printTbl.dense th { font-size: 20pt; }
table.printTbl.dense .placeCol { width: 16mm; font-size: 16pt; }
table.printTbl.dense .timeCol { width: 30mm; font-size: 14pt; }
table.printTbl.dense td.names { font-size: 20pt; padding: 3mm .4mm 7.5mm; }
table.printTbl.dense .baton { font-size: 10pt; bottom: 1mm; }
table.printTbl.dense .baton.nextday .nda { font-size: 10pt; }
table.printTbl.dense .baton.nextday .nextName { font-size: 12.5pt; }
table.overviewTbl.dense td.names { font-size: 13px; }

@media print {
  body { background: #fff; }
  #layout { display: none !important; }
  #printArea { display: block; }
  .sheet { page-break-after: always; padding: 0; }
  .sheet:last-child { page-break-after: auto; }
  @page { size: A3 landscape; margin: 10mm; }
}
