/*
 * TripBooking B2B 代理商后台。无构建步骤，本文件即最终产物。
 *
 * 取值集中在 :root，组件一律引用变量而非写死色值——代理商后台会长期加页面，
 * 散落的十几种灰是丑的主因。
 */

:root {
  /* 画布与表面 */
  --canvas: #f5f6f8;
  --surface: #fff;
  --surface-sunken: #fafbfc;

  /* 墨色三档：标题 / 正文 / 弱化 */
  --ink: #111a26;
  --ink-body: #414d5c;
  --ink-muted: #8a94a3;

  /* 描边两档：外框 / 内分隔 */
  --line: #e3e7ec;
  --line-soft: #eef1f4;

  --accent: #2557d6;
  --accent-hover: #1c46b0;
  --accent-weak: #eef3ff;

  --ok: #0f7a4d;
  --ok-bg: #e6f5ed;
  --warn: #9a6400;
  --warn-bg: #fdf4e3;
  --danger: #b42318;
  --danger-bg: #fdecea;

  --r-card: 10px;
  --r-ctl: 6px;

  /* 两层叠加而非单层大模糊：单层在浅背景上会糊成一团灰 */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lift: 0 4px 12px rgba(16, 24, 40, .08), 0 12px 32px rgba(16, 24, 40, .10);
  --ring: 0 0 0 3px rgba(37, 87, 214, .16);
}

* { box-sizing: border-box; }

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

[hidden] { display: none !important; }

/* 金额、单号、行程号一律等宽等距，纵向能对齐着扫 */
.mono, .num, td.num, .price-row span:last-child {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .92em;
}

.muted { color: var(--ink-muted); }
.right { text-align: right; }

/* 筛选条末尾的计数，靠 auto 外边距推到右端 */
.count { margin-left: auto; }

a.link { color: var(--accent); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.hint { color: var(--ink-muted); font-size: 12px; margin-top: 4px; line-height: 1.45; }

/* ---------- 品牌标记 ---------- */

.mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--accent), #4b7bff);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.5px;
}

/* ---------- 登录 ---------- */

#login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, #e8eeff 0%, transparent 60%),
    radial-gradient(700px 400px at 95% 105%, #eaf3f0 0%, transparent 55%),
    var(--canvas);
}

.card {
  background: var(--surface);
  padding: 34px 36px 28px;
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--line-soft);
  width: 384px;
}

.card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.card h1 { font-size: 19px; margin: 0; color: var(--ink); letter-spacing: -.2px; }
.card p.sub { color: var(--ink-muted); margin: 0 0 20px; font-size: 13px; }
.card label:first-of-type { margin-top: 0; }

.card-foot {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center;
}

.card-foot .link { font-size: 13px; }

/* ---------- 表单件 ---------- */

label {
  display: block; margin: 14px 0 6px;
  color: var(--ink-body); font-size: 12.5px; font-weight: 500;
}

input, select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}

input::placeholder { color: #b6bec9; }

input:hover, select:hover { border-color: #cfd6de; }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

button {
  padding: 8px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-ctl);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}

button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

button.ghost {
  background: var(--surface); color: var(--ink-body); border-color: var(--line);
}

button.ghost:hover { background: var(--surface-sunken); border-color: #cfd6de; color: var(--ink); }
button.small { padding: 5px 11px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:disabled:hover { background: var(--accent); border-color: var(--accent); }
button.ghost:disabled:hover { background: var(--surface); border-color: var(--line); }

.err { color: var(--danger); margin-top: 12px; min-height: 18px; font-size: 12.5px; }

/* ---------- 框架 ---------- */

#app { display: none; }
#app.on { display: block; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}

header .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--ink); font-size: 15px; letter-spacing: -.2px;
}

header .who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
header .who #agentName { color: var(--ink); font-weight: 500; }

header .who #agentId {
  color: var(--ink-muted); background: var(--surface-sunken);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 2px 9px;
}

.body { display: flex; min-height: calc(100vh - 56px); align-items: stretch; }

nav {
  width: 208px; flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
}

nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; margin-bottom: 2px;
  color: var(--ink-body); text-decoration: none; cursor: pointer;
  border-radius: var(--r-ctl); font-size: 13.5px;
  transition: background .12s, color .12s;
}

nav a::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #c8d0da; flex: none; transition: background .12s;
}

nav a:hover { background: var(--surface-sunken); color: var(--ink); }
nav a.on { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
nav a.on::before { background: var(--accent); }

main { flex: 1; padding: 22px 24px 32px; min-width: 0; }

h2 {
  font-size: 17px; margin: 0 0 16px; color: var(--ink);
  font-weight: 600; letter-spacing: -.2px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.panel > h2 { font-size: 15px; margin-bottom: 4px; }

/* 面板内的表格铺满卡片宽度：卡片内边距由表格自己的首末列补偿 */
.panel > table, .panel > .table-wrap { margin: 14px -18px 0; width: calc(100% + 36px); }
/* 只有表格是卡片最后一块时才吃掉底部内边距；房型页表格后面还有政策区块 */
.panel > table:last-child, .panel > .table-wrap:last-child { margin-bottom: -18px; }
.panel > .table-wrap { overflow-x: auto; }
.panel > .table-wrap > table { width: 100%; }

/* ---------- 表单行 ---------- */

/*
 * 各格按顶端对齐，不按底端。带说明文字的格（儿童年龄）比别人高，
 * 底端对齐会把它的标签与输入框整体顶上去，一行字段就参差不齐了。
 */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.form-row > div { flex: 0 0 150px; }
.form-row > div.narrow { flex: 0 0 96px; }
.form-row > div.wide { flex: 0 0 210px; }
.form-row > div.shrink { flex: 0 0 auto; }
.form-row label { margin-top: 0; min-height: 18px; }

/* 查询按钮没有 label，补一段等高占位让它与输入框顶端对齐 */
.form-row > div.shrink button { margin-top: 24px; }

/* ---------- 城市 / 酒店联想 ---------- */

.form-row > div.combo { flex: 0 0 250px; position: relative; }

/* 下拉比输入框宽：酒店名普遍长，跟输入框同宽会截成「新加坡首都凯…」 */
.combo-pop {
  position: absolute; z-index: 30; top: 100%; left: 0; min-width: 380px; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  box-shadow: var(--shadow-lift); max-height: 320px; overflow-y: auto; padding: 4px;
}

.combo-head, .combo-group {
  padding: 6px 10px 4px; font-size: 11.5px; color: var(--ink-muted);
}

.combo-group { border-top: 1px solid var(--line-soft); margin-top: 4px; }
.combo-pop > .combo-group:first-child, .combo-head + .combo-group { border-top: 0; margin-top: 0; }

.combo-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 7px 10px; border-radius: 5px; cursor: pointer; color: var(--ink);
}

.combo-item:hover, .combo-item.on { background: var(--accent-weak); }
.combo-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-item > span:last-child { flex: none; font-size: 12px; }
.combo-empty { padding: 14px 10px; color: var(--ink-muted); font-size: 12.5px; line-height: 1.6; }

.target-hint {
  margin-top: 14px; padding: 9px 12px; border-radius: var(--r-ctl);
  background: var(--accent-weak); border: 1px solid #dce6ff; color: #2c4477;
  font-size: 12.5px; display: flex; align-items: center; gap: 12px;
}

/* ---------- 排序筛选条 ---------- */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 14px 0 0; font-size: 12.5px;
}

.toolbar select { width: auto; padding: 5px 9px; font-size: 12.5px; }

.check { display: flex; align-items: center; gap: 5px; margin: 0; cursor: pointer; font-weight: 400; }
.check input { width: auto; margin: 0; }

/* 筛选标签前的说明文字，与前一个控件拉开距离 */
.chip-label { margin-left: 8px; }

/* 筛选标签：取值来自数据本身（供应商给的包含项原文），不由前端归类 */
.chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-body);
  border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 400;
  display: inline-flex; gap: 5px; align-items: baseline;
}

