:root {
  color-scheme: light;
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --ink: #161d2b;
  --muted: #6b7689;
  --line: #e3e8f0;
  --line-strong: #cbd4e1;
  --brand: #3b4a8c;
  --brand-ink: #2a3568;
  --accent: #4f46e5;
  /* 台灣慣例：正/旺=紅，負/虧=綠 */
  --pos: #c0392b;
  --neg: #2e7d54;
  --slate: #5b6577;
  --ok: #2e7d54;
  --warn: #b8860b;
  --danger: #c0392b;
  --shadow: 0 10px 30px rgba(28, 40, 70, 0.07);
  --shadow-sm: 0 2px 8px rgba(28, 40, 70, 0.05);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html, body { height: 100%; }

#app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ---------- 側欄 ---------- */
.sidebar {
  background: linear-gradient(180deg, #1b2440 0%, #141a30 100%);
  color: #e7ebf6;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7c74f0);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 6px 16px rgba(79,70,229,.4);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 1px; }
.brand p { margin: 2px 0 0; font-size: 11.5px; color: #9aa6c8; letter-spacing: .5px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  text-align: left; border: 0; background: transparent;
  color: #b8c1dc; font-size: 14.5px; font-weight: 600;
  padding: 11px 13px; border-radius: 11px; cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.nav-ic { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(79,70,229,.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(124,116,240,.4); }
.nav-item.active .nav-ic { opacity: 1; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #8590b3; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #45d483; box-shadow: 0 0 0 4px rgba(69,212,131,.18); }

/* ---------- 主區 ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: rgba(238,241,246,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0; font-size: 11.5px; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.topbar h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: .5px; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.ctl { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 600; }
.ctl select {
  font-family: inherit; font-size: 13.5px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink); min-width: 110px;
}
.ghost-btn {
  align-self: flex-end; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--brand-ink); cursor: pointer;
}
.ghost-btn:hover { background: var(--panel-2); }

.room-tabs { display: flex; gap: 8px; padding: 14px 28px 0; flex-wrap: wrap; }
.room-tab {
  font-family: inherit; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  transition: all .15s;
}
.room-tab b { font-size: 14px; color: var(--ink); }
.room-tab span { font-size: 11px; color: var(--muted); }
.room-tab:hover { border-color: var(--accent); }
.room-tab.active { background: var(--brand-ink); border-color: var(--brand-ink); }
.room-tab.active b, .room-tab.active span { color: #fff; }
.room-tab.active span { color: #b9c0e6; }

.month-tabs { display: flex; gap: 6px; padding: 12px 28px 0; flex-wrap: wrap; }
.month-tab {
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.month-tab:hover { border-color: var(--accent); color: var(--accent); }
.month-tab.active { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }
.month-tab.off { opacity: .45; }
.month-tab.warn { border-color: #e2c372; }

.view { display: none; padding: 18px 28px 40px; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 面板 / 格線 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 15px; letter-spacing: .3px; }
.panel-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.wide-left { grid-template-columns: 1.5fr 1fr; }

.tag { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: #e7f5ee; color: var(--ok); border-color: #c6e8d6; }
.tag.danger { background: #fdecea; color: var(--danger); border-color: #f6cdc8; }
.tag.warn { background: #fdf4e1; color: var(--warn); border-color: #f0dfb4; }
.legend { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 3px; }
.dot.g { background: #2e7d54; } .dot.y { background: #d8a020; } .dot.r { background: #c0392b; }
.dot.off { background: #c3ccd9; } .dot.slate { background: var(--slate); } .dot.line { background: var(--accent); }

/* ---------- KPI ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px; position: relative; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 11.5px; color: var(--muted); }

/* 台灣慣例配色 */
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--panel-2); position: sticky; top: 0; }
tbody tr:hover { background: #fafbfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.memo { white-space: normal; color: var(--muted); font-size: 12.5px; max-width: 240px; }
tfoot th, tfoot td { background: var(--panel-2); font-weight: 700; border-top: 2px solid var(--line-strong); }
.strong-cell { font-weight: 800; }
.warn-cell { color: var(--warn); font-weight: 700; }
.dim { color: var(--line-strong); }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* 交叉表 */
.cross th.row-head, .cross td.row-head { position: sticky; left: 0; background: var(--panel); z-index: 1; font-weight: 700; }
.cross thead th { text-align: right; }
.cross thead th:first-child { text-align: left; }
.cross td { font-size: 12.5px; }
.cross .sum-row td, .cross .sum-row th { background: #f4f6fb; }
.cross .strong-row td, .cross .strong-row th { font-weight: 800; border-top: 2px solid var(--line-strong); }
.total-col { border-left: 2px solid var(--line-strong); background: #f4f6fb; }
.cell-jump { cursor: pointer; }
.cell-jump:hover { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

/* ---------- 燈號 ---------- */
.lights { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 16px 18px; }
.light { border: 0; cursor: pointer; border-radius: 12px; padding: 14px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: inherit; font-weight: 700; font-size: 13px; color: #fff; position: relative; transition: transform .12s; }
.light:hover { transform: translateY(-2px); }
.light::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 0 0 4px rgba(255,255,255,.25); }
.light.g { background: linear-gradient(160deg, #36a06a, #2e7d54); }
.light.y { background: linear-gradient(160deg, #e0ad3a, #c4901f); }
.light.r { background: linear-gradient(160deg, #d6573f, #b8341f); }
.light.off { background: #d3dae5; color: #8a96a8; }
.lights-note { padding: 0 18px 16px; margin: 0; line-height: 2; }
.lights-note .dot { margin-left: 6px; }
.lights-note .dot:first-child { margin-left: 0; }

/* ---------- 圖表 ---------- */
.chart-wrap { padding: 12px 14px 6px; }
.chart { width: 100%; height: 240px; display: block; }
.bar-income { fill: var(--pos); opacity: .82; }
.bar-expense { fill: var(--slate); opacity: .55; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: #fff; stroke: var(--accent); stroke-width: 1.6; }
.chart-x { fill: var(--muted); font-size: 10px; text-anchor: middle; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 92px 1fr 76px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar-label { color: var(--ink); font-weight: 600; }
.hbar-track { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, #7c74f0, var(--accent)); border-radius: 999px; }
.hbar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* sparkline */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.spark-bar { width: 7px; border-radius: 2px; background: var(--line-strong); display: block; }
.spark-bar.pos { background: var(--pos); }
.spark-bar.neg { background: var(--neg); }
.spark-cell { width: 1%; }

/* ---------- banner ---------- */
.banner { font-size: 13px; padding: 11px 14px; border-radius: 12px; margin-bottom: 14px; line-height: 1.6; }
.banner.ok { background: #eef4fb; color: #2f4a6b; border: 1px solid #d6e3f2; }
.banner.warn { background: #fdf4e1; color: #7a5a12; border: 1px solid #f0dfb4; }

/* ---------- 表單 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.form-grid.compact { grid-template-columns: repeat(5, 1fr); }
.form-grid label, .inline-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid input, .form-grid select, .inline-field input {
  font-family: inherit; font-size: 13.5px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
}
.inline-field { max-width: 280px; }
.primary-btn { font-family: inherit; font-size: 13.5px; font-weight: 700; padding: 10px 16px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; cursor: pointer; height: 39px; }
.primary-btn:hover { background: #4338ca; }

/* split editor */
.split-editor { display: flex; flex-direction: column; gap: 8px; }
.split-row { display: grid; grid-template-columns: 1.4fr .8fr auto auto; gap: 8px; align-items: center; }
.split-row select, .split-row input { font-family: inherit; font-size: 13px; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line-strong); }
.small-btn { font-family: inherit; font-size: 12px; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; color: var(--muted); }
.danger-btn { color: var(--danger); border-color: #f0c8c2; }
.danger-btn:hover { background: #fdecea; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.chip-x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }

.settings-list { display: flex; flex-direction: column; gap: 8px; }
.setting-row { display: flex; gap: 8px; align-items: center; }
.setting-row input { flex: 1; font-family: inherit; font-size: 13px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-strong); }

/* ---------- 日曆 ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 16px 18px; }
.weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.day-cell { min-height: 78px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.day-cell.muted { background: var(--panel-2); border-style: dashed; }
.day-number { font-size: 12px; color: var(--muted); font-weight: 700; }
.calendar-event { font-size: 10.5px; background: #eef0fb; border-radius: 6px; padding: 3px 5px; line-height: 1.3; }
.calendar-event.sale { background: #fbecea; }
.calendar-event strong { display: block; color: var(--ink); font-size: 10.5px; }
.calendar-event span { color: var(--muted); }

/* ---------- 登入 ---------- */
.auth-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #1b2440, #0f1426); }
.auth-card { width: 100%; max-width: 360px; background: var(--panel); border-radius: 18px; padding: 28px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 14px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-brand h1 { margin: 0; font-size: 19px; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.auth-card input { font-family: inherit; font-size: 15px; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line-strong); }
.auth-card .primary-btn { height: 44px; font-size: 15px; margin-top: 4px; }
.auth-error { margin: 0; font-size: 13px; color: var(--danger); min-height: 18px; font-weight: 600; }
.auth-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; text-align: center; }

/* 使用者 chip */
.sidebar-footer.has-user { display: block; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; }
.user-av { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #7c74f0); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta b { font-size: 13px; color: #e7ebf6; }
.user-meta span { font-size: 11px; color: #8590b3; }
.logout-btn { margin-left: auto; font-family: inherit; font-size: 12px; font-weight: 600; color: #c3cbe6; background: rgba(255,255,255,.08); border: 0; border-radius: 8px; padding: 6px 11px; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

/* 設定：罰款 / 參數 / 帳號 */
.sub-h { margin: 18px 0 10px; font-size: 13px; color: var(--ink); }
.param-row { display: flex; gap: 16px; flex-wrap: wrap; }
.penalty-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pen-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pen-field input { font-family: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-strong); }
.row-off { opacity: .55; }
.row-off strong { text-decoration: line-through; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--panel-2); display: grid; place-items: center; margin: 0 auto 8px; font-size: 22px; color: var(--line-strong); }
.empty h3 { margin: 0 0 4px; font-size: 14px; color: var(--ink); }
.empty p { margin: 0; font-size: 12.5px; }

/* ---------- RWD ---------- */
@media (max-width: 1080px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .cols-2, .wide-left { grid-template-columns: 1fr; }
  .lights { grid-template-columns: repeat(6, 1fr); }
}
/* ===== 手機漢堡抽屜（≤860px，與 app.js 的 MOBILE_BP 同一個數字）===== */
.nav-toggle, .nav-close { display: none; }
.nav-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15,20,38,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.nav-backdrop.show { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }

  /* 側欄 → 從左滑出的抽屜 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    width: 270px; max-width: 84vw; height: 100vh; overflow-y: auto;
    flex-direction: column; gap: 16px;
    transform: translateX(-100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open { transform: none; box-shadow: 6px 0 44px rgba(0,0,0,.4); }
  .nav { flex-direction: column; flex: 0 0 auto; gap: 4px; }
  .nav-item { font-size: 14.5px; padding: 13px 14px; }
  .sidebar-footer { display: flex; }            /* 手機也要看到 登出 / 改密碼 */

  /* 漢堡鈕（topbar 左側） */
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 42px; height: 42px; margin-right: 2px;
    border: 1px solid var(--line-strong); border-radius: 11px; background: #fff;
    font-size: 21px; line-height: 1; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle:active { background: #eef0f6; transform: scale(.96); }

  /* 抽屜內的 × 關閉鈕 */
  .nav-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto; flex: 0 0 auto; width: 34px; height: 34px;
    border: 0; background: rgba(255,255,255,.08); border-radius: 9px;
    font-size: 22px; line-height: 1; color: #cfd6ea; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .nav-close:active { background: rgba(255,255,255,.16); }

  /* topbar 改成 漢堡 + 標題 …自動… 工具列 */
  .topbar { justify-content: flex-start; flex-wrap: wrap; row-gap: 10px; padding: 12px 14px; }
  .topbar-title { margin-right: auto; }
  .topbar h2 { font-size: 19px; }
  .topbar-end { gap: 10px; flex-wrap: wrap; }
  .topbar-logo { height: 22px; }

  /* 房間 / 月份 切換改成可橫向滑動，不再擠成多行 */
  .room-tabs, .month-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .room-tabs::-webkit-scrollbar, .month-tabs::-webkit-scrollbar { display: none; }

  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr 1fr; }
  .lights { grid-template-columns: repeat(4, 1fr); }
  .view, .topbar, .month-tabs, .room-tabs { padding-left: 14px; padding-right: 14px; }
}

/* 很窄的手機（單欄） */
@media (max-width: 460px) {
  .kpi-strip { grid-template-columns: 1fr; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .lights { grid-template-columns: repeat(3, 1fr); }
  .toolbar { flex-wrap: wrap; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* API 版新增：搜尋 / header 按鈕 / inline 代收現金編輯 */
.search-input { font-family: inherit; font-size: 13px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; min-width: 180px; margin-left: auto; margin-right: 10px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.header-btns { display: flex; gap: 8px; }
.cash-input { width: 92px; font-family: inherit; font-size: 13px; text-align: right; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fffdf5; font-variant-numeric: tabular-nums; }
.cash-input:focus { outline: none; border-color: var(--accent); }

/* 日曆：點格子 + 週末色 + 彈窗 keyin */
.day-cell.clickable { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.day-cell.clickable:hover { box-shadow: 0 0 0 2px var(--accent) inset; transform: translateY(-1px); }
.day-cell.weekend { background: #fff5f5; }
.weekday.weekend { color: var(--pos); }

.modal-overlay { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(20,26,46,.5); backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden; animation: pop .14s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.modal-form input, .modal-form select { font-family: inherit; font-size: 15px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-actions .ghost-btn, .modal-actions .primary-btn { align-self: auto; }

/* 自動儲存提示 */
.toast { position: fixed; top: 18px; right: 18px; z-index: 300; background: var(--ok); color: #fff; font-size: 13.5px; font-weight: 700; padding: 9px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(46,125,84,.35); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translateY(0); }

/* 房務檢查清單 */
.check-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 4px 2px; border: 1px solid var(--line); border-radius: 10px; }
.check-row { display: grid; grid-template-columns: 1fr 130px; gap: 8px; align-items: center; padding: 4px 8px; }
.check-main { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.check-main input { width: 17px; height: 17px; }
.check-note { font-size: 12px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line-strong); }

/* 屋主檢視 */
.owner-side { display: flex; flex-direction: column; gap: 8px; }
.owner-room { padding: 10px 12px; border-radius: 11px; background: rgba(255,255,255,.06); color: #e7ebf6; font-size: 14px; }
.owner-room b { display: block; }
.owner-room span { font-size: 11.5px; color: #9aa6c8; }

/* 映策 logo on login */
.auth-logo { display: block; width: 100%; max-width: 230px; height: auto; margin: 0 auto 10px; }
.auth-tagline { text-align: center; font-size: 12px; color: var(--muted); margin: 12px 0 0; letter-spacing: 1px; }

/* 房務檢查月曆 */
.ins-badge { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 7px; margin-top: 4px; display: inline-block; line-height: 1.4; }
.ins-badge.warn { background: #fdf4e1; color: var(--warn); }
.ins-badge.warn b { font-size: 13px; }
.ins-badge.ok { background: #e7f5ee; color: var(--ok); }
.ins-badge.issue { background: #fdecea; color: var(--danger); }
.day-cell.ins-warn { box-shadow: inset 0 0 0 2px #e2c372; background: #fffdf6; }
.day-cell.ins-issue { box-shadow: inset 0 0 0 2px #e8a99e; background: #fff7f5; }
.day-cell.ins-ok { background: #f4fbf7; }
.ins-stay-list { display: flex; flex-direction: column; gap: 10px; }
.ins-stay-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ins-stay-row:last-child { border-bottom: 0; }

/* RWD：月曆（房務檢查 + 日曆表）在手機收緊 */
@media (max-width: 720px) {
  .calendar-grid { gap: 3px; padding: 10px 8px; }
  .day-cell { min-height: 52px; padding: 3px 2px; }
  .day-number { font-size: 11px; }
  .ins-badge { font-size: 9.5px; padding: 1px 4px; margin-top: 2px; }
  .ins-badge .ins-lbl { display: none; }
  .ins-badge.warn b { font-size: 12px; }
  .calendar-event { font-size: 9px; padding: 2px 3px; }
  .calendar-event strong { font-size: 9px; }
  .ins-stay-row { grid-template-columns: 1fr auto; }
  .ins-stay-row button { grid-column: 1 / -1; }
}

/* 改密碼連結 */
.pw-link { color: #9aa6c8; text-decoration: underline; cursor: pointer; }
.pw-link:hover { color: #fff; }

/* 映策 logo 右上角（後台署名）*/
.topbar-end { display: flex; align-items: center; gap: 18px; }
.topbar-logo-link { display: flex; align-items: center; flex-shrink: 0; }
.topbar-logo { height: 30px; width: auto; display: block; opacity: .92; }
.topbar-logo-link:hover .topbar-logo { opacity: 1; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar-end { gap: 10px; flex-wrap: wrap; }
  .topbar-logo { height: 22px; }
}

/* 試玩站帳密提示 */
.demo-creds { background: #eef4fb; border: 1px solid #d6e3f2; border-radius: 12px; padding: 12px 14px; margin: 4px 0 2px; font-size: 12.5px; color: #2f4a6b; }
.demo-title { margin: 0 0 6px; font-weight: 700; }
.demo-creds ul { margin: 0; padding-left: 2px; list-style: none; line-height: 1.9; }
.demo-creds li { font-variant-numeric: tabular-nums; }
.demo-creds b { color: var(--accent); }
.demo-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }

/* 給民宿主人的話（試玩站）+ 頁尾署名 */
.owner-msg { background: linear-gradient(135deg, #fff8ee, #fdf1de); border: 1px solid #f0dcb8; border-left: 5px solid #d99a2b; border-radius: 14px; padding: 20px 24px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.owner-msg h3 { margin: 0 0 12px; color: #8a5a12; font-size: 17px; letter-spacing: .5px; }
.owner-msg p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.9; color: #5d4a30; }
.owner-msg b { color: #b46f12; }
.owner-msg-cta { margin-top: 12px !important; font-size: 14px !important; }
.owner-msg-link { display: inline-block; margin-top: 8px; font-weight: 700; color: #b46f12; text-decoration: none; border-bottom: 2px solid #e9c98a; }
.owner-msg-link:hover { color: #8a5a12; }
.app-footer { text-align: center; padding: 20px 16px 28px; margin-top: 4px; }
.app-footer a { font-size: 12.5px; color: var(--muted); text-decoration: none; letter-spacing: .5px; }
.app-footer a b { color: var(--brand-ink); }
.app-footer a:hover { color: var(--accent); }
.app-footer a:hover b { color: var(--accent); }
