/* ==========================================================================
   手打ちそば・うどん 郷ごころ｜週間シフト作成・管理アプリ スタイルシート
   ========================================================================== */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-alt: #faf8f4;
  --border: #e2dcd0;
  --border-strong: #cfc7b8;
  --text: #2c2520;
  --text-muted: #6e655c;
  --primary: #8b4513;
  --primary-hover: #70360d;
  --primary-soft: #f5ebe1;
  --secondary: #3b5249;
  --secondary-hover: #2c3e37;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warning: #b9770e;
  --warning-soft: #fef5e7;
  --sat-bg: #eef5fc;
  --sat-text: #1f5f99;
  --sun-bg: #fdf0ef;
  --sun-text: #b83227;
  --closed-bg: #eceae5;
  --closed-text: #8c847b;
  --dayonly-bg: #fff8eb;
  --dayonly-text: #9c640c;

  /* セルバッジカラー */
  --badge-rest-bg: #f1f0ec;
  --badge-rest-text: #7d756d;
  --badge-off-bg: #fdeeee;
  --badge-off-text: #c0392b;
  --badge-day-bg: #fff0db;
  --badge-day-text: #b35900;
  --badge-day-border: #f3c88c;
  --badge-night-bg: #e6f0fc;
  --badge-night-text: #1b5ea8;
  --badge-night-border: #a6cbf2;
  --badge-both-bg: #e4f5ea;
  --badge-both-text: #1d6f42;
  --badge-both-border: #9bd6b2;

  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(44, 37, 32, 0.06);
  --shadow-md: 0 4px 14px rgba(44, 37, 32, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- パスワードロック画面 ---------- */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}

.auth-brand {
  text-align: center;
  margin-bottom: 20px;
}

.auth-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 6px;
}

.auth-brand h2 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--primary);
}

.auth-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.auth-label input {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 15px;
  outline: none;
}

.auth-label input:focus {
  border-color: var(--primary);
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}

.pin-input {
  text-align: center;
  font-size: 24px !important;
  font-weight: 800;
  letter-spacing: 0.45em;
  padding-left: 0.45em !important;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pin-key {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
}

.pin-key:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.pin-key:active:not(:disabled) {
  transform: scale(0.97);
}

.pin-key:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pin-key-sub {
  font-size: 15px;
  color: var(--text-muted);
}

.auth-submit-btn {
  padding: 10px 14px;
  font-size: 14px;
}

/* ---------- レイアウト ---------- */
.app-shell[hidden] {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
  line-height: 1;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.brand-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #e4cbb2;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.app-main {
  flex: 1;
  padding: 16px 20px 28px;
  max-width: 1420px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---------- ボタン ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12.5px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--surface-alt);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #e7b3ae;
}

.btn-danger-outline:hover {
  background: var(--danger-soft);
}

.file-label {
  margin: 0;
}

/* ---------- 操作バー ---------- */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.week-range-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  padding: 0 4px;
  white-space: nowrap;
}

/* ---------- 月間カレンダーパネル ---------- */
.calendar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.calendar-panel[hidden] {
  display: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.calendar-month-label {
  font-size: 14.5px;
  min-width: 90px;
  text-align: center;
}

.calendar-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.month-calendar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.month-calendar-table th,
.month-calendar-table td {
  border: 1px solid var(--border);
  padding: 4px 5px;
  text-align: center;
}

.month-calendar-table thead th {
  background: var(--surface-alt);
  font-weight: 700;
}

.month-calendar-table thead th.th-sat {
  background: var(--sat-bg);
  color: var(--sat-text);
}

.month-calendar-table thead th.th-sun {
  background: var(--sun-bg);
  color: var(--sun-text);
}

.cal-week-col {
  width: 66px;
}

.cal-week-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

.cal-week-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cal-week-row.is-active-week td {
  box-shadow: inset 0 2px 0 var(--primary), inset 0 -2px 0 var(--primary);
}

.cal-week-row.is-active-week .cal-week-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.cal-day-cell {
  cursor: pointer;
  transition: background 0.12s;
}

.cal-day-cell:hover {
  background: #faf6ef;
}

.cal-day-cell.cal-closed {
  background: var(--closed-bg);
  color: var(--closed-text);
}

.cal-day-cell.cal-day_only {
  background: var(--dayonly-bg);
  color: var(--dayonly-text);
}

.cal-day-num {
  font-weight: 700;
  margin-right: 4px;
}

.cal-day-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
}

