/* ============ Tokens (LPと共通) ============ */
:root {
  --green-900: #2f4a31;
  --green-800: #3d5a3d;
  --green-700: #4a6b4a;
  --green-600: #5b8259;
  --green-500: #7ba577;
  --green-100: #e6efe2;
  --green-50: #f1f5ec;
  --orange: #e87a3e;
  --orange-dark: #d05a20;
  --red: #c83a2a;
  --red-soft: #f5d8d3;
  --amber: #d8a838;
  --amber-soft: #fbeec0;
  --bg: #f6f4ee;
  --bg-warm: #faf7f0;
  --panel: #ffffff;
  --ink: #2a2a2a;
  --ink-soft: #5a5a5a;
  --ink-mute: #8a8a8a;
  --line: #e3ddcd;
  --line-soft: #ece6d6;
  --shadow-sm: 0 1px 2px rgba(60,50,30,.06);
  --shadow-md: 0 4px 12px rgba(60,50,30,.08);
  --shadow-lg: 0 10px 28px rgba(60,50,30,.12);
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; }

/* ============ App Shell ============ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 900px) {
  .app { grid-template-columns: 64px 1fr; }
}

/* Sidebar */
.sidebar {
  background: var(--green-900);
  color: #e8efe5;
  display: flex;
  flex-direction: column;
  padding: 18px 0 0;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }
.sb-brand {
  padding: 0 22px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
.sb-brand-mark {
  width: 36px; height: 36px;
  background: var(--green-100);
  color: var(--green-900);
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: "Noto Serif JP", serif;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
}
.sb-brand-text { line-height: 1.2; }
.sb-brand-text .ja { font-family: "Noto Serif JP", serif; font-weight: 700; font-size: 14px; color: #fff; }
.sb-brand-text .en { font-size: 10px; color: rgba(255,255,255,.55); letter-spacing: .15em; margin-top: 2px; }
.sb-section-label {
  padding: 16px 22px 6px;
  font-size: 10px;
  letter-spacing: .15em;
  color: rgba(255,255,255,.4);
  font-weight: 700;
}
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }
.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  color: rgba(255,255,255,.78);
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}
.sb-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-item.active {
  background: var(--green-700);
  color: #fff;
  font-weight: 600;
}
.sb-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sb-item .badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}
.sb-spacer { flex: 1; }
.sb-user {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.sb-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green-600);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-info .name { font-size: 12.5px; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info .role { font-size: 10.5px; color: rgba(255,255,255,.5); }
.sb-logout {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.4);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: grid; place-items: center;
}
.sb-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

@media (max-width: 900px) {
  .sb-brand-text, .sb-section-label, .sb-item span:not(.badge):not(.icon-wrap), .sb-user-info { display: none; }
  .sb-brand { padding: 0 14px 18px; justify-content: center; }
  .sb-nav { padding: 0 8px; }
  .sb-item { justify-content: center; padding: 10px; }
  .sb-user { justify-content: center; }
  .sb-logout { display: none; }
}

/* Main area */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  min-height: 64px;
}
.topbar-title {
  font-family: "Noto Serif JP", serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--green-900);
  margin: 0;
}
.topbar-sub { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }
.topbar-spacer { flex: 1; }
.topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  background: var(--green-800);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
}
.topbar-action:hover { background: var(--green-900); }
.topbar-action.ghost {
  background: #fff;
  color: var(--green-900);
  border: 1px solid var(--line);
}
.topbar-action.ghost:hover { background: var(--green-50); }
.topbar-bell {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid; place-items: center;
  color: var(--green-900);
}
.topbar-bell:hover { background: var(--green-50); }
.topbar-bell-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid #fff;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 80px;
}

/* ============ Cards & sections ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title {
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--green-900);
  margin: 0;
}
.card-body { padding: 18px 20px; }

.section-head {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: "Noto Serif JP", serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--green-900);
  margin: 0;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--green-50); border-color: var(--green-100); }
.btn.primary {
  background: var(--green-800);
  color: #fff;
  border-color: var(--green-800);
  font-weight: 600;
}
.btn.primary:hover { background: var(--green-900); border-color: var(--green-900); }
.btn.danger {
  background: #fff;
  color: var(--red);
  border-color: var(--red-soft);
}
.btn.danger:hover { background: var(--red-soft); }
.btn.subtle {
  background: var(--green-50);
  border-color: var(--green-100);
  color: var(--green-900);
}
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon-only { padding: 7px; width: 32px; height: 32px; }

/* ============ Forms ============ */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  font-weight: 600;
}
.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(91,130,89,.12);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

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

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 11.5px;
  letter-spacing: .04em;
  padding: 10px 14px;
  background: var(--green-50);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--bg-warm); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody td .sub { font-size: 11.5px; color: var(--ink-mute); margin-top: 2px; }