.chip:hover { background: var(--surface-sunken); border-color: #cfd6de; color: var(--ink); }

.chip.on {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.chip.on:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.chip.on .muted { color: rgba(255, 255, 255, .75); }

/* ---------- 表格 ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th, td { text-align: left; padding: 11px 14px; vertical-align: middle; }

th {
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  /*
   * 吸顶的参照是 .table-wrap 而不是页面：那个容器写了 overflow-x: auto，
   * 按 CSS 规范另一轴的 visible 随即变成 auto，于是它自己成了滚动容器。
   * 这里给 56px（顶栏高度）会把表头整体下推 56px，正好盖住第一行数据——
   * 表只有一行时看起来就是"有数据但表格空"。参照物是容器，只能是 0。
   */
  position: sticky; top: 0; z-index: 5;
}

tbody td { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #fbfcfd; }

td.num { text-align: right; font-weight: 600; color: var(--ink); }
td b, th.right { color: var(--ink); }

/* ---------- 标签 ---------- */

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
}

.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.no { background: var(--danger-bg); color: var(--danger); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.gray { background: #f0f2f5; color: #5a6675; }

/* ---------- 提示条 ---------- */

/*
 * 默认隐藏，只有带 .on 才显示（session.js 按「协议是否已签」切换）。
 * 缺了这条 display:none，签过协议的代理商也会一直挂着「尚未接受」的黄条。
 */
.banner { display: none; }

.banner.on {
  background: var(--warn-bg);
  border: 1px solid #f3dfb4;
  color: #7a4f00;
  padding: 12px 16px;
  border-radius: var(--r-card);
  margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}

.banner button { background: #9a6400; border-color: #9a6400; }
.banner button:hover { background: #7f5200; border-color: #7f5200; }

/* 空态：虚线框比一行灰字更像「这里本该有东西」 */
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--r-ctl);
  padding: 26px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface-sunken);
}

/* ---------- 弹层 ---------- */

.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 24px; backdrop-filter: blur(1.5px);
}

.modal {
  background: var(--surface); border-radius: 12px; padding: 26px 28px;
  width: 620px; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lift);
}

.modal h3 { margin: 0 0 14px; font-size: 16px; color: var(--ink); font-weight: 600; }

/* 弹层底部的按钮行 */
.actions { text-align: right; margin-top: 16px; }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 9px 14px; margin: 14px 0; }
.kv > div:nth-child(odd) { color: var(--ink-muted); font-size: 13px; }
.kv > div:nth-child(even) { color: var(--ink); }

/* ---------- 政策与费用 ---------- */

.policy-panel { border-top: 1px solid var(--line-soft); margin-top: 20px; padding-top: 16px; }
.policy-panel h3 { font-size: 14px; margin: 0 0 10px; color: var(--ink); font-weight: 600; }
.policy-line { color: var(--ink-body); margin-bottom: 12px; }
.policy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.policy-grid h4 { font-size: 12.5px; margin: 0 0 6px; color: var(--ink); font-weight: 600; }

/* 供应商政策文本按行展示：policy.js 已把 </li> 换成换行，这里靠 pre-line 还原分条 */
.policy-text { white-space: pre-line; color: var(--ink-body); line-height: 1.7; font-size: 12.5px; }

/*
 * 取消政策在表格里只出一行结论，细则收进 <details>。
 * 摊开写会让每行高到七八行，一屏看不下三个房型——这是页面显得乱的首因。
 */
td.policy-cell { max-width: 260px; }

