:root {
  --primary-color: #ACDBD1; /* ロゴのミントグリーン */
  --secondary-color: #E4ACAE; /* ロゴの薄い赤/ピンク */
  --accent-color: #F9EDB6; /* ロゴの薄い黄色 */
  --dark-gray: #333;
  --gray: #ccc;
  --light-gray: #f7f9fa; /* 背景を少し明るくクリーンに */
  --red: #dc3545;
  --blue: #007bff;
  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05); /* 統一用の柔らかい影 */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0; 
  background-color: var(--light-gray);
  color: var(--dark-gray);
  font-size: 16px;
  -webkit-text-size-adjust: 100%; 
}

/* =========================================
   共通コンポーネント (ボタン・入力フォーム)
   ========================================= */
/* ボタン全体のホバーアクション統一 */
button {
  transition: all 0.2s ease-in-out;
}
button:hover:not(:disabled) {
  opacity: 0.85;
  transform: translateY(-1px);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}

/* 入力フォームのフォーカス（選択時）の統一 */
input[type="date"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(172, 219, 209, 0.4);
}

/* =========================================
   メインレイアウト
   ========================================= */
/* メインコンテナ (カレンダー画面) */
.container {
  max-width: 600px; 
  margin: 10px auto; 
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

/* ヘッダー：月操作 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}
.header h2 {
  margin: 0;
  font-size: 1.4em;
  color: var(--primary-color); 
}
.month-nav button {
  background: var(--primary-color); 
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  margin-left: 5px;
  font-weight: 500;
}
.month-nav button:disabled {
  background: var(--gray);
  transform: none;
}

/* 管理者メッセージ */
.admin-message {
  background: var(--accent-color); 
  border: 1px solid #f0e194; 
  padding: 12px 15px;
  margin: 15px 0;
  border-radius: 8px;
  font-size: 0.9em;
  color: var(--dark-gray);
  line-height: 1.5;
}

/* カレンダー */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 15px;
}
.calendar-header {
  text-align: center;
  font-weight: bold;
  font-size: 0.85em;
  padding: 5px 0;
  color: #777;
}
.calendar-header:nth-child(6) { color: var(--blue); }
.calendar-header:nth-child(7) { color: var(--red); }

.calendar-day {
  position: relative;
  min-height: 75px; 
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  padding: 6px;
  font-size: 0.9em;
  transition: all 0.2s;
  overflow: hidden;
}
.calendar-day:hover {
  background: #f4fcfa;
  border-color: var(--primary-color);
}
.calendar-day.other-month {
  background: #fdfdfd;
  color: var(--gray);
  cursor: not-allowed;
  border-color: #f4f4f4;
}
.day-number {
  font-weight: bold;
  font-size: 0.9em;
}
.shift-info {
  font-size: 0.8em;
  color: var(--dark-gray); 
  background: #eaf5f3;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: bold;
  margin-top: 5px;
  word-break: break-all;
  display: inline-block;
}

/* 最終確定・全削除ボタン */
.submit-button-container {
  text-align: center;
  margin-top: 25px;
  display: flex;
  gap: 12px;
}
.submit-button {
  background: #28a745; 
  color: white;
  border: none;
  padding: 14px 25px;
  font-size: 1.05em;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  width: auto;
  flex-grow: 1;
}
.submit-button:disabled {
  background: var(--gray);
}
.delete-all-button {
  background: var(--secondary-color); 
  color: white;
  border: none;
  padding: 14px 20px;
  font-size: 1.05em;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  width: auto;
  flex-grow: 0;
}
.delete-all-button:disabled {
  background: var(--gray);
}

/* =========================================
   ポップアップ (モーダル)関連
   ========================================= */
