/* Peach Style GYM 加盟店ポータル
   ブランド：#FC9484（サーモンピンク）。グラデーション禁止・Material Pink系禁止（§8-A）。
   モバイル優先（アプリのように使える＝下部タブ＋1画面1目的）。 */
:root {
  --peach: #FC9484;
  --peach-dark: #F47A6A;
  --peach-soft: #ffe7e1;
  --peach-softer: #fff4f1;
  --ink: #333333;
  --muted: #8a817c;
  --line: #f0dcd6;
  --ok: #2e9e6b;
  --warn: #d67a12;
  --danger: #d64545;
  --bg: #fffaf8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(244,122,106,.10);
  --tabbar: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
button, input, select, textarea { font-family: inherit; font-size: 16px; color: var(--ink); }
button { cursor: pointer; }
a { color: var(--peach-dark); }
h2 { font-size: 19px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

/* ヘッダー */
.top {
  background: var(--peach); color: #fff; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow);
}
.top h1 { font-size: 16px; margin: 0; font-weight: 700; white-space: nowrap; }
@media (max-width: 420px) { .top h1 { font-size: 14px; } .top { padding: 12px 12px; gap: 8px; } }
/* ヘッダーの店舗切替（本部のみ表示）。何の入力欄か分かるようにラベルを付ける */
.top .switch-label { font-size: 12px; font-weight: 700; opacity: .95; flex: 0 0 auto; }
#store-switch { flex: 0 1 220px; min-width: 120px; }
#store-switch input {
  padding: 8px 30px 8px 12px; border-radius: 999px; border-width: 0; font-size: 14px;
  text-align: left; text-overflow: ellipsis;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23F47A6A' stroke-width='2'/></svg>") no-repeat right 12px center;
}
.top .spacer { flex: 1; }
.top .who { font-size: 12px; background: rgba(255,255,255,.22); padding: 5px 10px; border-radius: 999px; }
.top .icon-btn { background: rgba(255,255,255,.2); border: 0; color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.top #back { font-size: 18px; line-height: 1; padding: 5px 12px; flex: 0 0 auto; }

.wrap { max-width: 940px; margin: 0 auto; padding: 14px 14px 30px; }

/* カード */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card h3 { margin-top: 0; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-r { flex-wrap: wrap; }
.spacer { flex: 1; }
.right { margin-left: auto; }

/* ボタン */
.btn {
  background: #fff; border: 2px solid var(--line); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 700; color: var(--ink);
}
.btn:hover { border-color: var(--peach); }
.btn-primary { background: var(--peach); border-color: var(--peach); color: #fff; }
.btn-primary:hover { background: var(--peach-dark); border-color: var(--peach-dark); }
.btn-primary:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: #f3d3d3; }

/* 入力 */
label.f { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 700; color: #5b524e; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 11px 13px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--peach); }
textarea { min-height: 90px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 検索バー（全データ画面に必須） */
.searchbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.searchbar input[type=text] { flex: 1; min-width: 180px; border-radius: 999px; }
.searchbar select { width: auto; min-width: 150px; border-radius: 999px; padding: 9px 12px; }

/* コンボボックス（選択＋打ち込み絞り込み） */
.combo { position: relative; }
/* ⚠️ この部品はヘッダー（白文字）の中でも使う。色を指定しないと文字色が白のままになり、
   白い背景と同化して候補が読めなくなる（2026-08-25に代表から指摘・実測して修正）。 */
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
  /* 高さが足りないと最後の店舗（読谷など）が切れて「無い」ように見える。
     画面の高さに合わせて伸ばす（2026-08-25に代表から指摘・実測して修正）。 */
  /* vh が正しく取れない環境（一部の埋め込み表示）でも潰れないよう下限を付ける。 */
  max-height: max(400px, min(62vh, 460px)); overflow: auto; box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.combo-list div { padding: 10px 13px; font-size: 14px; color: var(--ink);
  border-bottom: 1px solid var(--peach-softer); }
.combo-list .muted, .combo-list .small { color: var(--muted); }
/* 入力中の文字と、うすい案内文も明示しておく（端末の設定で色が変わるのを防ぐ） */
.combo input { color: var(--ink); background-color: #fff; }
.combo input::placeholder { color: #9a908b; opacity: 1; }
#store-switch input { color: var(--ink); }
#store-switch input::placeholder { color: #9a908b; opacity: 1; }
.combo-list div:last-child { border-bottom: 0; }
.combo-list div:hover, .combo-list div.on { background: var(--peach-softer); }

/* バッジ・チップ */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--peach-soft); color: var(--peach-dark); }
.badge.ok { background: #e3f5eb; color: var(--ok); }
.badge.warn { background: #fdf0e0; color: var(--warn); }
.badge.danger { background: #fbe4e4; color: var(--danger); }
.badge.gray { background: #eee9e7; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; }
.chip.active { background: var(--peach); border-color: var(--peach); color: #fff; }

/* 進捗バー */
.bar { height: 10px; background: var(--peach-softer); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--peach); }

/* 一覧 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.item .t { font-weight: 700; font-size: 15px; }
.item .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item.done { opacity: .6; }
.item.locked { background: #faf7f6; }
.check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  background: #fff; flex: 0 0 auto; display: grid; place-items: center; font-size: 15px; color: #fff;
}
.check.on { background: var(--ok); border-color: var(--ok); }
.check.lock { background: #eee9e7; border-color: #e2dbd8; color: var(--muted); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 21px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .n { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* テーブル（横スクロール可） */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
th.sorted::after { content: ' ▾'; color: var(--peach); }
th.sorted.asc::after { content: ' ▴'; }

/* 画面が低いとき（横向きのスマホ・小さいウィンドウ）は、上下の帯で内容が潰れないようにする */
@media (max-height: 520px) {
  .top { position: static; padding: 8px 12px; }        /* 貼り付けをやめて場所を空ける */
  .top h1 { font-size: 13px; }
  .top .switch-label { display: none; }                /* ▼で選択欄と分かるのでラベルは省く */
  #store-switch input { padding: 6px 26px 6px 10px; font-size: 13px; }
  .tabbar button { padding: 4px 2px 6px; font-size: 9.5px; }
  .tabbar button .i { font-size: 16px; }
  .wrap { padding: 10px 12px 20px; }
  .card { padding: 12px 14px; margin-bottom: 10px; }
}

/* 指で押しやすい大きさを確保（スマホ） */
@media (pointer: coarse) {
  .btn, .chip, .check, .tabbar button { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .check { width: 30px; }
}

/* 下部タブ（アプリUX） */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; padding: 8px 2px 10px; font-size: 10.5px; color: var(--muted); font-weight: 700;
}
.tabbar button .i { display: block; font-size: 19px; line-height: 1.25; }
.tabbar button.on { color: var(--peach-dark); }

/* モーダル
   画面が低いとき（横向きのスマホなど）に、下の操作ボタンが画面の外に出て押せなくなっていた。
   本体をスクロールさせ、最後の操作ボタンは下に貼り付けて常に見えるようにする。 */
.modal-bg { position: fixed; inset: 0; background: rgba(51,48,46,.45); z-index: 40; display: grid; place-items: end center; }
.modal {
  background: #fff; width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh;      /* dvh＝ブラウザのバーを除いた実際の高さ */
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 18px 18px 0 0; padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
}
.modal > .row:first-child { flex: 0 0 auto; padding-bottom: 8px; }
.modal > [data-body] { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* 最後の操作ボタン（保存・追加など）を下端に固定して、スクロールしなくても押せるようにする */
.modal > [data-body] > button.btn-primary:last-child,
.modal > [data-body] > .row:last-child {
  position: sticky; bottom: 0; z-index: 2;
  background: #fff; box-shadow: 0 -8px 12px -8px rgba(51,48,46,.18);
  padding-top: 10px; margin-bottom: 0;
}
@media (min-width: 640px) {
  .modal-bg { place-items: center; }
  .modal { border-radius: 18px; }
}
.modal h3 { margin-top: 0; font-size: 17px; }

/* 通知バナー */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 14px);
  background: #333; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 50;
  max-width: 90vw; text-align: center;
}
.toast.err { background: var(--danger); }

.notice { background: var(--peach-softer); border: 1px solid var(--peach-soft); border-radius: 12px; padding: 11px 13px; font-size: 13px; }
.notice.warn { background: #fdf6ec; border-color: #f6e0c0; }
.notice.danger { background: #fdeeee; border-color: #f6cccc; }

.sig-pad { width: 100%; height: 170px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; }
img.evi { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.md { font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.md h1, .md h2 { font-size: 17px; margin: 12px 0 6px; }

/* ──────────────────────────────────────────────────────────────
   iOS Safari は、入力欄の文字が16px未満だとタップした瞬間に画面を自動で拡大する。
   拡大されると position:fixed の上下バーが画面の外へ押し出され、ボタンが押せなくなる
   （代表から報告された「拡大縮小すると上下のボタンが押せない」の直接の原因）。
   実測では、ヘッダーの店舗切替（14px／低い画面では13px）が全画面で該当していた。
   → スマホ幅では入力欄を必ず16pxにして、そもそも拡大させない。
   高さは文字ではなく余白で詰める。
   ※ C-2セッションからの共有を受けて、C-1/C-2/C-4と同じ対策を適用。
   ────────────────────────────────────────────────────────────── */
/* 幅ではなく「タッチ端末かどうか」で判定する。
   横向きのスマホは幅が812pxほどあり、幅だけの条件（768px以下）から漏れていたため。 */
@media (pointer: coarse), (max-width: 960px) {   /* 960px＝iPhone Pro Max の横向き956pxまで含める */
  input, select, textarea { font-size: 16px; }
  .searchbar select { font-size: 16px; }
  html { scroll-padding-top: 84px; }
  /* 高さは文字ではなく余白で詰める（文字を小さくすると自動拡大が復活する） */
  #store-switch input { font-size: 16px; padding: 7px 28px 7px 10px; }
}
@media (pointer: coarse) and (max-height: 520px), (max-width: 960px) and (max-height: 520px) {
  #store-switch input { font-size: 16px; padding: 4px 26px 4px 9px; }
  .top { padding: 6px 12px; }
}

/* ── 担当バー（全画面・ヘッダー直下）──────────────────────────────
   代表指示 2026-11-01：どのセッションがどう担当しているかを常に見えるようにする。
   小さい画面では折り返して2行になる。最終更新は“データ自身の時刻”しか出さない。 */
.ownerbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 7px 14px; font-size: 11.5px; line-height: 1.5;
  color: #6b625f; background: #fbf7f6; border-bottom: 1px solid #efe6e4;
}
.ownerbar .ob-item { white-space: nowrap; }
.ownerbar .ob-item b { color: #4a4240; font-weight: 600; }
.ownerbar .ob-sep { color: #d8cdca; }
.ownerbar .ob-src { white-space: normal; }
.ownerbar .ob-spacer { flex: 1 1 auto; }
.ownerbar .ob-btn {
  flex: 0 0 auto; border: 1px solid #f2b5aa; background: #fff; color: #c7543f;
  border-radius: 999px; padding: 4px 11px; font-size: 11.5px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ownerbar .ob-btn:hover { background: #fff4f1; }
.ownerbar .ob-btn[disabled] { opacity: .55; cursor: default; }
.ownerbar .ob-msg { white-space: normal; color: #2f7a4f; }
.ownerbar .ob-msg.err { color: #c0392b; font-weight: 600; }
.ownerbar .ob-none { color: #9a8f8c; }
@media (max-width: 420px) {
  .ownerbar { font-size: 11px; padding: 6px 12px; }
}
