* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", "Meiryo", sans-serif;
  margin: 0;
  color: #222;
  background: #f4f5f7;
  font-size: 13px;
}
header.app-header {
  background: #2c3e50;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
header.app-header h1 { font-size: 16px; margin: 0; }
nav.tabs { display: flex; gap: 4px; background: #34495e; padding: 0 8px; }
nav.tabs button {
  background: none; border: none; color: #cfd8dc; padding: 8px 14px;
  cursor: pointer; font-size: 13px; border-bottom: 3px solid transparent;
}
nav.tabs button.active { color: #fff; border-bottom-color: #1abc9c; font-weight: bold; }
main { padding: 12px 16px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 4px 6px; font-size: 13px; }
button.btn {
  background: #1abc9c; color: #fff; border: none; padding: 6px 12px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
button.btn:hover { background: #16a085; }
button.btn.secondary { background: #7f8c8d; }
button.btn.secondary:hover { background: #6c7a7a; }
button.btn.danger { background: #e74c3c; }
button.btn.small { padding: 3px 8px; font-size: 12px; }

.card { background: #fff; border: 1px solid #dcdfe3; border-radius: 6px; padding: 12px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }

/* グリッド */
.grid-wrap { overflow: auto; max-height: 72vh; border: 1px solid #ccc; background: #fff; }
table.grid { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.grid th, table.grid td { border: 1px solid #d0d4d8; text-align: center; padding: 2px 4px; }
table.grid thead th { position: sticky; top: 0; background: #ecf0f1; z-index: 3; }
table.grid .namecol {
  position: sticky; left: 0; background: #fff; z-index: 2; text-align: left;
  min-width: 120px; padding-left: 8px;
}
table.grid thead .namecol { z-index: 4; background: #ecf0f1; }
table.grid .sat { background: #eaf2fb; }
table.grid .sun, table.grid .holiday-col { background: #fbecec; }
table.grid .closed { background: #e9ecef; color: #aaa; }
.group-row td { background: #34495e; color: #fff; text-align: left; font-weight: bold; padding: 3px 8px; position: sticky; left: 0; }

td.cell { cursor: pointer; min-width: 26px; height: 24px; user-select: none; }
td.cell.work { background: #d5f5e3; font-weight: bold; }
td.cell.support { background: #fdebd0; font-weight: bold; color: #b9770e; }
td.cell.off { color: #ccc; }
td.cell.work.half { background: #eafaf1; font-size: 11px; }
td.cell.support.half { background: #fdf2e3; font-size: 11px; }
td.cell.closed {
  background: repeating-linear-gradient(45deg, #eef0f2, #eef0f2 4px, #e2e5e8 4px, #e2e5e8 8px);
}
td.cell.err { outline: 2px solid #e74c3c; outline-offset: -2px; }
td.cell.warn { outline: 2px solid #f39c12; outline-offset: -2px; }
td.cell.req-holiday::after { content: "休"; font-size: 9px; color: #e74c3c; }
td.cell.adj-holiday::after { content: "希"; font-size: 9px; color: #e67e22; }

.summary-row td { background: #f8f9fa; font-weight: bold; }
.summary-row td.short { background: #fdecea; color: #c0392b; }
.summary-row td.over { background: #fef5e7; color: #b9770e; }
.summary-label { position: sticky; left: 0; background: #f8f9fa; text-align: left; padding-left: 8px; }

/* 警告パネル */
.warnings { max-height: 160px; overflow: auto; }
.warn-item { padding: 3px 6px; border-bottom: 1px solid #eee; }
.warn-item.error { color: #c0392b; }
.warn-item.warn { color: #b9770e; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px; margin-left: 6px; }
.badge.err { background: #fdecea; color: #c0392b; }
.badge.warn { background: #fef5e7; color: #b9770e; }
.badge.ok { background: #e8f8f1; color: #1e8449; }

/* テーブル（マスタ） */
table.list { border-collapse: collapse; width: 100%; background: #fff; }
table.list th, table.list td { border: 1px solid #e0e0e0; padding: 5px 8px; text-align: left; font-size: 13px; }
table.list th { background: #f0f2f4; }
.form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.form-row label { min-width: 96px; color: #555; }
.form-row input, .form-row select { padding: 4px 6px; }
.wk-pick label { margin-right: 8px; font-weight: normal; min-width: auto; }
.chip { display: inline-block; background: #eaf2f8; border: 1px solid #aed6f1; border-radius: 10px; padding: 1px 8px; margin: 2px; font-size: 11px; }
.hint { color: #7f8c8d; font-size: 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; flex-wrap: wrap; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.sw { width: 14px; height: 14px; display: inline-block; border: 1px solid #bbb; }

/* 出力（印刷用） */
.print-area { background: #fff; padding: 8px; }
.print-title { text-align: center; margin: 4px 0 10px; font-size: 18px; }
.print-legend { font-size: 11px; margin-top: 6px; color: #333; }
table.print-grid { border-collapse: collapse; width: 100%; font-size: 11px; }
table.print-grid th, table.print-grid td { border: 1px solid #333; text-align: center; padding: 2px 3px; }
table.print-grid .pname { text-align: left; white-space: nowrap; padding: 2px 6px; }
table.print-grid .pgroup td { background: #ddd; font-weight: bold; text-align: left; }
table.print-grid .wend { background: #f0f0f0; }
table.cal-grid { border-collapse: collapse; width: 100%; }
table.cal-grid th { border: 1px solid #333; padding: 4px; background: #eee; }
table.cal-grid td { border: 1px solid #333; width: 14.28%; height: 70px; vertical-align: top; padding: 3px; }
table.cal-grid td.empty { background: #fafafa; }
table.cal-grid td.wend { background: #f5f5f5; }
.cal-day { font-size: 11px; color: #666; }
.cal-mark { font-size: 20px; font-weight: bold; text-align: center; margin-top: 8px; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; font-size: 11px; }
  .app-header, nav.tabs, .no-print { display: none !important; }
  main { padding: 0; }
  .print-area { padding: 0; }
}

/* ログイン画面 */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #2c3e50; }
.login-box { background: #fff; padding: 28px 32px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.3); width: 320px; text-align: center; }
.login-box h2 { margin: 0 0 6px; font-size: 18px; }
.login-box input { width: 100%; padding: 8px 10px; font-size: 14px; margin: 12px 0; border: 1px solid #ccc; border-radius: 4px; }
.login-box .btn { width: 100%; padding: 8px; font-size: 14px; }
.login-error { color: #c0392b; margin-top: 10px; font-size: 13px; }

/* セル編集メニュー */
.menu-overlay { position: fixed; inset: 0; z-index: 50; }
.cell-menu {
  position: fixed; z-index: 51; background: #fff; border: 1px solid #bbb;
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.2); padding: 6px;
  min-width: 170px;
}
.cell-menu-head { font-size: 12px; font-weight: bold; padding: 2px 6px 6px; border-bottom: 1px solid #eee; margin-bottom: 4px; }
.cell-menu-place { font-size: 12px; padding: 2px 6px 6px; }
.cell-menu-place button {
  border: 1px solid #ccc; background: #f4f5f7; border-radius: 4px; padding: 2px 6px;
  margin: 2px 2px 0 0; cursor: pointer; font-size: 12px;
}
.cell-menu-place button.sel { background: #1abc9c; color: #fff; border-color: #16a085; }
.cell-menu-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 6px 8px; cursor: pointer; font-size: 13px; border-radius: 4px;
}
.cell-menu-item:hover { background: #eaf2f8; }
.cell-menu-item.off { color: #c0392b; }