.modal-overlay,
.login-modal-overlay,
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px); /* 背景を少しぼかす現代的な表現 */
  display: none; 
  justify-content: center;
  align-items: center;
  z-index: 3000;
}
.modal-overlay,
.confirm-modal-overlay {
  display: none; /* 通常のモーダルと確認画面は最初隠す */
}
.login-modal-overlay {
  display: flex; /* ログイン画面のベースは表示（新規登録はHTML側で隠れる） */
}
.modal-content,
.login-modal-content,
.confirm-modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  width: 90%; 
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}
.modal-header {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 15px;
  color: var(--dark-gray);
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}
.modal-body .form-group,
#login-form .form-group,
#registration-form .form-group {
  margin-bottom: 15px;
}
.modal-body label,
#login-form label,
#registration-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9em;
  color: #555;
}
.modal-body input[type="time"],
.modal-body input[type="text"],
.modal-body select,
#login-form input[type="password"],
#login-form input[type="text"],
#login-form select,
#registration-form input[type="password"],
#registration-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 1em;
  border: 1px solid var(--gray);
  border-radius: 6px;
  box-sizing: border-box; 
  background-color: #fff;
  transition: all 0.2s;
}

/* selectの矢印カスタマイズ */
.modal-body select,
#login-form select {
  -webkit-appearance: none; 
  -moz-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23bbb%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-13%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2013l128%20128c3.6%203.6%207.8%205.4%2013%205.4s9.4-1.8%2013-5.4l128-128c3.6-3.6%205.4-7.8%205.4-13%200-4.9-1.8-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
  padding-right: 30px;
}
.modal-body input[type="text"] {
  background-image: none;
  padding-right: 12px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 25px;
  gap: 10px;
}
.modal-footer button {
  padding: 12px 15px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  flex-grow: 1;
}
#modal-cancel {
  background: #f0f0f0;
  color: var(--dark-gray);
}
#modal-delete {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--red);
}
#modal-register {
  background: var(--primary-color); 
  color: var(--dark-gray); /* 視認性向上のためダークグレーに変更 */
}

/* ローディング */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: none; 
  justify-content: center;
  align-items: center;
  z-index: 5000;
  font-size: 1.2em;
  font-weight: bold;
  color: var(--primary-color);
}

/* ログインモーダル特有 */
.login-modal-content h2 {
  text-align: center;
  margin-top: 0;
  color: var(--primary-color);
}
#login-button, #registration-button {
  width: 100%;
  padding: 14px;
  font-size: 1.1em;
  font-weight: bold;
  background: var(--primary-color); 
  color: var(--dark-gray);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 15px;
}
#login-error-message, #registration-error-message {
  color: var(--red);
  font-size: 0.9em;
  text-align: center;
  margin-top: 15px;
  min-height: 1.2em;
}
.modal-switch {
  text-align: center;
  margin-top: 25px;
  border-top: 1px solid #eee;
  padding-top: 15px;
}
.modal-switch p {
  margin: 0 0 10px 0;
  font-size: 0.9em;
  color: #777;
}
.switch-button {
  background: none;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}
.switch-button:hover {
  background: var(--primary-color);
  color: var(--dark-gray);
}

/* =========================================
   チェックボックス・コピペ関連
   ========================================= */
.day-checkbox {
  position: absolute;
  top: 4px;
  right: 4px;
  transform: scale(1.3); 
  margin: 0;
  cursor: pointer;
  z-index: 5;
  accent-color: var(--primary-color); /* チェックボックスの色をテーマに合わせる */
}

.copy-paste-container {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 15px;
  margin-bottom: 15px; 
}
.copy-paste-container button {
  flex-grow: 1;
  padding: 12px;
  font-size: 0.9em;
  font-weight: bold;
  border-radius: 8px;
  border: 2px solid var(--gray);
  cursor: pointer;
}
.copy-paste-container button:disabled {
  background: var(--light-gray);
  color: var(--gray);
  cursor: not-allowed;
  border-color: var(--gray);
}
#copy-shift-button {
  background: #fff;
  color: var(--primary-color);
  border-color: var(--primary-color);
}
#paste-shift-button {
  background: #fff;
  color: #28a745;
  border-color: #28a745;
}

.time-inputs {
  display: flex;
  gap: 10px; 
  align-items: center; 
}
.time-inputs label {
  font-size: 0.95em;
  font-weight: normal;
  margin: 0 5px 0 0;
  color: #555;
}
.time-inputs select {
  flex-grow: 1; 
  width: 50%; 
}

