/* ==========================================================================
   栖云 · 民宿管理系统  样式表
   设计原则：单一 HTML 结构 + 媒体查询适配双端；手机端底部标签栏，桌面端侧边栏。
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --panel: #111820;
  --card: #151d26;
  --card-2: #1a2431;
  --line: #22303f;
  --line-soft: #1a2431;
  --text: #e8eef4;
  --text-2: #c3cedb;
  --muted: #8d9bb0;
  --brand: #2dd4bf;
  --brand-soft: rgba(45, 212, 191, .13);
  --brand-line: rgba(45, 212, 191, .32);
  --amber: #f5a524;
  --amber-soft: rgba(245, 165, 36, .14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .13);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .13);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .13);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .38);
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}

html[data-theme="light"] {
  --bg: #f2f5f8;
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #f7f9fb;
  --line: #e2e8ef;
  --line-soft: #eef2f6;
  --text: #101b25;
  --text-2: #3a4a59;
  --muted: #64748b;
  --brand: #0e9b8d;
  --brand-soft: rgba(14, 155, 141, .10);
  --brand-line: rgba(14, 155, 141, .28);
  --amber: #b45309;
  --amber-soft: rgba(180, 83, 9, .10);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .09);
  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, .10);
  --info: #1d4ed8;
  --info-soft: rgba(29, 78, 216, .09);
  --shadow: 0 8px 24px rgba(16, 30, 45, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
button { font: inherit; color: inherit; }
a { color: var(--brand); }

/* ---------- 布局骨架 ---------- */
#app { display: flex; min-height: 100dvh; }

