:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1f2430; --muted: #6b7280;
  --line: #e3e6eb; --brand: #1f4e78; --wood-d: #173a5a; --accent: #2563eb;
  --accent-d: #1d4ed8;
  --kit: #6d4c00; --kitbg: #fff7e0;
  --resp: #b45309; --new: #047857;
  --yellow: #ffe08a; --red: #ff9a9a; --okbg: #dcfce7; --ngbg: #fee2e2;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; font-weight: 700; font-size: 16px;
  position: relative; display: inline-flex; align-items: center; }
/* ロゴ文字の後ろに湯気なし土鍋を透かし配置（落ち着いた単色） */
.brand .donabe { position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); height: 42px; width: auto;
  color: #fff; opacity: .16; z-index: 0; pointer-events: none; }
.brand > span { position: relative; z-index: 1; }
.thanks { position: relative; }
.thanks .donabe { position: absolute; left: 50%; top: 40px;
  transform: translateX(-50%); width: 190px; height: auto;
  color: #7ea3c4; opacity: .16; z-index: 0; pointer-events: none; }
.thanks > *:not(.donabe) { position: relative; z-index: 1; }

/* なかよし ロゴ（最初のページ） */
.brandlogo { text-align: center; margin: 6px 0 18px; }
.brandlogo-img { display: block; width: 78%; max-width: 320px; height: auto; margin: 0 auto; }
.topbar a:hover { text-decoration: none; }
main { max-width: 1200px; margin: 0 auto; padding: 18px; }
main.wide { max-width: none; padding: 12px 14px; }

.mainnav { display: flex; gap: 2px; }
.mainnav a { color: #cdd9e8; padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.mainnav a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.logout { color: #cdd9e8; font-size: 12px; margin-left: auto; }
.logout:hover { color: #fff; }
.loginwrap { display: flex; justify-content: center; padding-top: 60px; }
.logincard { width: 320px; max-width: 90vw; }
.viewnav { display: flex; gap: 4px; margin-left: auto; }
.viewnav a { color: #cdd9e8; padding: 4px 10px; border-radius: 6px; }
.viewnav a.active { background: rgba(255,255,255,.18); color: #fff; }

/* フォーム */
.rowbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.formcard { max-width: 720px; }
.vform { display: flex; flex-direction: column; gap: 14px; }
.vform > label { font-size: 13px; color: var(--muted); }
.vform > label input, .vform > label select { width: 100%; margin-top: 4px; }
.frow { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.frow > label { flex: 1; min-width: 120px; }
fieldset.stores { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
fieldset.stores legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.chkbox { display: inline-flex; align-items: center; gap: 4px; margin: 3px 10px 3px 0;
  font-size: 13px; color: var(--ink); }
.chkbox input { width: auto; }
table.daygrid td, table.daygrid th { text-align: center; }
table.daygrid select { padding: 4px 6px; }
.editform { margin-top: 8px; }
.resetform { margin-top: 12px; }
.urlbox { width: 100%; min-width: 240px; font-size: 12px; color: var(--muted); }

/* 店舗シフト（現行スプレッドシート互換グリッド） */
.sheetwrap { overflow: auto; max-height: 82vh; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; }
table.sheetgrid { border-collapse: collapse; font-size: 13px; table-layout: fixed; }
table.sheetgrid th, table.sheetgrid td { border: 1px solid #d7dbe0; padding: 1px 4px;
  white-space: nowrap; text-align: left; overflow: hidden; text-overflow: ellipsis;
  height: 20px; line-height: 18px; }
.sheetgrid col.c-label { width: 120px; }
.sheetgrid col.c-name { width: 120px; }
.sheetgrid col.c-time { width: 120px; }
.sheetgrid thead th { position: sticky; top: 0; z-index: 3; background: #f0f3f7;
  text-align: center; }
.sheetgrid thead tr:nth-child(2) th { top: 22px; }
.sheetgrid thead tr:nth-child(3) th { top: 44px; color: var(--muted); font-weight: 400; }
.sheetgrid .dayhdr { background: #e7edf5; }
.sheetgrid .bandhdr { background: #eef2f7; font-weight: 600; }
.sheetgrid .corner { left: 0; z-index: 5; }
.sheetgrid .storelabel { position: sticky; left: 0; z-index: 2; background: #f7f9fb;
  font-weight: 700; text-align: center; vertical-align: middle; min-width: 64px;
  border-right: 2px solid #aab; }
.sheetgrid tr.sep td { background: #222; height: 16px; padding: 0; border-color: #222; }
.sheetgrid .dstart { border-left: 2px solid #555; }
.sheetgrid .gnm { font-weight: 700; }
.sheetgrid .gtm { color: #111; font-size: 12px; font-weight: 700; }
.sheetgrid .gnm.short { color: #dc2626; font-weight: 800; text-align: center; }
.sheetgrid .closed { background: #ff6b6b; }
/* ランチ=薄オレンジ / ディナー=薄青（手動の塗り色＝inline style が優先される） */
.sheetgrid .band-lunch { background: #fff3e0; }
.sheetgrid .band-dinner { background: #e9f2fb; }
.sheetgrid .gcell { cursor: text; }
.sheetgrid .gcell:hover { outline: 1px solid var(--accent); }
body.painting .sheetgrid .gcell { cursor: pointer; }
body.painting .sheetgrid .gcell:hover { outline: 2px solid #333; }
.sheetgrid .active { outline: 2px solid var(--accent); outline-offset: -2px; background: #eaf1ff; }
/* 範囲選択（塗り色の上でも見えるよう inset shadow で重ねる） */
.sheetgrid .sel { box-shadow: inset 0 0 0 100px rgba(37, 99, 235, .12); }
.sheetgrid .sel-br { position: relative; }
.sheetgrid .sel-br::after { content: ''; position: absolute; right: -1px; bottom: -1px;
  width: 8px; height: 8px; background: var(--accent); cursor: crosshair; }
.sheetgrid .fillpv { box-shadow: inset 0 0 0 100px rgba(37, 99, 235, .07);
  outline: 1px dashed var(--accent); outline-offset: -1px; }
.sheetgrid .gcell.editing { padding: 0; }
.sheetgrid .dup { outline: 2px solid #dc2626; outline-offset: -2px; }
.sheetgrid .dupmark { color: #dc2626; font-weight: 800; margin-left: 2px; }
.sheetgrid .cellinp { width: 100%; box-sizing: border-box; font-size: 13px; font-weight: 700;
  padding: 1px 3px; border: 2px solid var(--accent); outline: none; }

/* グリッド編集ツールバー */
.toolbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.modebtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.palette { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 26px; height: 26px; border: 2px solid var(--line); border-radius: 6px;
  cursor: pointer; padding: 0; }
.swatch.clear { width: auto; padding: 0 8px; height: 26px; background: #fff; font-size: 12px; }
.swatch.sel { border-color: #333; box-shadow: 0 0 0 2px rgba(0,0,0,.2); }

/* グリッド編集 */
.savemsg { color: var(--new); font-weight: 600; margin-left: 8px; }
.storegrid.edit .bandcell { line-height: 2; }
.chip2 { display: inline-flex; align-items: center; gap: 2px; background: #eef2f7;
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px 1px 7px;
  margin: 2px 4px 2px 0; font-size: 12px; white-space: nowrap; }
.chip2.resp { color: var(--resp); font-weight: 700; }
.chip2.newc { color: var(--new); }
.chip2.kit { background: var(--kitbg); }
.chip2 .rm { border: none; background: transparent; color: #b00; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0 2px; }
.chip2 .rm:hover { color: #f00; }
.kdiv2 { display: block; height: 0; border-top: 1px dashed #c9ccd2; margin: 3px 0; }
.addsel { font-size: 11px; padding: 1px 2px; margin: 2px 0; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 6px; max-width: 92px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; margin-bottom: 18px; }
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; }

.genform { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; background: #fff; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 14px; }
.btn.primary, .btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; }
.viewlinks { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }

table.grid { border-collapse: collapse; width: 100%; background: #fff; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
table.grid thead th { background: #f0f3f7; position: sticky; top: 0; }
.msg { color: var(--muted); }
.num { text-align: center; }

.status { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status.done { background: var(--okbg); color: #166534; }
.status.running, .status.pending { background: #e0ecff; color: #1e40af; }
.status.error, .status.infeasible { background: var(--ngbg); color: #991b1b; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 12px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 店舗シフト */
.legend { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: var(--muted); margin: 8px 0 16px; }
.chip { padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.chip.resp { background: #fff2dd; color: var(--resp); }
.chip.newc { background: #e7f7f0; color: var(--new); }
.chip.kit { background: var(--kitbg); color: var(--kit); }
.chip.yellow { background: var(--yellow); color: #7a5b00; }
.chip.red { background: var(--red); color: #7f1d1d; }

.storeblock { margin-bottom: 22px; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.storegrid { border-collapse: collapse; min-width: 100%; }
table.storegrid th, table.storegrid td { border: 1px solid var(--line); padding: 4px 6px;
  vertical-align: top; min-width: 96px; }
table.storegrid thead th { background: #f0f3f7; white-space: nowrap; font-size: 12px; }
.rowhdr { background: #f7f9fb; white-space: nowrap; font-weight: 600; position: sticky; left: 0; }
.storegrid .p { font-size: 12px; line-height: 1.35; white-space: nowrap; }
.storegrid .p.resp { color: var(--resp); font-weight: 700; }
.storegrid .p.newc { color: var(--new); }
.storegrid .p.kit { background: var(--kitbg); border-radius: 4px; padding: 0 3px; }
.storegrid .p .t { color: var(--muted); font-size: 11px; }
.storegrid .kdiv { border-top: 1px dashed #c9ccd2; margin: 3px 0; }
.shortage { color: #dc2626; font-weight: 800; }
.closed { background: #eef0f3; color: var(--muted); text-align: center; }

/* 店舗シフト: 日=行 / ランチ・ディナー=横並び */
table.storegrid.wide { width: 100%; table-layout: fixed; }
table.storegrid.wide .rowhdr { width: 92px; }
table.storegrid.wide thead th { text-align: center; }
.bandcell { vertical-align: top; }
.bandcell .p { display: inline-block; margin: 1px 6px 1px 0; white-space: nowrap; }
.bandcell .kdiv { display: block; width: 100%; }
tr.closedrow .rowhdr { color: var(--muted); }

/* 個人 */
.picker { margin: 10px 0 16px; }
table.personal td .t { color: var(--muted); font-size: 12px; }
table.personal td.t { color: #1d6fb8; }
tr.offrow td { background: #fafbfc; color: var(--muted); }
tr.totalrow td { background: #f0f3f7; font-weight: 600; }

/* 集計 */
table.summary .nm { font-weight: 600; white-space: nowrap; }
table.grid tr.yellow td { background: var(--yellow); }
table.grid tr.red td { background: var(--red); }
table.grid .nm { font-weight: 600; white-space: nowrap; }
table.summary .unmet { color: #991b1b; font-weight: 600; }

/* チェック */
.banner { padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.banner.ok { background: var(--okbg); color: #166534; }
.banner.ng { background: var(--ngbg); color: #991b1b; }
.checkgroup { background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; margin: 10px 0; }
.checkgroup h2 { margin: 4px 0; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.count { background: var(--ngbg); color: #991b1b; border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.count.zero { background: var(--okbg); color: #166534; }
.checklist { margin: 6px 0; padding-left: 20px; }
.checklist li { margin: 2px 0; }

/* スマホ: 店舗シフトを画面いっぱい＋指でつまんで拡大縮小（ピンチズーム） */
@media (max-width: 820px) {
  main, main.wide { padding: 4px; }
  .sheetwrap { overflow: visible; max-height: none; border: none; }
  .topbar { flex-wrap: wrap; row-gap: 4px; padding: 8px 10px; }
  .mainnav, .viewnav { flex-wrap: wrap; }
}

/* 店舗ルール設定 */
.rules-store h2 { margin: 0 0 8px; }
.rules-store h3 { margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
table.rulesgrid input[type=number] { width: 56px; text-align: center; }
table.rulesgrid .rk { font-size: 12px; color: var(--muted); white-space: nowrap; }
tr.frow-min td { border-bottom: none; }
.totalfield { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.totalfield input { width: 64px; margin-left: 6px; text-align: center; }
.rules-resp { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; }
.msel { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.msel select[multiple] { min-width: 150px; padding: 4px; }
.btn.danger { border-color: #dc2626; color: #dc2626; }
.btn.danger:hover { background: #dc2626; color: #fff; }
p.ok { background: var(--okbg); color: #166534; padding: 8px 12px; border-radius: 8px; }

/* 生成カウントダウン */
.countdown-wrap { margin: 10px 0 6px; }
.countdown { font-size: 30px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.progtrack { margin-top: 8px; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progbar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 1s linear; }

/* 名簿の操作ボタン */
.rowact { white-space: nowrap; }
.rowact form { margin-left: 8px; }
.btn-sm { padding: 3px 10px; font-size: 12px; border-radius: 6px; }

/* 提出完了画面 */
.thanks { text-align: center; max-width: 460px; margin: 40px auto; }
.thanks-mark { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.thanks h1 { border: none; padding: 0; justify-content: center; }
.thanks-btns { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* 休み希望なし */
.chkbox.nooff { display: flex; margin: 0 0 8px; padding: 6px 10px; border-radius: 8px;
  background: #eef4ff; border: 1px solid #cfe0ff; font-weight: 600; }

/* 発表 */
.publishbox { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.publishbox h3 { margin: 0 0 6px; }
.pubbadge { margin-left: 10px; color: #166534; font-weight: 600; font-size: 13px; }

/* 希望入力: 区分選択 */
.pickkind { display: flex; gap: 14px; margin: 8px 0; }
.btn.big { font-size: 18px; padding: 18px 28px; flex: 1; text-align: center; }
.back { margin-top: 14px; font-size: 13px; }
