/* ============================================================
  シフト管理アプリ — ライトテーマ / レスポンシブ
  ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
  タブレット横向き専用最適化（768px-1366px / 横向き）
  タッチ操作向けにセル高さ・ボタンサイズ・サイドバー幅を調整
  ============================================================ */
@media (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
  :root {
  --sidebar-w: 180px;
  --day-w: 48px;
  --staff-w: 90px;
  }
  /* サイドバー項目をタッチ向けに大きく */
  .sidebar-item {
  padding: 12px 14px !important;
  font-size: 13px !important;
  min-height: 44px;
  display: flex;
  align-items: center;
  }
  /* ナビタブ */
  .nav-tab {
  padding: 12px 14px !important;
  font-size: 13px !important;
  min-height: 44px;
  }
  /* シフトセルをタッチ向けに大きく */
  .cell {
  min-height: 30px !important;
  font-size: 13px !important;
  }
  /* ボタンのタッチターゲット */
  .btn { min-height: 36px; padding: 8px 14px; }
  .btn-sm { min-height: 32px; padding: 6px 10px; font-size: 12px; }
  /* テーブル行の高さ */
  .tc-table th, .tc-table td,
  .rq-table th, .rq-table td {
  padding: 10px 12px !important;
  font-size: 13px !important;
  }
  .staff-table th,
  .staff-table td {
  padding: 5px 8px !important;
  font-size: 12px !important;
  line-height: 1.35;
  }
  /* 入力フィールド */
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="date"], input[type="time"], input[type="number"],
  select, textarea {
  min-height: 36px;
  font-size: 14px;
  }
  /* モーダル */
  .modal-card { max-width: 90vw; }
  /* タブレット横向きでも PC 同様にサイドバー表示 */
  .sidebar { display: flex !important; }
  .mobile-header, .nav-tabs { display: none !important; }
}

/* ============================================================
  スタッフ用スマホUI: モバイル業務アプリ型テンプレート
  ============================================================ */
.staff-mobile-nav {
  display: none;
}

@media (max-width: 767px) {
  body {
    background: #f3f6fb;
  }

  .main-area {
    background: #f3f6fb;
  }

  .mobile-header {
    justify-content: center;
    padding: 12px 16px 10px;
    background: #fff;
    border-bottom: 0;
    box-shadow: none;
  }

  .mobile-header-title {
    color: #0f172a;
    font-size: 16px;
    font-weight: 900;
  }

  .mobile-quickbar {
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px 10px;
    background: #fff;
    border-bottom: 1px solid #e6edf5;
  }

  .mobile-quickbar .btn {
    min-height: 32px;
    border-radius: 999px;
    font-size: 11px !important;
    padding: 0 10px !important;
  }

  .mobile-user-label {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
  }

  .staff-mobile-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 130;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid #dbe4ef;
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
    backdrop-filter: blur(10px);
  }

  .staff-mobile-nav-btn {
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
  }

  .staff-mobile-nav-btn.active {
    background: #1d4ed8;
    color: #fff;
  }

  .staff-dashboard {
    padding: 12px 12px calc(92px + env(safe-area-inset-bottom));
    background: #f3f6fb;
  }

  .staff-dash-hero {
    position: relative;
    align-items: flex-start;
    padding: 18px;
    margin-bottom: 12px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffffff 0%, #eef5ff 100%);
    box-shadow: 0 10px 26px rgba(37, 99, 235, .10);
  }

  .staff-dash-kicker {
    color: #2563eb;
    font-size: 11px;
    font-weight: 900;
  }

  .staff-dash-hero h1 {
    max-width: 260px;
    font-size: 22px;
    line-height: 1.25;
  }

  .staff-dash-hero p {
    color: #475569;
    font-size: 12px;
  }

  .staff-dash-bell {
    width: 42px;
    height: 42px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .12);
  }

  .staff-dash-section,
  .staff-attendance-panel {
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  }

  .staff-clock-card {
    border-color: #dbeafe;
  }

  .staff-dash-section-head {
    align-items: flex-start;
    margin-bottom: 10px;
  }

  .staff-dash-section-title {
    font-size: 15px;
  }

  .staff-dash-section-sub {
    font-size: 11px;
    line-height: 1.45;
  }

  .staff-clock-store {
    height: 42px;
    border-radius: 12px;
    font-size: 13px;
  }

  .staff-clock-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .staff-clock-btn {
    min-height: 58px;
    border-radius: 14px;
    font-size: 15px;
    box-shadow: 0 6px 14px rgba(15, 23, 42, .06);
  }

  .staff-clock-btn.in,
  .staff-clock-btn.out {
    min-height: 64px;
  }

  .staff-clock-info {
    padding: 9px 10px;
    border-radius: 12px;
    background: #f8fafc;
    line-height: 1.45;
  }

  .staff-clock-row {
    grid-template-columns: 74px 58px minmax(0, 1fr);
    border-radius: 12px;
    padding: 9px 10px;
  }

  .staff-dash-notices {
    gap: 7px;
  }

  .staff-notice-row {
    grid-template-columns: 1fr;
    border-radius: 12px;
    padding: 11px 12px;
  }

  .staff-dash-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .staff-dash-action {
    min-height: 104px;
    border: 1px solid #dbe4ef;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  }

  .staff-dash-action strong {
    font-size: 15px;
  }

  .staff-dash-action span {
    font-size: 11px;
  }

  #staffTab-shift,
  #staffTab-docs,
  #staffTab-attendance {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
    background: #f3f6fb;
  }

  .staff-view-toolbar {
    justify-content: center;
    padding: 12px 14px;
    border-bottom: 0;
    background: #fff;
  }

  .staff-view-toolbar.in-scroll {
    top: 0;
    margin: -14px -14px 0;
  }

  .staff-view-title {
    color: #0f172a;
    font-size: 16px;
    font-weight: 900;
  }

  .staff-view-actions {
    padding: 8px 14px 10px;
    border-bottom: 1px solid #e6edf5;
    background: #fff;
  }

  .staff-back-btn,
  .staff-mini-btn {
    min-height: 36px;
    border-radius: 999px;
  }

  .staff-attendance-panel {
    margin: 12px 0 0;
  }

  .staff-attendance-nav {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ============================================================
  印刷／PDF保存用スタイル
  シフトタブ（#tab-shifts）だけを印刷対象に
  ============================================================ */

/* 画面モードでもクラスが付いたときに有効（html2pdf 用） */
body.hide-mgr-on-print [data-role="admin"],
body.hide-mgr-on-print [data-role="manager"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  border: 0 !important;
}
body.hide-count-on-print .count-col,
body.hide-count-on-print .count-header,
body.hide-count-on-print .hdr-count {
  display: none !important;
  visibility: hidden !important;
}
/* 出勤数列を非表示にしたとき、契約日数列もまとめて消し、
  さらに CSS Grid のトラック幅を 0 にして右端の空白カラムを除去する */
body.hide-count-on-print {
  --count-w: 0px;
  --contract-w: 0px;
}
body.hide-count-on-print .contract-col,
body.hide-count-on-print .hdr-contract {
  display: none !important;
  visibility: hidden !important;
}

/* ============================================================
  PDF出力（html2canvas）時の sticky 解除
  html2canvas は position:sticky を正しく扱えず、
  名前列やヘッダーが左端に重なって表示される（"名前が変なところに出る" 現象）
  PDF生成中（body.pdf-export）はすべて static に戻し、Grid本来の位置で描画する
  ============================================================ */
body.pdf-export #shiftTable .hdr-staff,
body.pdf-export #shiftTable .hdr-role,
body.pdf-export #shiftTable .hdr-date,
body.pdf-export #shiftTable .hdr-count,
body.pdf-export #shiftTable .hdr-contract,
body.pdf-export #shiftTable .staff-name,
body.pdf-export #shiftTable .role-col,
body.pdf-export #shiftTable .count-col,
body.pdf-export #shiftTable .contract-col,
body.pdf-export #shiftTable .store-row-name,
body.pdf-export #shiftTable .store-row-name-cell,
body.pdf-export #shiftTable .summary-label,
body.pdf-export #shiftTable .summary-label-avg,
body.pdf-export #shiftTable .summary-label-ly {
  position: static !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  z-index: auto !important;
}

