/* ==========================================================================
   project021 手足文旅订单管理系统 · 样式表（M1）
   手机优先（mobile first）；纯手写 CSS，不引用任何 CDN / 外部字体 / 框架。
   断点：768px —— 以下为手机（汉堡菜单 + 表格卡片化），以上为桌面。
   ========================================================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d6fd4;
  --primary-dark: #175bb0;
  --primary-soft: #eef3fa;
  --brand-bg: #c8102e;      /* 品牌标底色（红）—— 只用于顶栏 logo，不影响链接/按钮的主色 */
  --danger-bg: #fdecec;
  --danger-border: #f3b7b7;
  --danger-text: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
code {
  background: var(--primary-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  word-break: break-all;
}
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 6px 14px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;            /* 双字标（手足）横向撑开；将来若改回单字仍是 32×32 方块 */
  border-radius: 8px;
  background: var(--brand-bg);
  color: #fff;
  font-size: 14px;           /* 16 → 14：两个字在 32px 高度内不挤边 */
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}
.brand-text { font-size: 17px; font-weight: 600; }

/* 汉堡菜单：用 checkbox 纯 CSS 实现，不依赖 JS */
.nav-toggle { display: none; }
.nav-burger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-left: auto;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.nav-burger span { display: block; width: 20px; height: 2px; background: var(--text); }
.nav-toggle:checked + .nav-burger { background: var(--primary-soft); border-color: var(--primary); }

.nav {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.nav-toggle:checked ~ .nav { display: flex; }
.nav-link {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
}
.nav-link:hover, .nav-link:active { background: var(--primary-soft); }
.nav-user {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 10px;
  color: var(--muted);
  font-size: 14px;
}
.nav-logout { margin: 0; }
.nav-logout .btn { width: 100%; }

/* ------------------------------------------------------------- 主体区域 */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}
.page-head { margin-bottom: 14px; }
.page-title { margin: 0 0 2px; font-size: 22px; line-height: 1.3; }
.page-sub { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-title { margin: 0 0 10px; font-size: 16px; }
.section { margin-top: 14px; }

/* 占位卡片：手机一列，桌面三列 */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { margin: 4px 0 2px; font-size: 34px; font-weight: 700; line-height: 1.2; }
.stat-note { color: var(--muted); font-size: 13px; }

/* 键值列表 */
.kv { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.kv li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.kv li:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; word-break: break-all; text-align: right; }

/* ------------------------------------------------------------- 表单/按钮 */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); font-size: 14px; }
.input {
  width: 100%;
  height: 46px;                 /* ≥ 44px：手机上更好点 */
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;              /* ≥16px：iOS 不会自动放大 */
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 111, 212, .15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }

