/* ==========================================================================
   布局：顶部栏 / 页面容器 / 底部导航 / 各页面专用样式
   ========================================================================== */

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- 顶部栏（固定） ----------
   注意：#app 上有 overflow-x:hidden，会使 position:sticky 失效，
   因此这里必须用 fixed，并由 .page 的 padding-top 做高度补偿（见下方）。 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  background: rgba(11, 22, 40, .88);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--c-border);
  padding-top: var(--safe-t);
}
.topbar-in {
  max-width: var(--max-w); margin: 0 auto;
  padding: 8px var(--s-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  min-height: 48px;   /* 紧凑，避免固定区占过多高度 */
}
.topbar .brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.topbar .brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--c-teal);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.topbar .brand-name { font-size: 16px; font-weight: 700; color: var(--c-navy); letter-spacing: .2px; }
.topbar .brand-sub { font-size: 11px; color: var(--c-text-sub); }

/* ---- 固定顶部：网站品牌名 ---- */
.brand-title {
  font-size: 16.5px; font-weight: 800; color: var(--c-navy); letter-spacing: .6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-feature-settings: "tnum";
}

/* ---- 固定顶部：AI 记账按钮（蓝紫渐变 + 星标） ---- */
.tb-ai {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: linear-gradient(96deg, #3E7BFA 0%, #7C5CFF 100%);
  color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .3px;
  padding: 9px 15px; border-radius: 999px; border: none;
  box-shadow: 0 4px 14px rgba(101, 92, 255, .34), inset 0 1px 0 rgba(255, 255, 255, .22);
  white-space: nowrap; cursor: pointer; line-height: 1.2;
}
.tb-ai .ai-ico { font-size: 13px; line-height: 1; transform: translateY(-.5px); }
.tb-ai:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(101, 92, 255, .3); }

/* ---------- 页面 ---------- */
.page {
  flex: 1; max-width: var(--max-w); width: 100%; margin: 0 auto;
  /* 顶部留出固定顶栏的高度（--topbar-h 由 JS 实测写入，保证不被遮挡） */
  padding: calc(var(--topbar-h, 56px) + var(--safe-t) + var(--s-2)) var(--s-4)
           calc(var(--nav-h) + var(--safe-b) + var(--s-6));
}
.page-in { display: flex; flex-direction: column; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 600;
  background: rgba(11, 22, 40, .92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  box-shadow: var(--shadow-nav);
  padding-bottom: var(--safe-b);
}
.tabbar-in {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; height: var(--nav-h);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; color: var(--c-text-faint); font-size: 11px;
  position: relative;
}
.tabbar button .ti { font-size: 19px; line-height: 1; }
.tabbar button.on { color: var(--c-teal); font-weight: 600; }
.tabbar button.on .ti { transform: translateY(-1px); }
.tabbar .badge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--c-amber); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 首页：当前旅行条 ---------- */
.tripbar {
  display: flex; align-items: center; gap: var(--s-2);
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-card);
  padding: 10px 12px; margin-bottom: var(--s-3); box-shadow: var(--shadow-card);
}
.tripbar .tn { font-size: 15px; font-weight: 700; color: var(--c-navy); }
.tripbar .td { font-size: 12px; color: var(--c-text-sub); }

