:root {
  --teal: #0F766E;
  --teal-d: #115E59;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --ink: #1F2937;
  --mut: #6B7280;
  --line: #E5E7EB;
  --red: #DC2626;
  --blue: #2563EB;
  --amber-bg: #FEF3C7; --amber-ink: #92400E;
  --indigo-bg: #E0E7FF; --indigo-ink: #3730A3;
  --teal-bg: #CCFBF1; --teal-ink: #115E59;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* デモバナー */
.demo-banner {
  background: #1F2937; color: #FDE68A;
  font-size: 12px; font-weight: 500;
  padding: 7px 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  position: sticky; top: 0; z-index: 50;
}
.bn-reset {
  background: none; border: 1px solid #FDE68A66; color: #FDE68A;
  border-radius: 99px; font-size: 11px; padding: 1px 10px;
}

/* ヘッダー */
.app-header {
  background: linear-gradient(135deg, var(--teal), var(--teal-d));
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.shop { display: flex; align-items: center; gap: 10px; }
.shop-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,.15);
  display: grid; place-items: center; font-size: 22px;
}
.shop-name { font-weight: 900; font-size: 17px; letter-spacing: .04em; }
.shop-sub { font-size: 11px; opacity: .85; }
.role-switch { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.role-switch span { font-size: 10px; opacity: .85; }
.role-switch select {
  font-family: inherit; font-size: 13px; font-weight: 700;
  border: none; border-radius: 8px; padding: 6px 8px;
  background: #fff; color: var(--ink); max-width: 190px;
}

/* レイアウト */
main { padding: 14px 12px 8px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: 14px;
  padding: 16px 14px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card.slim { padding: 10px 14px; }
.card h2 { font-size: 16px; margin: 0 0 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.mut { color: var(--mut); }
.small { font-size: 12px; }
.empty { color: var(--mut); font-size: 13px; text-align: center; padding: 18px 0; margin: 0; }

.badge {
  background: #F3F4F6; color: var(--mut);
  border-radius: 99px; font-size: 12px; font-weight: 700; padding: 3px 11px; white-space: nowrap;
}
.badge.ok { background: var(--teal-bg); color: var(--teal-ink); }
.badge.warn { background: var(--amber-bg); color: var(--amber-ink); }
.notice {
  background: var(--amber-bg); color: var(--amber-ink);
  border-radius: 10px; font-size: 13px; padding: 9px 12px; margin: 8px 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.notice.ok-n { background: var(--teal-bg); color: var(--teal-ink); }

/* ボタン */
.btn {
  border: none; border-radius: 11px;
  font-weight: 700; font-size: 14px;
  padding: 11px 16px;
  transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:disabled { background: #9CA3AF; cursor: default; }
.btn.ghost { background: #F3F4F6; color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.big { font-size: 15px; padding: 14px 18px; }
.btn.wide { width: 100%; display: block; }
.btn.mini { font-size: 11px; padding: 4px 12px; border-radius: 99px; background: #fff; color: var(--amber-ink); border: 1px solid currentColor; }
.btnrow { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; min-width: 130px; }

/* セグメント切替 */
.seg { display: inline-flex; background: #F3F4F6; border-radius: 99px; padding: 3px; }
.seg-b { border: none; background: none; border-radius: 99px; font-size: 13px; font-weight: 700; padding: 5px 16px; color: var(--mut); }
.seg-b.on { background: var(--teal); color: #fff; }

/* カレンダー */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin: 10px 0 6px; }
.cal-h { text-align: center; font-size: 11px; font-weight: 700; color: var(--mut); padding: 2px 0; }
.cal-h.sun { color: var(--red); }
.cal-h.sat { color: var(--blue); }
.cal-cell {
  background: #FAFAFB; border: 1px solid var(--line); border-radius: 8px;
  min-height: 54px; padding: 3px 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  overflow: hidden;
}
.cal-cell.blank { background: none; border: none; }
.cal-cell[data-act] { cursor: pointer; }
.cal-cell.today { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.cal-d { font-size: 11px; font-weight: 700; color: var(--mut); line-height: 1.2; }
.cal-cell.sun .cal-d { color: var(--red); }
.cal-cell.sat .cal-d { color: var(--blue); }

.pill {
  display: inline-block; border-radius: 6px;
  font-size: 11px; font-weight: 900; line-height: 1.5;
  padding: 1px 7px; white-space: nowrap;
}
.p-early { background: var(--amber-bg); color: var(--amber-ink); }
.p-late { background: var(--indigo-bg); color: var(--indigo-ink); }
.p-both { background: var(--teal-bg); color: var(--teal-ink); }
.p-off { background: #F3F4F6; color: var(--mut); }
.p-none { color: #D1D5DB; background: none; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--mut); }

/* 確定プレビュー用カレンダー */
.cal.cf .cal-cell { min-height: 64px; }
.cf-slot {
  font-size: 9.5px; font-weight: 700; line-height: 1.45;
  width: 100%; text-align: center; border-radius: 4px; padding: 0 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cf-slot.early { background: var(--amber-bg); color: var(--amber-ink); }
.cf-slot.late { background: var(--indigo-bg); color: var(--indigo-ink); }
.cf-slot.short { background: #FEE2E2; color: var(--red); }

/* 次の出勤カード */
.next-card { background: linear-gradient(135deg, var(--teal), var(--teal-d)); color: #fff; }
.next-card .mut { color: rgba(255,255,255,.8); }
.next-main { font-size: 17px; font-weight: 900; margin-top: 2px; }

.stats3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin: 10px 0; }
.stats3 div { background: #F8FAFA; border-radius: 10px; text-align: center; padding: 9px 4px; }
.stats3 b { font-size: 18px; display: block; line-height: 1.3; }
.stats3 span { font-size: 11px; color: var(--mut); }

/* 「代わって」 */
.swap-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.swap-row:last-child { border-bottom: none; }
.swap-row .btn { flex-shrink: 0; padding: 8px 14px; font-size: 13px; }

/* 希望状況テーブル（店長） */
.tbl-wrap { overflow-x: auto; margin: 8px -14px 4px; padding: 0 14px; }
.ptable { border-collapse: collapse; font-size: 11px; }
.ptable th, .ptable td { border: 1px solid var(--line); text-align: center; min-width: 26px; padding: 3px 2px; }
.ptable thead th { background: #F8FAFA; font-weight: 700; color: var(--mut); }
.ptable thead th.sun { color: var(--red); }
.ptable thead th.sat { color: var(--blue); }
.ptable .sticky {
  position: sticky; left: 0; background: #fff; z-index: 2;
  font-weight: 700; white-space: nowrap; padding: 3px 7px; text-align: left;
}
.ptable thead .sticky { background: #F8FAFA; }
.mini-warn { color: var(--red); font-size: 9px; vertical-align: super; margin-left: 1px; }
.c-early { background: var(--amber-bg); color: var(--amber-ink); font-weight: 700; }
.c-late { background: var(--indigo-bg); color: var(--indigo-ink); font-weight: 700; }
.c-both { background: var(--teal-bg); color: var(--teal-ink); font-weight: 700; }
.c-off { background: #F3F4F6; color: var(--mut); }
.c-un { color: #D1D5DB; }
.lg { display: inline-block; border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; }

/* シフト作成（店長） */
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-card { background: var(--card); border-radius: 12px; padding: 9px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.day-head { font-size: 13px; font-weight: 900; margin-bottom: 4px; }
.day-head.sun { color: var(--red); }
.day-head.sat { color: var(--blue); }
.slot-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.slot-lb { font-size: 11px; font-weight: 900; border-radius: 6px; padding: 2px 8px; flex-shrink: 0; }
.slot-lb.early { background: var(--amber-bg); color: var(--amber-ink); }
.slot-lb.late { background: var(--indigo-bg); color: var(--indigo-ink); }
.cnt { font-size: 11px; font-weight: 700; color: var(--mut); flex-shrink: 0; }
.cnt.short { color: var(--red); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #F3F4F6; border: 1px solid var(--line); border-radius: 99px;
  font-size: 12px; font-weight: 700; padding: 3px 9px;
}
.chip i { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }
.chip b { color: var(--mut); font-weight: 400; }
.chip.add { background: var(--teal-bg); color: var(--teal-ink); border-color: transparent; font-weight: 900; padding: 3px 12px; }

/* 候補リスト（ボトムシート内） */
.cand-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.cand {
  display: flex; align-items: center; gap: 10px;
  background: #F8FAFA; border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; text-align: left; font-weight: 700;
}
.cand i { width: 11px; height: 11px; border-radius: 99px; flex-shrink: 0; }
.cand small { margin-left: auto; color: var(--mut); font-weight: 400; font-size: 11px; text-align: right; }
.cand.dis { opacity: .45; cursor: default; }

/* 人件費 */
.cost-total {
  display: flex; align-items: baseline; justify-content: space-between;
  background: #F8FAFA; border-radius: 10px; padding: 10px 14px; margin: 8px 0;
}
.cost-total b { font-size: 22px; color: var(--teal); }
.ctable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctable th, .ctable td { border-bottom: 1px solid var(--line); padding: 7px 4px; text-align: left; }
.ctable thead th { font-size: 11px; color: var(--mut); font-weight: 700; }
.ctable .r { text-align: right; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 99px; display: inline-block; margin-right: 6px; }

/* タブバー */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; max-width: 180px;
  border: none; background: none;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10.5px; font-weight: 700; color: var(--mut);
  padding: 5px 2px; border-radius: 10px;
}
.tab .ic { font-size: 19px; line-height: 1.2; }
.tab.on { color: var(--teal); background: var(--teal-bg); }

/* ボトムシート */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet.hidden { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #fff; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 72vh; overflow-y: auto;
  max-width: 720px; margin: 0 auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-panel h3 { margin: 0 0 4px; font-size: 16px; }
.optgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 10px; }
.opt {
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font-weight: 900; font-size: 14px; padding: 13px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.opt small { font-weight: 400; font-size: 11px; color: var(--mut); }
.o-early { background: var(--amber-bg); border-color: var(--amber-bg); color: var(--amber-ink); }
.o-late { background: var(--indigo-bg); border-color: var(--indigo-bg); color: var(--indigo-ink); }
.o-both { background: var(--teal-bg); border-color: var(--teal-bg); color: var(--teal-ink); }
.o-off { background: #F3F4F6; border-color: #F3F4F6; color: var(--mut); }
.opt.sel { border-color: var(--ink); }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1F2937; color: #fff;
  border-radius: 12px; font-size: 13px; font-weight: 500;
  padding: 11px 18px; z-index: 70;
  max-width: calc(100vw - 32px); width: max-content;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  animation: up .2s ease-out;
}
.toast.hidden { display: none; }

/* スピナー */
.spin-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(255,255,255,.7);
  display: grid; place-items: center;
}
.spin-box {
  background: #fff; border-radius: 14px; padding: 20px 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,.15);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 700;
}
.spinner {
  width: 30px; height: 30px; border-radius: 99px;
  border: 4px solid var(--teal-bg); border-top-color: var(--teal);
  animation: rot .7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* イントロ */
.overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(17,24,39,.55);
  display: grid; place-items: center; padding: 20px;
}
.intro {
  background: #fff; border-radius: 18px;
  padding: 26px 22px; max-width: 420px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.intro-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 10px;
  background: linear-gradient(145deg, var(--teal), #134E4A);
  display: grid; place-items: center; font-size: 32px;
}
.intro h2 { font-size: 18px; margin: 0 0 8px; }
.intro p { font-size: 13.5px; margin: 0 0 12px; text-align: left; }
.demo-chip { background: var(--amber-bg); color: var(--amber-ink); border-radius: 6px; font-size: 11px; padding: 2px 8px; vertical-align: middle; }

/* 印刷 */
.print-title { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
  .print-title { display: block; }
}

/* デスクトップ微調整 */
@media (min-width: 760px) {
  body { font-size: 15.5px; }
  .cal-cell { min-height: 62px; }
  .cal.cf .cal-cell { min-height: 72px; }
  .cf-slot { font-size: 11px; }
}