.alert { margin-bottom: 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.alert-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); }
.alert-warn { background: #fff8e1; border: 1px solid #f0d68a; color: #8a6100; }

/* --------------------------------------------------- 工具条（搜索 / 筛选） */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar .input { width: auto; }
.toolbar-grow { flex: 1 1 200px; min-width: 0; }
.toolbar select.input { flex: 0 0 auto; max-width: 100%; }

/* --------------------------------------------------------- 表单栅格/按钮组 */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field-full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
textarea.input { height: auto; min-height: 46px; padding-top: 10px; padding-bottom: 10px; resize: vertical; }

/* 行内操作按钮组 */
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { margin: 0; }
.btn-sm { min-height: 36px; padding: 0 10px; font-size: 14px; }
.is-disabled { opacity: .5; cursor: default; pointer-events: none; }

/* 状态徽章 / 停用行 / 空态 */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; }
.badge-on { background: #e7f5ec; color: #1c7a43; border: 1px solid #b6e0c5; }
.badge-off { background: #f1f2f4; color: #6b7280; border: 1px solid #d8dbe0; }
.row-disabled { background: #fafafa; }
.row-disabled td { color: var(--muted); }
.empty { color: var(--muted); text-align: center; }

/* 段落（行程 / 包含 / 不含） */
.para { margin: 0 0 8px; }
.para:last-child { margin-bottom: 0; }

/* 分页 */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pager-total { color: var(--muted); font-size: 14px; }
.pager-nav { display: flex; align-items: center; gap: 8px; }
.pager-page { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- 登录页 */
.login-wrap { display: flex; justify-content: center; padding: 18px 0 40px; }
.login-card { width: 100%; max-width: 380px; padding: 22px 18px; }
.login-title { margin: 0; font-size: 22px; }
.login-sub { margin: 2px 0 18px; color: var(--muted); font-size: 14px; }
.login-hint { margin: 16px 0 0; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- 错误页 */
.error-wrap { display: flex; justify-content: center; padding: 20px 0 40px; }
.error-card { width: 100%; max-width: 460px; text-align: center; }
.error-code { font-size: 44px; font-weight: 700; color: var(--primary); line-height: 1; }
.error-title { margin: 8px 0 6px; font-size: 20px; }
.error-message { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.error-actions { margin: 0; }

/* ------------------------------------------------------------------ 表格 */
/* 桌面：常规表格；手机（<768px）：表头隐藏，每行变成卡片堆叠。
   写法：每个 <td> 带 data-label="列名"，手机端用它做行内标签。 */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-all;
}
.data-table th { background: #f7f9fc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------------- 页脚 */
.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 14px 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ================================================== 断点：平板 / 桌面 */
@media (min-width: 768px) {
  .container { padding: 24px 20px 48px; }
  .page-title { font-size: 26px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .login-wrap { padding: 40px 0 60px; }

  .nav-burger { display: none; }
  .nav {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }
  .nav-link { padding: 0 12px; border-radius: 8px; }
  .nav-user { padding: 0 8px; white-space: nowrap; }
  .nav-logout .btn { width: auto; }
}

/* ================================================== 手机：表格卡片化 */
@media (max-width: 767px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    margin-bottom: 10px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border: 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
  }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 600;
    text-align: left;
  }
}


/* -------------------------------------------- 订单状态徽章（任务书 003 §4.5） */
.badge-pending   { background: #fff4e5; color: #9a5b00; border: 1px solid #f0cf9b; }
.badge-confirmed { background: #e8f0fe; color: #1a4fa0; border: 1px solid #b9cdf0; }
.badge-ontour    { background: #e6f4f1; color: #12695c; border: 1px solid #a9d8cf; }
.badge-done      { background: #e7f5ec; color: #1c7a43; border: 1px solid #b6e0c5; }
.badge-cancelled { background: #f1f2f4; color: #6b7280; border: 1px solid #d8dbe0; }

/* 订单详情：状态流转 / 回退按钮组 */
.status-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.status-actions form { margin: 0; }

/* 工具条内的行内日期标签（订单列表出团日期区间） */
.field-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.field-inline .input { width: auto; }
/* ============================================ 财务（任务书 005：收款/费用/利润） */
/* 利润条：手机 sticky 在顶栏之下，首屏可见（纯 CSS） */
.profit-bar {
  position: sticky;
  top: 56px;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 600;
}
.profit-item { white-space: nowrap; }
.profit-sep { color: var(--border); }

/* 金额颜色：欠款醒目红 / 已结清灰 / 多收蓝 */
.money-due { color: #c8102e; font-weight: 600; }
.money-clear { color: var(--muted); }
.money-over { color: var(--primary); font-weight: 600; }
.money-total { color: var(--text); }

/* 费用总表汇总行 */
.expense-summary { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 12px; }


/* ============================ 工作台：我的团 / 提醒（任务书 007 §2 §3） */
.tel-link { white-space: nowrap; }
.remind-sub { margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.remind-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.9; }
.remind-list li { word-break: break-all; }

/* ============================ 统计（任务书 007 §4） */
.range-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.range-switch .is-current { cursor: default; }
.trend-legend { display: flex; gap: 14px; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.trend-key { display: inline-flex; align-items: center; gap: 6px; }
.trend-key::before { content: ""; display: inline-block; width: 14px; height: 8px; border-radius: 3px; }
.trend-key-est::before { background: var(--primary); }
.trend-key-real::before { background: #1c7a43; }
.trend { display: flex; flex-direction: column; gap: 12px; }
.trend-row { border-bottom: 1px dashed var(--border); padding-bottom: 10px; }
.trend-row:last-child { border-bottom: 0; padding-bottom: 0; }
.trend-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; font-size: 14px; }
.trend-month { font-variant-numeric: tabular-nums; }
.trend-num { color: var(--muted); white-space: nowrap; }
.trend-bars { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.trend-bar { height: 12px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.trend-bar i { display: block; height: 100%; border-radius: 999px; }
.trend-est i { background: var(--primary); }
.trend-real i { background: #1c7a43; }

/* ==========================================================================
   M6 · Excel 导入 / 凭证上传 / 单据打印 / 备份页（任务书 008）
   ========================================================================== */

/* 费用行里的凭证区：<details> 折叠，不依赖任何 JS */
.file-box { display: inline-block; }
.file-box > summary { cursor: pointer; list-style: none; }
.file-box > summary::-webkit-details-marker { display: none; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-list a { word-break: break-all; }
.file-link { font-size: 13px; }
.file-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.file-input { font-size: 13px; max-width: 100%; }

/* 导入预览：问题行标红 + 校验结果文字 */
.row-bad { background: #fff4f4; }
.cell-bad { color: var(--danger-text); }
.cell-ok { color: #1c7a43; }

/* 备份页：恢复步骤命令块 */
.code-block {
  background: #0f172a; color: #e5e7eb; border-radius: var(--radius);
  padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.7; white-space: pre;
}

/* 单据打印：屏幕上也好看（A4 宽度的白纸感） */
.print-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.print-sheet {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; padding: 28px 30px; color: #111827;
}
.sheet-head { text-align: center; border-bottom: 2px solid #111827; padding-bottom: 12px; margin-bottom: 18px; }
.sheet-company { font-size: 20px; font-weight: 700; letter-spacing: 4px; color: var(--brand-bg); }
.sheet-title { font-size: 22px; margin: 6px 0 4px; letter-spacing: 6px; }
.sheet-meta { color: var(--muted); font-size: 13px; }
.sheet-h2 { font-size: 16px; margin: 22px 0 8px; padding-left: 8px; border-left: 3px solid var(--primary); }
.sheet-h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); }
.sheet-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.sheet-table th, .sheet-table td {
  border: 1px solid #cdd5df; padding: 7px 9px; font-size: 14px; text-align: left; vertical-align: top;
}
.sheet-table th { background: #f3f6fa; font-weight: 600; }
.sheet-table thead th { text-align: center; }
.sheet-text { font-size: 14px; }
.sheet-text p { margin: 0 0 6px; }
.sheet-two-col { display: flex; gap: 20px; }
.sheet-two-col > div { flex: 1 1 50%; min-width: 0; }
.sheet-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.sheet-foot { margin-top: 26px; padding-top: 12px; border-top: 1px dashed #cdd5df; }
.sheet-sign { width: 100%; border-collapse: collapse; margin-top: 18px; }
.sheet-sign td { padding: 16px 10px 0 0; font-size: 14px; }

@media (max-width: 767px) {
  .print-sheet { padding: 18px 14px; }
  .sheet-two-col { flex-direction: column; gap: 10px; }
  .sheet-company { font-size: 17px; }
  .sheet-title { font-size: 18px; letter-spacing: 3px; }
}

/* 打印：隐藏导航 / 按钮 / 页脚与提示条，去背景色，A4 宽度，表格行不跨页断开 */
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  html, body { background: #fff !important; }
  .topbar, .footer, .no-print, .print-toolbar, .alert { display: none !important; }
  .container { padding: 0 !important; max-width: none !important; margin: 0 !important; }
  .print-sheet {
    border: 0 !important; border-radius: 0; box-shadow: none;
    max-width: none; margin: 0; padding: 0; width: auto;
  }
  .sheet-table { page-break-inside: auto; }
  .sheet-table tr { page-break-inside: avoid; page-break-after: auto; }
  .sheet-table thead { display: table-header-group; }
  .sheet-h2 { page-break-after: avoid; }
  a { color: inherit !important; text-decoration: none; }
}