.sidebar {
  display: none;
  flex-direction: column;
  width: 224px;
  flex: 0 0 224px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px calc(16px + var(--sab));
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .12em; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.side-nav a .nav-ico { width: 18px; text-align: center; opacity: .85; font-size: 15px; }
.side-nav a:hover { background: var(--card-2); color: var(--text); }
.side-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.store-badge {
  font-size: 11.5px; color: var(--muted); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.store-badge.cloud { color: var(--brand); border-color: var(--brand-line); background: var(--brand-soft); }
.store-badge.offline { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--sat)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar h1 { font-size: 19px; }
.topbar-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.view { padding: 16px 16px calc(88px + var(--sab)); flex: 1; max-width: 1240px; width: 100%; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--sab));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0 2px; text-decoration: none; color: var(--muted); font-size: 10.5px;
  border-radius: 10px;
}
.tabbar a .tab-ico { font-size: 19px; line-height: 1; }
.tabbar a.active { color: var(--brand); }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .tabbar { display: none; }
  .view { padding: 22px 28px 40px; }
  .topbar { padding: 16px 28px; }
  .topbar h1 { font-size: 21px; }
}

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: transform .08s, filter .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #04211d; font-weight: 600; }
html[data-theme="light"] .btn-primary { color: #fff; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card-2);
  cursor: pointer; font-size: 15px; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 15px; /* ≥16px 可避免 iOS 自动缩放，此处 15 配合 font-size 修正 */
  outline: none; transition: border-color .15s, box-shadow .15s;
}
@media (max-width: 899px) { .input, .select, textarea.input { font-size: 16px; } }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea.input { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row.stack-sm { grid-template-columns: 1fr; gap: 0; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 14.5px; font-weight: 600; }
.card-hint { font-size: 12px; color: var(--muted); }

.section-title { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .04em; margin: 20px 0 10px; text-transform: uppercase; }
.section-title:first-child { margin-top: 0; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-value.sm { font-size: 19px; }
.kpi-note { font-size: 11.5px; color: var(--muted); }
.kpi.accent .kpi-value { color: var(--brand); }

/* ---------- 状态标签 ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-booked { color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.pill-in { color: var(--brand); background: var(--brand-soft); border-color: var(--brand-line); }
.pill-out { color: var(--muted); background: var(--card-2); border-color: var(--line); }
.pill-cancel { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.pill-ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 32%, transparent); }

/* ---------- 列表（桌面表格 / 手机卡片） ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; gap: 6px 14px; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  transition: border-color .15s;
}
.row:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.row-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; grid-column: 1 / -1; margin-top: 2px; }

@media (min-width: 820px) {
  .row {
    grid-template-columns: minmax(200px, 1fr) 130px auto;
    padding: 12px 18px;
  }
  .row-amount { font-size: 15px; }
  .row-actions { grid-column: auto; justify-content: flex-end; margin-top: 0; }
}

/* ---------- 房态日历 ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-month { display: flex; align-items: center; gap: 8px; }
.cal-month strong { font-size: 17px; font-variant-numeric: tabular-nums; min-width: 96px; text-align: center; }

.cal-scroll {
  overflow-x: auto; overflow-y: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  -webkit-overflow-scrolling: touch;
}
.cal {
  display: grid;
  min-width: 100%;
  grid-auto-rows: minmax(46px, auto);
  font-size: 12px;
}
.cal-corner {
  position: sticky; left: 0; z-index: 3;
  background: var(--card); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 10px; font-weight: 600; color: var(--muted);
  font-size: 11.5px; min-height: 34px;
}
.cal-day {
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted); min-height: 34px;
  font-size: 11px; line-height: 1.15; padding: 2px 0;
}
.cal-day b { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.cal-day.we { background: var(--card-2); }
.cal-day.today b { color: var(--brand); }
.cal-day.today { box-shadow: inset 0 -2px 0 var(--brand); }

.cal-room {
  position: sticky; left: 0; z-index: 2;
  background: var(--card); border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; padding: 4px 10px; min-width: 0;
}
.cal-room b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-room small { color: var(--muted); font-size: 10.5px; }

.cal-cell {
  border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft);
  cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center;
  font-size: 10px; overflow: hidden; color: transparent;
  transition: background .12s;
}
.cal-cell.we { background: color-mix(in srgb, var(--card-2) 70%, transparent); }
.cal-cell:hover { background: var(--brand-soft); }
.cal-cell.today { box-shadow: inset 0 0 0 1px var(--brand-line); }
.cal-cell.bk { color: #04211d; font-weight: 700; }
html[data-theme="light"] .cal-cell.bk { color: #fff; }
.cal-cell.bk-booked { background: var(--amber); }
.cal-cell.bk-in { background: var(--brand); }
.cal-cell.bk-out { background: color-mix(in srgb, var(--muted) 45%, var(--card)); color: var(--text); }
.cal-cell.bk-cancel { background: repeating-linear-gradient(45deg, var(--card-2), var(--card-2) 4px, var(--bg) 4px, var(--bg) 8px); color: var(--muted); }

.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.cal-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* ---------- 图表 ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 132px; padding-top: 8px; }
.bars .bar { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bars .bar i {
  display: block; width: 100%; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 55%, transparent));
  min-height: 2px; transition: height .35s ease;
}
.bars .bar.zero i { background: var(--line); }
.bars-x { display: flex; gap: 4px; margin-top: 6px; }
.bars-x span { flex: 1; min-width: 0; text-align: center; font-size: 9.5px; color: var(--muted); overflow: hidden; white-space: nowrap; }

.hbar { display: flex; flex-direction: column; gap: 10px; }
.hbar-item { display: grid; grid-template-columns: 76px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }

/* ---------- 房态小方块 ---------- */
.room-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.room-chip {
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; background: var(--card-2);
  display: flex; flex-direction: column; gap: 2px; cursor: pointer;
}
.room-chip b { font-size: 13.5px; }
.room-chip small { font-size: 11px; color: var(--muted); }
.room-chip.free { border-color: var(--brand-line); background: var(--brand-soft); }
.room-chip.busy { border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: var(--amber-soft); }
.room-chip.maint { opacity: .6; }

/* ---------- 空状态 / 提示 ---------- */
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty-ico { font-size: 30px; opacity: .5; margin-bottom: 8px; }
.empty p { margin: 0 0 14px; font-size: 13.5px; }

.notice {
  display: flex; gap: 9px; padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.5; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text-2);
}
.notice.warn { border-color: color-mix(in srgb, var(--amber) 34%, transparent); background: var(--amber-soft); color: var(--text); }
.notice.info { border-color: color-mix(in srgb, var(--info) 30%, transparent); background: var(--info-soft); color: var(--text); }
.notice b { font-weight: 700; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 12, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
@media (min-width: 640px) { .modal-mask { align-items: center; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + var(--sab));
  box-shadow: var(--shadow); animation: slideUp .2s ease;
}
@media (min-width: 640px) { .modal { border-radius: 16px; padding-bottom: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 17px; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  position: sticky; bottom: 0; z-index: 2;
  margin: 16px -18px 0; padding: 12px 18px calc(2px + var(--sab));
  background: var(--panel); border-top: 1px solid var(--line-soft);
}
@media (max-width: 520px) { .modal-foot { flex-direction: column-reverse; } .modal-foot .btn { width: 100%; } }

.form-error {
  display: none; font-size: 12.5px; color: var(--danger);
  background: var(--danger-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}
.form-error.show { display: block; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--sab)); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
@media (min-width: 900px) { .toast-root { bottom: 28px; } }
.toast {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 9px 15px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: toastIn .2s ease; max-width: 92vw;
}
.toast.ok { border-color: var(--brand-line); color: var(--brand); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 启动 / 登录 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 300; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.boot-logo { font-size: 26px; font-weight: 700; letter-spacing: .18em; color: var(--brand); }
.boot-text { font-size: 12.5px; color: var(--muted); letter-spacing: .06em; }
.boot[hidden], #app[hidden], .login-mask[hidden] { display: none; }

.login-mask {
  position: fixed; inset: 0; z-index: 250; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.login-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-desc { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.login-error { font-size: 12.5px; color: var(--danger); min-height: 18px; margin-bottom: 8px; }

/* ---------- 工具类 ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.only-desktop { display: none; }
@media (min-width: 900px) { .only-desktop { display: inline-flex; } .only-mobile { display: none !important; } }
.themeIcon { font-size: 15px; }
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
hr.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }
code.k {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; background: var(--card-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 5px; word-break: break-all;
}
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