.cal-day-tag.tag-closed {
  background: #dcd8d0;
  color: #554e47;
}

.cal-day-tag.tag-day_only {
  background: #fdebd0;
  color: #935116;
}

.cal-day-tag.tag-full {
  color: #266041;
}

/* ---------- 週間シフト表 ---------- */
.shift-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.weekly-shift-table {
  width: 100%;
  min-width: 1020px;
  border-collapse: collapse;
  table-layout: fixed;
}

.weekly-shift-table th,
.weekly-shift-table td {
  border: 1px solid var(--border);
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
}

/* 左端スタッフ列 */
.weekly-shift-table .col-staff {
  width: 160px;
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-alt);
}

/* 曜日ヘッダー */
.weekly-shift-table thead th {
  background: var(--surface-alt);
  font-weight: 700;
  padding: 8px 6px;
}

.weekly-shift-table thead th.th-sat {
  background: var(--sat-bg);
  color: var(--sat-text);
}

.weekly-shift-table thead th.th-sun {
  background: var(--sun-bg);
  color: var(--sun-text);
}

.weekly-shift-table thead th.th-closed {
  background: var(--closed-bg);
  color: var(--closed-text);
}

.weekly-shift-table thead th.th-dayonly {
  background: var(--dayonly-bg);
  color: var(--dayonly-text);
}

.day-header-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.day-label {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.day-date-sub {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}

.day-status-toggle {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.35;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.day-status-toggle:hover {
  background: #ffffff;
  border-color: var(--primary);
}

.day-status-toggle.status-closed {
  background: #e1ded7;
  color: #5c554e;
  border-color: #c8c2b8;
}

.day-status-toggle.status-day_only {
  background: #fdebd0;
  color: #935116;
  border-color: #e5b97b;
}

.day-status-toggle.status-full {
  background: #eef6f0;
  color: #266041;
  border-color: #b4d8be;
}

/* 左端スタッフ名＆役割バッジ1つ＋連絡用テキストボタン */
.staff-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.staff-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.btn-contact-msg {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-contact-msg:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.staff-name-text {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.role-kitchen {
  background: #f5ebe1;
  color: #8b4513;
}

.role-hall {
  background: #e6f2ec;
  color: #235c43;
}

.role-both {
  background: #edeaf8;
  color: #4f3a8f;
}

.role-rookie {
  background: #fff1d6;
  color: #a65c00;
  border: 1px solid #ecc67f;
}

/* セル本体（ゆとりのあるサイズ） */
.shift-cell {
  padding: 10px 8px !important;
  height: 84px;
  transition: background 0.12s;
}

.shift-cell.cell-closed {
  background: var(--closed-bg);
  color: var(--closed-text);
}

.closed-dash {
  font-size: 13px;
  font-weight: 600;
  color: var(--closed-text);
}

.shift-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 136px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
  border: 1px solid transparent;
  user-select: none;
}

.shift-badge-off {
  background: var(--badge-off-bg);
  color: var(--badge-off-text);
  border-color: #f3c6c2;
}

.manual-cell-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.off-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  max-width: 124px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: pre-line;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.off-chip:hover {
  background: #f0eee8;
  border-color: var(--border-strong);
  color: var(--text);
}

.off-chip.is-open {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.18);
}

.off-chip.off-val-rest {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
}

.off-chip.off-val-working {
  background: #f6f4ef;
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
}

.off-chip.off-val-off,
.off-chip.off-val-off_day,
.off-chip.off-val-off_night {
  color: var(--danger);
  border-color: #e7b3ae;
  background: #fff8f8;
  font-weight: 800;
}

.slot-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 6px;
  width: 100%;
  max-width: 128px;
}

.slot-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

button.slot-chip:hover {
  background: #f0eee8;
  border-color: var(--border-strong);
  color: var(--text);
}

button.slot-chip.is-open {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.18);
  color: var(--text);
}