/* ============================================================
  PDF出力（html2pdf）用：黒文字・黒線で読みやすく
  ============================================================ */
body.pdf-export #shiftTable,
body.pdf-export #shiftTable * {
  color: #000 !important;
  border-color: #000 !important;
}
body.pdf-export #shiftTable .cell,
body.pdf-export #shiftTable .staff-name,
body.pdf-export #shiftTable .role-col,
body.pdf-export #shiftTable .count-col,
body.pdf-export #shiftTable .hdr-staff,
body.pdf-export #shiftTable .hdr-date,
body.pdf-export #shiftTable .hdr-count,
body.pdf-export #shiftTable .store-row-name {
  color: #000 !important;
  border-color: #000 !important;
  border-style: solid !important;
}
/* セル枠を明示的に黒・全て同じ太さ(1px)で統一 */
body.pdf-export #shiftTable > * {
  border-top:  0 !important;
  border-left:  0 !important;
  border-right:  1px solid #000 !important;
  border-bottom: 1px solid #000 !important;
  outline: none !important;
  box-shadow: none !important;
}
/* テーブル全体の外枠を黒で */
body.pdf-export #shiftTable {
  border: 1px solid #000 !important;
  outline: none !important;
}
/* ── 日付ヘッダー（hdr-date）: 背景を白にして黒文字で読みやすく ── */
/*  既定では青/赤背景+白文字のため、PDFでは白文字が見えなくなる  */
body.pdf-export #shiftTable .hdr-date,
body.pdf-export #shiftTable .hdr-date.is-today,
body.pdf-export #shiftTable .hdr-date.is-sat,
body.pdf-export #shiftTable .hdr-date.is-sun,
body.pdf-export #shiftTable .hdr-staff,
body.pdf-export #shiftTable .hdr-count {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  color: #000 !important;
  outline: none !important;
}
body.pdf-export #shiftTable .hdr-date .dn,
body.pdf-export #shiftTable .hdr-date .dw {
  color: #000 !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}
/* 役職列も背景の青色を白に */
body.pdf-export #shiftTable .role-col {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  color: #000 !important;
}
/* ステータスに応じた背景はキープしつつ、文字は黒で読みやすく */
body.pdf-export #shiftTable .cell[data-status] {
  color: #000 !important;
  font-weight: 700 !important;
}
/* 他店舗セルもしっかり黒文字に */
body.pdf-export #shiftTable .cell-other-store-name {
  color: #000 !important;
  font-weight: 600 !important;
}
/* PDF出力時はテーブルを実寸表示（scale 解除）→ html2canvas が全体を撮影 */
body.pdf-export #tab-shifts.print-fit-mode .scroll-wrap {
  transform: none !important;
  width: 100% !important;
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
}
body.pdf-export #tab-shifts.print-fit-mode .shift-table {
  width: max-content !important;
  overflow: visible !important;
}

@media print {
  /* サイドバー・ヘッダー・タブナビ・モーダルを非表示 */
  .sidebar, .mobile-header, .nav-tabs, .modal-overlay,
  .notif-panel, .legend, .subheader > .month-nav,
  #publishDraftsBtn, button[onclick*="startCsvImport"],
  button[onclick*="printShiftView"], button[onclick*="publishDrafts"],
  .subheader .store-select {
  display: none !important;
  }

  /* 1枚フィット：JSで計算された --print-scale でテーブル本体を縮小 */
  /* tab-shifts 内の余分要素（凡例・サブヘッダ等）を完全に隠して、シフト表だけを scale */
  #tab-shifts.print-fit-mode .subheader,
  #tab-shifts.print-fit-mode .legend,
  #tab-shifts.print-fit-mode .summary-bar,
  #tab-shifts.print-fit-mode .register-bar,
  #tab-shifts.print-fit-mode .my-shift-hint,
  #tab-shifts.print-fit-mode #coverageSection {
  display: none !important;
  }
  #tab-shifts.print-fit-mode {
  overflow: visible !important;
  height: auto !important;
  width: 100% !important;
  }
  #tab-shifts.print-fit-mode .scroll-wrap {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  transform: scale(var(--print-scale, 1));
  transform-origin: top left;
  width: calc(100% / var(--print-scale, 1)) !important;
  }
  #tab-shifts.print-fit-mode .shift-table {
  width: max-content !important;
  overflow: visible !important;
  }
  /* ページ分割を防ぐ */
  #tab-shifts.print-fit-mode * {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
  }
  /* 出勤数列を印刷時に隠す（ユーザーが「表示しない」を選択時） */
  body.hide-count-on-print .count-col,
  body.hide-count-on-print .count-header {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  overflow: hidden !important;
  }
  /* 管理者・責任者の行を印刷時に隠す（オプション選択時） */
  body.hide-mgr-on-print [data-role="admin"],
  body.hide-mgr-on-print [data-role="manager"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  border: 0 !important;
  }
  /* レイアウト解放 */
  body, html, .main-area, .tab-content, #tab-shifts {
  height: auto !important;
  overflow: visible !important;
  background: #fff !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
  }
  /* シフトタブだけ表示 */
  .tab-content:not(#tab-shifts) { display: none !important; }
  #tab-shifts { display: block !important; padding: 8px !important; }
  /* スクロール領域を解放してすべて見えるように */
  .scroll-wrap {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  }
  /* グリッド全行を見せる */
  .shift-table {
  overflow: visible !important;
  page-break-inside: auto;
  }
  /* セル境界を黒で印刷向け */
  .cell, .row-store, .row-name, .col-num {
  border: 1px solid #000 !important;
  color: #000 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  }
  /* 状態色を維持 */
  .cell[data-status] {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  }
  /* ページ設定（横向き推奨） */
  @page { size: A4 landscape; margin: 8mm; }
}

/* タブレット縦向き時の警告（任意の表示用） */
@media (min-width: 768px) and (max-width: 1366px) and (orientation: portrait) {
  body::before {
  content: '横向きでのご使用を推奨します（端末を回転してください）';
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #FEF3C7;
  color: #92400E;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 99998;
  border-bottom: 1px solid #FDE68A;
  }
}

:root {
  --bg:  #F8FAFC;
  --surface:  #FFFFFF;
  --surface2:  #F1F5F9;
  --border:  #E2E8F0;
  --border-dark: #CBD5E1;
  --accent:  #2563EB;
  --accent-dark: #1D4ED8;
  --accent-light:#EFF6FF;
  --accent2:  #7C3AED;
  --text:  #0F172A;
  --text-sub:  #334155;
  --text-muted:  #64748B;
  --work:  #059669;
  --work-bg:  #ECFDF5;
  --off:  #DC2626;
  --off-bg:  #FEF2F2;
  --paid:  #D97706;
  --paid-bg:  #FFFBEB;
  --today:  #2563EB;
  --sidebar-w:  220px;
  --day-w:  54px;  /* セル幅を広げて店舗名2行まで表示できるように */
  --staff-w:  100px;
  --role-w:  64px;
  --count-w:  48px;
  --contract-w:  48px;  /* 契約日数列の幅 */
  --row-h:  26px;
  --header-h:  40px;
  --radius:  0;  /* 管理システム向け: 丸みを排除 (2026-05-22) */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:  0 4px 12px rgba(0,0,0,.08);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

:focus-visible {
  outline: 3px solid rgba(37,99,235,.28);
  outline-offset: 2px;
}

/* ============================================================
  アプリレイアウト（PC: サイドバー + メイン）
  ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ──── サイドバー（PC のみ表示） ──── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .app-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.01em;
}
.sidebar-logo .app-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.sidebar-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.sidebar-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.sidebar-store-name {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.btn-logout-sidebar {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}
.btn-logout-sidebar:hover {
  background: var(--border);
  color: var(--text);
}

/* ──── メインエリア ──── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ============================================================
  モバイルヘッダー（モバイルのみ表示）
  ============================================================ */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 120;
}
.mobile-header-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}
.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-quickbar {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.mobile-user-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
  モバイルタブナビ（モバイルのみ）
  ============================================================ */
.nav-tabs {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.nav-tab {
  flex: 1;
  min-width: 80px;
  padding: 11px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all .2s;
}
.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* ============================================================
  PC用サブヘッダー（月ナビ・店舗選択・凡例）
  ============================================================ */
.subheader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.nav-btn:hover { background: var(--border); }
.nav-btn:active { transform: scale(.92); }

.month-label {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  min-width: 100px;
  text-align: center;
}

.store-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
  max-width: 260px;
}
.store-select:focus { outline: none; border-color: var(--accent); }

/* ============================================================
  凡例・サマリーバー
  ============================================================ */
.legend {
  display: flex;
  gap: 12px;
  padding: 6px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted);
}
.legend-dot {
  width: 10px; height: 10px; border-radius: 0;
}