/* カスタム確認ダイアログ */
#confirm-modal-message {
  margin-bottom: 25px;
  font-size: 1.1em;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--dark-gray);
}
.confirm-modal-buttons button {
  padding: 12px;
  border-radius: 6px;
}
#confirm-ok-button {
  background: var(--primary-color); 
  color: var(--dark-gray);
}
#confirm-cancel-button {
  background: #f0f0f0;
  color: var(--dark-gray);
}

/* =========================================
   サイドバー・ナビゲーション
   ========================================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: #2c3e50; /* 少しだけ青みを持たせてモダンに */
  color: white;
  padding-top: 20px;
  z-index: 3500; 
  display: none; 
}
.sidebar-header {
  padding: 0 20px 15px 20px;
  font-size: 1.1em;
  font-weight: bold;
  border-bottom: 1px solid #34495e;
  color: var(--primary-color);
}
.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav li {
  padding: 15px 20px;
  cursor: pointer;
  border-bottom: 1px solid #34495e;
  font-size: 0.95em;
  transition: background 0.2s;
}
.sidebar-nav li:hover {
  background: #34495e;
}
.sidebar-nav li.active {
  background: var(--primary-color);
  color: var(--dark-gray);
  font-weight: bold;
  border-left: 4px solid #fff; /* アクセントのバーを追加 */
}

.main-content-wrapper {
  transition: margin-left 0.3s ease;
  padding: 15px; 
}
.main-content-wrapper.with-sidebar {
  margin-left: 220px; 
}

.admin-staff-selector {
  display: none; 
  max-width: 600px;
  margin: 10px auto;
  padding: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}
.admin-staff-selector label {
  display: block;
  font-weight: bold;
  margin-bottom: 10px;
  color: #555;
}
.admin-staff-selector select {
  width: 100%;
  padding: 12px;
  font-size: 1.05em;
  border: 1px solid var(--gray);
  border-radius: 6px;
  background-color: #fff;
}

/* =========================================
   シフト作成画面 (新レイアウト)
   ========================================= */
.shift-creation-container {
  width: 100%;
  max-width: 1400px; 
  margin: 10px auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 15px;
  height: calc(100vh - 40px); 
  overflow: hidden;
  display: none; 
  flex-direction: column;
}

.creation-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eee;
  flex-shrink: 0; 
}
.creation-header label {
  font-weight: bold;
}
.creation-header input[type="date"] {
  font-size: 1.05em;
  padding: 6px 10px;
  border: 1px solid var(--gray);
  border-radius: 6px;
}
.creation-header button {
  background: var(--primary-color);
  color: var(--dark-gray);
  font-weight: bold;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
}
.creation-header #save-shift-button {
  background: #28a745; 
  color: white;
}

.shift-section {
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid #eee;
  flex-grow: 1;
  flex-basis: 0; 
  min-height: 0; 
  position: relative;
}
.shift-section:last-of-type {
  border-bottom: none;
}

.section-header {
  display: flex;
  flex-shrink: 0;
  cursor: pointer; 
  user-select: none; 
  transition: background-color 0.2s;
}
.section-header:hover .panel-title {
  background: #e9ecef;
}

.panel-title {
  font-size: 1.05em;
  font-weight: bold;
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
  box-sizing: border-box; 
  background: #f8f9fa;
  height: 42px; 
  display: flex;
  align-items: center;
  color: #444;
}

.section-body {
  display: flex;
  flex-grow: 1;
  overflow: hidden; 
  position: relative;
}

.staff-names-column {
  width: 220px; /* 少し広げて見やすく */
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  background: #fff;
  border-right: 1px solid #eee;
}
.staff-names-body {
  height: 100%;
  overflow-y: auto; 
  overflow-x: hidden;
  scrollbar-width: none;
}
.staff-names-body::-webkit-scrollbar {
  display: none;
}