.slot-chip.is-active {
  background: #f6f4ef;
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 800;
}

.slot-chip-time {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.slot-chip.slot-chip-off {
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 800;
  cursor: default;
  padding: 4px 8px;
}

.slot-popover {
  position: fixed;
  z-index: 1500;
  min-width: 132px;
  max-height: 290px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.slot-popover-title {
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted);
  background: #faf9f6;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.slot-popover-list {
  display: flex;
  flex-direction: column;
  padding: 4px;
  overflow-y: auto;
}

.slot-popover-item {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}

.slot-popover-item:hover {
  background: #f2efe9;
}

.slot-popover-item.kind-rest {
  color: var(--text-muted);
}

.slot-popover-item.kind-off {
  color: var(--danger);
}

.slot-popover-item.is-selected {
  background: #efe7de;
  color: var(--primary);
  font-weight: 800;
}

.slot-popover-item.is-selected::after {
  content: '✓';
  font-size: 12px;
  font-weight: 800;
}

.btn-quick-rest {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-quick-rest:hover:not(:disabled) {
  background: var(--badge-rest-bg);
  color: var(--text);
  border-color: var(--primary);
}

.btn-quick-rest:disabled {
  opacity: 0.35;
  cursor: default;
}

/* フッター（昼：〇/〇名、夜：〇/〇名 + ⚠️のみ） */
.weekly-shift-table tfoot td {
  background: var(--surface-alt);
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 700;
}

.weekly-shift-table tfoot td.foot-closed {
  background: var(--closed-bg);
  color: var(--closed-text);
}

.foot-count-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.foot-count-short {
  color: var(--danger);
}

.foot-warn-icon {
  appearance: none;
  border: none;
  background: transparent;
  padding: 1px 3px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.12s, background 0.12s;
}

.foot-warn-icon:hover,
.foot-warn-icon.is-open {
  background: #fdebd0;
  transform: scale(1.1);
}

.warn-popover {
  position: fixed;
  z-index: 1550;
  min-width: 210px;
  max-width: 310px;
  background: var(--surface);
  border: 1px solid #e7b3ae;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  pointer-events: none;
}

.warn-popover-header {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  color: #a52c20;
  background: #fff5f5;
  border-bottom: 1px solid #f3d5d2;
}

.warn-popover-list {
  margin: 0;
  padding: 8px 12px 10px 26px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.warn-popover-list li + li {
  margin-top: 3px;
}

/* ---------- カード・テーブル（スタッフ・設定タブ） ---------- */
.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 700;
}

.panel-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.sub-section-header {
  margin-top: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.data-table thead th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 12px;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.text-right {
  text-align: right !important;
}

.rank-stars {
  color: #c87f0a;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* 相性NGフォーム */
.ng-card {
  padding: 14px;
}

.ng-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ng-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.ng-field select {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  min-width: 170px;
}

.ng-x {
  font-weight: 700;
  font-size: 15px;
  color: var(--danger);
  padding-bottom: 7px;
}

/* 設定テーブル */
.setting-card {
  padding: 16px;
}

.setting-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.setting-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.req-table {
  width: 100%;
  border-collapse: collapse;
}

.req-table th,
.req-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}

.req-table thead th {
  background: var(--surface-alt);
  font-size: 12.5px;
}

.req-table input[type="number"] {
  width: 64px;
  padding: 5px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
}

.req-group {
  font-weight: 700;
  background: var(--surface-alt);
}

.password-setting-card {
  margin-top: 16px;
}

.password-change-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.password-change-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.password-change-form input {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13.5px;
}

.weekend-label {
  color: var(--sun-text);
  background: var(--sun-bg);
}

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 16, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
}

.required {
  color: var(--danger);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

/* ---------- トースト ---------- */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #2c2520;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: 340px;
}

.toast-success {
  background: #225d3c;
}

.toast-warning {
  background: #9a5d07;
}

.toast-error {
  background: #a52c20;
}

/* ---------- 連絡用テキストモーダル ---------- */
.modal-wide {
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.contact-week-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.contact-cards-list {
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.contact-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.contact-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-days-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}

.contact-textarea {
  width: 100%;
  min-height: 210px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
}

.btn-copy-msg.is-copied {
  background: #1d6f42;
  color: #fff;
  border-color: #1d6f42;
}

.contact-modal-footer {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border);
}

/* ---------- 印刷用CSS ---------- */
.print-only {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
    font-size: 11px;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .print-header h2 {
    margin: 0 0 8px;
    font-size: 15px;
  }

  .app-main {
    padding: 0;
    max-width: none;
  }

  .shift-table-wrap {
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  .weekly-shift-table {
    min-width: 0;
  }

  .day-status-toggle {
    border: none;
    background: transparent !important;
    padding: 0;
  }
}

/* ---------- 試作品：シフト傾向学習UI ---------- */
.proto-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
  background: #edeaf8;
  color: #4b3994;
  border: 1px solid #d2caee;
  vertical-align: middle;
}

.btn-learn {
  background: #f5f2fc;
  color: #4b3994;
  border: 1px solid #c6bce8;
  font-weight: 700;
}

.btn-learn:hover {
  background: #ebe4fa;
  border-color: #9e8fd6;
}

.btn-learn.is-learned {
  background: #e6f4ea;
  color: #1e6f3d;
  border-color: #a9d9b8;
}

.learn-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.learning-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.learn-mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.learned-weeks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.learned-week-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.learned-week-item.is-current-week {
  border-color: var(--primary);
  background: #fbf8f3;
}

.learned-week-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.learned-week-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.learned-current-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #efe7de;
  color: var(--primary);
}

.learned-week-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.learn-empty-box {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.pair-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.pair-synergy-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 13px;
}

.pair-rank {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--primary);
}

