:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-light: #ccfbf1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);
  --radius: 14px;
}

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

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== ヘッダー ===== */
.app-header {
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.brand-text h1 { font-size: 20px; letter-spacing: .02em; }
.subtitle { font-size: 12px; opacity: .85; }

/* ===== レイアウト ===== */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; }

/* ===== 集計サマリー ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  outline: 2px solid transparent;
  transition: box-shadow .12s ease, transform .05s ease, outline-color .12s ease;
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-card:active { transform: translateY(1px); }
.stat-card.active { outline-color: var(--teal); }
.stat-icon { font-size: 26px; }
.stat-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--teal-dark); }
.stat-label { font-size: 12px; color: var(--muted); }

/* ===== ツールバー ===== */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: .6;
}
#search {
  width: 100%;
  padding: 11px 12px 11px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--card);
}
#search:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-light); }

/* ===== ボタン ===== */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.6); color: inherit; }
.app-header .btn-ghost { color: #fff; }
.modal .btn-ghost { border-color: var(--border); color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }

/* ===== パネル ===== */
.layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ===== カレンダー ===== */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-head h2 { font-size: 17px; }
.nav-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--teal-dark);
}
.nav-btn:hover { background: var(--teal-light); }
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.weekdays .sun { color: #e11d48; }
.weekdays .sat { color: #2563eb; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 6px;
  font-size: 13px;
  cursor: pointer;
  background: #f8fafc;
  transition: background .12s ease, border .12s ease;
  display: flex;
  flex-direction: column;
}
.cell:hover { background: var(--teal-light); }
.cell.empty { background: transparent; cursor: default; }
.cell.empty:hover { background: transparent; }
.cell.today { border-color: var(--teal); font-weight: 700; }
.cell.selected { background: var(--teal); color: #fff; }
.cell.selected:hover { background: var(--teal); }
.cell .num { line-height: 1; }
.cell.sun .num { color: #e11d48; }
.cell.sat .num { color: #2563eb; }
.cell.selected .num { color: #fff; }
.cell .count {
  margin-top: auto;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  background: var(--teal);
  color: #fff;
  border-radius: 20px;
  padding: 1px 7px;
}
.cell.selected .count { background: #fff; color: var(--teal-dark); }

/* ===== 日別リスト ===== */
.day-panel h2 { font-size: 16px; margin-bottom: 12px; }
.day-list { display: flex; flex-direction: column; gap: 10px; }
.resv {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--teal);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .05s ease;
}
.resv:hover { box-shadow: var(--shadow); }
.resv.selected { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
.resv:active { transform: translateY(1px); }
.resv .time { font-weight: 700; font-size: 15px; min-width: 48px; }
.resv .info { flex: 1; min-width: 0; }
.resv .name { font-weight: 600; }
.resv .meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resv .resv-date { font-size: 11px; color: var(--muted); }
.resv.cancelled .name { text-decoration: line-through; color: var(--muted); }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge.confirmed { background: #dbeafe; color: #1d4ed8; }
.badge.done { background: #dcfce7; color: #15803d; }
.badge.cancelled { background: #f1f5f9; color: #94a3b8; }

.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
  font-size: 14px;
}

.footnote { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; }

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  padding: 22px;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-card h3 { font-size: 18px; margin-bottom: 16px; }
#form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
#form input, #form select, #form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
#form input:focus, #form select:focus, #form textarea:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-light);
}
#form textarea { resize: vertical; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

.hidden { display: none !important; }

/* ===== 担当フィルタ / 集計ボタン ===== */
.staff-filter {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  min-width: 130px;
  cursor: pointer;
}
.staff-filter:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-light); }
.btn-light { background: var(--card); border: 1px solid var(--border); color: var(--teal-dark); }
.btn-light:hover { background: var(--teal-light); }

/* ===== 担当タグ ===== */
.staff-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  padding: 1px 8px;
  border-radius: 20px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ===== 日パネルのヘッダ / 表示切替 ===== */
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.day-head h2 { font-size: 16px; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.vt-btn {
  border: none;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.vt-btn.active { background: var(--teal); color: #fff; }

/* ===== タイムライン（所要時間ブロック / クリック・ドラッグ追加） ===== */
.tl { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 12px; user-select: none; }
.tl-head, .tl-body { display: grid; }
.tl-corner { background: #f8fafc; border-bottom: 1px solid var(--border); }
.tl-shead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-top: 3px solid #94a3b8;
  text-align: center;
  font-weight: 700;
  padding: 6px 4px;
  font-size: 12px;
}
.tl-axis { position: relative; background: #f8fafc; }
.tl-hourlabel { position: absolute; right: 6px; font-size: 10px; color: var(--muted); }
.tl-track {
  position: relative;
  border-left: 1px solid var(--border);
  /* 36px = app.js の ROW_H（1スロットの高さ）。変更時は両方そろえる */
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, var(--border) 35px, var(--border) 36px);
  touch-action: none;
  cursor: crosshair;
}
.tl-ev {
  position: absolute;
  left: 3px; right: 3px;
  border: none;
  border-radius: 5px;
  color: #fff;
  text-align: left;
  padding: 2px 6px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .2);
}
.tl-ev:hover { filter: brightness(1.08); }
.tl-ev-t { font-size: 9px; font-weight: 700; opacity: .95; white-space: nowrap; }
.tl-ev-n { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-ev-m { font-size: 9px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sel {
  position: absolute;
  left: 3px; right: 3px;
  background: rgba(13, 148, 136, .25);
  border: 1px dashed var(--teal);
  border-radius: 5px;
  pointer-events: none;
}
.tl-hint { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: center; }

/* ===== 集計モーダル ===== */
.stats-card { max-width: 540px; }
.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.ss-card { background: #f8fafc; border-radius: 10px; padding: 10px 12px; text-align: center; }
.ss-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.ss-num { font-size: 18px; font-weight: 700; color: var(--teal-dark); }
.ss-num.muted { color: var(--muted); }
.stats-h { font-size: 13px; margin: 16px 0 6px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.stat-table th { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat-table th:nth-child(2), .stat-table th:nth-child(3),
.stat-table td:nth-child(2), .stat-table td:nth-child(3) { text-align: right; }
.stat-table .muted { color: var(--muted); text-align: center; }
.stats-note { margin-top: 12px; font-size: 11px; color: var(--muted); }

/* ===== レスポンシブ ===== */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat-card { padding: 12px 16px; }
  .app-header { padding: 14px 16px; }
  .brand-text h1 { font-size: 18px; }
  .cell { font-size: 12px; padding: 4px; }
  .cell .count { padding: 1px 5px; }
  .stats-summary { grid-template-columns: 1fr; }
  .day-list { overflow-x: auto; }
  .staff-filter { flex: 1; min-width: 0; }
}

/* ===== 「今日」ボタン / カレンダーナビ ===== */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.today-btn {
  border: 1px solid var(--teal);
  background: var(--card);
  color: var(--teal-dark);
  border-radius: 9px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.today-btn:hover { background: var(--teal-light); }

/* ===== モーダルのプルダウン色対応（左ボーダー色はJSで設定） ===== */
#form select { font-weight: 600; }
