:root {
  --cyan: #15b3cf;        /* 出勤（少し濃いめ） */
  --cyan-soft: #2bc4dc;
  --green: #bcd118;       /* 有給・PM休・リフ（黄緑） */
  --yellow: #ffd23d;      /* 夏・冬（黄色） */
  --purple: #9b27b0;
  --red: #e53935;
  --blue-date: #2196f3;
  --border: #cfcfcf;
  --bg: #ffffff;
  --ink: #222;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  /* 産前産後サロンらしい、温かみのあるやさしいピンク */
  background: linear-gradient(180deg, #fdeef2 0%, #fbe0e8 100%);
  background-attachment: fixed;
  min-height: 100vh;
}
.hidden { display: none !important; }
code { background: #eee; padding: 1px 5px; border-radius: 4px; }

/* ---- ログイン ---- */
.login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f7c6d4 0%, #f0a6bd 100%);
}
.login-box {
  background: #fff; padding: 32px 28px; border-radius: 12px; width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); text-align: center;
}
.login-box h1 { margin: 0 0 4px; font-size: 26px; }
.login-sub { margin: 0 0 18px; color: #666; font-size: 14px; }
.login-box input {
  width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 12px;
}
.login-box button {
  width: 100%; padding: 10px; font-size: 15px; border: none; border-radius: 8px;
  background: var(--cyan); color: #fff; cursor: pointer;
}
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.login-hint { color: #999; font-size: 12px; margin: 12px 0 0; }

/* ---- レイアウト ---- */
.app { max-width: 100%; padding: 12px 14px 28px; }
.topbar { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 12px; }
.logout { position: absolute; top: 0; right: 0; }
.salon-title { font-size: 22px; font-weight: 700; text-align: center; width: 100%; }

/* タブ */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button {
  flex: 1; padding: 11px 8px; border: 1px solid var(--border); background: #fff;
  border-radius: 10px 10px 0 0; font-size: 14px; font-weight: 700; color: #9a8b90; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--purple); border-color: var(--border); border-bottom: 3px solid var(--purple); background: #fff5f8; }

/* ページ別アクション */
.page-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.page-actions:empty { display: none; }
.palette-edit { display: flex; gap: 8px; }
.pal-btn.del { background: #fde2e2; border-color: #f3b0b0; }
.title-area { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-label { font-size: 20px; font-weight: 700; white-space: nowrap; text-align: center; min-width: 110px; }
.salon-name { font-size: 20px; font-weight: 700; }
.icon-btn { border: 1px solid var(--border); background: #fff; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1; }
.status-badge { padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.status-badge.draft { background: #fff3cd; color: #8a6d00; }
.status-badge.confirmed { background: #d3f3d8; color: #1b7a32; }

.controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ctrl { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.ctrl input { width: 64px; padding: 5px; border: 1px solid var(--border); border-radius: 6px; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--border); background: #fff; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn:hover { background: #f0f0f0; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn-primary:hover { background: #1fb0c7; }
.btn-ghost { background: transparent; }
.btn.small { font-size: 12px; padding: 5px 10px; }

/* ---- パレット ---- */
.palette { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.palette-label { font-size: 13px; color: #666; }
.palette-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.pal-btn { border: 2px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; background: #fff; }
.pal-btn.selected { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(21,179,207,.35); font-weight: 700; }
.pal-btn.work { background: #bfeaf2; }     /* 出勤系（水色） */
.pal-btn.leave { background: #e9f1a8; }    /* 有給・PM休・リフ（黄緑） */
.pal-btn.summer { background: #ffe79a; }   /* 夏・冬（黄色） */
.pal-btn.request { background: #fff; }     /* 希望休（白） */
.pal-btn.rest { background: #f0d7e0; }     /* 公休（休） */
.pal-btn.editing { border-style: dashed; border-color: #f0a; }
.btn.active { background: var(--cyan); color: #fff; border-color: var(--cyan); }
#deleteMode.active { background: #fde2e2; color: #c0392b; border-color: #f3b0b0; }
#customDelete { margin-right: auto; color: var(--red); border-color: var(--red); }

/* ---- シフト表 ---- */
.grid-wrap { overflow-x: auto; border: 2px solid #888; border-radius: 6px; background: #fff; }
.shift-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.shift-table th, .shift-table td { border: 1px solid var(--border); text-align: center; }
.shift-table thead th { background: #fff; padding: 4px 0; width: 34px; min-width: 34px; font-weight: 500; }
.shift-table thead th .dnum { font-size: 14px; }
.shift-table thead th .dwd { font-size: 11px; }
.col-sat .dnum, .col-sat .dwd { color: var(--blue-date); }
.col-sun .dnum, .col-sun .dwd, .col-hol .dnum, .col-hol .dwd { color: var(--red); }
.staff-col { background: #f3f3f3; width: 96px; min-width: 96px; position: sticky; left: 0; z-index: 2; }
.staff-name { cursor: pointer; font-size: 13px; padding: 8px 6px; font-weight: 600; }
.staff-name:hover { text-decoration: underline; color: var(--cyan); }
.shift-table tbody td { height: 44px; width: 34px; min-width: 34px; padding: 0; cursor: pointer; font-size: 11px; line-height: 1.1; }
.shift-table tbody td.work { background: var(--cyan); }
.shift-table tbody td.off-blank { background: #fff; }
.shift-table tbody td.off-leave { background: var(--green); }
.shift-table tbody td.off-summer { background: var(--yellow); }
.shift-table tbody td.off-rest { background: #f0d7e0; }
.cell-label { display: inline-block; padding: 2px; font-weight: 700; }
.cell-dot { color: rgba(255,255,255,.85); }

/* ---- ダイアログ ---- */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dialog { background: #fff; padding: 22px; border-radius: 12px; width: 340px; }
.dialog h2 { margin: 0 0 16px; font-size: 17px; }
.dialog label { display: block; font-size: 13px; margin-bottom: 12px; }
.dialog input, .dialog select { width: 100%; padding: 8px; margin-top: 4px; border: 1px solid var(--border); border-radius: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.warn-list { font-size: 13px; color: #b3261e; padding-left: 18px; max-height: 240px; overflow-y: auto; }

/* ---- カレンダー全画面 ---- */
.calendar-overlay { position: fixed; inset: 0; background: #fff; z-index: 60; display: flex; flex-direction: column; padding: 18px; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.calendar-header span { font-size: 22px; font-weight: 700; }
.cal-close {
  width: 36px; height: 36px; border: none; background: transparent; cursor: pointer;
  font-size: 26px; font-weight: 300; line-height: 1; color: #9a8b90; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.cal-close:hover { background: rgba(0, 0, 0, .06); color: var(--purple); }

/* カレンダー本体は画面の高さいっぱいに広げる */
.calendar-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.cal-head-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 4px; }
.cal-head { text-align: center; font-weight: 700; padding: 2px 0; font-size: 13px; }
.cal-cell { border: 1px solid var(--border); border-radius: 6px; padding: 4px; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cal-cell.empty { border: none; }
.cal-date { font-size: 13px; font-weight: 700; align-self: flex-start; }
.cal-status { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.cal-status.work { background: var(--cyan); color: #fff; }
.cal-status.off-leave { background: var(--green); }
.cal-status.off-summer { background: var(--yellow); }
.cal-status.off-rest { background: #f0d7e0; }
.cal-status.off-blank { color: #bbb; }
.cal-sat .cal-date { color: var(--blue-date); }
.cal-sun .cal-date, .cal-hol .cal-date { color: var(--red); }

/* ハンバーガーメニュー */
.menu-btn { position: absolute; top: 0; right: 0; }
.menu-dropdown { position: absolute; top: 44px; right: 0; z-index: 40; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); overflow: hidden; min-width: 150px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 12px 16px; border: none; background: #fff; font-size: 14px; cursor: pointer; }
.menu-item:hover { background: #fbe9ef; }

/* 共通ツール行（集計・横長シフト表） */
.tool-row { display: flex; gap: 8px; margin-bottom: 12px; }

/* カレンダーヘッダーのアクション */
.cal-header-actions { display: flex; align-items: center; gap: 8px; }

/* 集計テーブル */
.summary-body { max-height: 60vh; overflow-y: auto; }
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table th, .summary-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: center; font-size: 14px; }
.summary-table th { background: #fbe9ef; }
.summary-table td:first-child, .summary-table th:first-child { text-align: left; }

/* 横長シフト表（全画面） */
.landscape-overlay { position: fixed; inset: 0; background: #fff; z-index: 60; display: flex; flex-direction: column; padding: 14px; }
.landscape-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.landscape-header span { font-size: 20px; font-weight: 700; }
.landscape-body { flex: 1; overflow: hidden; }
.landscape-scale-wrap { display: inline-block; transform-origin: top left; }

/* 条件ページ（全画面・閲覧専用） */
.conditions-overlay { position: fixed; inset: 0; background: #fff; z-index: 60; display: flex; flex-direction: column; padding: 18px; }
.conditions-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.conditions-header span { font-size: 20px; font-weight: 700; }
.conditions-body { flex: 1; overflow-y: auto; font-size: 14px; line-height: 1.7; }
.conditions-body h3 { font-size: 16px; margin: 16px 0 6px; color: var(--purple); }
.conditions-body ol, .conditions-body ul { padding-left: 22px; margin: 6px 0; }
.conditions-note { color: #777; font-size: 13px; margin-top: 14px; }

/* ===================== モバイル最適化 ===================== */
@media (max-width: 640px) {
  .app { padding: 10px 10px 24px; }
  .salon-title { font-size: 20px; }
  .month-label { font-size: 19px; min-width: 96px; }
  .icon-btn { width: 40px; height: 40px; font-size: 20px; }
  .status-badge { font-size: 12px; }

  /* 月選択はタイトルと同様に中央配置 */
  .title-area { flex-direction: column; gap: 8px; }
  .salon-title { padding: 0 70px; } /* ログアウトボタンと重ならないように */

  /* タブ・操作ボタンは押しやすく */
  .tabs button { font-size: 13px; padding: 11px 4px; }
  .tool-row .btn { flex: 1 1 auto; min-height: 40px; }
  .page-actions { gap: 8px; }
  .page-actions .btn { flex: 1 1 auto; min-height: 42px; padding: 9px 12px; }
  /* 公休数はラベルと入力を左に寄せて密着 */
  .page-actions .ctrl { flex: 1 1 100%; justify-content: flex-start; gap: 8px; }
  .page-actions .ctrl input { width: 80px; min-height: 38px; }

  /* パレットは横スクロールで1行に */
  .palette { gap: 6px; padding: 8px; }
  .palette-buttons { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .pal-btn { flex: 0 0 auto; min-height: 40px; min-width: 44px; font-size: 14px; }
  #addCustom { flex: 0 0 auto; min-height: 40px; }

  /* シフト表: タップしやすいセル・固定スタッフ列を細く */
  .staff-col { width: 72px; min-width: 72px; }
  .staff-name { font-size: 12px; padding: 6px 4px; }
  .shift-table thead th { width: 38px; min-width: 38px; }
  .shift-table tbody td { width: 38px; min-width: 38px; height: 48px; font-size: 10px; }
  .shift-table thead th .dnum { font-size: 13px; }
  .shift-table thead th .dwd { font-size: 10px; }

  /* カレンダー全画面 */
  .calendar-overlay { padding: 10px; }
  .calendar-header { margin-bottom: 10px; }
  .calendar-header span { font-size: 22px; } /* タイトル（スタッフ名・月）を大きく */
  .cal-grid, .cal-head-row { gap: 3px; }
  .cal-grid { flex: 0 0 auto; grid-auto-rows: 115px; } /* セル高さを約80%に */
  .cal-head { padding: 2px 0; font-size: 12px; }
  .cal-cell { padding: 3px; gap: 2px; }
  .cal-date { font-size: 13px; }
  .cal-status { font-size: 11px; padding: 2px 6px; }

  /* ダイアログは画面幅に追従 */
  .dialog { width: calc(100vw - 40px); max-width: 360px; }
}