.pair-names {
  font-weight: 700;
  flex: 1;
}

.pair-count-badge {
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e6f4ea;
  color: #1e6f3d;
}

.pace-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-chip-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.slot-rate-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.slot-rate-chip.slot-rate-high {
  background: #efe7de;
  border-color: #d6c3ae;
  color: #5c3a1d;
  font-weight: 800;
}

.slot-rate-chip.slot-rate-mid {
  background: #f6f4ef;
  border-color: var(--border-strong);
  color: var(--text);
}

.habit-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.habit-tag.habit-both {
  background: #edeaf8;
  color: #4b3994;
}

.habit-tag.habit-time {
  background: #fff4e0;
  color: #965a00;
  border: 1px solid #f0d49e;
}

.habit-tag.habit-muted {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.season-trigger-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.season-trigger-btn:hover {
  filter: brightness(0.97);
}

.season-trigger-btn.is-open {
  box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.22);
}

.season-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.season-busy {
  background: #fff0ed;
  color: #b42b1d;
  border: 1px solid #f0b8b1;
}

.season-normal {
  background: #ebf7ee;
  color: #1d6b38;
  border: 1px solid #b3dec0;
}

.season-quiet {
  background: #edf4fc;
  color: #1f5692;
  border: 1px solid #b5d0ef;
}

.season-compare-card {
  margin-bottom: 18px;
}

.season-compare-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.season-compare-header h3 {
  margin: 0 0 4px;
}

.season-compare-header .setting-hint {
  margin: 0;
}

.season-compare-table th,
.season-compare-table td {
  vertical-align: middle;
}

/* ---------- Cloudflare KV 同期UI ---------- */
.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  white-space: nowrap;
}

.sync-status-badge.sync-synced {
  background: #ebf7ee;
  color: #1d6b38;
  border-color: #b3dec0;
}

.sync-status-badge.sync-saving {
  background: #fff4e0;
  color: #965a00;
  border-color: #f0d49e;
}

.sync-status-badge.sync-conflict,
.sync-status-badge.sync-error {
  background: #fff0ed;
  color: #b42b1d;
  border-color: #f0b8b1;
}

.conflict-desc {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}