/* ============ Status pills ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.pending { background: #fbeec0; color: #8a6a10; }
.pill.confirmed { background: var(--green-100); color: var(--green-900); }
.pill.done { background: #e2e8e0; color: #5a6258; }
.pill.cancelled { background: #f0e0dc; color: #a93b22; }
.pill.new { background: #ffe2c8; color: #b04c10; }

/* ============ Stat tiles ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-tile-label {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: .04em;
  display: flex; align-items: center; gap: 6px;
}
.stat-tile-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--green-50);
  color: var(--green-800);
  margin-bottom: 10px;
}
.stat-tile-icon.orange { background: #fce8d8; color: var(--orange-dark); }
.stat-tile-icon.amber { background: var(--amber-soft); color: #8a6a10; }
.stat-tile-icon.red { background: var(--red-soft); color: var(--red); }
.stat-tile-value {
  font-family: "Noto Serif JP", serif;
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 900;
  color: var(--green-900);
  line-height: 1.15;
  margin: 4px 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-tile-value .unit { font-size: 14px; color: var(--ink-soft); font-weight: 700; margin-left: 4px; }
.stat-tile-delta {
  font-size: 11.5px;
  color: var(--green-700);
  font-weight: 600;
}
.stat-tile-delta.down { color: var(--red); }

/* ============ Calendar ============ */
.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cal-view-switch {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 0;
}
.cal-view-switch button {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 6px;
}
.cal-view-switch button.active {
  background: var(--green-800);
  color: #fff;
}
.cal-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cal-nav-btn {
  width: 32px; height: 32px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid; place-items: center;
  color: var(--green-900);
}
.cal-nav-btn:hover { background: var(--green-50); }
.cal-current {
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--green-900);
  margin: 0 8px;
  min-width: 140px;
  text-align: center;
}
.cal-today-btn { padding: 6px 12px; font-size: 12px; }

