/*
 * Lシステム 画面の土台。
 *
 * 店内は暗いのでダークを既定にする（docs/03_SCREENS.md）。
 * 明るい環境の端末のためにライトも用意する。
 * タップ領域は 44px 以上。片手で押せる位置に主要操作を置く。
 */

:root {
  color-scheme: dark light;

  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #212530;
  --line: #2c313d;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #3ddc97;
  --accent-ink: #06281c;
  --danger: #ff6b6b;
  --warn: #ffc857;

  --free: #2f3542;
  --occupied: #1f6f4f;
  --checking: #7a5c12;
  --paid: #384766;
  --cleaning: #4a3a55;
  --disabled: #23262d;

  --radius: 12px;
  --tap: 44px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --line: #d8dce3;
    --text: #1b2027;
    --muted: #5f6773;
    --accent: #0f9d63;
    --accent-ink: #ffffff;
    --free: #e6e9ef;
    --occupied: #cdebdc;
    --checking: #f6e6b8;
    --paid: #dbe3f5;
    --cleaning: #e7dcee;
    --disabled: #e0e2e6;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .spacer { flex: 1; }
.topbar .clock {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: var(--tap);
  white-space: nowrap;
}

/*
 * 店舗名は長いことがある（「◯◯◯◯ 銀座本店」など）。
 * 2行まで折り返し、それ以上は省略する。ボタンを押し出さない。
 */
.topbar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  padding-top: 11px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* ── ハンバーガーメニュー ───────────────── */
/*
 * ハンバーガー。
 *
 * grid + place-items にすると、行が高さいっぱいに引き伸ばされて
 * 線の間隔が gap ではなく 15px 開いてしまう（place-items は行の中の位置しか
 * 決めない）。flex なら主軸方向に伸びないので、指定した間隔のまま出る。
 */
.nav-toggle {
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border-color: transparent;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  flex: none;
  background: var(--text);
  border-radius: 1px;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 20;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 82vw);
  z-index: 21;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.nav-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.35;
  padding-top: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.nav-close {
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: transparent;
  border-color: transparent;
  font-size: 1.1rem;
}

.nav-list { padding: 8px; display: flex; flex-direction: column; }
.nav-item {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  font-size: 1rem;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item[aria-current="page"] { background: var(--surface-2); font-weight: 600; }

main { padding: 14px; max-width: 1100px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

button, .btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}
.btn-danger { color: var(--danger); }
/* style="" 属性は CSP（style-src 'self'）で弾かれるので、クラスで持つ */
.btn-wide { flex: 1; }
.btn-flex { flex: 1 1 160px; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.mt { margin-top: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: .9rem; }
input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

/* エラーは人間の言葉で出す。403 や例外をそのまま見せない */
.notice {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.notice-error { border-color: var(--danger); }
.notice-hint { color: var(--muted); font-size: .9rem; margin-top: 4px; }
[hidden] { display: none !important; }

/* ── ログイン ───────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.brand { text-align: center; margin-bottom: 6px; font-size: 1.3rem; font-weight: 600; }
.brand-sub { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 18px; }

/* ── ホール ─────────────────────────────── */
.floors { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.floors button { white-space: nowrap; }
.floors button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.floor-view { position: relative; width: 100%; overflow: auto; }
.floor-canvas { position: relative; min-height: 320px; }

.obj { position: absolute; border-radius: 8px; }
.obj-wall, .obj-pillar { background: var(--line); }
.obj-door { background: transparent; border: 2px dashed var(--muted); }
.obj-counter { background: var(--surface-2); border: 1px solid var(--line); }
.obj-text { color: var(--muted); font-size: .8rem; display: grid; place-items: center; }

.table-btn {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 4px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: .8rem; line-height: 1.25;
}
.table-btn .no { font-size: 1rem; font-weight: 700; }
/* 色だけで状態を表さない。必ず文字を併記する */
.table-btn .state { font-size: .75rem; }
.st-free { background: var(--free); }
.st-occupied { background: var(--occupied); }
.st-checking { background: var(--checking); color: #1b2027; }
.st-paid { background: var(--paid); }
.st-cleaning { background: var(--cleaning); }
.st-disabled { background: var(--disabled); color: var(--muted); }

/* 狭い画面は縦リスト。俯瞰図は出さない（切れて読めないため） */
.floor-list { display: flex; flex-direction: column; gap: 8px; }
.list-table {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}
.list-table .no { font-size: 1.05rem; font-weight: 700; min-width: 5.5em; }
.list-table .state { font-size: .9rem; }
.list-table .grow { flex: 1; }

.summary {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}
.summary b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── 卓詳細・注文 ───────────────────────── */
.rows { border-top: 1px solid var(--line); margin-top: 12px; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row .grow { flex: 1; min-width: 0; }
.row .amount { font-variant-numeric: tabular-nums; }
.row.voided { color: var(--muted); text-decoration: line-through; }
.meta { color: var(--muted); font-size: .85rem; }

.total-line {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; font-size: 1.1rem;
}
.total-line b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.grid-products {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-top: 12px;
}
.grid-products button { flex-direction: column; padding: 10px; min-height: 72px; }
.grid-products .price { color: var(--muted); font-size: .85rem; }

.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

.section-title { font-size: 1rem; margin: 0 0 4px; font-weight: 600; }

/* 初回パスワードの表示。読み上げ・書き写しのため大きく等幅で */
.creds {
  margin: 10px 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.15rem;
  white-space: pre-line;
  user-select: all;
}

/* ── 本部が「見ている」ことを画面に出す ──── */
/*
 * 本部が店舗を見ているとき、画面のどこにいても分かるようにする。
 * 「いま自分は他店のデータを見ている」を隠さない（docs/02_RBAC.md §4）。
 */
.viewing-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
}
.viewing-banner b { color: var(--text); }
.viewing-banner .grow { flex: 1; }

/* ── 一覧の行（店舗・代理店・会員証） ────── */
.row-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px; margin-bottom: 8px;
  text-align: left; min-height: var(--tap);
}
/* 店舗名・会社名は長いことがある。2行まで折り返して、ボタンを押し出さない */
.row-title {
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .78rem; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.pill-active { background: var(--occupied); color: var(--text); border-color: transparent; }
.pill-quiet { background: var(--checking); color: #1b2027; border-color: transparent; }
.pill-dormant { background: var(--surface-2); color: var(--danger); }

.field-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-row .grow { flex: 1 1 200px; }

/* ── デジタル会員証 ─────────────────────── */
/*
 * お客様が開く画面。片手・暗い店内・人に見られる前提。
 * 出すのは呼び名とポイントまで。連絡先も来店履歴も出さない。
 */
.member-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.member-card {
  width: 100%; max-width: 380px;
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
}
.member-store { font-size: .9rem; color: var(--muted); }
.member-name { font-size: 1.6rem; font-weight: 700; margin: 6px 0 2px; overflow-wrap: anywhere; }
.member-rank { display: inline-block; margin-top: 6px; }
.member-points {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between;
}
.member-points b { font-size: 2rem; font-variant-numeric: tabular-nums; }
.member-no {
  margin-top: 16px; color: var(--muted); font-size: .85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.member-note { margin-top: 14px; color: var(--muted); font-size: .8rem; line-height: 1.5; }

/* 入力欄のあいだに置くラベル。上の欄と近づきすぎないように */
.mt-label { display: block; margin-top: 14px; }

/* 行の中に置く小さなボタン（指名の取消など） */
.btn-inline {
  min-height: 0; padding: 2px 8px; margin-left: 8px;
  font-size: .8rem; vertical-align: middle;
}

/*
 * 入り口の行き来。
 *
 * 立場ごとに入り口を分けてあるので、間違えた人がすぐ移れるようにする。
 * ただし主役はいまの入り口なので、小さく置く（1画面1目的を崩さない）。
 */
.other-doors {
  display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: .9rem;
}
/* 見た目は控えめでも、押せることが分かる形にする（タップ領域は44px） */
.other-doors a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text); text-decoration: none;
}
.other-doors a:hover { border-color: var(--muted); }
