:root {
  --navy: #1a2f5e;
  --navy-dark: #12224a;
  --navy-light: #2c4a86;
  --ink: #1c1f26;
  --ink-sub: #5a6273;
  --line: #d9dee7;
  --line-soft: #eaeef4;
  --bg: #f4f6fa;
  --white: #ffffff;
  --accent-soft: #eef2f9;
  --ok: #0f7a52;
  --ok-bg: #e8f5ef;
  --warn: #9a5b00;
  --warn-bg: #fdf3e2;
  --danger: #a32020;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(26, 47, 94, .06), 0 4px 16px rgba(26, 47, 94, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 700; margin: 0; line-height: 1.45; letter-spacing: .01em; }
p { margin: 0; }

/* ---------- ヘッダー ---------- */
.site-header {
  background: var(--navy);
  color: var(--white);
  padding: 14px 16px 15px;
  border-bottom: 3px solid var(--navy-light);
}
.site-header .inner { max-width: 760px; margin: 0 auto; }
.site-header .org {
  font-size: 11px;
  letter-spacing: .12em;
  color: #b9c6e0;
  font-weight: 500;
  margin-bottom: 3px;
}
.site-header h1 {
  font-size: 17px;
  letter-spacing: .02em;
}

/* ---------- レイアウト ---------- */
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--navy);
}

.lead { font-size: 14px; color: var(--ink-sub); margin-bottom: 16px; }
.cap-note { font-size: 12px; color: var(--ink-sub); margin: -8px 0 16px; }

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .28s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- フォーム ---------- */
.field { margin-bottom: 18px; }
.field > label.lbl {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 7px;
}
.field .hint { font-size: 12px; color: var(--ink-sub); margin-top: 6px; }
.req {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  background: #b03a3a;
  border-radius: 2px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: 2px;
  letter-spacing: .04em;
}

