/* カフェルナカルド 予約管理 — カルドブラウン × ルナイエロー */
:root {
  --brown: #8B5A3C;
  --brown-dark: #6E442C;
  --yellow: #FFC93C;
  --teal: #5DC2D0;
  --pink: #FF7A9C;
  --ink: #1E1A17;
  --muted: #7A6A5E;
  --line: #E7DED6;
  --bg: #FBF8F4;
  --card: #FFFFFF;
  --ok: #3E9B6B;
  --warn: #D9534F;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30,26,23,.06), 0 6px 18px rgba(30,26,23,.06);
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.warn { color: var(--warn); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- レイアウト ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--brown); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; flex: 1; }
.logo { width: 24px; height: 24px; border-radius: 6px; display: block; }
.logo.big { width: 56px; height: 56px; border-radius: 12px; }
.view { flex: 1; padding: 12px 12px 84px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  border: 0; background: none; padding: 10px 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); min-height: var(--tap);
}
.tab.on { color: var(--brown); font-weight: 700; }


/* ---------- 部品 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 999px; padding: 10px 16px;
  background: var(--brown); color: #fff; font-weight: 600; cursor: pointer;
  min-height: var(--tap);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brown); }
.btn.ghost { background: #fff; color: var(--brown); border-color: var(--line); }
.btn.danger { color: var(--warn); }
.btn.danger.ghost { border-color: #F0D6D5; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  width: 38px; height: 38px; cursor: pointer; color: var(--brown); font-size: 18px; line-height: 1;
}
.icon-btn.danger { color: var(--warn); }
.topbar .icon-btn { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.card.pad { padding: 14px; }
.sub-head { font-size: 14px; color: var(--brown-dark); margin-bottom: 10px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; line-height: 1.6; }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #F2ECE6; color: var(--muted); margin-left: 6px; }
.chip.gold { background: #FFF3D2; color: #8A6300; font-weight: 700; }
.chip.new { background: #E4F6F8; color: #256B76; }
.chip.warn { background: #FBE7E7; color: var(--warn); }
.toolbar { margin-bottom: 10px; }
.search, .day-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-height: var(--tap);
}

/* ---------- カレンダー ---------- */
.month-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.month-head h2 { flex: 1; font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wday { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-wday.sun, .cal-date.sun { color: #C8553D; }
.cal-wday.sat, .cal-date.sat { color: #3D6DC8; }
.cal-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  min-height: 62px; padding: 4px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
}
.cal-cell.empty { background: transparent; border: 0; cursor: default; }
.cal-cell.today { border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.cal-cell.selected { background: #FFF8E8; }
.cal-date { font-size: 13px; font-weight: 700; }
.cal-count { display: flex; flex-direction: column; font-size: 10px; color: var(--brown); line-height: 1.3; }
.cal-count strong { font-size: 12px; }
.cal-sub { font-size: 10px; color: var(--warn); }

/* ---------- 日別ヘッダ ---------- */
.day-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.day-nav { display: flex; align-items: center; gap: 6px; }
.day-nav .day-input { flex: 1; }
.day-stat { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.day-stat strong { font-size: 16px; color: var(--ink); }
.day-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- タイムライン ---------- */
.timeline-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.timeline { display: grid; grid-template-columns: 92px minmax(560px, 1fr); min-width: max-content; }
.tl-corner { position: sticky; left: 0; z-index: 3; background: #F7F2ED; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px 8px; font-size: 11px; color: var(--muted); }
.tl-ruler { display: grid; grid-template-columns: repeat(var(--cols), 1fr); border-bottom: 1px solid var(--line); background: #F7F2ED; }
.tl-tick { font-size: 10px; color: var(--muted); padding: 6px 0 6px 3px; border-left: 1px solid transparent; }
.tl-tick.hour { border-left-color: var(--line); }
.tl-label {
  position: sticky; left: 0; z-index: 2; background: var(--card);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 6px 8px; display: flex; flex-direction: column; justify-content: center;
}
.tl-label strong { font-size: 13px; }
.tl-label small { font-size: 10px; color: var(--muted); }
.tl-label.room { background: #FFF8E8; }
.tl-track {
  position: relative; height: 48px; border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(var(--cols), 1fr);
}
.tl-slot { border: 0; border-left: 1px solid #F3EDE7; background: transparent; cursor: pointer; padding: 0; }
.tl-slot.hour { border-left-color: var(--line); }
.tl-slot:hover { background: #FFF8E8; }
.tl-block {
  position: absolute; top: 4px; bottom: 4px; border: 0; border-radius: 8px; cursor: pointer;
  padding: 3px 6px; overflow: hidden; text-align: left; color: #fff;
  display: flex; flex-direction: column; justify-content: center; min-width: 34px;
  background: var(--brown); box-shadow: var(--shadow);
}
.tl-block-name { font-size: 12px; font-weight: 700; white-space: nowrap; }
.tl-block-meta { font-size: 10px; opacity: .85; white-space: nowrap; }
.tl-block.seated { background: var(--ok); }
.tl-block.done { background: #9A8C81; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--pink); z-index: 1; pointer-events: none; }

/* ---------- 予約リスト ---------- */
.res-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.res-row:last-child { border-bottom: 0; }
.res-row.cancelled, .res-row.noshow { opacity: .55; }
.res-main { flex: 1; display: flex; gap: 10px; padding: 10px 12px; background: none; border: 0; text-align: left; cursor: pointer; }
.res-time { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.res-time strong { font-size: 15px; }
.res-time small { font-size: 10px; color: var(--muted); }
.res-body { flex: 1; min-width: 0; }
.res-name { font-size: 14px; font-weight: 700; }
.res-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.res-note { font-size: 11px; color: var(--brown); margin-top: 3px; background: #FFF8E8; border-radius: 6px; padding: 2px 6px; display: inline-block; }
.res-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 8px 8px 8px 0; align-content: center; }
.st-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font-size: 10px; padding: 5px 6px; cursor: pointer; color: var(--muted); min-width: 52px;
}
.st-btn.sm { min-width: 0; }
.st-btn.on.seated { background: var(--ok); border-color: var(--ok); color: #fff; }
.st-btn.on.done { background: #9A8C81; border-color: #9A8C81; color: #fff; }
.st-btn.on.cancelled, .st-btn.on.noshow { background: var(--warn); border-color: var(--warn); color: #fff; }

/* ---------- 顧客 ---------- */
.cust-head, .cust-row {
  display: grid; grid-template-columns: 1.5fr .6fr 1.2fr 1.1fr; gap: 8px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px;
}
.cust-head { background: #F7F2ED; color: var(--muted); font-size: 11px; }
.cust-row { background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.cust-name { font-weight: 700; font-size: 13px; display: flex; flex-direction: column; }
.cust-name small { font-weight: 400; color: var(--muted); font-size: 10px; }
.cust-visits { font-weight: 700; }
.cust-visits.gold { color: #8A6300; }
.cust-last, .cust-contact { color: var(--muted); }
.cust-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.cust-summary > div { background: #F7F2ED; border-radius: 10px; padding: 8px; text-align: center; display: flex; flex-direction: column; }
.cust-summary strong { font-size: 15px; }
.cust-summary small { font-size: 10px; color: var(--muted); }
.hist-row { display: grid; grid-template-columns: 1.4fr .5fr .9fr .7fr auto; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.hist-row.cancelled, .hist-row.noshow { opacity: .55; }
.hist-status { color: var(--muted); }

/* ---------- 設定テーブル ---------- */
.tbl { font-size: 12px; }
.tbl-head, .tbl-row { display: grid; grid-template-columns: 1.4fr .6fr 1fr .8fr .5fr 38px; gap: 6px; align-items: center; padding: 6px 0; }
.tbl-head { color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.tbl-row.off { opacity: .5; }
.tbl input, .tbl select { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 8px; min-height: 38px; }
.tbl-add { padding-top: 10px; }
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #F7F2ED; }

/* ---------- モーダル・フォーム ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(30,26,23,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh;
  border-radius: 16px 16px 0 0; display: flex; flex-direction: column;
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-actions {
  display: flex; gap: 8px; align-items: center; padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #FCFAF8;
}
.form { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.field-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: var(--tap); width: 100%;
}
.field textarea { min-height: 60px; resize: vertical; }
.field small { font-size: 10px; color: var(--muted); }

.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.suggest-item { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover { background: #FFF8E8; }
.suggest-name { font-size: 13px; font-weight: 600; }
.suggest-meta { font-size: 10px; color: var(--muted); }

.visit-badge { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; background: #FFF8E8; border: 1px solid #F4E3B8; border-radius: 10px; padding: 8px 10px; font-size: 12px; }
.visit-badge strong { color: #8A6300; }
.form-summary { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }

.seat-picker { display: flex; flex-direction: column; gap: 8px; }
.seat-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seat-area { width: 100%; font-size: 10px; color: var(--muted); }
.seat {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; min-width: 62px; min-height: 44px; justify-content: center;
}
.seat-name { font-size: 12px; font-weight: 600; }
.seat-cap { font-size: 9px; color: var(--muted); }
.seat.on { background: var(--brown); border-color: var(--brown); color: #fff; }
.seat.on .seat-cap { color: rgba(255,255,255,.8); }
.seat.busy { border-color: var(--pink); background: #FFF0F4; }
.seat.busy.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.seat.room { border-style: dashed; }

/* ---------- ログイン ---------- */
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 22px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.login-card h1 { font-size: 16px; }
.login-card input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; min-height: var(--tap); }
.login-card .btn { width: 100%; }

/* ---------- トースト ---------- */
#toasts { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 15px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); max-width: 88vw; }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--warn); }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- 広い画面 ---------- */
@media (min-width: 760px) {
  .view { padding: 16px 20px 90px; max-width: 1100px; margin: 0 auto; width: 100%; }
  .cal-cell { min-height: 82px; }
  .overlay { align-items: center; }
  .modal { border-radius: 16px; }
  .day-head { flex-direction: row; align-items: center; }
  .day-nav { flex: 0 0 auto; }
  .day-stat { flex: 1; }
}

/* 設定のチェックボックス行 */
.field.check { flex-direction: row; align-items: center; gap: 8px; margin: 8px 0; }
.field.check input { width: 20px; height: 20px; min-height: 0; flex: none; }
.field.check span { font-size: 13px; }
/* 予約番号 */
.chip.code { background: #EFE7DF; color: var(--brown-dark); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }

/* 予約フォームの駐車場の行 */
.parking-line { font-size: 12px; color: var(--muted); }
.parking-line .warn { font-weight: 700; }

/* 席マスタの表（接続グループ列を追加） */
.tbl-head, .tbl-row { grid-template-columns: 1.3fr .55fr .95fr .7fr .5fr .55fr 38px; }
.tbl-head span { display: block; }

/* ---------- 新着（未確認）予約 ---------- */
.bell {
  position: relative; border: 1px solid rgba(255,255,255,.4); background: transparent;
  border-radius: 10px; min-width: 52px; height: 38px; padding: 0 10px; cursor: pointer;
  color: #fff; font-size: 12px; font-weight: 600; line-height: 1;
}
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--brown);
}
.chip.new-mark { background: var(--warn); color: #fff; font-weight: 700; }
.res-row.unseen { background: #FFF6DF; box-shadow: inset 3px 0 0 var(--warn); }
.res-copy { display: flex; align-items: center; padding: 0 8px 0 0; }

/* 新着バナー */
.newres {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 90;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.28); width: min(92vw, 460px);
  animation: slideUp .2s ease-out;
}
.newres strong { display: block; font-size: 14px; }
.newres small { font-size: 11px; opacity: .75; }
.newres > div { flex: 1; }
.newres .icon-btn { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.newres-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* 未確認一覧 */
.pend-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #FFF9EE; }
.pend-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.pend-head strong { font-size: 14px; }
.pend-text { font-size: 14px; font-weight: 600; line-height: 1.6; margin: 0 0 8px; color: var(--ink); word-break: break-all; }
.pend-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-fallback {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-size: 13px; line-height: 1.7; background: #FFF9EE; resize: vertical;
  -webkit-user-select: text; user-select: text;
}
/* 通知を受け取る端末の一覧 */
.dev-list { font-size: 12px; }
.dev-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.dev-row:last-child { border-bottom: 0; }
.dev-row.off { opacity: .75; }
.dev-row span:last-child { color: var(--muted); text-align: right; }