.cx { font-size: 12.5px; }
.cx summary { cursor: pointer; color: var(--ink-muted); font-size: 12px; margin-top: 3px; }
.cx summary::marker { color: #c3cad3; }
.cx summary:hover { color: var(--accent); }
.cx .cx-body { margin-top: 6px; color: var(--ink-body); line-height: 1.65; }
.cx .cx-body p { margin: 0 0 4px; }

.image-strip { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0 4px; padding-bottom: 6px; }

/*
 * 尺寸写死而非 width:auto：图片是懒加载的，未加载时 auto 会把每张塌成一条竖线，
 * 看着像页面坏了。给定宽高 + cover，占位始终是一块灰底。
 */
.image-strip img {
  width: 156px; height: 104px; object-fit: cover; flex: none;
  border-radius: 8px; border: 1px solid var(--line-soft); background: var(--surface-sunken);
}

details.checkout-policy {
  margin: 14px 0; border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 10px 14px; background: var(--surface-sunken);
}

details.checkout-policy summary { cursor: pointer; color: var(--ink-body); font-size: 13px; }
details.checkout-policy .policy-text { max-height: 190px; overflow: auto; margin-top: 10px; }

/* ---------- 价格明细 ---------- */

.price-panel {
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 12px 16px; margin: 14px 0; background: var(--surface-sunken);
}

.price-head { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 8px; }
.price-head small { margin-left: 8px; }
.price-row { display: flex; justify-content: space-between; gap: 18px; padding: 6px 0; }
.price-row + .price-row { border-top: 1px dashed #e7ebf0; }
.price-row small { display: block; color: var(--ink-muted); font-size: 11.5px; }
.price-row span:last-child { white-space: nowrap; color: var(--ink); }
.price-row.is-sub { color: var(--ink-muted); font-size: 12.5px; }
.price-row.is-due, .price-row.is-grand { border-top: 1px solid var(--line); }
.price-row.is-grand b, .price-row.is-due b { font-size: 15px; color: var(--ink); }

.info-dot {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-muted);
  width: 16px; height: 16px; line-height: 1; border-radius: 50%;
  font-size: 10px; padding: 0; margin-left: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

.info-dot:hover { background: var(--accent-weak); color: var(--accent); border-color: #c9d8ff; }

.tax-note {
  background: var(--accent-weak); border: 1px solid #dce6ff; border-radius: var(--r-ctl);
  padding: 10px 12px; margin: 6px 0; font-size: 12px; color: #2c4477;
}

.tax-note p { margin: 0 0 5px; line-height: 1.65; }
.tax-note p:last-child { margin: 0; }

.doc-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid var(--line-soft);
}

/* ---------- 单据 ---------- */

#docView { position: fixed; inset: 0; background: var(--canvas); overflow: auto; z-index: 60; }

.doc-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}

.doc-tabs { display: flex; gap: 6px; }
.doc-tabs button.on { background: var(--accent-weak); color: var(--accent); border-color: #c9d8ff; }
.doc-bar > div:last-child { display: flex; align-items: center; gap: 10px; }

.doc {
  background: var(--surface); max-width: 800px; margin: 24px auto 48px;
  padding: 44px 52px; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow); line-height: 1.85; color: var(--ink-body);
}

.doc h1 {
  font-size: 21px; margin: 0 0 6px; text-align: center;
  letter-spacing: 1.5px; color: var(--ink); font-weight: 600;
}

.doc .doc-sub { text-align: center; color: var(--ink-muted); margin: 0 0 28px; font-size: 12.5px; }
.doc section { margin-bottom: 24px; }

.doc h2 {
  font-size: 13px; margin: 0 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line); color: var(--ink);
  font-weight: 600; letter-spacing: .04em;
}

.doc-line { display: flex; gap: 18px; padding: 5px 0; }
.doc-line > span:first-child { flex: 0 0 150px; color: var(--ink-muted); }
.doc-line > span:last-child { flex: 1; color: var(--ink); }
.doc-notes { margin: 0; padding-left: 20px; color: var(--ink-body); font-size: 12.5px; }
.doc-notes li { margin-bottom: 6px; }

/* ---------- 页脚 ---------- */

footer#siteFooter {
  padding: 16px 24px; color: var(--ink-muted); font-size: 12.5px;
  border-top: 1px solid var(--line); background: var(--surface);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

/* ---------- 打印 ---------- */

@media print {
  body { background: #fff; }
  .no-print, #app, #login { display: none !important; }
  #docView { position: static; background: #fff; overflow: visible; }
  .doc { border: 0; margin: 0; padding: 0; max-width: none; box-shadow: none; }
  .doc h2 { break-after: avoid; }
  .doc section { break-inside: avoid; }
}