.timeline-main {
  flex-grow: 1;
  position: relative;
  background: #fafafa;
}
.timeline-header-wrapper {
  overflow: hidden;
  padding: 0;
  height: 42px; 
  background: #f8f9fa;
}
.timeline-body-wrapper {
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
  z-index: 1;
}
.timeline-body-wrapper::-webkit-scrollbar {
  height: 8px;
}
.timeline-body-wrapper::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

#kitchen-section .timeline-body-wrapper {
  overflow-x: auto;
}

/* 時間軸 */
.timeline-header {
  display: flex;
  background: transparent;
  z-index: 10;
  height: 41px; 
  width: 1440px; 
}
.timeline-hour {
  width: 60px; 
  text-align: center;
  padding: 5px 0;
  border-left: 1px solid #ddd;
  font-size: 0.85em;
  color: #666;
  flex-shrink: 0;
  box-sizing: border-box; 
  display: flex;
  align-items: center; 
  justify-content: center;
}

.timeline-body {
  position: relative;
  width: 1440px; 
  background-image: linear-gradient(90deg, #eaeaea 1px, transparent 1px);
  background-size: 15px 100%; 
  min-height: 100%; 
}

.timeline-body.drag-over {
  background-color: #f0fdfa; 
  outline: 2px dashed var(--primary-color);
  outline-offset: -2px;
}

.staff-name {
  width: 100%; 
  height: 52px; 
  padding: 6px 15px;
  font-size: 0.9em;
  background: white;
  border-bottom: 1px solid #f0f0f0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.staff-name-row {
  font-weight: bold;
  color: var(--dark-gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.staff-skills {
  font-size: 0.8em;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-top: 3px;
}

.comment-indicator {
  display: inline-block;
  margin-left: 5px;
  cursor: help; 
  vertical-align: middle;
  width: 16px; 
  height: 16px; 
}
.comment-indicator svg {
  fill: var(--red); 
  width: 100%;
  height: 100%;
}

.confirmed-hours {
  font-weight: normal;
  color: #666;
}

.staff-row {
  height: 52px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

/* シフトバーのデザイン調整 */
.shift-bar {
  position: absolute;
  top: 11px;
  height: 30px;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  overflow: hidden;
  padding: 5px 8px;
  font-size: 0.8em;
  font-weight: bold;
  box-sizing: border-box;
  white-space: nowrap;
  transition: box-shadow 0.2s;
}
.shift-bar:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}
.shift-bar.request {
  background: rgba(255, 255, 255, 0.8);
  border: 2px dashed var(--secondary-color);
  color: #d1787c; /* ピンクの枠に合わせて文字も調整 */
  z-index: 1;
  cursor: grab; 
}
.shift-bar.confirmed {
  background: var(--primary-color);
  color: var(--dark-gray); /* ★ 視認性向上のためダークグレーに変更 */
  z-index: 2;
  cursor: grab; 
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #94cabd; /* 少しだけ濃い枠線で引き締める */
}

.shift-bar-text {
  position: relative;
  z-index: 5; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 5px; 
}

.shift-bar .resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px; 
  z-index: 10; 
  cursor: ew-resize; 
  background: rgba(0,0,0,0.03); /* リサイズ部分をほんのり可視化 */
}
.shift-bar .resizer:hover {
  background: rgba(0,0,0,0.1);
}
.shift-bar .resizer.left { left: 0; }
.shift-bar .resizer.right { right: 0; }

.submit-note {
  font-size: 0.85em;
  color: #856404;
  background-color: #fff3cd;
  padding: 12px;
  border: 1px solid #ffeeba;
  border-radius: 8px;
  margin-bottom: 15px;
  line-height: 1.5;
  text-align: center;
}

/* スマホ用ハンバーガーボタン */
.mobile-menu-btn {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 4000; 
  background: #fff;
  color: var(--dark-gray);
  border: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2em;
  display: none; 
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
  .sidebar {
    transform: translateX(-100%); 
    transition: transform 0.3s ease;
    display: block !important; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content-wrapper.with-sidebar { margin-left: 0; }
}

/* 確定シフト表示モード */
.container.confirmed-mode {
  border: none;
  border-top: 4px solid var(--blue); 
  background-color: #fff;
}
.container.confirmed-mode .header h2 { color: var(--blue); }
.container.confirmed-mode .calendar-day {
  background-color: #fff;
  border-color: #e2e8f0;
}
.container.confirmed-mode .shift-info {
  color: #fff;
  background: var(--blue);
}
.container.confirmed-mode .day-checkbox { display: none; }
.confirmed-message-area {
  display: none; 
  background-color: #e6f2ff;
  color: #0056b3;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.95em;
  border: 1px solid #b8daff;
  line-height: 1.5;
}

/* ボトムナビ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 65px;
  background-color: #fff;
  border-top: 1px solid #eaeaea;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 4000; 
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav-item {
  flex-grow: 1;
  text-align: center;
  background: none;
  border: none;
  font-size: 0.85em;
  font-weight: bold;
  color: #999;
  padding: 10px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  transition: all 0.2s;
}
.bottom-nav-item:hover {
  background: #fafafa;
}
.bottom-nav-icon {
  font-size: 1.4em;
  margin-bottom: 4px;
  display: block;
}
.bottom-nav-item.active {
  color: var(--primary-color);
  background-color: #f4fcfa; 
  border-top: 3px solid var(--primary-color);
}
.bottom-nav-item#nav-btn-confirmed.active {
  color: var(--blue);
  background-color: #f0f8ff;
  border-top: 3px solid var(--blue);
}
body.has-bottom-nav { padding-bottom: 80px; }

body.user-mode .mobile-menu-btn { display: none !important; }
body.user-mode #admin-sidebar,
body.user-mode #admin-selector-container,
body.user-mode #shift-create-panel,
body.user-mode #shift-creation-container,
body.user-mode #print-section {
    display: none !important;
}

/* 印刷操作パネル */
.print-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}
.print-controls input[type="date"],
.print-controls select {
  padding: 6px 10px;
  font-size: 1em;
  border: 1px solid var(--gray);
  border-radius: 4px;
}
.print-controls button {
  padding: 8px 18px;
  font-size: 1em;
}
#btn-print-execute {
  background: var(--dark-gray);
  color: white;
  margin-left: auto; 
}

/* --- 印刷プレビューエリア --- */
#print-preview-area {
  background: white;
  padding: 30px;
  min-height: 500px;
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}
.print-page-title {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 20px;
  color: var(--dark-gray);
  border-bottom: 3px solid var(--primary-color);
  padding-bottom: 10px;
}

