* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Sans', sans-serif;
  background: #f4f4f6;
  /* 画面全体を固定してカード内コンテンツだけスクロール */
  height: 100dvh;
  overflow: hidden;
}

.card {
  background: #fff;
  /* フレックスコラムで ヘッダー固定 / コンテンツスクロール を実現 */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border-radius: 0;
  max-width: 100%;
}

/* ── ヘッダー: 左タイトル / 右ロゴ（隊員ページと同構造） ── */
.admin-header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #eee;
}

.admin-header-left {
  flex: 1;
  min-width: 0;
}

.admin-header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.admin-header-logo img {
  height: 64px;
  width: auto;
  display: block;
  mix-blend-mode: multiply;
}

h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
  padding: 0;
  border: none;
}

/* ログインセクション */
#login-section {
  flex-shrink: 0;
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
}

/* メインセクション: 残り全高さを占有し、この枠ごと縦スクロールさせる。
   → タブバーも固定せず、コンテンツと一緒にスクロールして上へ流れる（ロゴヘッダーのみ固定） */
#main-section {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* タブバー直上の office-links / tab-menu-toggle（タブと一緒にスクロールする） */
#main-section > .office-links,
#main-section > .office-toolbar { flex-shrink: 0; padding: 0.6rem 1.25rem 0; }
#main-section > .tab-menu-toggle { flex-shrink: 0; margin: 0.5rem 1.25rem; }

/* タブバー: 固定しない（コンテンツと一緒にスクロールして上へ流れる） */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid #eee;
  flex-shrink: 0;
  padding: 0 1.25rem;
  /* margin-bottom をなくしてコンテンツと隙間をなくす */
}

/* タブコンテンツ: 中身の高さぶん広がり、#main-section ごとスクロールさせる */
#main-section > div[id^="tab-"] {
  flex-shrink: 0;
  padding: 1.25rem;
}