input[type="number"], input[type="text"], select {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #a9b3c4;
  border-radius: 6px;
  padding: 11px 12px;
  width: 100%;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus {
  outline: 2px solid var(--navy-light);
  outline-offset: 1px;
  border-color: var(--navy-light);
}
select {
  background-image: linear-gradient(45deg, transparent 50%, #55617a 50%), linear-gradient(135deg, #55617a 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.dob-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 7px; align-items: center; }
.dob-unit { display: flex; align-items: center; gap: 5px; min-width: 0; }
.dob-unit select { min-width: 0; }
.dob-unit span { font-size: 13px; color: var(--ink-sub); flex: none; }

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 13px 18px;
  width: 100%;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-dark); }
.btn-outline { background: var(--white); color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-quiet { background: var(--white); color: var(--ink-sub); border-color: var(--line); }
.btn-quiet:hover { background: var(--bg); }
.btn-danger { background: var(--white); color: var(--danger); border-color: #d9a5a5; }
.btn-danger:hover { background: #fbf0f0; }
.btn-sm { font-size: 13px; padding: 8px 12px; width: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 通知 ---------- */
.notice {
  border-left: 4px solid var(--navy);
  background: var(--accent-soft);
  padding: 12px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  margin-bottom: 16px;
}
.notice .notice-t { font-weight: 700; margin-bottom: 4px; font-size: 13px; }
.notice ul { margin: 6px 0 0; padding-left: 1.1em; }
.notice li { margin-bottom: 2px; }

.login-note {
  font-size: 12px;
  color: var(--ink-sub);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.error-msg {
  display: none;
  background: #fdf0f0;
  border: 1px solid #e5bcbc;
  color: #8f1f1f;
  border-radius: 6px;
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.error-msg.show { display: block; }

/* ---------- 本人確認 ---------- */
.person-box {
  background: var(--accent-soft);
  border: 1px solid #c9d5ea;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 18px;
}
.person-box .row { display: flex; gap: 12px; font-size: 13px; padding: 3px 0; }
.person-box .row .k { color: var(--ink-sub); width: 5.5em; flex: none; }
.person-box .row .v { font-weight: 700; }
.person-box .row .v.big { font-size: 19px; letter-spacing: .04em; }

/* ---------- 枠リスト ---------- */
.day-group { margin-bottom: 18px; }
.day-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  padding: 6px 0 7px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.day-head .dow { font-size: 12px; color: var(--ink-sub); font-weight: 500; }

.slot-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  font-family: inherit;
  background: var(--white);
  border: 1px solid #b9c3d4;
  border-radius: 6px;
  padding: 14px 10px;
  min-height: 62px;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.slot:hover {
  border-color: var(--navy);
  background: #f7f9fd;
  box-shadow: 0 2px 8px rgba(26, 47, 94, .1);
}
.slot .time { font-size: 19px; font-weight: 700; letter-spacing: .02em; line-height: 1.2; }
.slot .state { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--navy); }
.slot.mine {
  border-color: var(--navy);
  border-width: 2px;
  background: var(--accent-soft);
  padding: 13px 9px;
}

.contact-note {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 14px;
  margin-bottom: 16px;
  text-align: center;
}

.op-btns { display: flex; flex-wrap: wrap; gap: 6px; }

.empty-note {
  background: var(--accent-soft);
  border: 1px solid #c9d5ea;
  border-radius: 6px;
  padding: 16px;
  font-size: 14px;
  text-align: center;
}

/* ---------- 完了 ---------- */
.done-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--ok-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.done-mark svg { width: 24px; height: 24px; }
.done-title { text-align: center; font-size: 18px; margin-bottom: 6px; }
.done-sub { text-align: center; font-size: 13px; color: var(--ink-sub); margin-bottom: 20px; }

.receipt {
  border: 2px solid var(--navy);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}
.receipt .rh {
  background: var(--navy);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 7px 14px;
  text-align: center;
}
.receipt .rb { padding: 4px 14px 14px; }
.receipt .line { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.receipt .line:last-child { border-bottom: 0; }
.receipt .line .k { font-size: 12px; color: var(--ink-sub); width: 5.5em; flex: none; }
.receipt .line .v { font-weight: 700; font-size: 15px; }
.receipt .line .v.dt { font-size: 20px; letter-spacing: .02em; }

/* ---------- モーダル ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(18, 27, 45, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.modal-back[hidden] { display: none; }
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--white);
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  padding: 22px 20px 20px;
  transform: translateY(10px) scale(.985);
  transition: transform .2s ease;
  box-shadow: 0 18px 50px rgba(12, 22, 45, .3);
}
.modal-back.open .modal { transform: none; }
.modal h3 { font-size: 16px; margin-bottom: 12px; }
.modal .m-body { font-size: 14px; margin-bottom: 18px; }
.modal .m-slot {
  background: var(--accent-soft);
  border: 1px solid #c9d5ea;
  border-radius: 6px;
  text-align: center;
  padding: 14px 10px;
  margin: 12px 0 14px;
}
.modal .m-slot .d { font-size: 14px; font-weight: 700; }
.modal .m-slot .t { font-size: 24px; font-weight: 700; letter-spacing: .03em; }
.modal .m-note { font-size: 12px; color: var(--ink-sub); }
.modal .m-btns { display: flex; gap: 10px; }
.modal .m-btns .btn { flex: 1; }


/* ---------- 管理画面 ---------- */
.admin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 16px; }
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat .l { font-size: 11px; color: var(--ink-sub); font-weight: 500; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 620px;
}
table.grid th {
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .04em;
  text-align: left;
  padding: 9px 10px;
  white-space: nowrap;
}
table.grid td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.grid tbody tr:nth-child(even) { background: #fafbfd; }
table.grid tbody tr:hover { background: var(--accent-soft); }
table.grid td.rank { font-weight: 700; color: var(--navy); text-align: center; width: 44px; }
table.grid td.num { font-variant-numeric: tabular-nums; }
table.grid td.name { font-weight: 700; white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.badge.none { background: #eef0f4; color: #6b7382; }
.badge.guided { background: var(--warn-bg); color: var(--warn); }
.badge.fixed { background: var(--ok-bg); color: var(--ok); }
.fixed-dt { font-size: 12px; font-weight: 700; margin-top: 2px; white-space: nowrap; }

.slotgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sg-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--white);
}
.sg-item.full { background: var(--ok-bg); border-color: #b3ddca; }
.sg-item.partial { background: var(--warn-bg); border-color: #e8cf9f; }
.sg-item .sg-d { font-size: 11px; color: var(--ink-sub); }
.sg-item .sg-t {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.sg-item .sg-cap {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-sub);
  background: rgba(255, 255, 255, .75);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 5px;
  flex: none;
}
.sg-item.full .sg-cap { color: var(--ok); border-color: #a9d5c1; }
.sg-item.partial .sg-cap { color: var(--warn); border-color: #e0c48f; }
.sg-item .sg-w {
  font-size: 12px;
  line-height: 1.6;
  font-weight: 700;
  color: var(--ok);
  padding-top: 2px;
  border-top: 1px dotted rgba(90, 98, 115, .28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-item.partial .sg-w { color: var(--warn); }
.sg-item .sg-w.free { color: #a3aab8; font-weight: 500; }

@media (min-width: 600px) {
  .site-header h1 { font-size: 20px; }
  .wrap { padding: 26px 20px 48px; }
  .card { padding: 26px 24px; }
  .slot-list { grid-template-columns: repeat(3, 1fr); }
  .slotgrid { grid-template-columns: repeat(4, 1fr); }
  .btn-row { flex-direction: row; }
  .btn-row .btn { flex: 1; }
  .btn-row.right { justify-content: flex-end; }
}


/* ---------- 本番版の追加 ---------- */
input[type="password"] {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #a9b3c4;
  border-radius: 6px;
  padding: 11px 12px;
  width: 100%;
  line-height: 1.4;
}
input[type="password"]:focus {
  outline: 2px solid var(--navy-light);
  outline-offset: 1px;
  border-color: var(--navy-light);
}

table.grid td .op-btns { flex-wrap: nowrap; }
table.grid .badge + .fixed-dt { margin-top: 3px; }

.btn:disabled { opacity: .6; cursor: progress; }

#updated-at { text-align: right; margin-top: 4px; }

/* ---------- 2時間ブロック対応 ---------- */
/* 枠カードは「18:00〜20:00」を1行で読ませるため、スマホは1列 */
.slot-list { grid-template-columns: 1fr; }
.slot .time { font-size: 18px; letter-spacing: 0; }

/* 当日の進行（どちらが先か） */
.sched {
  border-top: 1px solid var(--line);
  margin: 0 -14px;
  padding: 12px 14px 2px;
}
.sched-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-sub);
  margin-bottom: 8px;
}
.sched-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--line);
}
.sched-row:last-child { border-bottom: 0; }
.sched-row .sr-p {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  background: var(--navy-light);
  border-radius: 3px;
  padding: 2px 7px;
}
.sched-row .sr-t { flex: none; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sched-row .sr-v { font-size: 13px; font-weight: 700; color: var(--navy); }

/* 管理画面: 枠グリッドのポジション表示 */
.sg-item .sg-pos {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  line-height: 1.6;
  padding-top: 3px;
  border-top: 1px dotted rgba(90, 98, 115, .28);
}
.sg-item .sg-pt {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-sub);
  background: rgba(255, 255, 255, .75);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
}
.sg-item .sg-pv { font-weight: 700; color: var(--ok); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-item.partial .sg-pv { color: var(--warn); }
.sg-item .sg-pos.free .sg-pv { color: #a3aab8; font-weight: 500; }
.fixed-dt.sub { color: var(--ink-sub); font-weight: 500; }

@media (min-width: 600px) {
  .slot-list { grid-template-columns: 1fr 1fr; }
  .slotgrid { grid-template-columns: repeat(3, 1fr); }
}


/* 当日の進行: 時刻内訳は出さず「どちらが先か」+所要時間 */
.sched-order {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  padding: 4px 0 6px;
}
.sched-note {
  font-size: 12px;
  color: var(--ink-sub);
  line-height: 1.7;
  padding-bottom: 8px;
}