.print-table-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
  gap: 15px;
  width: 100%;
}
.print-date-block {
  border: 1px solid #eaeaea;
  border-radius: 8px;
  background-color: #fff;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.print-date-header {
  background-color: #f8f9fa;
  padding: 8px 12px;
  font-weight: bold;
  border-bottom: 1px solid #eaeaea;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.print-date-header.saturday { color: #0056b3; background-color: #f0f7ff; }
.print-date-header.sunday { color: #c82333; background-color: #fff0f0; }

.print-shift-table {
  width: 100%;
  border-collapse: collapse;
}
.print-shift-table tr:nth-child(even) { background-color: #fafafa; }
.print-shift-table td {
  border-bottom: 1px dashed #eee;
  padding: 6px 8px;
  font-size: 0.9em;
}
.print-name-col {
  width: 45%;
  text-align: left;
  word-break: break-all; 
  font-weight: 500;
}
.print-time-col {
  width: 55%;
  text-align: right;
  color: #555;
  letter-spacing: 0.5px;
}

/* タイムライン印刷形式用 */
.print-timeline-wrapper {
  display: flex;
  flex-direction: column;
  gap: 40px; 
}
.print-timeline-day-block {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  page-break-inside: avoid; 
}
.print-timeline-header {
  background: var(--primary-color);
  color: var(--dark-gray);
  padding: 10px 15px;
  font-weight: bold;
  font-size: 1.2em;
}
.print-timeline-grid {
  position: relative;
  width: 100%;
  overflow-x: auto;
}
.print-timeline-time-axis {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}
.print-timeline-time-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: #777;
  padding: 4px 0;
  border-left: 1px solid #eee;
}
.print-timeline-rows {
  position: relative;
  background-image: linear-gradient(90deg, #f4f4f4 1px, transparent 1px);
}
.print-timeline-row {
  height: 32px;
  border-bottom: 1px dashed #eee;
  position: relative;
  display: flex;
  align-items: center;
}
.print-timeline-name {
  position: absolute;
  left: 8px;
  font-size: 11px;
  font-weight: bold;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  padding: 2px 6px;
  border-radius: 4px;
}
.print-timeline-bar {
  position: absolute;
  height: 22px;
  background-color: var(--primary-color); 
  color: var(--dark-gray);
  font-weight: bold;
  font-size: 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid #94cabd;
}

/* 折りたたみ機能 */
.collapse-icon {
  display: inline-block;
  margin-right: 8px;
  font-size: 0.8em;
  color: #888;
  transition: transform 0.3s; 
}
.shift-section.collapsed {
  flex-grow: 0 !important;
  flex-basis: auto !important;
}
.shift-section.collapsed .section-body {
  display: none !important;
}
.shift-section.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

/* 追加: リスト内蔵型のスタッフ追加ボタン */
.btn-inline-add-staff {
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 6px;
  border: 2px dashed var(--blue);
  background: #f0f8ff;
  color: var(--blue);
  font-weight: bold;
  font-size: 0.85em;
  transition: all 0.2s;
}
.btn-inline-add-staff:hover {
  background: #e6f2ff;
  border-color: #0056b3;
}

/* =============== 印刷時の設定 (@media print) =============== */
@media print {
  @page { size: A4 portrait; margin: 5mm; }

  body {
    background: white !important;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    color: black !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-size: 9px !important;
  }

  .sidebar, .mobile-menu-btn, .print-controls, .creation-header,
  .container, #shift-creation-container, .bottom-nav, .modal-overlay,
  #admin-selector-container, .admin-message, .submit-button-container {
    display: none !important;
  }

  .main-content-wrapper {
    margin: 0 !important; padding: 0 !important; width: 100% !important;
    max-width: none !important; box-shadow: none !important;
    position: static !important; background: transparent !important;
  }

  #print-section {
    position: relative !important;
    width: 100%;
    max-width: 1200px;
    margin: 10px auto;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 20px;
    box-sizing: border-box; /* paddingを含めた幅計算にする */
  }

  #print-preview-area {
    padding: 0 !important; margin: 0 !important; border: none !important;
    width: 100% !important; overflow: visible !important; box-shadow: none !important;
  }

  .print-table-wrapper {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .print-date-block {
    width: auto !important; margin: 0 !important;
    page-break-inside: avoid !important; break-inside: avoid !important;
    background-color: #fff !important; border: 1px solid #000 !important;
    border-radius: 0 !important;
  }

  .print-date-header {
    background-color: #e0e0e0 !important; color: black !important;
    border-bottom: 1px solid #000 !important; padding: 2px !important;
    font-size: 10px !important;
  }
  
  .print-shift-table {
    width: 100% !important; table-layout: fixed !important; border-collapse: collapse;
  }
  .print-shift-table td {
    border: 1px solid #ccc !important; padding: 2px !important;
    font-size: 9px !important; line-height: 1.2;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
  }
  
  .print-name-col { width: 40% !important; text-align: left; }
  .print-time-col { width: 60% !important; text-align: right; }

  .print-page-title {
    font-size: 16px !important; margin-bottom: 5mm !important; border: none !important;
    color: black !important; text-align: left !important; width: 100% !important;
  }

  /* タイムラインの印刷補正 */
  .print-timeline-header { background-color: #e0e0e0 !important; color: black !important; border-bottom: 1px solid #000 !important;}
  .print-timeline-bar { background-color: #ddd !important; border: 1px solid #000 !important; color: black !important;}
}

/* ★ 追加: 休憩時間と詳細ボタンのデザイン */
.btn-edit-detail {
  background: none;
  border: 1px solid #ccc;
  color: #555;
  font-size: 0.75em;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.2s;
}
.btn-edit-detail:hover {
  background: #f0f0f0;
  border-color: #aaa;
}

/* タイムライン上の休憩ブロック（斜線でくり抜かれたように見せる） */
.break-visual {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.7) 5px,
    rgba(200, 200, 200, 0.5) 5px,
    rgba(200, 200, 200, 0.5) 10px
  );
  z-index: 4; /* テキストより下、背景より上 */
  border-left: 1px solid rgba(0,0,0,0.1);
  border-right: 1px solid rgba(0,0,0,0.1);
}

/* ★ 追加: 元の時間を示すプレースホルダー（破線枠） */
.shift-bar-original {
  position: absolute;
  top: 11px; /* シフトバーと同じ高さ */
  height: 30px;
  border: 2px dashed #bbb; /* グレーの破線 */
  border-radius: 6px;
  box-sizing: border-box;
  pointer-events: none; /* マウス操作を貫通させる（ドラッグの邪魔にならない） */
  z-index: 1; /* 本物のバーより下に敷く */
  background: rgba(0, 0, 0, 0.02); /* ほんの少しだけ色をつける */
}

/* =========================================
   ★ 修正: 詳細・休憩モーダルのサイズ最適化
   ========================================= */
/* 要素が多い詳細モーダルのみ、最大幅を拡張（7インチタブレット対応） */
#edit-shift-modal .modal-content {
  max-width: 550px; 
}