.summary-bar {
  display: flex;
  gap: 18px;
  padding: 6px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.sum-item { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.sum-item span { font-weight: 700; }
.sum-work span { color: var(--work); }
.sum-off  span { color: var(--off); }
.sum-paid span { color: var(--paid); }

/* ============================================================
  グリッドスクロール
  ============================================================ */
.scroll-wrap {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  /* Androidエッジスワイプ（戻る/ホーム）との競合を防止 */
  overscroll-behavior-x: contain;
  overscroll-behavior-y: contain;
  touch-action: pan-x pan-y;
}

/* シフトテーブル本体も同様に */
.shift-table {
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

/* テーブル全般（管理タブのスクロールも保護） */
.staff-table-wrap,
.stores-table-wrap,
.tc-list-card,
.rq-card {
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

/* ============================================================
  シフトテーブル（グリッド）
  ============================================================ */
.shift-table {
  display: grid;
  min-width: max-content;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  /* 1行目（ヘッダー）は40px、それ以降は26pxに固定 → 隙間ゼロ */
  grid-template-rows: var(--header-h);
  grid-auto-rows: var(--row-h);
}

.hdr-staff, .hdr-date,
.staff-name, .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0;
  margin: 0;
  line-height: 1;
  box-sizing: border-box;
}
/* セル同士を密着させる */
.shift-table { gap: 0; }

/* 左固定列：スタッフ名 */
.hdr-staff, .staff-name {
  position: sticky;
  left: 0;
  z-index: 10;
  width: var(--staff-w);
  min-width: var(--staff-w);
  background: var(--surface);
  justify-content: flex-start;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border-right: 2px solid var(--border-dark) !important;
  /* 必ず col 1 から始める。出勤数・契約日数列を hide した時、
  前行の末尾の空きセル（display:none で空いた N+3,N+4）に
  auto-flow が滑り込むのを防止 */
  grid-column-start: 1;
}
/* 役職列も col 2 固定で安全に */
.role-col {
  grid-column-start: 2;
}
.hdr-staff {
  height: var(--header-h);
  font-size: 11px;
  font-weight: 700;
  /* 縦・横どちらにスクロールしても固定（左上コーナー固定） */
  position: sticky;
  top: 0;
  left: 0;
  z-index: 25;
  background: #1a3a6b;
  color: #fff;
}

/* 日付ヘッダー */
.hdr-date {
  height: var(--header-h);
  width: var(--day-w);
  min-width: var(--day-w);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  background: #1e40af;
  color: #fff;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 0;
  z-index: 15;
}
.hdr-date .dn { font-size: 12px; }
.hdr-date .dw { font-size: 8px; font-family: 'Noto Sans JP', sans-serif; font-weight: 400; opacity: 0.85; }
.hdr-date.is-today { background: #1d4ed8; outline: 2px solid #f59e0b; outline-offset: -2px; }
.hdr-date.is-sat { background: #1d4ed8; }
.hdr-date.is-sun { background: #be123c; }

/* スタッフ名行 — セルと同じ高さに揃える */
.staff-name {
  line-height: 1;
  padding: 0 10px;
  height: var(--row-h);
  min-height: var(--row-h);
}
.staff-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.staff-name.is-me {
  background: #EFF6FF;
  color: var(--accent);
}
.lock-badge { font-size: 9px; margin-left: 3px; opacity: .6; }

/* セル */
.cell {
  width: var(--day-w);
  min-width: var(--day-w);
  height: var(--row-h);
  min-height: var(--row-h);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  margin: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--surface);
  color: transparent;
  /* 中央寄せを徹底（flexはshared base ruleで定義済みだが上書き対策） */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.cell:hover { background-color: #f1f5f9; }
.cell:active { background-color: #e2e8f0; }

/* シンボル表示
  ●=出勤（黒丸、平日色固定で曜日変化なし）
  ×=休み（赤）
  有=有給（赤）
  △=未定（黄）
*/
.cell[data-status="●"],
.cell[data-status="○"] { background: #dcfce7 !important; color: #000 !important; font-weight: 700; }
.cell[data-status="×"] { background: #fee2e2 !important; color: #dc2626 !important; font-weight: 700; }
.cell[data-status="有"] { background: #fee2e2 !important; color: #dc2626 !important; font-weight: 700; }
.cell[data-status="可"] { background: #dbeafe !important; color: #1d4ed8 !important; font-weight: 700; }
.cell[data-status="確"] { background: #FCE7F3 !important; color: #9D174D !important; font-weight: 700; }
.cell[data-status="△"] { background: #fef9c3; color: #a16207; font-weight: 700; }
.cell[data-status="有申"] { background: #fef3c7; color: #b45309; font-weight: 700; font-size: 9px; }
.cell[data-status="申"]  { background: #e0e7ff; color: #4338ca; font-weight: 700; font-size: 10px; }
.cell[data-status=""]  { background: var(--surface); color: transparent; }

/* 本日列の枠は維持（背景色は上書きしない） — 旧仕様（互換用） */
.cell.is-today-col { outline: 2px solid #f59e0b; outline-offset: -2px; }

/* ────────────────────────────────────────
  トグルスイッチ（メンテナンスON/OFF等）
  ──────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d1d5db;
  transition: 0.2s;
  border-radius: 0;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: #dc2626;
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

/* ────────────────────────────────────────
  メンテナンスオーバーレイ（staff画面用）
  ──────────────────────────────────────── */
.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
}
.maintenance-overlay.show { display: flex; }
.maintenance-overlay .icon {
  font-size: 80px;
  margin-bottom: 18px;
  animation: spin 4s linear infinite;
}
.maintenance-overlay h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 16px;
}
.maintenance-overlay .msg {
  font-size: 15px;
  line-height: 1.8;
  max-width: 480px;
  color: #e5e7eb;
  white-space: pre-wrap;
  margin-bottom: 18px;
}
.maintenance-overlay .time {
  font-size: 12px;
  color: #9ca3af;
  background: rgba(255,255,255,0.06);
  padding: 8px 14px;
  border-radius: 0;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to  { transform: rotate(360deg); }
}

/* ────────────────────────────────────────
  通知（ベルボタン+ドロワー）
  ──────────────────────────────────────── */
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  margin-right: 4px;
  transition: background .12s, border-color .12s;
}
.notif-bell:hover { background: var(--accent-light); border-color: var(--accent); }
.notif-bell:active { transform: scale(0.96); }
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  background: #dc2626;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-sizing: border-box;
  line-height: 1;
}

.notif-panel {
  position: fixed;
  top: 56px;
  right: 12px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 80px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.notif-panel.open { display: flex; }
.notif-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.notif-header strong { flex: 1; font-size: 14px; }
.notif-action {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
}
.notif-action:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.is-unread { background: #EFF6FF; }
.notif-item.is-unread:hover { background: #DBEAFE; }
.notif-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1.2;
  width: 28px;
  text-align: center;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  word-break: break-word;
}
.notif-text {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
  word-break: break-word;
}
.notif-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.notif-dot {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 8px;
  height: 8px;
  background: #dc2626;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (max-width: 540px) {
  .notif-panel {
  top: 56px;
  left: 8px;
  right: 8px;
  width: auto;
  }
}

/* ダッシュボード: 本日の出勤者 */
.dash-today-group {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.dash-today-group:last-child { border-bottom: none; }
.dash-today-store {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.dash-today-store-icon::before { content: ""; }
.dash-today-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1px 8px;
  margin-left: 4px;
}
.dash-today-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dash-today-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 13px;
  color: var(--text);
}
.dash-today-role {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 0;
}

/* 当日列を店舗グループ全体で枠囲み（左右のみは中段、上は最上行、下は最下行）。
  背景色は上書きしないので box-shadow inset で枠を描画する。 */
.is-today-col-group {
  box-shadow: inset 2px 0 0 #f59e0b, inset -2px 0 0 #f59e0b;
}
.is-today-col-group.is-today-col-top {
  box-shadow: inset 2px 0 0 #f59e0b, inset -2px 0 0 #f59e0b, inset 0 2px 0 #f59e0b;
}
.is-today-col-group.is-today-col-bottom {
  box-shadow: inset 2px 0 0 #f59e0b, inset -2px 0 0 #f59e0b, inset 0 -2px 0 #f59e0b;
}
.is-today-col-group.is-today-col-top.is-today-col-bottom {
  box-shadow: inset 2px 0 0 #f59e0b, inset -2px 0 0 #f59e0b, inset 0 2px 0 #f59e0b, inset 0 -2px 0 #f59e0b;
}
/* 土日列の背景色は空セルにのみ適用、ステータス付きセルは曜日関係なく上記固定色 */
.cell.is-sat-col { background-color: #f0f7ff; }
.cell.is-sun-col { background-color: #fff5f5; }
.cell.cell-locked { cursor: not-allowed; }
.cell.cell-locked:hover { background-color: inherit; }
.cell.cell-locked:active { background-color: inherit; }
.cell.cell-other-store { cursor: not-allowed; background: #f8fafc !important; color: #cbd5e1; font-size: 11px; }
/* 他店舗セル: 行先店舗名を2行まで折返し表示（高さは他セルと同じ26px） */
.cell.cell-other-store-name {
  cursor: not-allowed;
  background: #EFF6FF !important;
  color: #1e40af !important;
  font-size: 8px !important;
  font-weight: 700;
  /* セルと同じ高さを維持しつつ2行表示 */
  height: var(--row-h) !important;
  min-height: var(--row-h) !important;
  max-height: var(--row-h) !important;
  padding: 0 2px !important;
  white-space: normal;
  word-break: break-all;
  overflow: hidden;
  /* 2行まで表示、3行目以降は省略 */
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  text-align: center;
  line-height: 1.1;
  box-sizing: border-box !important;
}
.cell.cell-other-store-name:hover { background: #DBEAFE !important; }
/* 公休: 全店舗共通の休日 */
.cell[data-status="公"] {
  background: #FEF3C7 !important;
  color: #92400E !important;
  font-weight: 700;
}

/* 下書きセル（公開前）: 黄色の点線枠でマーク */
.cell.cell-draft {
  outline: 2px dashed #F59E0B;
  outline-offset: -2px;
  position: relative;
}
.cell.cell-draft::after {
  content: '*';
  position: absolute;
  top: 0; right: 2px;
  font-size: 12px;
  color: #D97706;
  font-weight: 700;
  line-height: 1;
}
/* 雇用期間外（採用日前・退職日以降）のセル：少し濃いグレーで操作不可 */
.cell.cell-out-of-employment {
  cursor: not-allowed !important;
  background: #6B7280 !important;
  color: transparent !important;
  font-size: 0 !important;
  background-image: linear-gradient(135deg, rgba(255,255,255,0.08) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.08) 75%, transparent 75%, transparent) !important;
  background-size: 6px 6px !important;
}
.cell.cell-out-of-employment::before,
.cell.cell-out-of-employment::after { content: none !important; }
.cell.cell-out-of-employment:hover { background-color: #6B7280 !important; }
.cell.cell-out-of-employment:active { background-color: #6B7280 !important; }

/* 未納品日のセル：グレー背景+クリック不可・文字は非表示 */
.cell.cell-no-delivery {
  cursor: not-allowed !important;
  background: #9CA3AF !important;
  color: transparent !important;
  font-size: 0 !important;
  font-weight: 700;
}
.cell.cell-no-delivery::before,
.cell.cell-no-delivery::after { content: none !important; }
.cell.cell-no-delivery:hover { background: #9CA3AF !important; }
.cell.cell-no-delivery:active { background: #9CA3AF !important; }
.cell.cell-prefill { opacity: 0.55; }

/* 役職列 — セルと同じ高さに揃える */
.hdr-role, .role-col {
  position: sticky;
  left: var(--staff-w);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--role-w);
  min-width: var(--role-w);
  height: var(--row-h);
  min-height: var(--row-h);
  border-right: 2px solid var(--border-dark) !important;
  border-bottom: 1px solid #e2e8f0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 0 2px;
  margin: 0;
  background: #f8fafc;
  white-space: nowrap;
  box-sizing: border-box;
}
.hdr-role {
  height: var(--header-h);
  font-size: 9px;
  font-weight: 600;
  background: #334155;
  color: #e2e8f0;
  z-index: 20;
  position: sticky;
  top: 0;
}
.role-keeper  { color: #475569; }
.role-leader  { color: #2563ab; }
.role-manager { color: #dc2626; }

/* 出勤数列 — セルと同じ高さに揃える */
.hdr-count, .count-col {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--count-w);
  min-width: var(--count-w);
  height: var(--row-h);
  min-height: var(--row-h);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  margin: 0;
  background: #f8fafc;
  box-sizing: border-box;
}
/* ヘッダー行の出勤数・役職列はヘッダー高さに合わせる */
.hdr-count, .hdr-role { height: var(--header-h); min-height: var(--header-h); }
.hdr-count {
  height: var(--header-h);
  font-size: 10px;
  font-weight: 600;
  background: #1a3a6b;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 15;
}

/* ============================================================
  登録バー（スタッフ用）
  ============================================================ */
.register-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}
.register-status { font-size: 13px; color: var(--text-muted); }
.register-status.locked { color: var(--off); font-weight: 700; }

.ux-help-strip {
  align-items: flex-start;
  gap: 8px;
  line-height: 1.55;
}
.ux-help-strip strong {
  color: var(--accent-dark);
}
.register-bar {
  box-shadow: 0 -4px 12px rgba(15,23,42,.06);
}
.register-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-weight: 700;
}
.cell:focus-visible,
.sidebar-item:focus-visible,
.nav-tab:focus-visible {
  outline: 3px solid rgba(37,99,235,.28);
  outline-offset: -2px;
}

/* ============================================================
  コンテンツエリア（スタッフタブ・概要タブ用）
  ============================================================ */
.content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }
.admin-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.admin-overview-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.admin-overview-text {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.admin-overview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.admin-overview-btn {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.admin-overview-btn:hover,
.admin-overview-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}
.admin-page {
  flex: 1;
  overflow: auto;
  padding: 24px 32px;
  background: #F3F6FA;
}
.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: #fff;
}
.admin-header-control-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: -4px 0 14px;
}
.logs-control-row {
  justify-content: space-between;
}
.admin-page-kicker {
  color: var(--accent);
  font-family: 'DM Mono', 'Consolas', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}
.admin-page-title {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.admin-page-subtitle {
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.admin-primary-action {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.admin-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.admin-status-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.admin-status-tile strong {
  font-family: 'DM Mono', 'Consolas', monospace;
  font-size: 28px;
  line-height: 1;
}
.admin-status-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}
.admin-status-tile.active,
.admin-status-tile:hover,
.admin-status-tile:focus-visible {
  border-color: #BFDBFE;
  border-left-color: var(--accent);
  background: #EFF6FF;
  outline: none;
}
.admin-toolbar,
.admin-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: #fff;
}
.admin-toolbar-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}
.admin-data-panel {
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}
.admin-data-panel .rq-table th,
.admin-data-panel table th {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.admin-data-panel .rq-table td,
.admin-data-panel table td {
  vertical-align: middle;
}
.rq-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rq-filter select,
.admin-panel-toolbar select {
  min-height: 34px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 12px;
}
#tab-requests .rq-card,
#tab-requests .rq-table {
  border-radius: 0;
}
#tab-requests .rq-table th,
#tab-requests .rq-table td {
  padding: 9px 12px;
}
#tab-requests .rq-action-btn {
  border-radius: 0;
  border: 1px solid transparent;
}
.doc-subtab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  padding: 5px;
  overflow-x: auto;
}
.doc-subtab {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.doc-subtab.active,
.doc-subtab:hover,
.doc-subtab:focus-visible {
  border-color: #BFDBFE;
  background: #fff;
  color: var(--accent);
  outline: none;
}
.doc-workspace {
  padding: 0;
}
.doc-split-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.admin-side-panel {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 168px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}
.admin-side-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.doc-send-panel {
  padding: 16px;
  margin-bottom: 14px;
}
.contract-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.contract-metric {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.contract-metric:hover,
.contract-metric:focus-visible {
  border-color: #93C5FD;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  outline: none;
}
.contract-metric-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.contract-metric strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}
.contract-metric span:last-child {
  color: var(--text-muted);
  font-size: 11px;
}
.doc-send-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.contract-send-form {
  position: sticky;
  top: 0;
}
.contract-preview-pane {
  padding: 14px;
  min-width: 0;
}
.contract-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}
.contract-step-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.contract-table-panel {
  overflow: hidden;
}
.contract-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.contract-list-table th {
  text-align: left;
  padding: 9px 12px;
  color: var(--text-muted);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.contract-list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.contract-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}
.contract-row-submitted {
  background: #FFFBEB;
}

.staff-contract-list {
  display: grid;
  gap: 10px;
}
.staff-contract-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--border);
  padding: 14px;
}
.staff-contract-card.is-returned {
  border-color: #FCA5A5;
}
.staff-contract-kicker {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}
.staff-contract-main h3 {
  margin: 4px 0 4px;
  font-size: 15px;
  line-height: 1.35;
}
.staff-contract-main p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}
.staff-contract-note,
.staff-contract-alert {
  margin-top: 8px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: #F8FAFC;
}
.staff-contract-alert {
  color: #991B1B;
  border-color: #FCA5A5;
  background: #FEF2F2;
}
.staff-contract-side {
  border-left: 1px solid var(--border);
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.staff-contract-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
}
.staff-contract-status.ready {
  background: #DBEAFE;
  color: #1D4ED8;
}
.staff-contract-status.danger {
  background: #FEE2E2;
  color: #DC2626;
}
.staff-contract-date {
  color: var(--text-muted);
  font-size: 11px;
}
.staff-contract-open {
  margin-top: auto;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .contract-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .doc-send-grid {
    grid-template-columns: 1fr;
  }
  .contract-send-form {
    position: static;
  }
}

@media (max-width: 560px) {
  .contract-dashboard {
    grid-template-columns: 1fr;
  }
  .contract-list-table th:nth-child(3),
  .contract-list-table td:nth-child(3) {
    display: none;
  }
  .staff-contract-card {
    grid-template-columns: 1fr;
  }
  .staff-contract-side {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 10px 0 0;
    align-items: stretch;
  }
}

/* ============================================================
  カード
  ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
  サマリーカード（概要タブ）
  ============================================================ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.summary-card .number {
  font-size: 30px;
  font-weight: 800;
  font-family: 'DM Mono', monospace;
  color: var(--accent);
}
.summary-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
  スタッフリスト
  ============================================================ */
.staff-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.staff-row:last-child { border-bottom: none; }
.staff-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.staff-info { flex: 1; min-width: 0; }
.staff-name-text { font-size: 14px; font-weight: 600; }
.staff-detail { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ============================================================
  バッジ
  ============================================================ */
.shift-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 0;
  font-weight: 600;
  white-space: nowrap;
}
.badge-confirmed { background: var(--work-bg); color: var(--work); }
.badge-pending  { background: var(--paid-bg); color: var(--paid); }

/* ============================================================
  ボタン
  ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  min-height: 38px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--border); box-shadow: 0 1px 4px rgba(15,23,42,.08); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger {
  background: var(--off-bg);
  border-color: #FECACA;
  color: var(--off);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* ============================================================
  モーダル
  ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  /* サイドバーを覆わない位置取り（PC）。下寄せ表示。 */
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.4);
  z-index: 500;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
/* モバイルではサイドバーが非表示なので全画面に */
@media (max-width: 900px) {
  .modal-overlay {
  left: 0;
  align-items: center; /* スマホでは中央 */
  }
}
.modal-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-card .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-card .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.modal-card .modal-body {
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to  { transform: translateY(0);  opacity: 1; }
}
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 18px; color: var(--text); }
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  appearance: none;
}
.form-control:focus { border-color: var(--accent); background: var(--surface); }
select.form-control { cursor: pointer; }
.form-control:focus {
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-help {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.password-field {
  position: relative;
}
.password-field .form-control {
  padding-right: 68px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 54px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ============================================================
  アラート
  ============================================================ */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-info  { background: var(--accent-light); color: var(--accent-dark); border-color: #BFDBFE; }
.alert-danger  { background: var(--off-bg); color: #991B1B; border-color: #FECACA; }

/* ============================================================
  ローディング・空状態
  ============================================================ */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 10px;
  font-size: 14px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 38px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }
.staff-doc-empty {
  padding: 14px 16px;
  border: 1px solid #86EFAC;
  background: #F0FDF4;
  color: #166534;
  font-size: 13px;
  line-height: 1.6;
}
.staff-doc-empty.muted {
  border-color: var(--border);
  background: var(--surface2);
  color: var(--text-muted);
}
.load-error {
  width: min(100%, 520px);
  margin: 18px auto;
  padding: 18px;
  border: 1px solid #FCA5A5;
  background: #FEF2F2;
  color: #7F1D1D;
  text-align: center;
}
.load-error-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
}
.load-error-message,
.load-error-detail {
  font-size: 13px;
  line-height: 1.6;
}
.load-error-detail {
  color: #991B1B;
  margin-top: 4px;
}
.load-error .btn {
  margin-top: 12px;
}

/* ============================================================
  ログインページ
  ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(248,250,252,.92)),
    radial-gradient(circle at 20% 10%, rgba(37,99,235,.10), transparent 32%),
    linear-gradient(135deg, #F8FAFC 0%, #EEF2FF 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(37,99,235,.1), 0 4px 16px rgba(0,0,0,.08);
}
.ux-login-card {
  max-width: 420px;
  border-top: 4px solid var(--accent);
}
.login-logo { text-align: left; margin-bottom: 20px; }
.login-logo .app-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.login-logo .app-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-guide {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.login-guide-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.login-guide-text {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.login-error {
  background: var(--off-bg);
  color: #991B1B;
  border: 1px solid #FECACA;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.login-footnote {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
  ユーティリティ
  ============================================================ */
.hidden { display: none !important; }

/* スクロールバー */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 0; }

/* ============================================================
  レスポンシブ
  ============================================================ */

/* PC（768px以上）: サイドバーあり、タブナビなし */
@media (min-width: 768px) {
  .sidebar  { display: flex; }
  .mobile-header { display: none; }
  .nav-tabs  { display: none; }
  .summary-grid  { grid-template-columns: repeat(4, 1fr); }
}

/* モバイル（767px以下）: サイドバーなし、タブナビ表示 */
@media (max-width: 767px) {
  .app-layout  { flex-direction: column; }
  .sidebar  { display: none; }
  .mobile-header { display: flex; }
  .mobile-quickbar { display: flex; }
  .nav-tabs  { display: flex; }
  .main-area  { overflow-y: auto; }
  .scroll-wrap  { min-height: 300px; }
  :root {
  --day-w:  48px;  /* スマホでも店舗名2行表示できる幅 */
  --staff-w:  80px;
  --role-w: 50px;
  --count-w:  40px;
  --contract-w: 40px;
  --row-h:  26px;
  }
  .cell { height: var(--row-h); min-height: var(--row-h); }
}

/* ============================================================
  パフォーマンス改善: 旧 cssText を CSS クラスに置換（描画高速化）
  セル毎にインライン style 文字列をパースする負荷を削減
  ============================================================ */
.store-row-name-cell {
  grid-column: 1 / span 2;  /* 必ず col 1-2 に固定。出勤数列を hide した時の auto-flow 滑り込みを防止 */
  position: sticky;
  left: 0;
  z-index: 8;
  background: #fff;
  padding: 0 12px;
  height: var(--row-h);
  min-height: var(--row-h);
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  border-right: 2px solid var(--border-dark);
  border-bottom: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  width: auto;
  min-width: calc(var(--staff-w) + var(--role-w));
  box-sizing: border-box;
}
.store-cat-cell {
  background: #fff;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--row-h);
  min-height: var(--row-h);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #cbd5e1;
  box-sizing: border-box;
}
.store-cat-cell.store-cat-zakka {
  background: #DBEAFE;
  color: #1E40AF;
}
.store-cat-cell.store-cat-food {
  background: #FCE7F3;
  color: #9D174D;
}
.store-cat-cell.store-cat-both {
  background: #E0E7FF;
  color: #3730A3;
}
.store-cat-cell.store-cat-nd {
  background: #9CA3AF;
  color: #9CA3AF;
}
/* スタッフセル: 雑貨日/食品日ラベル（シフト未設定時に表示） */
.cell.cell-cat-label { font-size: 9px; font-weight: 600; }
.cell.cell-cat-zakka { color: #3B82F6; }
.cell.cell-cat-food  { color: #EC4899; }
.cell.cell-cat-both  { color: #6366F1; font-size: 7px; }
.store-row-filler {
  background: #fff;
  height: var(--row-h);
  min-height: var(--row-h);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #cbd5e1;
  box-sizing: border-box;
}
.count-col-has { color: #1e293b; }
.count-col:not(.count-col-has) { color: #cbd5e1; }

/* 納品量サマリー（前2月平均 / 去年同日） */
.summary-label {
  grid-column: 1 / span 2;  /* col 1-2 固定 */
  position: sticky;
  left: 0;
  z-index: 7;
  padding: 0 12px;
  height: 24px;
  min-height: 24px;
  font-size: 11px;
  font-weight: 700;
  border-right: 2px solid var(--border-dark);
  border-bottom: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  width: auto;
  min-width: calc(var(--staff-w) + var(--role-w));
  box-sizing: border-box;
}
.summary-label-avg {
  background: #EFF6FF;
  color: #1d4ed8;
  border-top: 1px solid #BFDBFE;
}
.summary-label-ly  {
  background: #FEF3C7;
  color: #92400E;
}
.summary-cell {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-height: 24px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #cbd5e1;
  box-sizing: border-box;
}
.summary-cell-avg {
  background: #EFF6FF;
  color: #1d4ed8;
  border-top: 1px solid #BFDBFE;
}
.summary-cell-ly {
  background: #FEF3C7;
  color: #92400E;
}
.summary-filler { /* 出勤数列スペース（文字なし） */ }

/* ============================================================
  契約日数列（出勤数列の隣）
  ============================================================ */
.hdr-contract, .contract-col {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--contract-w);
  min-width: var(--contract-w);
  height: var(--row-h);
  min-height: var(--row-h);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  margin: 0;
  background: #f8fafc;
  color: #475569;
  box-sizing: border-box;
}
.hdr-contract {
  height: var(--header-h);
  min-height: var(--header-h);
  font-size: 10px;
  font-weight: 600;
  background: #1a3a6b;
  color: #fff;
}
.contract-col.contract-col-unset { color: #cbd5e1; }
.contract-col.contract-col-under { color: #dc2626; }  /* 出勤数 < 契約日数 */
.contract-col.contract-col-met  { color: #16a34a; }  /* 出勤数 >= 契約日数 */

body.hide-count-on-print .contract-col,
body.hide-count-on-print .hdr-contract { display: none !important; }

body.pdf-export #shiftTable .hdr-contract,
body.pdf-export #shiftTable .contract-col {
  background: #FFFFFF !important;
  color: #000 !important;
  border-color: #000 !important;
}

/* ============================================================
  雇用契約書プレビュー（契約書本文・印影風レイアウト）
  ============================================================ */
.contract-preview {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0;
  padding: 36px 44px;
  max-width: 760px;
  margin: 0 auto;
  color: #111827;
  font-family: 'Meiryo', 'Yu Gothic', 'Hiragino Sans', sans-serif;
  font-size: 13px;
  line-height: 1.8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.contract-preview h1 {
  font-size: 22px;
  text-align: center;
  margin: 0 0 10px;
  letter-spacing: 0.2em;
  font-weight: 700;
}
.contract-preview .doc-sub {
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  margin: 0 0 24px;
}
.contract-preview h2 {
  font-size: 14px;
  margin: 22px 0 8px;
  padding: 4px 10px;
  background: #f1f5f9;
  border-left: 4px solid #1e40af;
  font-weight: 700;
}
.contract-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
  font-size: 12.5px;
}
.contract-preview table th,
.contract-preview table td {
  border: 1px solid #cbd5e1;
  padding: 7px 12px;
  text-align: left;
  vertical-align: middle;
}
.contract-preview table th {
  background: #f1f5f9;
  font-weight: 700;
  width: 32%;
}
.contract-preview .clause {
  margin: 4px 0;
  padding-left: 1.4em;
  text-indent: -1.4em;
}
.contract-preview .sign-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 36px;
  gap: 30px;
}
.contract-preview .sign-row > div {
  flex: 1;
}
.contract-preview .sign-label {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}
.contract-preview .sign-line {
  border-bottom: 1px solid #111827;
  min-height: 60px;
  padding: 6px 4px;
  font-size: 13px;
}
.contract-preview .sign-line img { max-height: 56px; max-width: 100%; }
.contract-preview .doc-date {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 8px;
}

/* ============================================================
  スマホ最適化 (480px以下)
  ============================================================ */
@media (max-width: 480px) {
  /* 全体 */
  body { font-size: 13px; }
  .app-layout { flex-direction: column; height: auto; min-height: 100vh; }
  .main-area { padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* モバイルヘッダー */
  .admin-overview {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }
  .admin-overview-actions {
    justify-content: stretch;
  }
  .admin-overview-btn {
    flex: 1 1 120px;
  }
  .admin-page {
    padding: 14px;
  }
  .admin-page-header {
    flex-direction: column;
    padding: 14px;
  }
  .admin-status-grid {
    grid-template-columns: 1fr 1fr;
  }
  .doc-split-layout {
    grid-template-columns: 1fr;
  }
  .admin-side-panel {
    position: static;
    max-height: 260px;
  }
  .mobile-header { padding: 8px 12px; }
  .mobile-header h1 { font-size: 15px; }

  /* ナビタブ: 横スクロール */
  .nav-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    padding: 0 4px;
    flex-wrap: nowrap;
  }
  .nav-tab {
    flex-shrink: 0;
    padding: 10px 12px;
    font-size: 11px;
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* フォーム: タッチ向け */
  .form-control { font-size: 16px; min-height: 44px; padding: 10px 12px; }
  select.form-control { font-size: 16px; min-height: 44px; }
  textarea.form-control { font-size: 14px; min-height: 80px; }
  .btn { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .btn-sm { min-height: 38px; padding: 8px 12px; font-size: 13px; }

  /* モーダル: フルスクリーンに近い */
  .modal-overlay { padding: 8px; }
  .modal-card { max-width: 100%; max-height: 95vh; }
  .modal { max-width: 100%; padding: 16px 14px; }
  .modal-card .modal-header { padding: 12px 14px; }
  .modal-card .modal-header h3 { font-size: 15px; }
  .modal-card .modal-body { padding: 12px 14px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { min-width: 0; }

  .login-page {
    align-items: flex-start;
    padding: 14px;
  }
  .login-card {
    padding: 24px 18px;
    margin-top: 28px;
  }
  .login-logo .app-name {
    font-size: 20px;
  }
  .login-guide {
    padding: 10px 12px;
  }
  .mobile-header-right {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .mobile-user-label {
    max-width: 140px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
    font-size: 11px;
    text-align: right;
  }
  #storeLabel {
    flex-basis: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    font-size: 11px !important;
    line-height: 1.25;
  }
  .legend {
    gap: 6px;
    padding: 6px 10px;
  }
  .legend-item {
    font-size: 10px;
  }
  .summary-bar {
    padding: 6px 10px;
    gap: 10px;
  }
  .register-bar {
    position: sticky;
    bottom: 0;
    z-index: 80;
    padding: 10px 12px;
    align-items: stretch;
  }
  .register-status {
    flex: 1;
    min-width: 0;
    justify-content: center;
    text-align: center;
  }

  /* テーブル: 横スクロール */
  .staff-table { font-size: 12px; }
  .staff-table th, .staff-table td { padding: 5px 6px; font-size: 12px; line-height: 1.35; }
  .col-num { display: none; }

  /* スタッフフィルターバー: 縦積み */
  .staff-filter-bar {
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
  }
  .staff-filter-bar input,
  .staff-filter-bar select {
    width: 100%;
    font-size: 16px;
  }
  .staff-filter-bar .btn,
  .staff-filter-bar .col-toggle-btn {
    font-size: 12px;
    padding: 8px 10px;
  }

  /* シフトグリッド */
  :root {
    --day-w: 38px;
    --staff-w: 138px;
    --role-w: 42px;
    --count-w: 36px;
    --contract-w: 36px;
    --row-h: 32px;
  }
  .cell {
    height: var(--row-h);
    min-height: var(--row-h);
    font-size: 10px;
  }
  .staff-name {
    height: var(--row-h);
    min-height: var(--row-h);
    padding: 2px 6px;
    font-size: 10px;
    line-height: 1.2;
  }
  .staff-name span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    display: block;
  }
  .hdr-role,
  .role-col {
    display: flex;
    visibility: visible;
    width: var(--role-w);
    min-width: var(--role-w);
    height: var(--row-h);
    min-height: var(--row-h);
    padding: 2px 1px;
    border-right: 2px solid var(--border-dark) !important;
    border-bottom: 1px solid #e2e8f0;
    overflow: hidden;
    font-size: 8.5px;
    line-height: 1.15;
    white-space: nowrap;
  }
  .store-row-name-cell {
    height: var(--row-h);
    min-height: var(--row-h);
    min-width: calc(var(--staff-w) + var(--role-w));
    padding: 2px 6px;
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    text-overflow: clip;
  }
  .store-cat-cell,
  .store-row-filler {
    height: var(--row-h);
    min-height: var(--row-h);
    font-size: 8px;
  }
  .hdr-staff, .name-col { font-size: 10px; }

  /* ダッシュボード */
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .summary-card { padding: 12px; }
  .summary-card .value { font-size: 20px; }

  /* 勤怠 */
  .tc-btn { min-height: 54px; font-size: 14px; }

  /* 詳細ドロワー: フルスクリーン化 */
  #staffDetailDrawer, #storeDetailDrawer {
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* 書類サブタブ */
  .doc-subtab { font-size: 10px; padding: 4px 8px; }

  /* 設定サブタブ */
  .settings-subtab { font-size: 11px; padding: 6px 10px; }
  .log-subtab { font-size: 11px; padding: 6px 10px; }

  /* チェックボックス列 */
  .staff-email-cb { width: 18px; height: 18px; }
}

/* ============================================================
  タブレット最適化 (481px - 1024px)
  ============================================================ */
@media (min-width: 481px) and (max-width: 1024px) {
  /* フォーム: タッチ向け */
  .form-control { min-height: 40px; font-size: 15px; }
  select.form-control { min-height: 40px; font-size: 15px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }

  /* モーダル */
  .modal-card { max-width: 90vw; }

  /* テーブル行 */
  .staff-table th, .staff-table td { padding: 5px 8px; line-height: 1.35; }

  /* シフトグリッド */
  :root {
    --day-w: 44px;
    --staff-w: 88px;
  }
  .cell { min-height: 28px; font-size: 12px; }

  /* ダッシュボード */
  .summary-grid { grid-template-columns: repeat(3, 1fr); }

  /* フィルターバー: 折り返し */
  .staff-filter-bar { flex-wrap: wrap; gap: 6px; }

  /* 詳細ドロワー */
  #staffDetailDrawer, #storeDetailDrawer {
    width: 60vw !important;
    min-width: 400px;
  }

  /* 勤怠ボタン */
  .tc-btn { min-height: 48px; }
}

/* ============================================================
  タブレット縦向き (768px-1024px portrait): サイドバー非表示
  ============================================================ */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .nav-tabs { display: flex; }
}

/* ============================================================
  タッチデバイス共通: hover 無効化 + タッチターゲット確保
  ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .cell:hover { background-color: inherit; }
  .btn:hover { filter: none; }
  .sidebar-item:hover { background: inherit; }
  .row-clickable:hover { background: inherit; }
  .row-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  /* タッチターゲット最小サイズ 44px */
  .sidebar-item { min-height: 44px; }
  .nav-tab { min-height: 44px; }
  a, button { min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
}

/* セルフ申請リンク: 車両申請書などをボタンではなく軽いテキスト導線にする */
.self-submit-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.self-submit-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
}

.self-submit-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
}

.self-submit-link:hover,
.self-submit-link:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* スタッフ用ダッシュボード */
.staff-dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #F6F8FB;
}

.staff-dash-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 22px 24px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--border);
}

.staff-dash-kicker {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.staff-dash-hero h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.staff-dash-hero p {
  margin: 6px 0 0;
  color: var(--text-sub);
  font-size: 13px;
}

.staff-dash-bell {
  position: relative;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  cursor: pointer;
}

.staff-dash-bell::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto;
  border: 2px solid #475569;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 0;
}

.staff-dash-bell::after {
  content: '';
  display: block;
  width: 8px;
  height: 3px;
  margin: 3px auto 0;
  background: #475569;
}

.staff-dash-bell span {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #DC2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
}

.staff-dash-section,
.staff-attendance-panel {
  background: #fff;
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 14px;
}

.staff-dash-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.staff-dash-section-title {
  font-size: 16px;
  font-weight: 800;
}

.staff-dash-section-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 3px;
}

.staff-clock-store {
  margin-bottom: 12px;
}

.staff-clock-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.staff-clock-btn {
  min-height: 52px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.staff-clock-btn.in {
  border-color: #86EFAC;
  background: #DCFCE7;
  color: #166534;
}

.staff-clock-btn.out {
  border-color: #FCA5A5;
  background: #FEE2E2;
  color: #991B1B;
}

.staff-clock-btn.break {
  border-color: #FDE68A;
  background: #FFFBEB;
  color: #92400E;
}

.staff-clock-btn.store {
  border-color: #BFDBFE;
  background: #EFF6FF;
  color: #1D4ED8;
}

.staff-clock-info {
  min-height: 20px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.staff-today-clock-list {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.staff-clock-row,
.staff-attendance-row {
  display: grid;
  grid-template-columns: 100px 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #F8FAFC;
  border: 1px solid #E5E7EB;
  font-size: 12px;
}

.staff-clock-row strong {
  font-family: 'SF Mono','Menlo','Consolas',monospace;
}

.staff-clock-row em {
  min-width: 0;
  color: var(--text-muted);
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-dash-notices {
  display: grid;
  gap: 8px;
}

.staff-notice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px;
  background: #F8FAFC;
  border: 1px solid #E5E7EB;
}

.staff-notice-row strong {
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-notice-row span {
  color: var(--text-muted);
  font-size: 11px;
}

.staff-notice-row p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.5;
}

.staff-dash-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.staff-dash-action {
  min-height: 92px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.staff-dash-action:hover,
.staff-dash-action:focus-visible {
  border-color: #93C5FD;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  outline: none;
}

.staff-dash-action strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.staff-dash-action span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.staff-view-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.staff-view-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.staff-view-toolbar.in-scroll {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -14px -14px 14px;
}

.staff-back-btn,
.staff-mini-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.staff-view-title {
  font-size: 15px;
  font-weight: 800;
}

.staff-attendance-list {
  display: grid;
  gap: 8px;
}

.staff-attendance-row {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.staff-attendance-row div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.staff-attendance-row strong {
  font-size: 13px;
}

.staff-attendance-row span {
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-attendance-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.staff-attendance-nav strong {
  min-width: 96px;
  text-align: center;
  font-size: 14px;
}

.staff-att-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
}

.staff-att-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}

.staff-att-table th,
.staff-att-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  line-height: 1.45;
}

.staff-att-table th {
  background: #F8FAFC;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.staff-att-table td:nth-child(2),
.staff-att-table td:nth-child(3),
.staff-att-table td:nth-child(4) {
  font-family: 'SF Mono','Menlo','Consolas',monospace;
  white-space: nowrap;
}

.staff-att-table td:first-child strong {
  display: block;
  font-size: 13px;
}

.staff-att-table td:first-child span {
  color: var(--text-muted);
  font-size: 11px;
}

.staff-att-table tr.is-today {
  background: #EFF6FF;
}

.staff-att-table .muted {
  color: #CBD5E1;
}

.staff-att-claim-pill {
  display: inline-block;
  padding: 2px 6px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.staff-att-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: #fff;
}

.staff-att-cal-head,
.staff-att-cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.staff-att-cal-head {
  padding: 8px 6px;
  background: #F8FAFC;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.staff-att-cal-cell {
  min-height: 132px;
  padding: 8px;
  background: #fff;
}

.staff-att-cal-cell.is-empty {
  background: #F8FAFC;
}

.staff-att-cal-cell.is-today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.staff-att-cal-cell.has-clock {
  background: #F8FBFF;
}

.staff-att-cal-date {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.staff-att-cal-date strong {
  font-size: 15px;
}

.staff-att-cal-date span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.staff-att-cal-times {
  display: grid;
  gap: 5px;
}

.staff-att-cal-times div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.staff-att-cal-times span {
  color: var(--text-muted);
  font-weight: 700;
}

.staff-att-cal-times strong {
  font-family: 'SF Mono','Menlo','Consolas',monospace;
  font-size: 13px;
}

.staff-att-cal-times .is-muted strong,
.staff-att-cal-times .is-muted span {
  color: #CBD5E1;
}

.staff-att-cal-break {
  padding-top: 4px;
  border-top: 1px dashed #CBD5E1;
}

.staff-att-cal-store {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-att-store-visits {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed #CBD5E1;
}

.staff-att-store-visits div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  font-size: 11px;
}

.staff-att-store-visits span {
  min-width: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-att-store-visits strong {
  font-family: 'SF Mono','Menlo','Consolas',monospace;
  font-size: 11px;
}

.staff-att-cal-claim {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  background: #FEF3C7;
  color: #92400E;
  font-size: 10px;
  font-weight: 800;
}

.multi-store-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  font-size: 9px;
  font-weight: 800;
  vertical-align: middle;
  white-space: nowrap;
}

.staff-empty-line {
  color: var(--text-muted);
  font-size: 13px;
  padding: 10px 0;
}

@media (max-width: 900px) {
  .staff-dash-actions,
  .staff-clock-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .staff-dashboard {
    padding: 12px;
  }
  .staff-dash-hero {
    padding: 16px;
  }
  .staff-dash-hero h1 {
    font-size: 20px;
  }
  .staff-dash-actions,
  .staff-clock-actions {
    grid-template-columns: 1fr;
  }
  .staff-clock-row {
    grid-template-columns: 80px 64px minmax(0, 1fr);
  }
  .staff-attendance-row {
    grid-template-columns: 1fr;
  }
  .staff-attendance-nav {
    justify-content: flex-start;
  }
  .staff-att-calendar {
    display: block;
    border-right: 1px solid var(--border);
  }
  .staff-att-cal-head,
  .staff-att-cal-cell.is-empty {
    display: none;
  }
  .staff-att-cal-cell {
    min-height: 0;
    border-right: 0;
  }
  .staff-att-cal-times {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .staff-att-cal-break {
    grid-column: 1 / -1;
  }
}

/* スタッフ用スマホUIの最終上書き */
@media (max-width: 767px) {
  .staff-dashboard {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
  .staff-dash-actions,
  .staff-clock-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .staff-mobile-nav {
    display: grid;
  }
}
