/* pages.css —— S2/S3 业务页样式（预订 / 客户 / 交班 / 现付账 / 报表）
 *
 * 命名空间：**所有规则都以 .pages / .pages-* 开头**，不触碰 styles.css 与 css/board2.css 的既有类名，
 * 因此可以和旧视图并存、按需挂载/卸载。
 *
 * 品牌色：styles.css 目前没有 :root 颜色变量，这里沿用 board2.css 的「有则引用、无则兜底」写法
 * （var(--brand-*, fallback)）。后续品牌色变量落到 :root 后，本文件无需改动即跟随。
 *
 * 断点：模块只在桌面（≥900px）挂载。基础排版（pill / 错误条 / 表格 / 表单）在所有宽度都安全；
 * 多列布局、统计卡列数、粘性表头等**只出现在 @media (min-width:900px)**，
 * ≤899px 给一套单列兜底，保证窄窗或预览页不塌。
 *
 * 视觉基准（与 0.7 / S0 一致）：13px 正文、#087c61 主色、#dbe7f2 描边、14px 圆角面板、
 * 表格行 hover 浅底、按钮最小高 38px（触摸目标 ≥44px 的规则由 styles.css 的 ≤640 段负责）。
 */

/* —— 基础：变量、容器、文字 —— */
.pages {
  --pg-brand: var(--brand-primary, #087c61);
  --pg-brand-deep: var(--brand-primary-deep, #0b3d66);
  --pg-ink: var(--brand-ink, #193b34);
  --pg-ink-soft: var(--brand-ink-soft, #31546e);
  --pg-muted: var(--brand-muted, #7c9188);
  --pg-line: var(--brand-line, #dbe7f2);
  --pg-line-soft: var(--brand-line-soft, #edf3f9);
  --pg-surface: var(--brand-surface, #ffffff);
  --pg-page: var(--brand-page, #eef6ff);
  --pg-ok: var(--brand-clean, #087c61);
  --pg-ok-bg: var(--brand-clean-bg, #e4f5ec);
  --pg-warn: var(--brand-dirty, #b5762a);
  --pg-warn-bg: var(--brand-dirty-bg, #fdf2e2);
  --pg-bad: var(--brand-danger, #c84d45);
  --pg-bad-bg: var(--brand-danger-bg, #fbeae7);
  --pg-info: var(--brand-inhouse, #2f7fc4);
  --pg-info-bg: var(--brand-inhouse-bg, #e8f2fd);
  --pg-neutral: var(--brand-locked, #6f8298);
  --pg-neutral-bg: var(--brand-locked-bg, #eef2f7);

  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--pg-ink);
  font-size: 13px;
  line-height: 1.5;
  min-width: 0;
}

.pages .section-title {
  margin: 0;
  font-size: 15px;
  color: var(--pg-ink);
}

.pages .muted {
  color: var(--pg-muted);
  font-weight: 400;
}

.pages-note {
  margin: 8px 0;
  color: var(--pg-muted);
  font-size: 12px;
  line-height: 1.6;
}

.pages-subtitle {
  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--pg-ink-soft);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--pg-line-soft);
}

.pages-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* —— 工具条 / 筛选表单 —— */
/* 工具条用 flex + 自动换行：字段自适应宽度，操作按钮靠右，一行放不下才折行 */
.pages-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  padding: 14px 16px;
  background: var(--pg-surface);
  border: 1px solid var(--pg-line);
  border-radius: 14px;
  box-shadow: 0 5px 20px #37648a10;
}

.pages-field {
  display: flex;
  flex: 1 1 158px;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  font-weight: 800;
  color: var(--pg-ink-soft);
}

.pages-field input,
.pages-field select,
.pages-field textarea {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--pg-line);
  border-radius: 9px;
  background: #fff;
  color: var(--pg-ink);
  font: inherit;
  font-weight: 400;
  outline: 0;
}

.pages-field textarea {
  height: auto;
  padding: 8px 11px;
  resize: vertical;
  line-height: 1.6;
}

.pages-field input:focus,
.pages-field select:focus,
.pages-field textarea:focus {
  border-color: var(--pg-brand);
  box-shadow: 0 0 0 3px #087c611a;
}

.pages-field input:disabled,
.pages-field select:disabled {
  background: #f5f8f7;
  color: var(--pg-muted);
}

/* 字段级校验失败：只加红框，不改变布局（错误文案在页头 inline 提示） */
.pages-field-invalid input,
.pages-field-invalid select {
  border-color: var(--pg-bad);
  box-shadow: 0 0 0 3px #c84d451a;
}

.pages-field-full {
  flex: 1 1 100%;
  grid-column: 1 / -1;
}

.pages-field-grow {
  flex: 2 1 260px;
}

.pages-field-inline {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.pages-field-inline select {
  width: auto;
  min-width: 110px;
}

.pages-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.pages-quick {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* 导出区：粒度 + 按钮 + 说明左对齐一行 */
.pages-export-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pages-export-row .pages-hint {
  flex: 1 1 240px;
}

/* —— 面板头 —— */
.pages-panel {
  padding: 18px;
  min-width: 0;
}

.pages-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pages-panel-head-plain {
  border-bottom: 1px solid var(--pg-line-soft);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.pages-head-note {
  color: var(--pg-muted);
  font-size: 11px;
}

.pages-count {
  color: var(--pg-muted);
  font-size: 12px;
}

/* —— 提示条：flash / inline 错误 —— */
.pages-flash {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--pg-line);
  font-size: 12px;
  line-height: 1.6;
}

.pages-flash-ok {
  background: var(--pg-ok-bg);
  border-color: #c9e8d8;
  color: #14664a;
}

.pages-flash-error {
  background: var(--pg-bad-bg);
  border-color: #f3d9d3;
  color: #a8443c;
}

.pages-flash-text {
  flex: 1 1 320px;
  min-width: 0;
  font-weight: 700;
}

.pages-flash-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pages-error {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--pg-bad-bg);
  border: 1px solid #f3d9d3;
  color: #a8443c;
  font-size: 12px;
  line-height: 1.6;
}

.pages-error strong {
  font-weight: 700;
}

.pages-code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #ffffffb3;
  border: 1px solid #d9c3bf;
  color: #94463f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.pages-hint {
  color: var(--pg-muted);
  font-size: 11px;
  line-height: 1.6;
}

.pages-hint-inline {
  align-self: center;
}

/* —— 表格 —— */
.pages-table {
  width: 100%;
  border-collapse: collapse;
}

.pages-table th,
.pages-table td {
  vertical-align: middle;
}

.pages-table td {
  line-height: 1.55;
}

.pages-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pages-nowrap {
  white-space: nowrap;
}

.pages-money {
  font-weight: 800;
  color: var(--pg-ink);
  font-variant-numeric: tabular-nums;
}

.pages-money-due {
  color: #b4483d;
}

.pages-row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.pages-row-actions .btn.small {
  padding: 5px 9px;
  min-height: 28px;
  font-size: 11px;
}

.pages-scroll-table {
  max-height: 480px;
  overflow: auto;
}

/* —— 分页 —— */
.pages-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--pg-line-soft);
}

.pages-pager-info {
  color: var(--pg-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.pages-pager-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* —— 状态 pill（不复用 .pill 的既有状态色，避免与订单状态语义混淆） —— */
.pages-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  background: var(--pg-neutral-bg);
  color: var(--pg-neutral);
}

.pages-pill-pending { background: #fff0d5; color: #a26a1d; }
.pages-pill-confirmed { background: var(--pg-info-bg); color: #1f6ca6; }
.pages-pill-arrived { background: var(--pg-ok-bg); color: #0c7a5a; }
.pages-pill-cancelled,
.pages-pill-no_show { background: #eef0f1; color: #7b8d84; }
.pages-pill-open { background: var(--pg-ok-bg); color: #0c7a5a; }
.pages-pill-closed { background: var(--pg-neutral-bg); color: var(--pg-neutral); }
.pages-pill-ok { background: var(--pg-ok-bg); color: #0c7a5a; }
.pages-pill-warn { background: var(--pg-warn-bg); color: #96601f; }
.pages-pill-bad { background: var(--pg-bad-bg); color: #b4483d; }
.pages-pill-neutral { background: var(--pg-neutral-bg); color: var(--pg-neutral); }
.pages-pill-member { background: #f1ecfb; color: #6a51a8; }
.pages-pill-inhouse { background: var(--pg-info-bg); color: #1f6ca6; }
.pages-pill-due { background: var(--pg-warn-bg); color: #96601f; }
.pages-pill-unknown { background: var(--pg-neutral-bg); color: var(--pg-neutral); }

/* —— 表单面板 —— */
.pages-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pages-form-grid-narrow {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pages-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--pg-line-soft);
}

.pages-form-foot .form-help {
  margin: 0;
  max-width: 62ch;
}

.pages-form-foot .btn.primary {
  min-width: 132px;
}

/* —— 统计卡 —— */
.pages-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.pages-stat-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pages-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 15px;
  background: var(--pg-surface);
  border: 1px solid var(--pg-line);
  border-radius: 12px;
  box-shadow: 0 4px 16px #37648a0d;
  min-width: 0;
}

.pages-stat-label {
  color: var(--pg-muted);
  font-size: 11px;
  font-weight: 700;
}

.pages-stat-value {
  font-size: 21px;
  line-height: 1.2;
  color: var(--pg-ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.pages-stat-note {
  color: var(--pg-muted);
  font-size: 11px;
  line-height: 1.5;
}

/* —— 交班：现金行 / 方式拆分 —— */
.pages-cash-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 6px;
}

.pages-cash-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 13px;
  border-radius: 10px;
  background: #f7fbfe;
  border: 1px solid var(--pg-line-soft);
  min-width: 0;
}

.pages-cash-item > span {
  color: var(--pg-muted);
  font-size: 11px;
  font-weight: 700;
}

.pages-cash-item > strong {
  font-size: 15px;
  color: var(--pg-ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.pages-cash-item-wide {
  grid-column: span 2;
}

.pages-method-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 4px 0 8px;
}

.pages-method-legend {
  margin: 0 0 8px;
}

.pages-method-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 2fr) minmax(0, 3fr);
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

.pages-method-name {
  font-weight: 800;
  color: var(--pg-ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pages-method-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.pages-method-bar {
  display: block;
  height: 6px;
  min-width: 2px;
  border-radius: 20px;
  background: var(--pg-brand);
}

.pages-method-bar-out {
  background: #e0867a;
}

.pages-method-nums {
  color: var(--pg-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.pages-detail {
  padding: 12px 4px 4px;
}

.pages-detail-row > td {
  background: #fafcfe;
  padding: 4px 14px 14px;
}

/* —— 报表：占比条 —— */
.pages-chart {
  padding: 4px 0 2px;
}

.pages-bar-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.pages-bar {
  flex: 1 1 auto;
  min-width: 56px;
  max-width: 140px;
  height: 8px;
  border-radius: 20px;
  background: var(--pg-line-soft);
  overflow: hidden;
}

.pages-bar > i {
  display: block;
  height: 100%;
  border-radius: 20px;
  background: var(--pg-brand);
}

.pages-export .pages-form-foot {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.pages-export .pages-field-inline {
  font-size: 12px;
}

/* —— 空态：紧凑版（页面内多处空态时不要占满屏） —— */
.pages-empty-compact {
  padding: 26px 16px;
}

.pages-empty-compact span {
  font-size: 22px;
  margin-bottom: 6px;
}

/* —— 桌面布局（≥900px）：工具条一行、四列统计卡、粘性表头 —— */
@media (min-width: 900px) {
  .pages-filters {
    padding: 16px 18px;
  }

  .pages-field {
    flex: 1 1 172px;
  }

  .pages-field-grow {
    flex: 2 1 280px;
  }

  .pages-hint-inline {
    flex: 1 1 100%;
  }

  .pages-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pages-stat-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pages-table th {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .pages-table tbody tr:hover td {
    background: #fafdff;
  }

  /* 桌面 1024 起：列多的业务表格不再被压扁，由 .table-wrap 横向滚动承接。
     预订列表 8 列（含 6 个行内操作）在 1024 的内容宽 ~860px 下会把「房型/房间」「订单」竖排、
     操作按钮拆成 2 行；1240px 让每列回到可读宽度。1280（内容宽 ~1114px）同样受益，
     1440+（~1276px）不触发滚动。
     其余 pages 表格（客户 7 列 / 待收款 6 列 / 房型贡献 8 列 / 渠道 4 列 / 交班 9 列）在 1024
     实测 858px 内自然折行、行高不变（交班用真实表头 + 示例行验证），故不加 min-width。 */
  .pages-reservations .pages-table {
    min-width: 1240px;
  }

  .pages-cash-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pages-form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pages-form-grid-narrow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* —— 窄窗兜底（<900px）：模块本应只在桌面挂载，这里保证预览页/窄窗不塌 —— */
@media (max-width: 899px) {
  .pages-field {
    flex: 1 1 100%;
  }

  .pages-filter-actions {
    margin-left: 0;
    flex: 1 1 100%;
  }

  /* 表格不压字：保持最小宽度，由 .table-wrap 横向滚动 */
  .pages-table {
    min-width: 720px;
  }

  .pages-stat-grid,
  .pages-stat-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pages-cash-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pages-cash-item-wide {
    grid-column: 1 / -1;
  }

  .pages-form-grid,
  .pages-form-grid-narrow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pages-method-row {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .pages-method-nums {
    grid-column: 1 / -1;
  }
}

/* —— 打印：报表/交班表可直接打印，隐藏操作与分页 —— */
@media print {
  .pages-filters,
  .pages-pager,
  .pages-row-actions,
  .pages-flash,
  .pages-form-panel,
  .pages-export {
    display: none !important;
  }

  .pages .panel {
    border: 0;
    box-shadow: none;
  }
}