/* Week view: time × days */
.cal-week {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.cal-events-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 4;
}
.cal-events-overlay .cal-event {
  pointer-events: auto;
  right: auto;
}
/* 施術後の片付け・お見送りバッファ（15分）— 薄いグレーの斜線パターン */
.cal-event-buffer {
  background: repeating-linear-gradient(45deg, rgba(180, 180, 180, 0.15) 0 4px, rgba(160, 160, 160, 0.08) 4px 8px);
  border-radius: 4px;
  border-top: none;
}
/* 📄 領収書希望・📝 メモ（時間と同じ行にインライン表示） */
.cal-event-icon-inline {
  font-size: 11px;
  margin-right: 3px;
  vertical-align: -1px;
}
.cal-week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  position: relative;
}
.cal-week-head {
  display: contents;
}
.cal-week-head > div {
  background: var(--green-50);
  border-bottom: 1px solid var(--line);
  padding: 10px 6px 8px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 5;
}
.cal-week-head .day-num {
  display: block;
  font-family: "Noto Serif JP", serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--green-900);
  margin-top: 2px;
}
.cal-week-head .day-num.sun { color: var(--red); }
.cal-week-head .day-num.sat { color: #2a5a8a; }
.cal-week-head .today { color: #fff; background: var(--green-800); border-radius: 50%; width: 28px; height: 28px; display: inline-grid; place-items: center; font-size: 14px; }
.cal-week-head .corner { background: var(--green-50); }

.cal-time-col {
  border-right: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--ink-mute);
  text-align: right;
  padding: 4px 6px 0 0;
  position: relative;
  height: 36px;
  background: #fafaf6;
}
.cal-time-col.hour { color: var(--green-900); font-weight: 700; }

.cal-day-col {
  border-right: 1px solid var(--line-soft);
  position: relative;
  height: 36px;
  cursor: pointer;
}
/* グリッド先頭に .cal-week-head が居るため day-col は 9,17,25... の位置に並ぶ。
   各週の最終列（土曜）は border-right を消す */
.cal-day-col:nth-child(8n+1) { border-right: none; }
.cal-day-col.hour-mark { border-top: 1px solid var(--line); }
.cal-day-col.half-mark { border-top: 1px dashed var(--line-soft); }
.cal-day-col:hover { background: var(--green-50); }
.cal-day-col.out-of-hours {
  background: rgba(214, 101, 30, 0.04);
}
.cal-day-col.out-of-hours:hover { background: rgba(214, 101, 30, 0.10); }
.cal-day-col.closed {
  background: repeating-linear-gradient(45deg, #f0ede4 0 4px, #e8e4d8 4px 8px);
  cursor: not-allowed;
}
.cal-day-col.closed:hover { background: repeating-linear-gradient(45deg, #f0ede4 0 4px, #e8e4d8 4px 8px); }
.cal-day-col.blocked {
  background: repeating-linear-gradient(45deg, #fde0db 0 4px, #f5d0c9 4px 8px);
  cursor: not-allowed;
}
.cal-day-col.blocked:hover { background: repeating-linear-gradient(45deg, #fde0db 0 4px, #f5d0c9 4px 8px); }
.cal-day-col.today-col { background: rgba(123,165,119,.05); }

.cal-event {
  position: absolute;
  left: 2px;
  right: 2px;
  background: var(--green-100);
  border-left: 3px solid var(--green-700);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  color: var(--green-900);
  cursor: grab;
  overflow: hidden;
  z-index: 3;
  box-shadow: var(--shadow-sm);
  user-select: none;
  transition: transform .15s, box-shadow .15s;
}
.cal-event:hover { box-shadow: var(--shadow-md); transform: translateX(1px); }
.cal-event.dragging { opacity: .4; cursor: grabbing; }
.cal-event-time { font-weight: 700; font-size: 10.5px; color: var(--green-800); }
.cal-event-name { font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-menu { font-size: 10px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.pending { background: #fbeec0; border-left-color: var(--amber); }
.cal-event.pending .cal-event-time { color: #8a6a10; }
.cal-event.confirmed { background: var(--green-100); border-left-color: var(--green-700); }
.cal-event.done { background: #e2e8e0; border-left-color: #7a8275; }
.cal-event.done .cal-event-time { color: #5a6258; }
.cal-event.cancelled { background: #f0e0dc; border-left-color: var(--red); text-decoration: line-through; opacity: .7; }
.cal-event.no_show { background: #ede1de; border-left-color: #bf6951; text-decoration: line-through; opacity: .55; color: #6b4d44; }

/* ===== メニュー別カラー（最優先で適用、status色を上書き） ===== */
/* 初回お試し：緑 */
.cal-event.menu-color-first, .cal-day-event.menu-color-first { background: #d8ecd6; border-left: 4px solid #4f8c4d; }
/* 60分コース：青 */
.cal-event.menu-color-60, .cal-day-event.menu-color-60 { background: #d4e2f5; border-left: 4px solid #3568b0; }
/* 90分コース：オレンジ */
.cal-event.menu-color-90, .cal-day-event.menu-color-90 { background: #fadcc4; border-left: 4px solid #d6651e; }
/* 回数券・月額プラン：紫 */
.cal-event.menu-color-ticket, .cal-day-event.menu-color-ticket { background: #e2d5ee; border-left: 4px solid #7e3fae; }
/* その他メニュー：灰系 */
.cal-event.menu-color-other, .cal-day-event.menu-color-other { background: #e8e6df; border-left: 4px solid #8a8576; }

/* 来院済（done）：チェックバッジ + 半透明（position は base の absolute を維持） */
.cal-event.done { opacity: .65; filter: saturate(.7); }
.cal-event.done::before {
  content: "✓済";
  position: absolute;
  top: 2px; right: 3px;
  background: #2966a3;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: .04em;
  z-index: 2;
}
/* 来院済 + 初回バッジが両方ある場合：初回を左に寄せる */
.cal-event.done.new-flag::after { right: 30px; }

/* DayView用も同様 */
.cal-day-event.done { opacity: .65; filter: saturate(.7); }

.cal-event.new-flag::after {
  content: "初回";
  position: absolute;
  top: 2px; right: 3px;
  background: var(--orange);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: .04em;
}

.cal-drop-indicator {
  position: absolute;
  left: 2px; right: 2px;
  background: rgba(91,130,89,.25);
  border: 1.5px dashed var(--green-600);
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

/* Day view */
.cal-day-view {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 80px 1fr;
  overflow: hidden;
}
.cal-day-times {
  border-right: 1px solid var(--line);
  background: #fafaf6;
}
.cal-day-times .row {
  height: 60px;
  text-align: right;
  padding: 4px 8px 0 0;
  font-size: 11px;
  color: var(--ink-mute);
}
.cal-day-times .row.hour { color: var(--green-900); font-weight: 700; font-size: 12px; }
.cal-day-area {
  position: relative;
}
.cal-day-area .row {
  height: 60px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.cal-day-area .row:nth-child(4n+1) { border-bottom-color: var(--line); }
.cal-day-area .row.closed {
  background: repeating-linear-gradient(45deg, #f0ede4 0 4px, #e8e4d8 4px 8px);
  cursor: not-allowed;
}
.cal-day-area .row.blocked {
  background: repeating-linear-gradient(45deg, #fde0db 0 4px, #f5d0c9 4px 8px);
  cursor: not-allowed;
}
.cal-day-area .row.out-of-hours { background: rgba(214, 101, 30, 0.04); }
.cal-day-area .row:hover:not(.closed) { background: var(--green-50); }
.cal-day-event {
  position: absolute;
  left: 8px;
  right: 8px;
  background: var(--green-100);
  border-left: 4px solid var(--green-700);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: grab;
  z-index: 3;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cal-day-event-time { font-size: 11px; font-weight: 700; color: var(--green-800); }
.cal-day-event-name { font-size: 14px; font-weight: 700; color: var(--green-900); }
.cal-day-event-menu { font-size: 11.5px; color: var(--ink-soft); }

/* Month view */
.cal-month-grid {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cal-month-headrow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--green-50);
}
.cal-month-headrow > div {
  text-align: center;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--green-900);
}
.cal-month-headrow .sun { color: var(--red); }
.cal-month-headrow .sat { color: #2a5a8a; }
.cal-month-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-month-cell {
  min-height: 110px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 6px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.cal-month-cell:nth-child(7n) { border-right: none; }
.cal-month-cell.other-month { background: #fafaf6; color: var(--ink-mute); }
.cal-month-cell.closed { background: repeating-linear-gradient(45deg, #f0ede4 0 4px, #e8e4d8 4px 8px); }
.cal-month-cell.blocked-day {
  background: repeating-linear-gradient(45deg, #fde0db 0 4px, #f5d0c9 4px 8px);
}
.cal-month-cell.blocked-day .cal-month-day { color: var(--red); font-weight: 800; }
.cal-month-block-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: .04em;
  box-shadow: 0 1px 3px rgba(200,58,42,.3);
}
.cal-month-block-badge.partial {
  background: var(--orange);
  box-shadow: 0 1px 3px rgba(232,122,62,.3);
}
.cal-month-cell { position: relative; }
.cal-month-cell.today .cal-month-day { background: var(--green-800); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; }
.cal-month-day {
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--green-900);
  align-self: flex-start;
  margin-bottom: 2px;
}
.cal-month-day.sun { color: var(--red); }
.cal-month-day.sat { color: #2a5a8a; }
.cal-month-event {
  font-size: 10.5px;
  background: var(--green-100);
  color: var(--green-900);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid var(--green-700);
}
.cal-month-event.pending { background: #fbeec0; border-left-color: var(--amber); color: #8a6a10; }
.cal-month-event.cancelled { background: #f0e0dc; border-left-color: var(--red); text-decoration: line-through; opacity: .7; }
.cal-month-event.more { background: transparent; color: var(--ink-mute); border: none; padding: 1px 2px; font-weight: 600; }

.cal-legend-row {
  display: flex;
  gap: 14px;
  padding: 10px 14px;
  background: #fafaf6;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.cal-legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cal-legend-row span::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--green-100);
  border-left: 3px solid var(--green-700);
}
.cal-legend-row .pending::before { background: #fbeec0; border-left-color: var(--amber); }
.cal-legend-row .confirmed::before { background: var(--green-100); border-left-color: var(--green-700); }
.cal-legend-row .done::before { background: #e2e8e0; border-left-color: #7a8275; }
.cal-legend-row .cancelled::before { background: #f0e0dc; border-left-color: var(--red); }
.cal-legend-row .closed::before { background: repeating-linear-gradient(45deg, #f0ede4 0 3px, #e8e4d8 3px 6px); border: none; }
.cal-legend-row .blocked::before { background: repeating-linear-gradient(45deg, #fde0db 0 3px, #f5d0c9 3px 6px); border: none; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(40,32,16,.45);
  display: grid;
  place-items: center;
  z-index: 300;             /* mobile-nav(100) / FAB(110) / more-sheet(200) より上 */
  padding: 20px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s;
}
.modal.lg { max-width: 720px; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-title {
  font-family: "Noto Serif JP", serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--green-900);
  margin: 0;
  flex: 1;
}
.modal-close {
  background: transparent;
  border: none;
  width: 30px; height: 30px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--ink-mute);
}
.modal-close:hover { background: var(--green-50); color: var(--ink); }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fafaf6;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-footer .left { margin-right: auto; }

/* Detail rows */
.detail-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px 14px;
  font-size: 13px;
}
.detail-grid dt { color: var(--ink-soft); font-size: 12px; font-weight: 600; align-self: center; }
.detail-grid dd { margin: 0; color: var(--ink); }

/* ============ Login ============ */
.login-shell {
  height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(91,130,89,.15), transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(232,122,62,.10), transparent 60%),
    var(--bg);
  padding: 20px;
}
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 36px 32px 30px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  text-align: center;
  margin-bottom: 22px;
}
.login-brand-mark {
  width: 56px; height: 56px;
  margin: 0 auto 10px;
  background: var(--green-800);
  color: #fff;
  border-radius: 14px;
  display: grid; place-items: center;
  font-family: "Noto Serif JP", serif;
  font-weight: 900;
  font-size: 24px;
}
.login-brand-name {
  font-family: "Noto Serif JP", serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--green-900);
  margin: 0;
}
.login-brand-sub { font-size: 11px; letter-spacing: .2em; color: var(--ink-mute); margin-top: 4px; }
.login-title {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 0 18px;
}
.login-error {
  background: var(--red-soft);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
}
.login-hint {
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.login-submit {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  background: var(--green-800);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  margin-top: 4px;
}
.login-submit:hover { background: var(--green-900); }

/* ============ Filters ============ */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; }
.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.search-input input {
  width: 100%;
  padding-left: 34px;
}
.search-input svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
}

/* ============ Toggle ============ */
.toggle {
  position: relative;
  width: 38px;
  height: 22px;
  background: #d8d2c2;
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.toggle.on { background: var(--green-700); }
.toggle.on::after { transform: translateX(16px); }

/* ============ Notifications ============ */
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.notif-item.unread { border-left: 3px solid var(--orange); background: #fffbf5; }
.notif-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--green-50);
  color: var(--green-800);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.notif-icon.cancel { background: var(--red-soft); color: var(--red); }
.notif-icon.new { background: #fce8d8; color: var(--orange-dark); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 700; font-size: 13px; color: var(--ink); margin: 0 0 2px; }
.notif-text { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--ink-mute); margin-top: 4px; }

/* ============ Two-col layout helpers ============ */
.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .three-col { grid-template-columns: 1fr; } }

/* ============ Reports ============ */
.chart-wrap {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px 8px 0;
  border-bottom: 1px solid var(--line);
}
.chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.chart-bar .bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--green-600), var(--green-800));
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height .3s;
}
.chart-bar .bar.alt { background: linear-gradient(180deg, var(--orange), var(--orange-dark)); }
.chart-bar .label {
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 4px;
  white-space: nowrap;
}
.chart-bar .val {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--green-900);
}
.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 8px;
}
.chart-legend span::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--green-700);
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}
.chart-legend .alt::before { background: var(--orange); }

/* ============ Settings ============ */
.settings-row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  gap: 14px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; }
.settings-row-title { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.settings-row-desc { font-size: 11.5px; color: var(--ink-mute); margin-top: 2px; }

/* ============ Hours grid ============ */
.hours-grid {
  display: grid;
  grid-template-columns: 80px 1fr 1fr auto;
  gap: 10px 12px;
  align-items: center;
  font-size: 13px;
}
.hours-grid .day-label {
  font-weight: 700;
  color: var(--green-900);
}
.hours-grid .day-label.sun { color: var(--red); }
.hours-grid .day-label.sat { color: #2a5a8a; }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-mute);
}
.empty-icon { width: 48px; height: 48px; margin: 0 auto 10px; opacity: .35; }
.empty-title { font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.empty-sub { font-size: 11.5px; }

/* Misc */
.text-muted { color: var(--ink-mute); }
.text-soft { color: var(--ink-soft); }
.text-green { color: var(--green-800); }
.text-orange { color: var(--orange-dark); }
.text-red { color: var(--red); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-12 { gap: 12px; }

/* ============ Block Matrix (休講管理) ============ */
.cal-mode-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 14px;
}
.cal-mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.cal-mode-tab:hover {
  background: var(--green-50);
  color: var(--green-800);
}
.cal-mode-tab.active {
  background: var(--green-700);
  color: #fff;
  box-shadow: 0 2px 6px rgba(74,107,74,.25);
}
.cal-mode-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-mute);
  padding-right: 8px;
}
@media (max-width: 700px) {
  .cal-mode-hint { display: none; }
}

.block-howto {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, #fff8ec, #fff4dc);
  border: 1px solid #f0d99a;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.block-howto-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.block-howto-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 4px;
}
.block-howto-desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.block-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.block-legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.b-leg { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.b-leg.ok { color: var(--green-700); }
.b-leg.ng { color: var(--red); }
.b-leg.booked { color: #6b4d99; }
.b-leg.cl { color: var(--ink-mute); }

.block-matrix-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  max-height: calc(100vh - 280px);
}
.block-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 720px;
}
.block-matrix thead .bm-day-row th {
  position: sticky;
  top: 0;
  background: var(--green-50);
  z-index: 2;
  padding: 8px 4px;
  border-bottom: 2px solid var(--line);
  border-left: 1px solid var(--line-soft);
  text-align: center;
  font-weight: 700;
}
.block-matrix thead .bm-corner {
  width: 60px;
  background: var(--green-50);
  border-left: none;
}
.block-matrix thead .bm-day-week {
  font-size: 10.5px;
  color: var(--ink-soft);
  font-weight: 600;
}
.block-matrix thead th.sun .bm-day-week,
.block-matrix thead th.sun .bm-day-num { color: #c33; }
.block-matrix thead th.sat .bm-day-week,
.block-matrix thead th.sat .bm-day-num { color: #3a7ec0; }
.block-matrix thead th.today {
  background: linear-gradient(180deg, #fff4e1, var(--green-50));
}
.block-matrix thead th.today .bm-day-num {
  color: var(--orange-dark);
}
.block-matrix thead th.past { opacity: .55; }
.block-matrix thead .bm-day-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--green-900);
  margin-top: 1px;
}
.bm-allday {
  display: block;
  margin: 6px auto 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.bm-allday:hover:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.bm-allday.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.bm-allday.has-bookings {
  background: #fff4e1;
  border-color: #f0c878;
  color: #b8762a;
}
.bm-allday.has-bookings:hover {
  background: #f0c878;
  border-color: #b8762a;
  color: #fff;
}
.bm-allday:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.bm-day-bookings {
  display: inline-block;
  background: #6b4d99;
  color: #fff;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: .02em;
}

.block-matrix tbody td {
  border-top: 1px solid #f0ece0;
  border-left: 1px solid #f0ece0;
  text-align: center;
  padding: 0;
  height: 30px;
  vertical-align: middle;
}
.bm-time {
  background: var(--green-50);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 10.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  width: 60px;
  position: sticky;
  left: 0;
  z-index: 1;
}
.bm-time.hour {
  color: var(--green-800);
  font-weight: 900;
  font-size: 11px;
  border-top: 1.5px solid var(--line);
}
.block-matrix tbody td.bm-cell {
  cursor: pointer;
  transition: background .12s, transform .1s;
  user-select: none;
}
.block-matrix tbody td.bm-cell:hover:not(.past):not(.closed) {
  background: var(--green-50);
}
.block-matrix tbody td.bm-cell.open .bm-mark {
  color: #5b3d8a;
  font-weight: 900;
  font-size: 16px;
}
.block-matrix tbody td.bm-cell.blocked,
.block-matrix tbody td.bm-cell.blocked-day {
  background: linear-gradient(135deg, #fde0db 0%, #f5d8d3 100%);
}
.block-matrix tbody td.bm-cell.blocked .bm-mark,
.block-matrix tbody td.bm-cell.blocked-day .bm-mark {
  color: var(--red);
  font-weight: 900;
  font-size: 18px;
}
.block-matrix tbody td.bm-cell.blocked-day {
  background:
    repeating-linear-gradient(45deg, #fde0db, #fde0db 4px, #f5d8d3 4px, #f5d8d3 8px);
}
.block-matrix tbody td.bm-cell.closed {
  background: #f4f0e4;
  cursor: not-allowed;
}
.block-matrix tbody td.bm-cell.closed .bm-mark {
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 700;
}
.block-matrix tbody td.bm-cell.closed-booked {
  background:
    repeating-linear-gradient(45deg, #fff4e1, #fff4e1 4px, #ffe4cc 4px, #ffe4cc 8px);
  cursor: pointer;
}
.block-matrix tbody td.bm-cell.closed-booked .bm-mark {
  color: var(--orange-dark);
  font-size: 16px;
  font-weight: 900;
}
.block-matrix tbody td.bm-cell.closed-booked:hover {
  filter: brightness(.96);
}
.block-matrix tbody td.bm-cell.past {
  background: #f6f4ee;
  cursor: not-allowed;
  opacity: .5;
}
.block-matrix tbody td.bm-cell.past .bm-mark {
  color: var(--ink-mute);
  font-size: 12px;
}
.block-matrix tbody td.bm-cell.booked {
  background: linear-gradient(135deg, #ece4f7 0%, #ddd0ec 100%);
  cursor: not-allowed;
  position: relative;
}
.block-matrix tbody td.bm-cell.booked .bm-mark {
  color: #6b4d99;
  font-size: 14px;
  font-weight: 800;
}
.block-matrix tbody td.bm-cell.booked:hover {
  background: linear-gradient(135deg, #e0d4ee 0%, #cdbce0 100%);
}
.block-matrix tbody td.bm-cell.blocked-booked {
  background:
    repeating-linear-gradient(45deg, #f5d8d3, #f5d8d3 4px, #ddd0ec 4px, #ddd0ec 8px);
  position: relative;
}
.block-matrix tbody td.bm-cell.blocked-booked .bm-mark {
  color: var(--red);
  font-size: 16px;
  font-weight: 900;
}
.bm-booking-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--orange);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.block-matrix tbody td.bm-cell {
  position: relative;
}
.block-matrix tbody tr:has(td.bm-time.hour) td {
  border-top: 1.5px solid var(--line);
}
.bm-mark {
  display: inline-block;
  line-height: 1;
}

.block-stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 0 4px;
}
.block-stat {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.block-stat strong {
  color: var(--red);
  font-size: 15px;
  margin: 0 4px;
  font-weight: 800;
}

/* Conflict modal */
.conflict-warn {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: linear-gradient(135deg, #fff4e1, #ffe4cc);
  border: 1px solid #f0c878;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
.conflict-warn-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px;
  font-weight: 900;
  flex-shrink: 0;
}
.conflict-warn-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-900);
  margin-bottom: 4px;
}
.conflict-warn-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.conflict-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.conflict-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .12s;
}
.conflict-item:last-child { border-bottom: none; }
.conflict-item:hover { background: var(--green-50); }
.conflict-time {
  flex-shrink: 0;
  text-align: center;
  background: #6b4d99;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 56px;
}
.conflict-time .t {
  font-size: 14px;
  font-weight: 800;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.conflict-time .dur {
  font-size: 9.5px;
  opacity: .85;
  margin-top: 2px;
}
.conflict-info {
  flex: 1;
  min-width: 0;
}
.conflict-info .name {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-900);
}
.conflict-info .menu {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.conflict-info .tel {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 2px;
}
.conflict-hint {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 10px;
  text-align: center;
}

/* ============ Mobile bottom nav (≤600px で表示) ============ */
.mobile-nav { display: none; }
.more-sheet-backdrop { display: none; }
.fab-add { display: none; } /* デスクトップでは非表示 */

@media (max-width: 600px) {
  /* サイドバーを完全に非表示にして、下部にタブバーを設置（スマホアプリ風） */
  .sidebar { display: none !important; }
  .app { grid-template-columns: 1fr !important; }

  /* メインのスクロール領域に下部バーぶんの余白を追加 */
  .main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* Bottom nav 本体 */
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 8px rgba(60,50,30,.06);
  }
  .mn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    background: transparent;
    border: 0;
    color: var(--ink-mute);
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    min-height: 52px;
    transition: color .15s, background .15s;
  }
  .mn-item.active {
    color: var(--green-900);
    font-weight: 700;
  }
  .mn-item.active .mn-icon {
    color: var(--green-900);
  }
  .mn-icon {
    color: var(--ink-mute);
    display: grid;
    place-items: center;
  }
  .mn-label {
    line-height: 1;
    letter-spacing: .02em;
  }
  .mn-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: var(--orange);
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
  }

  /* More sheet（スライドアップ） */
  .more-sheet-backdrop {
    display: block;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    animation: fadeIn .18s ease;
  }
  .more-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 210;
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -8px 28px rgba(0,0,0,.22);
  }
  .more-sheet-handle {
    width: 40px;
    height: 4px;
    background: #d8d4c8;
    border-radius: 2px;
    margin: 6px auto 14px;
  }
  .more-sheet-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-mute);
    letter-spacing: .14em;
    margin-bottom: 6px;
    padding: 0 4px;
  }
  .more-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 12px;
    background: transparent;
    border: 0;
    border-radius: 10px;
    font-size: 15px;
    color: var(--ink);
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    position: relative;
  }
  .more-item:active { background: var(--green-50); }
  .more-item.active { background: var(--green-50); color: var(--green-900); font-weight: 700; }
  .more-icon { color: var(--green-800); flex-shrink: 0; display: grid; place-items: center; }
  .more-item.active .more-icon { color: var(--green-900); }
  .more-label { flex: 1; }
  .more-badge {
    background: var(--orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
  }
  .more-divider { height: 1px; background: var(--line); margin: 6px 12px; }
  .more-logout { color: var(--red); }
  .more-logout .more-icon { color: var(--red); }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* ============ Phone optimizations (iPhone等 ≤600px) ============ */
@media (max-width: 600px) {

  /* Topbar: 縦積みにしてボタンが折れないように */
  .topbar {
    flex-wrap: wrap;
    padding: 12px 14px;
    gap: 10px;
    min-height: auto;
  }
  .topbar-title { font-size: 17px; }
  .topbar-sub { font-size: 11.5px; }
  .topbar-spacer { display: none; }
  /* スマホでは上部の「予約を追加」ボタンは非表示（FAB に集約） */
  .topbar-action { display: none !important; }

  /* Floating Action Button：常時 右下に表示 */
  .fab-add {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: calc(64px + env(safe-area-inset-bottom) + 12px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    background: var(--orange);
    color: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(214,101,30,.35), 0 2px 6px rgba(0,0,0,.12);
    z-index: 110;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .fab-add:active {
    transform: scale(.94);
    box-shadow: 0 3px 10px rgba(214,101,30,.30);
  }

  /* モーダル/シート表示時は下部ナビとFABを完全非表示（半透明背景越しの透けを防ぐ） */
  body:has(.modal-backdrop) .mobile-nav,
  body:has(.modal-backdrop) .fab-add,
  body:has(.more-sheet-backdrop) .fab-add {
    display: none !important;
  }

  /* カレンダーのモードタブ縮小・ヒント非表示 */
  .cal-mode-tab {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
  .cal-mode-hint { display: none !important; }

  /* カレンダーのツールバー：「予約を追加」非表示（FAB へ）／日付ナビ縮小 */
  .cal-toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .cal-toolbar > .btn.primary { display: none !important; }
  .cal-today-btn { padding: 6px 10px !important; font-size: 12px !important; }
  .cal-current { font-size: 13px !important; }
  .cal-view-switch button { padding: 5px 10px !important; font-size: 12px !important; }

  /* メインコンテンツの余白を削減 */
  .main { overflow-y: auto; }
  .main > .content,
  .main > div:not(.topbar) {
    padding: 12px !important;
  }

  /* Stats grid: インラインの repeat(4,1fr) / repeat(3,1fr) を強制上書きして2列固定 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }
  .stat-tile { padding: 12px 12px; }
  .stat-tile-icon { width: 28px; height: 28px; margin-bottom: 6px; }
  .stat-tile-label { font-size: 11px; }
  .stat-tile-value {
    font-size: 19px !important;
    white-space: normal;        /* ¥1‥ の省略を解除して全桁表示 */
    overflow: visible;
    text-overflow: clip;
    word-break: break-all;
  }
  .stat-tile-value .unit { font-size: 12px; }
  .stat-tile-delta { font-size: 10.5px; line-height: 1.4; }

  /* 2列・3列レイアウトを強制1列に */
  .two-col, .three-col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* カード内余白の削減 */
  .card { padding: 14px; }
  .card-header { gap: 8px; flex-wrap: wrap; }
  .card-title { font-size: 14px; }

  /* テーブルは横スクロール可能に（既存設定の念押し） */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { font-size: 12.5px; }
  .table th, .table td { padding: 8px 6px; }

  /* ボタン類のタップ領域を広めに */
  .btn { min-height: 36px; padding: 8px 12px; font-size: 13px; }
  .btn.sm { min-height: 32px; padding: 6px 10px; font-size: 12px; }

  /* AI相談ログ等の独自グリッドも上書き */
  .ai-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .ai-split { grid-template-columns: 1fr !important; }

  /* カレンダー：下端の予約がFABに隠れないよう余白を確保（FAB ≒ 132px 占有） */
  .cal-month-grid,
  .cal-week,
  .cal-day-view {
    margin-bottom: 96px !important;
  }

  /* モーダル：スマホでは画面ぎりぎりまで使う＋タップ領域を広く */
  .modal-backdrop { padding: 8px !important; }
  .modal {
    max-height: calc(100vh - 16px) !important;
    border-radius: 12px !important;
  }
  .modal-header { padding: 14px 16px 10px !important; }
  .modal-title { font-size: 16px !important; }
  .modal-body { padding: 14px 16px !important; }
  .modal-footer { padding: 10px 16px !important; }
  /* 入力フォームのタップ領域を 44px 以上に */
  .modal .input,
  .modal .select,
  .modal input[type="text"],
  .modal input[type="date"],
  .modal input[type="time"],
  .modal input[type="email"],
  .modal input[type="tel"],
  .modal select {
    min-height: 42px !important;
    font-size: 16px !important; /* iOS の自動ズーム防止（16px以上） */
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  /* grid item が内容で押し広げられないように（iOS date input が隣にはみ出す問題対策） */
  .modal .field {
    min-width: 0 !important;
  }
  /* スマホでは予約モーダルの2列フォームを1列に切り替え（日付/時間の重なり対策・タップ領域確保） */
  .modal-body > div[style*="grid-template-columns"],
  .modal-body > div[style*="gridTemplateColumns"] {
    grid-template-columns: 1fr !important;
  }
  .modal textarea {
    font-size: 16px !important;
    min-height: 80px !important;
  }
  .modal .btn { min-height: 42px !important; padding: 10px 16px !important; }

  /* 予約一覧／顧客一覧の filter-bar: 上部「予約を追加」をFABに集約・検索全幅化 */
  .filter-bar {
    gap: 10px !important;
  }
  .filter-bar > .btn.primary { display: none !important; }
  .filter-bar .search-input {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    order: 2;
  }
  .filter-bar .cal-view-switch {
    order: 1;
    flex: 1 1 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .filter-bar .cal-view-switch::-webkit-scrollbar { display: none; }
  .filter-bar .cal-view-switch button {
    padding: 6px 12px !important;
    font-size: 12.5px !important;
    flex: 0 0 auto;
  }

  /* 予約一覧テーブル：下端をFABに隠さない */
  .table-wrap {
    margin-bottom: 96px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* 経営分析：table-wrap 無しで .table が card 直下にある場合も横スクロール対応 */
  .card > .table,
  .card-body > .table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* 超小型端末（iPhone SE 等 ≤380px）: 売上カードが2列でも詰まる時の保険 */
@media (max-width: 380px) {
  .stat-tile-value { font-size: 16px !important; }
  .topbar-title { font-size: 16px; }
  .topbar-action { padding: 7px 10px; font-size: 12px; }
}