/* ---------- 首页：总览卡 ---------- */
.overview {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: var(--s-4); margin-bottom: var(--s-3);
  position: relative; overflow: hidden;
}
.overview::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c-teal);
}
.ov-label { font-size: 12px; color: var(--c-text-sub); }
.ov-main {
  font-size: 32px; font-weight: 800; color: var(--c-teal); line-height: 1.15;
  margin: 4px 0 var(--s-1); font-family: var(--font-num);
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
}
.ov-sub { font-size: 12px; color: var(--c-text-sub); }
.ov-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2);
  margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--c-border);
}
.ov-grid > div { text-align: center; min-width: 0; }
.ov-grid .k { font-size: 11px; color: var(--c-text-sub); }
.ov-grid .v {
  font-size: 15px; font-weight: 700; color: var(--c-navy); margin-top: 2px;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.ov-mode {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: var(--s-3); padding: 8px 12px; border-radius: var(--r-btn);
  background: var(--c-mist); font-size: 12.5px;
}

/* ---------- 核心操作区 ---------- */
.acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); margin-bottom: var(--s-3); }
.act {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-card-sm);
  padding: var(--s-3); display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-card); text-align: left; transition: border-color .15s;
}
.act:hover { border-color: var(--c-teal); }
.act .ai {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--c-teal-soft); color: #0E8C7E;
}
.act.amber .ai { background: var(--c-amber-soft); color: #B26E00; }
.act.navy .ai { background: var(--c-mist); color: var(--c-navy); }
.act .at { font-size: 14px; font-weight: 600; color: var(--c-navy); }
.act .as { font-size: 11px; color: var(--c-text-sub); margin-top: 1px; }
.act-primary { grid-column: span 2; }
.act-primary .ai { background: var(--c-teal); color: #fff; width: 40px; height: 40px; font-size: 20px; }

/* ---------- 每日时间轴 ---------- */
.daygrp {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); margin-bottom: var(--s-2); overflow: hidden;
}
.dayhd {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); cursor: pointer; user-select: none;
}
.dayhd .dt { font-size: 14px; font-weight: 700; color: var(--c-navy); }
.dayhd .dw { font-size: 11px; color: var(--c-text-sub); }
.dayhd .dc {
  font-size: 11px; color: var(--c-text-sub); background: var(--c-mist);
  padding: 1px 7px; border-radius: var(--r-tag);
}
.dayhd .dsum {
  margin-left: auto; font-size: 16px; font-weight: 700; color: var(--c-teal);
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.dayhd .caret {
  width: 16px; color: var(--c-text-faint); font-size: 11px;
  transition: transform .2s; text-align: center;
}
.daygrp.open .caret { transform: rotate(90deg); }
.daybd { border-top: 1px solid var(--c-border); padding: 0 var(--s-4); display: none; }
.daygrp.open .daybd { display: block; }
.daygrp.today { border-color: #C9EEE9; }
.daygrp.today .dayhd { background: var(--c-teal-soft); }

/* ---------- 账单条目 ---------- */
.bill {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border); cursor: pointer;
}
.bill:last-child { border-bottom: none; }
.bill.sel { background: var(--c-teal-soft); margin: 0 calc(-1 * var(--s-4)); padding-left: var(--s-4); padding-right: var(--s-4); }
.bill-check { display: flex; align-items: center; padding-top: 4px; }
.bill-check input { width: 18px; height: 18px; -webkit-appearance: auto; appearance: auto; accent-color: var(--c-teal); }
.bill-body { flex: 1; min-width: 0; }
.bill-t1 { display: flex; align-items: baseline; gap: 6px; }
.bill-merchant { font-size: 14.5px; font-weight: 600; color: var(--c-navy); flex: 1; min-width: 0; }
.bill-amt {
  font-size: 15px; font-weight: 700; color: var(--c-navy); flex-shrink: 0;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.bill-amt.refund { color: var(--c-success); }
.bill-amt.none { color: var(--c-text-faint); font-weight: 500; }
.bill-t2 { font-size: 12px; color: var(--c-text-sub); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.bill-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.bill-time {
  font-size: 11px; color: var(--c-text-faint); font-family: var(--font-num);
  min-width: 42px; padding-top: 2px; flex-shrink: 0;
}

/* ---------- 筛选栏 ---------- */
.filters {
  display: flex; gap: var(--s-2); overflow-x: auto; padding: 2px 0 var(--s-3);
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--glass-bg-2); border: 1px solid var(--glass-border);
  font-size: 13px; color: var(--c-text-sub); white-space: nowrap;
}
.chip.on { background: var(--c-blue); border-color: var(--c-blue); color: #fff; font-weight: 600; }
.chip.on.teal { background: var(--c-teal); border-color: var(--c-teal); color: var(--c-text-inv); }
.searchbar { position: relative; margin-bottom: var(--s-3); }
.searchbar input { padding-left: 34px; background: var(--glass-bg-2); border-color: var(--c-border-strong); }
.searchbar .si { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-faint); font-size: 14px; }
.bulkbar {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 550;
  background: var(--c-navy); color: #fff; border-radius: var(--r-card);
  padding: 10px 14px; display: flex; align-items: center; gap: var(--s-2);
  box-shadow: var(--shadow-pop); margin-bottom: var(--s-3); font-size: 14px;
}
.bulkbar .btn { min-height: 32px; font-size: 13px; }

/* ---------- 结算中心 ---------- */
.settle-hd {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-card);
  box-shadow: var(--shadow-card); padding: var(--s-4); margin-bottom: var(--s-3);
}
.mode-tabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-3); }
.mode-tab {
  flex: 1; background: #fff; border: 1px solid var(--c-border);
  border-radius: var(--r-card-sm); padding: 10px 8px; text-align: center;
  transition: .15s;
}
.mode-tab .mt-n { font-size: 13px; font-weight: 600; color: var(--c-navy); }
.mode-tab .mt-d { font-size: 11px; color: var(--c-text-sub); margin-top: 2px; }
.mode-tab.on { border-color: var(--c-teal); background: var(--c-teal-soft); }
.mode-tab.on .mt-n { color: #0E8C7E; }

.bal-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border);
}
.bal-row:last-child { border-bottom: none; }
.bal-mid { flex: 1; min-width: 0; }
.bal-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.bal-net { font-size: 15px; font-weight: 700; }
.bal-net.pos { color: var(--c-teal); }
.bal-net.neg { color: var(--c-amber); }
.bal-net.zero { color: var(--c-text-faint); font-weight: 500; }