/* プルダウンが1行に4つ並んでも潰れないように調整 */
.time-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap; /* 折り返しを防ぐ */
}

.time-inputs select {
  width: auto !important; /* 既存の 50% 指定を強制解除 */
  flex-grow: 1;
  min-width: 65px; /* 文字と矢印が被らない最低限の幅を確保 */
  padding-left: 8px !important;
  padding-right: 24px !important; /* 矢印アイコン用のスペース */
  text-align: center; /* タップしやすいように数字を中央に */
  font-size: 1.05em; /* タブレットでタップしやすい文字サイズ */
}

.time-inputs label {
  margin: 0;
  white-space: nowrap; /* 「時」「分」が絶対に改行されないようにする */
  font-size: 0.95em;
}

/* 「〜」の記号も改行させない */
.time-inputs span {
  white-space: nowrap;
}

/* スマホなど極端に狭い画面用（念のための安全装置） */
@media (max-width: 480px) {
  .time-inputs {
    gap: 4px;
  }
  .time-inputs select {
    min-width: 55px;
    padding-left: 4px !important;
    padding-right: 20px !important;
  }
}

/* =========================================
   印刷画面：日付ヘッダーのカラー変更
   ========================================= */
.print-timeline-header,
.print-date-header {
  /* サイドバーの色味に近い、落ち着いたダークグレー */
  background-color: #3f4e62 !important; 
  color: #ffffff !important; /* 文字を白にして読みやすく */
  font-weight: bold;
  border-bottom: none !important; /* 元の枠線があれば消す */
}