.login-form { display: flex; gap: 0.75rem; flex-direction: column; }
.login-form input {
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}
.btn-login {
  padding: 0.75rem;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-login:hover { opacity: 0.85; }

.error { color: #e74c3c; font-size: 0.85rem; margin-top: 0.5rem; }

/* タブ */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #eee;
  /* タブが多くて収まらない時は横スクロール（端で切れないように）。収まる時は無害 */
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  padding-bottom: 2px; /* アクティブ下線がスクロール時に欠けないよう */
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 0.6rem 1.2rem;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  flex-shrink: 0;        /* 縮ませず、収まらなければ横スクロールさせる */
  white-space: nowrap;   /* タブ内の文字を折り返さない */
}
.tab.active { color: #1a1a2e; border-bottom-color: #1a1a2e; }
.tab-hidden { display: none; }
.tab-menu-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.65rem;
  border: 1px solid #c8dbe4;
  border-radius: 8px;
  background: #f8fbfc;
  color: #1a1a2e;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}
.tab-menu-icon { font-size: 1.1rem; line-height: 1; }

/* テーブル共通 */
.data-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.data-table th {
  text-align: left;
  font-size: 0.78rem;
  color: #888;
  border-bottom: 1px solid #eee;
  padding: 0.5rem 0.75rem;
}
.data-table td {
  font-size: 0.88rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-active   { background: #d1fae5; color: #065f46; }
.badge-retired  { background: #f3f4f6; color: #6b7280; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-near     { background: #d1fae5; color: #065f46; }
.badge-far      { background: #fee2e2; color: #991b1b; }
.badge-nogps    { background: #f3f4f6; color: #6b7280; }

/* ボタン */
.btn-approve {
  padding: 0.35rem 0.85rem;
  background: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-stop {
  padding: 0.35rem 0.85rem;
  background: #e67e22;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-add {
  padding: 0.6rem 1.2rem;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 1rem;
}
.btn-approve:hover, .btn-stop:hover, .btn-add:hover { opacity: 0.85; }

/* 現場登録フォーム */
.site-form {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  display: none;
}
.site-form.open { display: block; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
}
.form-full { grid-column: 1 / -1; }
/* チェックボックス項目（現場フォーム等）: 全幅1行+説明文を下段に。
   .form-grid input の width:100% がチェックボックスに効いて崩れるのを打ち消す */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
}
.form-check input[type="checkbox"] {
  width: auto !important;
  flex-shrink: 0;
  margin-top: 0.18rem;
  cursor: pointer;
}
.form-check span small {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: #888;
  margin-top: 0.1rem;
}
/* 登録フォーム内のセクション見出し・ラベル付き項目 */
.form-section-title {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #999;
  margin-top: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #e6e6e6;
}
.form-section-title:first-child { margin-top: 0; }
.form-field label {
  font-size: 0.72rem;
  color: #888;
  display: block;
  margin-bottom: 0.2rem;
}
.btn-submit {
  padding: 0.6rem 1.5rem;
  background: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-cancel {
  padding: 0.6rem 1.2rem;
  background: #eee;
  color: #555;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.5rem;
}

.msg { font-size: 0.85rem; color: #888; margin-top: 1rem; text-align: center; }
.form-error { color: #e74c3c; font-size: 0.82rem; margin-top: 0.5rem; }

/* 配置タブ */
.date-search-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.date-search-row input[type="date"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
}
.btn-search {
  padding: 0.6rem 1.2rem;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-search:hover { opacity: 0.85; }
.schedule-card {
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  transition: border-color 0.3s, background 0.3s;
}
.schedule-card.full {
  border-color: #10b981;
  background: #f0fdf4;
}
/* 苦情のある現場: 充足しても緑にせず赤系で注意喚起する（2026-08-07 CEO指示） */
.schedule-card.full.has-complaint {
  border-color: #dc2626;
  background: #fef2f2;
}
.schedule-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.schedule-card-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.schedule-site-name {
  display: inline-block;
}
.schedule-spot-address {
  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
}
.shift-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.shift-type-badge.day {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.shift-type-badge.patrol {
  background: #ede9fe;
  color: #5b21b6;
}
.shift-type-badge.night {
  background: #111827;
  color: #fff;
  border: 1px solid #334155;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}
.shift-type-badge.large {
  font-size: 0.72rem;
  padding: 0.13rem 0.55rem;
}
.shift-type-badge.compact {
  font-size: 0.6rem;
  padding: 0.06rem 0.35rem;
}
.schedule-card-meta  { font-size: 0.8rem; color: #888; margin-bottom: 0.75rem; }
.schedule-collapse-toggle {
  padding: 0.28rem 0.65rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.schedule-collapse-toggle:hover { background: #e5e7eb; }
.schedule-card-body { padding-top: 0.25rem; }
.guard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
  min-height: 2rem;
}
.guard-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #e0e7ff;
  color: #1e40af;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
}
.guard-chip.avail  { background: #d1fae5; color: #065f46; }
/* 当欠者チップは赤系で強調表示 */
.guard-chip.absent { background: #fee2e2; color: #991b1b; text-decoration: line-through; opacity: 0.85; }
.btn-absent {
  padding: 0.15rem 0.45rem;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.2rem;
}
.btn-absent:hover { background: #fca5a5; }

/* 残業時間の変更ボタン（打刻記録・終了打刻の残業セル） */
.btn-ot-edit {
  padding: 0.1rem 0.4rem;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.3rem;
}
.btn-ot-edit:hover { background: #c7d2fe; }
.guard-chip button {
  background: none;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.guard-chip.avail button { color: #6ee7b7; }
.guard-chip button:hover { color: #1e40af; }
.guard-chip .guard-shift-start {
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  color: #374151;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.guard-chip button.btn-shift-time {
  padding: 0.12rem 0.35rem;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
}
.guard-chip button.btn-shift-time:hover {
  background: #dbeafe;
  color: #1e3a8a;
}
.btn-add-guard {
  padding: 0.25rem 0.75rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-add-guard:hover { opacity: 0.85; }
.guard-add-row {
  display: none;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.guard-add-row.open { display: flex; }
.guard-add-row .guard-add-inner {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.guard-add-row input[type="text"] {
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.82rem;
  box-sizing: border-box;
}
.guard-add-row select {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
}
.btn-confirm-add {
  padding: 0.4rem 0.85rem;
  background: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-confirm-add:hover { opacity: 0.85; }
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: #6366f1;
  border-radius: 4px;
  transition: width 0.3s;
}
.schedule-card.full .progress-fill { background: #10b981; }
.schedule-card.full.has-complaint .progress-fill { background: #dc2626; } /* 苦情現場は充足バーも赤 */
.btn-delete-schedule {
  padding: 0.2rem 0.6rem;
  background: #fee2e2;
  color: #991b1b;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-delete-schedule:hover { opacity: 0.8; }
.btn-publish-schedule {
  padding: 0.2rem 0.7rem;
  background: #dbeafe;
  color: #1e40af;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 700;
}
.btn-publish-schedule:hover { background: #bfdbfe; }
.btn-edit-count {
  padding: 0.2rem 0.6rem;
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 700;
}
.btn-edit-count:hover { background: #e5e7eb; }
.avail-legend {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.75rem;
}

/* ── 稼働希望タブ: フィルター固定 + tbody のみ縦横スクロール ── */

/* タブ自体を flex 列にしてフィルター/サマリーを固定枠とする */
#tab-availability {
  overflow-y: hidden !important; /* タブ全体のスクロールを止める */
  display: flex;
  flex-direction: column;
}
#tab-availability .filter-row  { flex-shrink: 0; }
#tab-availability #avail-summary { flex-shrink: 0; }
#tab-availability #avail-msg    { flex-shrink: 0; }

/* テーブルラッパー: 縦横ともこのボックス内でスクロール。
   #main-section ごとスクロールする構成になったため、高さ上限を設けて
   ヘッダー(thead)・合計(tfoot)の sticky が効く独立スクロール枠を維持する */
#avail-table-wrapper {
  flex: 1;
  min-height: 0;
  max-height: 70vh;
  overflow: auto; /* 縦横両方をこのボックスで処理 */
}

/* thead を上端に固定（ヘッダー行がスクロールに追従しない） */
#avail-table thead { position: sticky; top: 0; z-index: 4; }
/* tfoot を下端に固定（合計行が常に見える） */
#avail-table tfoot { position: sticky; bottom: 0; z-index: 4; }

/* 氏名列（1列目）を左端に固定 */
#avail-table tbody tr td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

/* 左上コーナー(氏名ヘッダー): 縦・横 両方向に固定 */
#avail-table thead tr th:first-child {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5; /* 他の sticky セルより前面 */
  background: #f8f9fa;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

/* 日付ヘッダー列(氏名以外): 上端固定のみ */
#avail-table thead tr th:not(:first-child) {
  position: sticky;
  top: 0;
  background: #f8f9fa;
}

/* 合計行の氏名セル: 下端 + 左端の両方に固定 */
#avail-table tfoot tr td:first-child {
  position: sticky;
  bottom: 0;
  left: 0;
  z-index: 5;
  background: #f8f9fa;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

/* 合計行の日付セル: 下端固定のみ */
#avail-table tfoot tr td:not(:first-child) {
  background: #f8f9fa;
}

/* 稼働希望: 行を交互色にして見やすくする（偶数行）。 */
/* 固定の氏名列(td:first-child)は #fff 指定があるので、ここで上書きして縞模様を揃える */
#avail-table tbody tr:nth-child(even) td { background: #f4f7fa; }
#avail-table tbody tr:nth-child(even) td:first-child { background: #f4f7fa; }

/* ── スケジュール一覧（週次）: 現場名を左端固定・日付ヘッダーを上端固定・合計を下端固定 ── */
/* スマホでも現場名・日付・合計を見失わないようにする（#avail-table と同じ手法） */
#sl-week-wrapper {
  overflow: auto;           /* 縦横スクロールをこのボックスで処理 */
  max-height: 70vh;         /* 縦に長い週はスクロール。日付ヘッダー・合計は固定で残る */
}
/* 日付ヘッダー行を上端に固定（日別合計行はJSでヘッダー直下に固定） */
#sl-week-table thead { position: sticky; top: 0; z-index: 4; }
/* 現場名列(1列目)を左端に固定 */
#sl-week-table tbody tr td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}
/* 左上コーナー(現場名ヘッダー): 縦・横 両方向に固定 */
#sl-week-table thead tr th:first-child {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  background: #f8f9fa;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}
/* 日付ヘッダー(現場名以外): 上端固定のみ */
#sl-week-table thead tr th:not(:first-child) {
  position: sticky;
  top: 0;
  background: #f8f9fa;
}
.sl-site-cell-main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
/* #5/#2 ドラッグ&ドロップ配置: 未配置隊員プールを上部に固定（スクロールしても見える） */
#assign-guard-pool-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  padding: 0.5rem 0;
  box-shadow: 0 6px 8px -6px rgba(0,0,0,0.25);
}
.assign-guard-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.6rem;
  border: 1px dashed #c7d2fe;
  border-radius: 8px;
  background: #f8fafc;
}
.pool-guard {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.7rem;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1a2e;
  cursor: grab;
  user-select: none;
}
.pool-guard:active { cursor: grabbing; }
.pool-guard.avail { border-color: #34d399; background: #ecfdf5; color: #065f46; }
/* ドラッグ中の現場カードのドロップ可視化 */
.schedule-card.drag-over {
  outline: 3px dashed #2563eb;
  outline-offset: 2px;
  background: #eff6ff;
}

/* 複数選択フィルタ（紹介者など）: ボタン＋チェックボックスのドロップダウン */
.multi-select { position: relative; display: inline-block; }
.multi-select-btn { cursor: pointer; text-align: left; background: #fff; white-space: nowrap; }
.multi-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  padding: 0.4rem;
}
.multi-select-panel label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 6px;
}
.multi-select-panel label:hover { background: #f3f4f6; }

/* ソート可能なヘッダー */
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { background: #f8f9fa; }

/* 週次グリッド計画フォーム */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.week-nav-label { font-weight: 700; font-size: 0.9rem; }
.btn-week-nav {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  font-size: 1rem;
}
.btn-week-nav:hover { background: #f0f0f0; }
/* 7列グリッド: 各列が均等幅 */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.week-cell { text-align: center; }
.week-cell-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #888;
  margin-bottom: 0.2rem;
}
.week-cell-date {
  font-size: 0.68rem;
  color: #aaa;
  margin-bottom: 0.35rem;
}
/* 土日は赤系で強調 */
.week-cell.weekend .week-cell-label,
.week-cell.weekend .week-cell-date { color: #e74c3c; }
.week-count-input {
  width: 100%;
  text-align: center;
  padding: 0.4rem 0.2rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
}
.week-count-input:focus { border-color: #0CB6D5; outline: none; }

/* ── 機能17: フィルター行 ──────────────────────────────────── */
/* 各タブのテーブル直上に配置するフィルター入力エリア */
.filter-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.85rem;
}
.filter-row label {
  color: #888;
  white-space: nowrap;
  font-size: 0.8rem;
}
/* フィルター用の text / select 共通スタイル */
.filter-input {
  padding: 0.4rem 0.65rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  min-width: 140px;
}
.filter-input:focus { border-color: #6366f1; outline: none; }

.filter-input:disabled {
  background: #f3f4f6;
  color: #aaa;
}

/* ── LINE問い合わせセクション (機能16) ────────────────────── */
/* 管理画面の下部に配置し、担当者へのサポート問い合わせ窓口として機能させる */

/* ── 機能15: 代理打刻・代理希望登録 ──────────────────────────────────── */
/* ※代理 バッジ: 打刻履歴テーブルの代理打刻行に小さく表示するグレー系ラベル */
.badge-proxy {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.35rem;
  vertical-align: middle;
  white-space: nowrap;
}
/* 代理打刻ボタン: 隊員管理行・稼働希望行に置くインラインボタン */
.btn-proxy {
  padding: 0.25rem 0.6rem;
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.3rem;
}
.btn-proxy:hover { background: #c7d2fe; }
/* 代理モーダル内の日付チェックリスト領域 */
.proxy-date-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}
.proxy-date-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  cursor: pointer;
}

/* ── 機能5: 状態監視タブ ──────────────────────────────────────────── */
/* 遅延アラートカード(赤)・予定未入力カード(黄)・正常カード(緑)の3種 */
.status-card {
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.status-card.alert { background: #fff1f2; border: 2px solid #fca5a5; }
.status-card.warn  { background: #fffbeb; border: 2px solid #fcd34d; }
.status-card.ok    { background: #f0fdf4; border: 2px solid #86efac; }
.status-card-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.5rem; }
.collapsible-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #f8f9fa;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  color: #1a1a2e;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.collapsible-section:not(.is-open) .collapsible-header {
  border-bottom-color: transparent;
}
.collapse-label {
  flex-shrink: 0;
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
}
.collapsible-body {
  padding: 0.9rem 1rem 1rem;
}
.monitor-collapse-toggle {
  margin-left: auto;
  padding: 0.18rem 0.6rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.monitor-collapse-toggle:hover { background: #e5e7eb; }
.monitor-finished-detail {
  border-top: 1px solid #eee;
  margin-top: 0.45rem;
  padding-top: 0.15rem;
}
.monitor-guard-row {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f3f4f6;
}
.monitor-guard-row:last-child { border-bottom: none; }
.monitor-guard-info {
  min-width: 0;
  overflow: hidden;
}
.monitor-guard-name {
  font-size: 0.83rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.monitor-punch-badges {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}
.monitor-punch-badge {
  display: block;
  min-height: 2.15rem;
  padding: 0.32rem 0.2rem;
  border-radius: 4px;
  background: #f3f4f6;
  color: #9ca3af;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}
.monitor-punch-badge.done {
  background: #d1fae5;
  color: #065f46;
}
.monitor-punch-badge.planned {
  background: #fee2e2;
  color: #991b1b;
}
.monitor-punch-badge.late {
  background: #fee2e2;
  color: #991b1b;
}
.monitor-punch-badge.waiting {
  background: #e0f2fe;
  color: #075985;
}
.monitor-punch-time {
  display: block;
  margin-top: 0.12rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  opacity: 0.78;
}
.schedule-plan-badges {
  display: grid;
  grid-template-columns: repeat(2, minmax(3.8rem, 1fr));
  gap: 0.35rem;
  align-items: center;
  margin-left: auto;
}
/* アラート行: バッジ + 氏名 + 現場名 + 予定時刻 を横並びで表示 */
.status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.88rem;
  flex-wrap: wrap;
}
.status-item:last-child { border-bottom: none; }
.status-badge-alert {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-badge-warn {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: #d97706;
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
/* 更新ボタン: ブランドカラーで「更新」操作を明示 */
.btn-refresh {
  padding: 0.5rem 1.2rem;
  background: #0CB6D5;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 1.25rem;
}
.btn-refresh:hover { opacity: 0.85; }

/* ── 機能14: 当欠確認モーダル ─────────────────────────────────────── */
/* 画面全体を覆う半透明オーバーレイ。表示時のみ visible にする */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}
/* モーダル本体: 既存カードと同じ角丸・シャドウを踏襲 */
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  /* 項目が多いモーダル（委託書設定など）が画面からはみ出して見切れないよう、
     高さを画面内に収めて中身をスクロールできるようにする */
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 1rem;
}
.modal-label {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 0.35rem;
  display: block;
}
/* 代替隊員セレクトボックス */
.modal-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}
.modal-select:focus { border-color: #6366f1; outline: none; }
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
/* 確定ボタン: 赤系で当欠の深刻さを表現 */
.btn-modal-confirm {
  padding: 0.55rem 1.25rem;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-modal-confirm:hover { opacity: 0.85; }
/* キャンセルボタン: 既存 btn-cancel に合わせる */
.btn-modal-cancel {
  padding: 0.55rem 1.1rem;
  background: #eee;
  color: #555;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-modal-cancel:hover { background: #ddd; }

.itakusho-modal-box { max-width: 560px; }
/* 委託書設定は項目が多いので余白を詰める */
#itakusho-settings-modal .modal-select { margin-bottom: 0.55rem; }
#itakusho-settings-modal .modal-label { margin-top: 0.5rem; margin-bottom: 0.2rem; }
.itakusho-field-hint {
  display: block;
  margin: -0.3rem 0 0.7rem;
  color: #6b7280;
  font-size: 0.74rem;
  line-height: 1.5;
}
.itakusho-field-hint code {
  background: #f3f4f6;
  padding: 0 0.25rem;
  border-radius: 3px;
  word-break: break-all;
}
.itakusho-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.itakusho-form-grid label > span {
  display: block;
  margin-bottom: 0.3rem;
  color: #6b7280;
  font-size: 0.78rem;
  font-weight: 700;
}
.itakusho-form-grid .modal-select { margin-bottom: 0; }
.itakusho-status {
  min-height: 1.4rem;
  margin: 0.6rem 0;
  color: #047857;
  font-size: 0.82rem;
  font-weight: 700;
}
.btn-itakusho-generate,
.btn-itakusho-send {
  border: none;
  border-radius: 6px;
  background: #0f766e;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-itakusho-send { flex: 0 0 auto; padding: 0.45rem 0.7rem; }
.btn-itakusho-generate:disabled,
.btn-itakusho-send:disabled { cursor: not-allowed; opacity: 0.45; }

/* ── モバイル対応 (max-width: 600px) ─────────────────────────────────── */
@media (max-width: 600px) {

  /* タブ: 横スクロール。スクロールバー非表示でスッキリ見せる */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { font-size: 0.78rem; padding: 0.45rem 0.65rem; white-space: nowrap; }
  .tab-menu-toggle { display: flex; }
  /* 管理ページのタブは ☰ ドロップダウン化する（事務ページ .office-tabs は office.css 側で定義） */
  .tabs.admin-tabs {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 1rem;
    padding: 0.35rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    overflow: visible;
  }
  .tabs.admin-tabs.open { display: flex; }
  .tabs.admin-tabs .tab {
    width: 100%;
    text-align: left;
    border-bottom: none;
    border-radius: 6px;
    margin-bottom: 0;
    padding: 0.62rem 0.75rem;
  }
  .tabs.admin-tabs .tab.active {
    background: #f1f8fb;
    border-bottom-color: transparent;
  }

  /* フォームグリッドを1列に */
  .form-grid { grid-template-columns: 1fr; }

  /* テーブルセルを詰める */
  .data-table th { font-size: 0.72rem; padding: 0.4rem 0.5rem; }
  .data-table td { font-size: 0.82rem; padding: 0.55rem 0.5rem; }

  /* 週次グリッド(7列): セル・フォントを最小化 */
  .week-grid { gap: 0.15rem; }
  .week-cell-label { font-size: 0.56rem; }
  .week-cell-date  { font-size: 0.52rem; }
  .week-count-input { font-size: 0.8rem; padding: 0.3rem 0.05rem; }
  .week-nav-label { font-size: 0.82rem; }

  /* 配置カード */
  .schedule-card { padding: 0.75rem 0.85rem; }
  .schedule-card-title { font-size: 0.9rem; }
  .schedule-card-meta  { font-size: 0.75rem; }

  /* フィルター入力を伸縮させる */
  .filter-input { min-width: 0; flex: 1; }
  .filter-row { gap: 0.4rem; padding: 0.5rem 0.6rem; }

  /* 状態監視アイテム: gap縮小 */
  .status-item { gap: 0.4rem; font-size: 0.82rem; }
  .monitor-guard-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.35rem;
  }
  .monitor-punch-badges { gap: 0.25rem; }
  .monitor-punch-badge {
    min-height: 2rem;
    padding: 0.28rem 0.12rem;
    font-size: 0.64rem;
  }
  .monitor-punch-time { font-size: 0.58rem; }
  .schedule-plan-badges {
    width: 100%;
    margin-left: 0;
  }

  /* モーダル */
  .modal-box { padding: 1.25rem 1rem; }
  .itakusho-form-grid { grid-template-columns: 1fr; }

  /* ボタン類 */
  .btn-add    { font-size: 0.82rem; padding: 0.5rem 0.85rem; }
  .btn-search { font-size: 0.82rem; padding: 0.5rem 0.85rem; }
  .btn-refresh { font-size: 0.82rem; padding: 0.45rem 0.9rem; }
  .btn-submit  { font-size: 0.85rem; padding: 0.55rem 1.1rem; }
  .date-search-row { gap: 0.5rem; }

  /* 配置・予定入力行のselectを全幅に */
  .guard-add-row select { font-size: 0.82rem; }
}

/* ── PC 大画面向け（1280px 以上）────────────────────────────────── */
/* スマートフォン版には手を加えない。幅広画面でより見やすく大きく表示する */
@media (min-width: 1280px) {

  /* ── ロゴを右上に大きく配置（白背景ベース） ── */

  /* PC: 中央寄せ・最大幅制限。フレックス構造はベーススタイルで定義済み */
  .card {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
  }

  /* カード上部：白ベースのヘッダー帯。左端にアクセントラインを入れる */
  .card::before {
    content: '';
    display: block;
    height: 96px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }

  /* PC: ヘッダー内余白を広げる */
  .admin-header-inner {
    padding: 1.25rem 2.5rem 1rem;
    gap: 2rem;
  }

  /* PC: タイトルを大きく */
  h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.06em;
  }

  /* PC: ロゴをさらに大きく */
  .admin-header-logo img {
    height: 80px;
  }

  /* PC: カード本文のパディング（ヘッダー以外） */
  .card > *:not(.admin-header-inner) {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }

  /* PC: ログインセクション余白 */
  #login-section { padding: 2rem 2.5rem; }

  /* PC: メインセクションは左右余白のみ（上下はタブとコンテンツで制御） */
  #main-section { padding: 0; }
  #main-section > .office-links,
  #main-section > .office-toolbar { padding: 0.75rem 2.5rem 0; }
  #main-section > .tab-menu-toggle { margin: 0.65rem 2.5rem; }

  /* PC: タブバー余白 */
  .tabs { padding: 0 2.5rem; }

  /* PC: タブコンテンツの余白 */
  #main-section > div[id^="tab-"] { padding: 1.75rem 2.5rem; }
  .tab-section { padding: 1.75rem 2.5rem; }

  /* コンテナ最大幅を広げる */
  .container, .page-wrap, .admin-wrap { max-width: 1400px !important; }

  /* フォントサイズ全体を底上げ */
  body { font-size: 1rem; }
  h2   { font-size: 1.4rem; }
  .tab-btn { font-size: 1rem; padding: 0.65rem 1.4rem; }

  /* テーブルを見やすく */
  table th, table td { padding: 0.75rem 1rem; font-size: 0.95rem; }

  /* ボタン */
  .btn-add    { font-size: 0.95rem; padding: 0.6rem 1.2rem; }
  .btn-submit { font-size: 0.95rem; padding: 0.6rem 1.4rem; }
  .btn-proxy, .btn-approve, .btn-retire { font-size: 0.88rem; }

  /* フィルター行 */
  .filter-row { padding: 1rem 1.25rem; gap: 0.85rem; }
  .filter-input { font-size: 0.95rem; }

  /* モーダル */
  .modal-box { max-width: 580px; padding: 2rem 2.25rem; }
  .modal-label { font-size: 0.92rem; }
  .modal-select { font-size: 0.95rem; padding: 0.6rem 0.85rem; }

  /* 配置カード */
  .schedule-card { padding: 1.1rem 1.4rem; }
  .schedule-card-title { font-size: 1.05rem; }

  /* 状態監視 */
  .status-item { font-size: 1rem; gap: 0.75rem; }
  .monitor-guard-name { font-size: 0.95rem; }
  .monitor-punch-badge { font-size: 0.74rem; }
  .monitor-punch-time { font-size: 0.68rem; }
}

/* アプリ通知（アラート）設定のトグル一覧（状態監視タブ内） */
.alert-toggle {
  display: block;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.5;
}
.alert-toggle input { margin-right: 0.5rem; transform: scale(1.2); vertical-align: middle; }
.alert-toggle small { color: #64748b; }