.transfer-row {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 12px; background: var(--c-mist); border-radius: var(--r-btn);
  margin-bottom: var(--s-2); font-size: 14px;
}
.transfer-row .arrow { color: var(--c-teal); font-weight: 700; }
.transfer-row .tv { margin-left: auto; font-weight: 700; font-family: var(--font-num); }

/* 分摊规则编辑 */
.split-item {
  border: 1px solid var(--c-border); border-radius: var(--r-card-sm);
  padding: var(--s-3); margin-bottom: var(--s-2); background: #fff;
}
.split-item.excluded { background: var(--c-mist); }
.si-hd { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.si-merchant { font-size: 14px; font-weight: 600; color: var(--c-navy); flex: 1; min-width: 0; }
.si-amt { font-weight: 700; font-family: var(--font-num); }
.si-members { display: flex; flex-direction: column; gap: 6px; }
.si-mrow { display: flex; align-items: center; gap: var(--s-2); }
.si-mrow .nm { flex: 1; font-size: 14px; min-width: 0; }
.si-mrow input { width: 88px; flex-shrink: 0; text-align: right; padding: 6px 8px; font-size: 14px; }
.si-sum {
  display: flex; justify-content: space-between; font-size: 12.5px;
  padding-top: 8px; margin-top: 6px; border-top: 1px dashed var(--c-border);
}
.si-sum .bad { color: var(--c-danger); font-weight: 600; }
.si-sum .good { color: var(--c-success); font-weight: 600; }

/* ---------- 核对界面 ---------- */
.review-img {
  width: 100%; max-height: 40vh; object-fit: contain;
  background: var(--c-mist); border-radius: var(--r-card-sm);
  border: 1px solid var(--c-border); display: block;
}
.review-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-2); }
.review-nav {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border);
}
.review-nav .rn-i { font-size: 13px; color: var(--c-text-sub); }

/* 上传区 */
.dropzone {
  border: 1.5px dashed var(--c-border-strong); border-radius: var(--r-card);
  background: #fff; padding: var(--s-6) var(--s-4); text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.on { border-color: var(--c-teal); background: var(--c-teal-soft); }
.dropzone .dz-ico { font-size: 30px; color: var(--c-teal); }
.upitem {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2); border: 1px solid var(--c-border); border-radius: var(--r-btn);
  margin-bottom: var(--s-2); background: #fff;
}
.upitem .ui-st { font-size: 12px; flex-shrink: 0; width: 64px; text-align: right; }

/* ---------- 历史旅行 ---------- */
.trip-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border);
  cursor: pointer;
}
.trip-item:last-child { border-bottom: none; }
.trip-item.cur { background: var(--c-teal-soft); }
.trip-item .ti-body { flex: 1; min-width: 0; }
.trip-item .ti-n { font-size: 14.5px; font-weight: 600; color: var(--c-navy); }

/* ---------- 图片导出预览 ---------- */
.exp-preview {
  background: var(--c-mist); border-radius: var(--r-card-sm); padding: var(--s-2);
  display: flex; flex-direction: column; gap: var(--s-2); align-items: center;
  max-height: 46vh; overflow-y: auto;
}
.exp-preview img {
  width: 100%; max-width: 380px; border-radius: 6px;
  box-shadow: var(--shadow-card); background: #fff; display: block;
}
.exp-kind {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border: 1px solid var(--c-border); border-radius: var(--r-card-sm);
  margin-bottom: var(--s-2); background: #fff; cursor: pointer;
}
.exp-kind.on { border-color: var(--c-teal); background: var(--c-teal-soft); }
.exp-kind .ek-n { font-size: 14px; font-weight: 600; color: var(--c-navy); }
.exp-kind .ek-d { font-size: 11.5px; color: var(--c-text-sub); }
.exp-kind .ek-i { font-size: 20px; flex-shrink: 0; }

/* ---------- 设置 ---------- */
.set-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border);
}
.set-row:last-child { border-bottom: none; }
.set-row .sr-b { flex: 1; min-width: 0; }
.set-row .sr-t { font-size: 14.5px; color: var(--c-navy); }
.set-row .sr-d { font-size: 12px; color: var(--c-text-sub); margin-top: 2px; }

/* ---------- 响应式：平板 / 桌面 ---------- */
@media (min-width: 700px) {
  .page { padding-left: var(--s-6); padding-right: var(--s-6); }
  .ov-grid { grid-template-columns: repeat(4, 1fr); }
  .acts { grid-template-columns: repeat(3, 1fr); }
  .act-primary { grid-column: span 1; }
}
@media (min-width: 1000px) {
  :root { --max-w: 860px; }
  .exp-preview { max-height: 56vh; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .exp-preview img { max-width: 300px; }
}