/* =========================================
   修正: タイムラインヘッダーのスクロール同期
   ========================================= */
.timeline-header-wrapper {
  overflow-x: hidden; /* スクロールバーは非表示にしつつ、JSからのスクロールを許可する */
  width: 100%;
}

/* =========================================
   印刷画面：表形式（スタッフ別期間一覧）
   ========================================= */
.print-matrix-wrapper {
  overflow-x: auto; 
  margin-top: 15px;
}
.print-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px; /* 日数が多い場合でも収まるサイズ */
  min-width: 800px;
}
.print-matrix-table th, 
.print-matrix-table td {
  border: 1px solid #777; /* ハッキリとした罫線 */
  padding: 6px 3px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.3;
}
.print-matrix-table th {
  background-color: #f0f0f0;
  font-weight: normal;
}
.matrix-th-name {
  min-width: 90px;
  font-weight: bold !important;
  background-color: #e2e8f0 !important;
}
.matrix-td-name {
  text-align: left !important;
  padding-left: 8px !important;
  font-weight: bold;
  white-space: nowrap;
}
/* シフトが入っているセルの背景色（写真のような薄い青） */
.matrix-shift-active {
  background-color: #eef7fa; 
  font-weight: 500;
}

/* =========================================
   人数カウント（ヒートマップ風）
   ========================================= */
