:root {
  --bg: #e9edf2;
  --card: #f7f9fb;
  --line: #c9d2dd;
  --head: #d8e1eb;
  --text: #253041;
  --muted: #6b7889;
  --primary: #2f5f8f;
  --primary-ink: #fff;
  --ok: #3f7a63;
  --warn: #9a6b2a;
  --danger: #a24a4a;
  --active-row: #e3edf6;
  --done-row: #eef1f4;
  --over-row: #f5e6e4;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; font-size: 14px; }

/* ボタン */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: #fff; border-color: var(--warn); color: var(--warn); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* ログイン */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(92, 128, 168, .35), transparent 60%),
    radial-gradient(800px 600px at 90% 95%, rgba(70, 110, 130, .30), transparent 60%),
    linear-gradient(160deg, #1a2433 0%, #233246 55%, #1c2a38 100%);
  position: relative; overflow: hidden; }
.login::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 32px 32px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.login-card { position: relative; width: 100%; max-width: 380px; padding: 28px 24px; border-color: rgba(255,255,255,.4);
  box-shadow: 0 20px 50px rgba(8, 14, 24, .45); text-align: center; }
.login-card label { text-align: left; }
.login-card h1 { font-size: 21px; margin: 10px 0 2px; letter-spacing: .04em; }
.login-sub { margin: 0 0 8px; font-size: 13px; }
.login-mark { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center;
  background: #e3ebf3; color: var(--primary); }
.login-card .btn.primary { margin-top: 6px; padding: 11px; }
label { display: block; margin: 12px 0 0; font-size: 14px; color: var(--muted); }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }

/* トップバー */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #1f2a3a; color: #dbe4ee; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
.brand { font-weight: 600; letter-spacing: .02em; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { background: transparent; border: 0; color: #9fb0c3; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: #33445a; color: #fff; }
.contact { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding-left: 12px; border-left: 1px solid #3a4b60; white-space: nowrap; }
.contact a, .tabs .contact button { color: #b8c7d8; text-decoration: none; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
@media (max-width: 1000px) {
  .tabs { flex-wrap: wrap; overflow: visible; }
  .contact { margin-left: 0; padding-left: 0; border-left: 0; }
}
}
.contact a:hover, .tabs .contact button:hover { background: #2b3a4d; color: #fff; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.who .btn { color: #dbe4ee; border-color: #43566d; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #b0654f; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
body:not(.is-admin) .admin-only { display: none; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 1px 2px rgba(20,30,45,.05); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sheet-head.center-title { display: grid; grid-template-columns: 1fr auto 1fr; }
.center-title h2 { text-align: center; }
.center-title .date-pick { justify-self: end; }
.audit-filter { display: flex; gap: 8px; }
.audit-filter select, .audit-filter input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.date-pick { white-space: nowrap; display: flex; align-items: center; gap: 4px; margin: 0; color: var(--muted); font-size: 16px; }
.date-pick input { margin: 0; width: auto; padding: 8px 10px; background: #e3e8ee; border: 1px solid var(--line); border-radius: 8px; }
.stats { color: var(--muted); margin: 12px 0; font-size: 14px; }
.stats b { color: var(--text); font-weight: 600; }
.stats .sep { margin: 0 10px; color: var(--line); }

/* 利用表 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 8px; text-align: center; vertical-align: middle; }
.sheet thead th { background: var(--head); font-weight: 600; white-space: nowrap; position: sticky; top: 0; z-index: 2; }
.sheet .sticky { position: sticky; left: 0; z-index: 3; background: inherit; }
.sheet tbody td.sticky { background: var(--card); }
.sheet thead th.sticky { background: var(--head); z-index: 4; }
.sheet tr.active td { background: var(--active-row); }
.sheet tr.done td { background: var(--done-row); }
.sheet tr.over td { background: var(--over-row); }
.sheet select { min-width: 120px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.sheet .locked { font-weight: 600; font-size: 16px; }
.sheet .time { font-variant-numeric: tabular-nums; font-size: 16px; }
.sheet .sub { display: block; font-size: 11px; color: var(--muted); }
.sheet .timer { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.sheet .timer.over { color: var(--danger); }
.sheet .timer.soon { color: var(--warn); }
.sheet .cell-btn { min-width: 76px; }
.flag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-top: 4px; }
.flag.pending { background: #f3e7d3; color: var(--warn); }
.flag.approved { background: #dcebe4; color: var(--ok); }
.flag.rejected { background: #efdede; color: var(--danger); }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* 修正依頼リスト */
.req-list { margin-top: 4px; }
.req { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.req h4 { margin: 0 0 6px; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.req .reason { background: var(--bg); border-radius: 6px; padding: 8px 10px; margin: 8px 0; white-space: pre-wrap; }
.diff { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 12px; font-size: 14px; }
.diff .h { color: var(--muted); font-size: 12px; }
.diff .chg { color: var(--primary); font-weight: 600; }
.req .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }

.list th, .list td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; font-size: 14px; white-space: nowrap; }
.list th { background: var(--head); }
.list tr:last-child td { border-bottom: 0; }
.req-table td { vertical-align: top; }
.req-table td.wrap { white-space: normal; min-width: 140px; }
.req-table .reason-cell { max-width: 280px; }
.req-table .chg { color: var(--primary); }
.req-table .sub { display: block; font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.req-table tr:hover td { background: #eef2f6; }

/* 日本語ピッカー */
.jp-picker { position: relative; display: inline-flex; align-items: stretch; gap: 4px; }
.jp-btn, .jp-nav { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.jp-btn { min-width: 9em; text-align: left; color: var(--text); font-variant-numeric: tabular-nums; }
.date-pick .jp-btn { background: #e3e8ee; font-size: 16px; }
.jp-btn.empty { color: var(--muted); }
.jp-nav { padding: 8px 10px; color: var(--muted); }
.jp-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; width: 272px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; box-shadow: 0 12px 30px rgba(20,30,45,.18); color: var(--text); font-size: 14px; }
.dt-field .jp-pop { left: 0; right: auto; }
.jp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; }
.jp-head button, .jp-days button, .jp-months button, .jp-foot button { border: 0; background: transparent; border-radius: 6px; cursor: pointer; padding: 6px 0; }
.jp-head button { padding: 4px 10px; font-size: 16px; }
.jp-head button:hover, .jp-days button:hover, .jp-months button:hover, .jp-foot button:hover { background: var(--bg); }
.jp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jp-days .wd { font-size: 12px; color: var(--muted); padding: 4px 0; }
.jp-days .sun { color: #a65555; } .jp-days .sat { color: #4a6f9a; }
.jp-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.jp-months button { padding: 10px 0; }
.jp-days button.today, .jp-months button.today { outline: 1px solid var(--line); }
.jp-days button.sel, .jp-months button.sel { background: var(--primary); color: #fff; }
.jp-foot { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.jp-foot button { padding: 4px 10px; color: var(--primary); }
.dt-field { margin-top: 12px; }
.dt-label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.dt-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dt-row select { padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.req-acts { white-space: nowrap; }

/* モーダル */
dialog { border: 0; border-radius: 14px; padding: 0; overflow: visible; width: min(520px, calc(100vw - 32px)); color: var(--text); background: var(--card); }
dialog::backdrop { background: rgba(20, 28, 40, .45); }
dialog form { padding: 18px; }
dialog h3 { margin: 0 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.note { font-size: 13px; color: var(--muted); background: var(--bg); padding: 8px 10px; border-radius: 6px; margin: 8px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #253041; color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: calc(100vw - 32px); font-size: 14px; }
.toast.err { background: var(--danger); }

@media (max-width: 640px) {
  main { padding: 10px; }
  .card { padding: 12px; }
  .sheet-head h2 { font-size: 19px; }
  .sheet-head.center-title { grid-template-columns: 1fr; justify-items: center; }
  .center-title > span:first-child { display: none; }
  .center-title .date-pick { justify-self: center; }
  .brand { width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- スマホ ---------- */
.m-only { display: none; }
.big-confirm { font-size: 18px; }
@media (max-width: 700px) {
  .m-only { display: block; }
  .pc-only { display: none !important; }

  /* ヘッダー：1 行目 ブランド＋ログアウト／2 行目 タブ／3 行目 電話・メール */
  .topbar { position: static; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand { grid-column: 1; grid-row: 1; width: auto; font-size: 15px; align-self: center; }
  .who { grid-column: 2; grid-row: 1; }
  .who #who { display: none; }
  .tabs { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: 6px; }
  .tabs > button { flex: 1 1 0; padding: 9px 4px; background: #2a384b; font-size: 14px; }
  .tabs > button.active { background: #4a6587; }
  .contact { flex: 0 0 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 0; border: 0; }
  .contact a, .tabs .contact button { display: block; text-align: center; background: #26333f; border: 1px solid #3a4b60; padding: 9px 4px; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  main { padding: 10px; }
  .card { padding: 12px; border-radius: 12px; }
  .stats { font-size: 13px; text-align: center; }
  .stats .sep { margin: 0 5px; }

  /* 利用中・退室済カード */
  .m-card { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
  .m-card.done { border-left-color: #9aa6b4; background: var(--done-row); }
  .m-card.over { border-left-color: var(--danger); background: var(--over-row); }
  .m-card-top { display: flex; align-items: center; gap: 10px; }
  .m-room { font-size: 26px; font-weight: 700; line-height: 1; }
  .m-meta { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  .chip { font-size: 12px; background: var(--bg); border-radius: 5px; padding: 2px 6px; }
  .m-meta .flag { margin-top: 0; }
  .m-timer .timer { font-size: 18px; text-align: right; display: block; }
  .m-timer .sub { display: block; font-size: 11px; }
  .m-times { margin-top: 8px; font-size: 14px; }
  .m-times .arrow { margin: 0 6px; color: var(--muted); }
  .m-acts { display: flex; gap: 8px; margin-top: 10px; }
  .m-acts:empty { display: none; }
  .m-acts .m-out { flex: 1; padding: 13px; font-size: 16px; font-weight: 600; border-radius: 10px; }
  .m-card.done .m-acts { justify-content: flex-end; margin-top: 6px; }
  .m-empty { text-align: center; padding: 12px 0; margin: 0; }

  /* 修正依頼表：表 → カード */
  .req-table, .req-table tbody, .req-table tr, .req-table td { display: block; width: 100%; }
  .req-table tr:first-child { display: none; }
  .req-table tr { border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .req-table td { border: 0; padding: 2px 0; white-space: normal; max-width: none !important; }
  .req-table td[data-l]::before { content: attr(data-l); display: inline-block; width: 5.5em; color: var(--muted); font-size: 12px; }
  .req-table td.req-acts { padding-top: 8px; }
  .req-table .btn { padding: 9px 14px; }
  .audit-filter { flex-wrap: wrap; }

  /* モーダル */
  dialog { max-height: 92dvh; overflow-y: auto; }
  .modal-actions .btn { flex: 1; padding: 12px; }
}

/* ---------- 新規入室パネル（PC・スマホ共通） ---------- */
  /* 新規入室 */
  .m-new { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 4px; }
  .m-sec-title { font-weight: 700; font-size: 16px; margin: 16px 2px 8px; }
  .m-new .m-sec-title { margin-top: 0; }
  .m-sec-title b { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 11px; background: var(--head); text-align: center; font-size: 13px; }
  .m-label { font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
  .m-rooms button, .m-seg button { border: 1px solid var(--line); background: #f4f6f9; border-radius: 9px; padding: 11px 0; font-size: 16px; font-weight: 600;
    cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .m-rooms button small { display: block; font-size: 10px; font-weight: 400; }
  .m-rooms button.sel, .m-seg button.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
  .m-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
  .m-seg button { font-size: 14px; padding: 12px 0; white-space: nowrap; letter-spacing: -.02em; }
  .m-seg button[data-mpay] { font-size: 13px; }
  .m-go { width: 100%; margin-top: 14px; padding: 15px; font-size: 16px; font-weight: 600; border-radius: 10px; }

  .m-rooms button small { color: var(--muted); }
  .m-rooms button.sel small { color: #dbe6f2; }
  .m-rooms button.busy { background: #dfe4ea; color: #7d8a99; border-color: transparent; }
  .m-rooms button.busy small { color: var(--primary); font-weight: 600; }
  .m-rooms button.busy.over { background: var(--over-row); color: var(--danger); }
  .m-rooms button.busy.over small { color: var(--danger); }

/* PC：左に部屋（フロアごと）、右にプラン・支払・入室 */
@media (min-width: 701px) {
  .m-new { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 24px; margin-bottom: 16px; padding: 16px 18px; }
  .floor { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .floor:last-child { margin-bottom: 0; }
  .fl { width: 30px; color: var(--muted); font-size: 13px; font-weight: 600; }
  .m-rooms button { flex: 0 1 86px; min-width: 50px; padding: 9px 0; }
  .np-rooms { min-width: 0; }
  .np-side { border-left: 1px solid var(--line); padding-left: 22px; display: flex; flex-direction: column; }
  .np-side .m-label:first-child { margin-top: 2px; }
  .m-go { margin-top: auto; }
  .np-side .m-seg { margin-bottom: 4px; }
}
/* スマホ：フロアの区切りなしで 5 列 */
@media (max-width: 700px) {
  .m-rooms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .floor { display: contents; }
  .fl { display: none; }
  .m-sec-title .sm { display: block; font-weight: 400; margin-top: 2px; }
}
