:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #dde1e6;
  --text: #232830;
  --muted: #6b7280;
  --accent: #2563eb;

  /* メニューカテゴリの配色（0番目＝一番上のカテゴリ）。予約表のカテゴリ色と設定画面のスウォッチで共有 */
  --cat-color-0-bg: #fce7f3; --cat-color-0-border: #ec4899;
  --cat-color-1-bg: #ede9fe; --cat-color-1-border: #8b5cf6;
  --cat-color-2-bg: #ccfbf1; --cat-color-2-border: #14b8a6;
  --cat-color-3-bg: #ffedd5; --cat-color-3-border: #f97316;
  --cat-color-4-bg: #fef3c7; --cat-color-4-border: #f59e0b;
  --cat-color-5-bg: #e0e7ff; --cat-color-5-border: #6366f1;
  --cat-color-6-bg: #cffafe; --cat-color-6-border: #06b6d4;
  --cat-color-7-bg: #ecfccb; --cat-color-7-border: #84cc16;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
header nav { display: flex; gap: 8px; }
header nav a {
  padding: 8px 18px;
  border-radius: 8px;
  color: var(--muted);
  background: #eef1f5;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
header nav a:hover { background: #e2e7ee; }
header nav a.current { color: #fff; background: var(--accent); }
header nav a.header-logout-link { margin-left: auto; }
main { max-width: 900px; margin: 24px auto; padding: 0 16px; }
main.schedule-main { max-width: 1100px; }

.search-form { margin-bottom: 20px; }
.search-form input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.search-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 4px 32px;
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}
.search-col {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  row-gap: 6px;
  column-gap: 10px;
}
.search-col label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.two-inputs { display: flex; align-items: center; gap: 4px; width: 100%; }
.two-inputs input, .two-inputs select { flex: 1; min-width: 0; width: 100%; box-sizing: border-box; }
.two-inputs label { flex: 1; min-width: 0; }
.range-sep { font-size: 11px; color: var(--muted); white-space: nowrap; }
.search-col select {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.search-form button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.patient-list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; }
.patient-list th, .patient-list td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.patient-list th { background: #eef1f5; color: var(--muted); font-weight: 600; }
.patient-list a { color: var(--accent); text-decoration: none; }
.empty { color: var(--muted); text-align: center; padding: 24px !important; }

.table-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.table-pagination a, .table-pagination .disabled { color: var(--accent); text-decoration: none; font-weight: 600; }
.table-pagination .disabled { color: var(--border); }
.table-pagination .pagination-info { color: var(--muted); font-size: 14px; }
.table-pagination .pagination-middle { display: flex; align-items: center; gap: 12px; }

.page-size-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

.patient-id { color: var(--muted); font-weight: normal; font-size: 15px; }

.profile-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}
.profile-box h3 {
  margin: 0;
  padding: 10px 16px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 14px;
}
.profile-box h3.with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.profile-box h3.with-action .btn-edit {
  padding: 4px 12px;
  font-size: 12px;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
}
.profile-item {
  background: var(--card);
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
}
.profile-item.full { grid-column: 1 / -1; }
.profile-item .label { color: var(--muted); min-width: 100px; flex-shrink: 0; }
.profile-item .value { word-break: break-word; }
.profile-item .value a { color: var(--accent); text-decoration: none; }

.record {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
}
.record summary {
  cursor: pointer;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; color: #fff; text-decoration: none; display: inline-block; }
.badge-karte { background: #2563eb; }
.badge-case_report { background: #16a34a; }
.badge-status-replied { background: #16a34a; }
.badge-status-booked { background: #f59e0b; }
.badge-status-visited { background: #2563eb; }
.badge-status-lost { background: #dc2626; }
.badge-status-other { background: #6b7280; }

/* 問合せ一覧の絞り込みタブ：外枠をステータスバッジと同じ色にする（選択中はその色で塗りつぶす） */
.view-tabs a.tab-status-replied { border: 2px solid #16a34a; }
.view-tabs a.tab-status-booked { border: 2px solid #f59e0b; }
.view-tabs a.tab-status-visited { border: 2px solid #2563eb; }
.view-tabs a.tab-status-lost { border: 2px solid #dc2626; }
.view-tabs a.tab-status-other { border: 2px solid #6b7280; }
.view-tabs a.tab-status-replied.current { background: #16a34a; }
.view-tabs a.tab-status-booked.current { background: #f59e0b; }
.view-tabs a.tab-status-visited.current { background: #2563eb; }
.view-tabs a.tab-status-lost.current { background: #dc2626; }
.view-tabs a.tab-status-other.current { background: #6b7280; }
.record summary .badge { font-size: 14px; padding: 10px 20px; border-radius: 6px; }
a.badge, .patient-list a.badge { color: #fff; }
.patient-status-badge { background: #6b7280; }
.patient-status-badge.status-優良 { background: #2f9e44; }
.patient-status-badge.status-通院中 { background: #2563eb; }
.patient-status-badge.status-休眠 { background: #9ca3af; }
.patient-status-badge.status-卒業 { background: #7c3aed; }
.patient-status-badge.status-離脱 { background: #dc2626; }
.clinic, .staff { color: var(--muted); font-size: 13px; }
.record-body { margin-top: 12px; }
.content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.soap-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.soap-box h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--accent);
}
.soap-box .content { max-height: 320px; }
.soap-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.soap-edit-form textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  background: #fafbfc;
  box-sizing: border-box;
}
.soap-edit-form button {
  align-self: flex-end;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.notes-form {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notes-form label { font-size: 12px; color: var(--muted); }
.notes-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.notes-form button {
  align-self: flex-end;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.profile-actions {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.profile-actions-right { display: flex; gap: 10px; }

.schedule-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.schedule-nav a { color: var(--accent); text-decoration: none; }
.schedule-nav strong { font-size: 16px; }
.schedule-nav input[type="date"] {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

/* 日表示の日付ナビゲーション */
.day-nav-bar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  padding: 6px 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.day-nav-date { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 235px; }
.fy-toggle-label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; flex-basis: 100%; }
.fy-toggle-label input { width: auto; }
.day-nav-date input[type="date"],
.day-nav-date select {
  min-height: 40px;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}
.day-nav-date select { width: 110px; }
.day-nav-days { display: flex; align-items: stretch; gap: 4px; flex-wrap: wrap; }
.day-nav-week-btn {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 4px;
  background: #3fa9dc;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-sizing: border-box;
}
.day-nav-week-btn:hover { background: #2f92c2; }
.day-nav-week-btn.selected { background: #f0c419; color: #4a3b00; }
.day-nav-week-btn.selected:hover { background: #f0c419; }
.day-nav-today-btn { margin-left: 36px; }
.day-nav-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 40px;
  padding: 4px 0;
  border-radius: 4px;
  background: #3fa9dc;
  color: #fff;
  text-decoration: none;
  line-height: 1.2;
  box-sizing: border-box;
}
.day-nav-day-btn:hover { background: #2f92c2; }
.day-nav-day-btn.selected { background: #f0c419; color: #4a3b00; }
.day-nav-weekday { font-size: 11px; }
.day-nav-daynum { font-size: 15px; font-weight: 700; }

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.view-tabs a {
  padding: 8px 18px;
  border-radius: 8px;
  background: #eef1f5;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.view-tabs a:hover { background: #e2e7ee; }
.view-tabs a.current { color: #fff; background: var(--accent); }

.entry-tabs-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.entry-tabs { display: flex; gap: 10px; }
.entry-tab {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.entry-tab:hover { background: #e2e7ee; }
.entry-tab.current { color: #fff; background: var(--accent); }
#paste_appt_btn { padding: 12px 28px; font-size: 16px; border-radius: 8px; }

.staff-tabs { margin-top: 4px; }

.week-grid-table thead th a { color: var(--muted); text-decoration: none; }
.week-grid-table thead th a:hover { color: var(--accent); }
.week-grid-table .appt-cell { padding: 0; }

.sales-summary { margin-bottom: 20px; }
.sales-total-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 150px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
}
.sales-total-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.sales-total-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.sales-yearly-table .sales-bar-cell { width: 40%; }
.sales-bar { height: 14px; min-width: 2px; border-radius: 3px; background: var(--accent); }
.sales-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 20px;
}

.calendar-count { font-size: 13px; color: var(--muted); margin-top: 4px; }
.calendar-day-link { display: block; padding: 8px; color: inherit; text-decoration: none; height: 100%; }
.calendar-day-link:hover { background: #f5f7fa; }
.add-appt-btn {
  margin-left: auto;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff !important;
  border-radius: 6px;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  font-size: 12px;
  table-layout: fixed;
}
.schedule-table th, .schedule-table td {
  border: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
  height: 32px;
}
.schedule-table thead th {
  background: #eef1f5;
  color: var(--muted);
  padding: 8px 4px;
  font-size: 13px;
}
.schedule-table .time-col { width: 56px; }
.schedule-table .time-label {
  padding: 4px 6px;
  color: var(--muted);
  font-weight: normal;
  white-space: nowrap;
  vertical-align: top;
}
.schedule-table .empty-cell { height: 32px; text-align: center; }
.schedule-table .add-link {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 32px;
  color: var(--border);
  text-decoration: none;
  font-size: 14px;
  line-height: 32px;
}
.schedule-table .empty-cell:hover .add-link { color: var(--accent); background: #f0f5ff; }
.schedule-table .closed-cell { height: 32px; background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #eaecef 6px, #eaecef 12px); }

.closed-banner {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.month-calendar {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--card);
  margin-bottom: 16px;
}
.month-calendar th, .month-calendar td {
  border: 1px solid var(--border);
  vertical-align: top;
  padding: 6px;
}
.month-calendar thead th {
  background: #eef1f5;
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}
.month-calendar thead th.calendar-head-sat { background: #337ab7; color: #fff; }
.month-calendar thead th.calendar-head-sun { background: #d9534f; color: #fff; }
.top-weekly-table { table-layout: fixed; margin-bottom: 12px; }
.top-weekly-table th, .top-weekly-table td { text-align: center; }
.top-weekly-table th.calendar-date-sun { color: #d9534f; }
.top-weekly-table th.calendar-date-sat { color: #337ab7; }
.calendar-blank { background: #fafbfc; }
.calendar-date { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.calendar-date-sun { color: #d9534f; }
.calendar-date-sat { color: #337ab7; }
.calendar-cell .checkbox-label { font-size: 11px; gap: 4px; margin-bottom: 4px; }
.calendar-cell .checkbox-label input { width: auto; }
.calendar-time { display: flex; align-items: center; gap: 2px; }
.calendar-time select {
  width: 100%;
  padding: 2px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.calendar-clinic-closed { background: repeating-linear-gradient(45deg, #f9fafb, #f9fafb 6px, #f1f2f4 6px, #f1f2f4 12px); }
.calendar-note { font-size: 11px; color: var(--muted); }

.appt-block {
  height: 100%;
  padding: 4px 6px;
  background: #fff7e6;
  border-left: 3px solid #f0b429;
  display: block;
  color: inherit;
  text-decoration: none;
}
.appt-block.event-block { background: #eef1f5; border-left-color: #6b7280; }

/* メニューカテゴリ別の配色（各院のカテゴリ並び順の0番目から8色を順に割り当て。0番目＝一番上のカテゴリはピンク） */
.appt-block.category-color-0 { background: var(--cat-color-0-bg); border-left-color: var(--cat-color-0-border); }
.appt-block.category-color-1 { background: var(--cat-color-1-bg); border-left-color: var(--cat-color-1-border); }
.appt-block.category-color-2 { background: var(--cat-color-2-bg); border-left-color: var(--cat-color-2-border); }
.appt-block.category-color-3 { background: var(--cat-color-3-bg); border-left-color: var(--cat-color-3-border); }
.appt-block.category-color-4 { background: var(--cat-color-4-bg); border-left-color: var(--cat-color-4-border); }
.appt-block.category-color-5 { background: var(--cat-color-5-bg); border-left-color: var(--cat-color-5-border); }
.appt-block.category-color-6 { background: var(--cat-color-6-bg); border-left-color: var(--cat-color-6-border); }
.appt-block.category-color-7 { background: var(--cat-color-7-bg); border-left-color: var(--cat-color-7-border); }

/* 来店済みは何よりも優先してグレー（カテゴリ色より後に書いて上書きする） */
.appt-block.status-来店済 { background: #f4f4f5; border-left-color: #9ca3af; }

/* 設定画面のカテゴリ見出し横に表示する色スウォッチ */
.category-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
  border: 2px solid transparent;
}
.category-color-swatch.category-color-0 { background: var(--cat-color-0-bg); border-color: var(--cat-color-0-border); }
.category-color-swatch.category-color-1 { background: var(--cat-color-1-bg); border-color: var(--cat-color-1-border); }
.category-color-swatch.category-color-2 { background: var(--cat-color-2-bg); border-color: var(--cat-color-2-border); }
.category-color-swatch.category-color-3 { background: var(--cat-color-3-bg); border-color: var(--cat-color-3-border); }
.category-color-swatch.category-color-4 { background: var(--cat-color-4-bg); border-color: var(--cat-color-4-border); }
.category-color-swatch.category-color-5 { background: var(--cat-color-5-bg); border-color: var(--cat-color-5-border); }
.category-color-swatch.category-color-6 { background: var(--cat-color-6-bg); border-color: var(--cat-color-6-border); }
.category-color-swatch.category-color-7 { background: var(--cat-color-7-bg); border-color: var(--cat-color-7-border); }
.appt-block.status-キャンセル { background: #f4f4f5; border-left-color: #9ca3af; opacity: 0.7; }
.appt-edit-link { display: block; color: inherit; text-decoration: none; }
.appt-id { font-size: 11px; color: var(--muted); margin-right: 4px; }
.appt-error { color: #dc2626; font-weight: 700; }
.appt-name { font-weight: 600; font-size: 13px; }
.appt-menu { font-size: 11px; color: var(--muted); }
.appt-notes { font-size: 11px; color: var(--muted); }
.appt-karte-link { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--accent); }
.appt-block-group { height: 100%; display: flex; flex-direction: column; }
.appt-block-group-single { display: block; }
.appt-block-compact {
  flex: 1;
  height: auto;
  padding: 2px 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.appt-block-compact:last-child { border-bottom: none; }
.appt-block-compact .appt-name { font-size: 11px; }

.appt-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}
.appt-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.appt-form-wide { max-width: none; margin-bottom: 20px; }
.appt-form-row {
  display: flex;
  gap: 12px;
}
.appt-form-row label { flex: 1; }
.checkbox-row { display: flex; gap: 24px; flex-wrap: wrap; }
.checkbox-column { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.appt-form label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.appt-form label.checkbox-label input { width: auto; }
.status-form {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}
.status-form label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
}
.status-form label.checkbox-label input { width: auto; }
.appt-form input, .appt-form select, .appt-form textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.time-select-pair { display: inline-flex; align-items: center; gap: 4px; }
.time-select-pair select { width: 72px; }
.time-select-sep { color: var(--muted); }
.appt-datetime-row { align-items: flex-end; flex-wrap: wrap; }
.appt-datetime-row label { flex: 0 0 auto; }
.time-display {
  display: inline-flex;
  align-items: center;
  min-height: 37px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}
.duration-adjust-buttons { display: inline-flex; gap: 8px; }
.duration-adjust-btn { width: 64px; text-align: center; white-space: nowrap; }

/* メニュー選択（カテゴリタブ付きの選択パネル） */
.last-menu-suggestion {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  background: #f2f7ff;
  color: var(--accent);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.last-menu-suggestion:hover { background: #e5f0ff; }
.menu-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  font-size: 14px;
  color: var(--text);
}
.menu-chip-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.menu-chip-remove:hover { color: #dc2626; }
.menu-picker-panel-inline {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.menu-picker-tabs { display: flex; flex-wrap: wrap; background: #eef1f5; }
.menu-picker-tab {
  padding: 12px 16px;
  border: none;
  background: none;
  color: #445;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.menu-picker-tab.current { color: var(--accent); border-bottom-color: var(--accent); background: #fff; }
.menu-picker-tab.has-selection { color: #178a4c; }
.menu-picker-tab.has-selection.current { color: var(--accent); }
.menu-picker-tab-check { color: #178a4c; margin-right: 4px; }
.menu-picker-tab.current .menu-picker-tab-check { color: var(--accent); }
.menu-picker-list { max-height: 280px; overflow-y: auto; }
.menu-picker-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.menu-picker-item-btn:hover { background: #eef1f5; }
.menu-picker-item-btn.is-selected { background: #eafaf1; border-left: 3px solid #178a4c; padding-left: 11px; }
.menu-picker-item-name { flex: 1; }
.menu-picker-item-check { color: #178a4c; font-weight: 700; margin-right: 6px; }
.menu-picker-item-price { color: var(--muted); font-size: 13px; }
.patient-select-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
.patient-select-section .section-title { font-weight: 600; color: var(--text); font-size: 14px; }
.patient-select-section label:not(.checkbox-label):not(.section-title) { margin-top: 4px; }
.patient-search-results { display: flex; flex-direction: column; gap: 4px; }
.patient-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.patient-search-select-btn {
  flex: 0 0 auto;
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.selected-patient-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.selected-patient-card .info-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.selected-patient-card .info-row:last-of-type { border-bottom: none; }
.selected-patient-card .info-label {
  flex: 0 0 110px;
  background: #f5f6f8;
  color: var(--muted);
  padding: 8px 10px;
  font-weight: 600;
}
.selected-patient-card .info-row > span:last-child {
  flex: 1;
  padding: 8px 10px;
  color: var(--text);
}
.selected-patient-card a { display: block; text-align: right; padding: 8px 10px; font-size: 13px; color: var(--accent); text-decoration: none; }
.search-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.appt-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.appt-form-actions .btn-edit {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.appt-form-actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.appt-delete-form { margin-top: 12px; max-width: 480px; }
.row-actions { display: flex; gap: 8px; }
.appt-delete-form button.danger,
.btn-danger,
.btn-edit,
.btn-primary {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}
.appt-delete-form button.danger,
.btn-danger {
  border: 1px solid #dc2626;
  color: #dc2626;
}
.btn-edit {
  border: 1px solid var(--border);
  color: var(--accent);
}
.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.staff-add-toggle-row { display: flex; justify-content: flex-end; margin: 12px 0; }

.inline-form { display: inline; }
.reorder-cell { display: flex; gap: 4px; }
.btn-reorder {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.btn-reorder:disabled { color: var(--border); cursor: default; }

.settings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.settings-list a {
  display: block;
  padding: 14px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.settings-list a:hover { background: #f5f7fa; }

.menu-category-heading {
  margin: 24px 0 8px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-reorder { display: flex; gap: 4px; }
.menu-table { margin-bottom: 4px; }
.menu-per-session { color: var(--muted); font-size: 12px; }

.section-note { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.section-note.toggle-retired { text-align: right; margin-top: 8px; }
.business-hours-table td { padding: 10px 12px; }
.business-hours-table select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.section-heading { margin-top: 24px; }
.report-chart-wrap { margin-bottom: 20px; height: 320px; position: relative; }
.ad-cost-item-input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; width: 140px; font-size: 14px; }
.table-scroll-wrap { overflow-x: auto; scrollbar-width: auto; }
.table-scroll-wrap::-webkit-scrollbar { height: 12px; }
.table-scroll-wrap::-webkit-scrollbar-track { background: #eef1f5; border-radius: 6px; }
.table-scroll-wrap::-webkit-scrollbar-thumb { background: #b7bfca; border-radius: 6px; }
.table-scroll-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.sales-detail-daily-table th, .sales-detail-daily-table td { white-space: nowrap; padding: 6px 8px; font-size: 13px; text-align: center; }
.sales-detail-total-row td { font-weight: 700; background: var(--card); border-top: 2px solid var(--border); }
.daily-detail-toggle {
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.daily-detail-toggle:hover { background: #1d4ed8; }
.daily-detail-row td { background: #f9fafb; white-space: normal; padding: 0; }
.daily-detail-inner-wrap { overflow-x: auto; max-width: 100%; margin: 8px; }
/* table-layout: fixed で列幅を均等固定にし、日ごとに列がずれないようにする */
.daily-detail-inner-table { margin: 0; white-space: nowrap; table-layout: fixed; width: 100%; }
.daily-detail-inner-table th, .daily-detail-inner-table td { text-align: center; overflow: hidden; text-overflow: ellipsis; }
.sales-detail-daily-table td.cell-amount, .sales-detail-daily-table th.cell-amount,
.daily-detail-inner-table td.cell-amount, .daily-detail-inner-table th.cell-amount,
.report-table td.cell-amount, .report-table th.cell-amount { text-align: right; }
.ticket-unlink-form { display: inline-block; margin-left: 6px; }
.ticket-unlink-btn {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: #dc2626;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ticket-unlink-btn:hover { background: #fef2f2; }
.manual-main { line-height: 1.7; }
.manual-lead { color: var(--muted); margin-bottom: 20px; }
.manual-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.manual-toc a {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.manual-toc a:hover { background: #eef1f5; }
.manual-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.manual-section h3 { margin-top: 0; }
.manual-section ul { padding-left: 20px; margin: 0; }
.manual-section li { margin-bottom: 10px; }
.appt-form-narrow { max-width: 400px; }
.edit-list-link { align-self: flex-start; font-size: 12px; color: var(--accent); text-decoration: none; }

/* 予約編集アクションボタン */
.appt-action-buttons { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
#copy_appt_btn { margin-left: auto; }
.appt-action-buttons a, .appt-action-buttons button {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.appt-action-buttons .action-checkout { background: var(--accent); color: #fff; border-color: var(--accent); }
.appt-action-buttons .action-cancel { color: #dc2626; border-color: #fecaca; }

/* 予約移動モード */
.move-banner {
  background: #fff7e6;
  border: 1px solid #f0b429;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.move-banner a { color: var(--accent); }

/* 会計(レジ)画面 */
.checkout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.checkout-patient { font-size: 18px; font-weight: 600; }
.checkout-patient a { color: var(--accent); text-decoration: none; }
.checkout-staff-select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.checkout-staff-select select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

.checkout-layout { display: flex; gap: 20px; align-items: flex-start; }
.checkout-left { flex: 1; min-width: 0; }
.checkout-right {
  flex: 0 0 260px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.checkout-right label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.checkout-right input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }

.checkout-cart { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); margin-bottom: 12px; }
.checkout-cart th, .checkout-cart td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
.checkout-cart th { background: #eef1f5; color: var(--muted); }
.checkout-cart input { width: 70px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; }
.cart-remove-btn { border: none; background: none; color: #dc2626; cursor: pointer; font-size: 16px; }

.checkout-picker { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.checkout-cat-tabs { display: flex; flex-wrap: wrap; background: #eef1f5; }
.checkout-cat-tab {
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.checkout-cat-tab.current { color: var(--accent); border-bottom-color: var(--accent); background: #fff; }
.checkout-item-list { max-height: 320px; overflow-y: auto; }
.checkout-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.checkout-item-name { flex: 1; font-size: 14px; }
.checkout-item-price { color: var(--muted); font-size: 13px; }
.checkout-add-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
}

.checkout-summary-box { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.checkout-summary-row { display: flex; justify-content: space-between; font-size: 15px; padding: 4px 0; }
.checkout-pay-methods { display: flex; gap: 8px; flex-direction: row !important; }
.checkout-pay-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.checkout-pay-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.checkout-type-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.checkout-type-btn.current { background: #0d9488; color: #fff; border-color: #0d9488; }
.checkout-finish-btn { width: 100%; padding: 14px; font-size: 16px; background: #f0740c; border: none; border-radius: 6px; color: #fff; cursor: pointer; }
.checkout-finish-btn:disabled { background: #cbd2d9; color: #6b7280; cursor: not-allowed; }
.checkout-edit-link {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  text-align: center;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}

/* ===== スマホ幅対応 ===== */
@media (max-width: 640px) {
  main { padding: 0 10px; }
  main.schedule-main { padding: 0 8px; }

  /* ヘッダーのナビゲーションが縦に伸びて場所を取りすぎるのを防ぐ（横スクロールにする） */
  header { padding: 10px 12px; gap: 10px; }
  header nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  header nav a {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }
  .view-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .view-tabs a { flex-shrink: 0; white-space: nowrap; }

  /* 売上・レポートなどのKPIボックスが幅からはみ出して重なるのを防ぐ */
  .sales-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .sales-total-box {
    display: flex;
    width: auto;
    padding: 12px 8px;
  }
  .sales-total-value { font-size: 20px; overflow-wrap: anywhere; }

  /* 列数の多い一覧表は、縮めて文字が潰れるのではなく横スクロールで見せる */
  table.patient-list:not(.sales-detail-daily-table):not(.daily-detail-inner-table) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* 予約表（日・週・月）は列を無理に縮めず、横スクロールで見せる */
  .schedule-table { min-width: 480px; }
  .week-grid-table { min-width: 700px; }
  .month-calendar { min-width: 770px; }
  .top-weekly-table { min-width: 500px; }

  /* 日表示の日付選択（«先週 火21 水22 ... 次週» 今日）は折り返さず横スクロールで1行に収める */
  .day-nav-days {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .day-nav-day-btn, .day-nav-week-btn { flex-shrink: 0; }
  .day-nav-today-btn { margin-left: 8px; }

  /* レポートのグラフは凡例が複数行になりやすいので、縦の高さを広めに確保する */
  .report-chart-wrap { height: 380px; }
}

/* 日報・週報・月報（A4 1枚でPDF保存する帳票） */
.report-print-btn { margin-left: auto; }
.report-sheet {
  max-width: 210mm;
  margin: 0 auto;
  background: var(--card);
  padding: 24px 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.report-sheet-title { margin: 0 0 16px; font-size: 20px; }
.report-sheet-subtitle { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); font-weight: 400; }
.report-stat-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.report-stat-box { flex: 1 1 120px; background: var(--bg); border-radius: 8px; padding: 12px 16px; text-align: center; }
.report-stat-label { font-size: 12px; color: var(--muted); }
.report-stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.report-section-heading { margin: 20px 0 8px; font-size: 15px; }
.report-table th, .report-table td { text-align: center; }

/* 事業計画 */
.bp-target-input { width: 100px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; }
.bp-inline-form { display: inline-block; margin: 0; }
.bp-inline-form select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; }

/* 日報の「予約状況」明細（時間・カテゴリー・売上を左に詰め、備考を広く取る） */
.report-schedule-table { table-layout: fixed; }
.report-schedule-table th, .report-schedule-table td { text-align: left; font-size: 13px; padding: 8px 10px; }
.report-schedule-table td.cell-amount, .report-schedule-table th.cell-amount { text-align: right; }
.report-schedule-table th:nth-child(1), .report-schedule-table td:nth-child(1) { width: 17%; white-space: nowrap; }
.report-schedule-table th:nth-child(2), .report-schedule-table td:nth-child(2) { width: 27%; white-space: nowrap; }
.report-schedule-table th:nth-child(3), .report-schedule-table td:nth-child(3) { width: 13%; white-space: nowrap; }
.report-schedule-table th:nth-child(4), .report-schedule-table td:nth-child(4) { width: 43%; }
.report-note-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.report-note-print-only { display: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .report-sheet { box-shadow: none; border: none; padding: 0; max-width: none; border-radius: 0; }
  .report-note-print-only {
    display: block;
    white-space: pre-wrap;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px;
    min-height: 50px;
    font-size: 13px;
  }
}