.headcount-cell {
  height: 100%;
  border-right: 1px dashed #eee;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: #555;
}
/* 人数によって色を濃くする */
.headcount-cell[data-count="0"] { color: transparent; }
.headcount-cell[data-count="1"] { background: #e0f2f1; }
.headcount-cell[data-count="2"] { background: #b2dfdb; }
.headcount-cell[data-count="3"] { background: #80cbc4; }
.headcount-cell[data-count="4"] { background: #4db6ac; color: white; }
.headcount-cell[data-count="5"] { background: #26a69a; color: white; }

/* =========================================
   スタッフ詳細ツールチップ（ホバー時）
   ========================================= */
.staff-name-row {
  position: relative;
  cursor: help;
}
.staff-tooltip {
  visibility: hidden;
  position: absolute;
  top: 100%;
  left: 0;
  background: #333;
  color: #fff;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  width: 200px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  white-space: normal;
}
.staff-name-row:hover .staff-tooltip {
  visibility: visible;
  opacity: 1;
}

/* =========================================
   追加: サイドバー折りたたみ機能
   ========================================= */
.sidebar {
  transition: transform 0.3s ease; /* スライドアニメーション */
}
.sidebar-toggle-btn {
  position: absolute;
  top: 15px;
  right: -30px; /* サイドバーの外側に飛び出させる */
  width: 30px;
  height: 40px;
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 5px rgba(0,0,0,0.2);
}
.sidebar-toggle-btn:hover {
  background: #34495e;
}
/* 折りたたみ時の状態 */
.sidebar.collapsed {
  transform: translateX(-100%); /* 画面の左外に隠す */
}
.main-content-wrapper {
  transition: margin-left 0.3s ease;
}
/* メインコンテンツの左マージンを消して画面を広げる */
.main-content-wrapper.with-sidebar.collapsed-main {
  margin-left: 0 !important;
}

/* =========================================
   予算・実績入力画面
   ========================================= */
.budget-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  min-width: 600px;
}
.budget-table th, .budget-table td {
  border: 1px solid #ddd;
  padding: 8px;
}
.budget-table th {
  background-color: #f8f9fa;
  color: #333;
  font-weight: bold;
  text-align: center;
}
.budget-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid transparent;
  text-align: right;
  font-size: 1em;
  border-radius: 4px;
}
.budget-input:focus {
  border: 1px solid var(--primary-color);
  outline: none;
  background-color: #f4fcfa;
}
.budget-input.bg-light {
  background-color: #fdfdfd;
}

.headcount-row > div {
    background-color: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    /* ペチャンコになる原因だった flex 指定を削除しました */
}

/* 人数が1人以上いる時間帯だけ、強制的にオレンジ色にする */
.headcount-row > div:not(:empty),
.headcount-row > div[style*="background-color"] {
    background-color: #ffe082 !important; 
    color: #d84315 !important; 
    font-weight: bold !important;
    border-radius: 2px;
}

.timeline-header, 
.timeline-body, 
.headcount-row {
    /* 中身（時間枠）の幅にピッタリ合わせ、無駄な余白を作らない */
    width: max-content !important;
    min-width: 100%;
}

#hall-staff-names::before,
#kitchen-staff-names::before {
    content: "時間別 人数";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 27px;
    min-height: 27px;
    box-sizing: border-box;
    border-bottom: 2px solid #ccc;
    background: #fdfdfd;
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
    /* 縦スクロール時に上部にピタッと固定 */
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 右側のオレンジ行（人数）も、縦スクロール時に上部にピタッと固定させる */
#hall-headcount-row,
#kitchen-headcount-row {
    position: sticky !important;
    top: 0;
    z-index: 10;
}
