:root {
  --navy: #0A1B33;
  --navy-soft: #16304f;
  --gold: #C9A254;
  --ivory: #FAF7F0;
  --line: #e6e1d6;
  --text: #1e2a38;
  --muted: #6b7684;
  --ok: #1f8a5b;
  --warn: #c98a1b;
  --bad: #b23a3a;
  --bg: #f5f3ee;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--navy); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 60%, #0f2540 100%); }
.login-card { background: var(--ivory); padding: 38px 34px; border-radius: 10px; width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 4px solid var(--gold); }
.login-card h1 { margin: 0 0 6px; font-size: 20px; color: var(--navy); letter-spacing: 1px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 12px; }
.demo-tip { background: #fff; border: 1px dashed var(--line); border-radius: 6px; padding: 10px 12px;
  font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.8; }
.demo-tip b { color: #0A1B33; }
.acc { display: inline-block; background: #F4F1EA; border: 1px solid var(--line); border-radius: 20px;
  padding: 2px 9px; margin: 0 5px 5px 0; cursor: pointer; color: #0A1B33; font-size: 11.5px;
  -webkit-tap-highlight-color: transparent; }
.acc:hover { border-color: var(--gold); background: #FBF6EA; }
.acc i { font-style: normal; color: var(--muted); margin-left: 4px; }

.dl-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; }
.dl-box .dl-t { color: var(--muted); }
.dl-box a { color: var(--navy); text-decoration: none; border: 1px solid var(--line);
  background: #F4F1EA; border-radius: 20px; padding: 3px 11px; }
.dl-box a:hover { border-color: var(--gold); background: #FBF6EA; }

/* ---------- 客户端变体（Android App 入口标识） ---------- */
.login-wrap.app-partner .login-card { border-top-color: #0F6B5C; }
.login-wrap.app-partner .login-card h1 { color: #0F6B5C; }
.login-wrap.app-admin .login-card { border-top-color: var(--gold); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 216px; background: var(--navy); color: #fff; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; }
.sidebar .brand { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .brand b { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
.sidebar .brand span { display: block; font-size: 11px; color: rgba(255,255,255,.55); margin-top: 4px; }
.nav-group { padding: 10px 8px; }
.nav-group .gt { font-size: 11px; color: rgba(255,255,255,.45); padding: 6px 10px; }
.nav-item { display: block; padding: 9px 12px; border-radius: 6px; color: rgba(255,255,255,.82);
  cursor: pointer; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 22px; display: flex;
  align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.topbar .title { font-size: 16px; font-weight: 600; color: var(--navy); }
.topbar .me { font-size: 12px; color: var(--muted); }
.content { padding: 20px 22px 60px; }
.redline { background: #fff8e8; border-left: 3px solid var(--gold); padding: 8px 12px; font-size: 12px;
  color: #6b5320; margin-bottom: 14px; border-radius: 0 4px 4px 0; }

/* ---------- 组件 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.card .u { font-size: 11px; color: var(--muted); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
.panel > h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--navy);
  display: flex; align-items: center; justify-content: space-between; }
.panel .body { padding: 14px 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #faf8f3; color: var(--navy); font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fcfbf8; }

.btn { background: var(--navy); color: #fff; border: none; padding: 7px 14px; border-radius: 5px; cursor: pointer;
  font-size: 13px; }
.btn:hover { background: var(--navy-soft); }
.btn.gold { background: var(--gold); color: var(--navy); font-weight: 600; }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 操作按钮内部文字不折行（按钮之间仍可换行），避免「条款与风险」被拆成两行 */
.row-actions .btn { white-space: nowrap; }

/* ---------- 导航图标 / 移动端构件（默认隐藏） ---------- */
.nav-item { display: flex; align-items: center; gap: 9px; }
.nav-item > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item > svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .92; }
.sidebar .brand { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.drawer-close, .icon-btn, .tabbar, .scrim { display: none; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #eef1f5; color: #43536a; }
.tag.gold { background: #fbf3e0; color: #8a6a1f; }
.tag.ok { background: #e6f4ec; color: var(--ok); }
.tag.warn { background: #fdf3e0; color: var(--warn); }
.tag.bad { background: #fbeaea; color: var(--bad); }
.empty { color: var(--muted); padding: 18px; text-align: center; font-size: 13px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 5px; font-size: 13px; font-family: inherit; background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
.modal-mask { position: fixed; inset: 0; background: rgba(10,27,51,.45); display: flex; align-items: center;
  justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 8px; width: 520px; max-width: 92vw; max-height: 86vh; overflow: auto;
  border-top: 4px solid var(--gold); }
.modal h3 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--navy); }
.modal .body { padding: 16px 18px; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--navy); color: #fff; padding: 10px 16px;
  border-radius: 6px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 8px 0 8px 18px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:before { content: ""; position: absolute; left: -6px; top: 12px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--gold); }
.timeline .t { font-size: 11px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.hit { background: #fbeaea; border-left: 3px solid var(--bad); padding: 6px 10px; margin: 6px 0; font-size: 12px; }
.warnbox { background: #fdf3e0; border-left: 3px solid var(--warn); padding: 6px 10px; margin: 6px 0; font-size: 12px; }
.okbox { background: #e6f4ec; border-left: 3px solid var(--ok); padding: 8px 12px; font-size: 12px; margin: 6px 0; }
.muted { color: var(--muted); font-size: 12px; }

/* ==================================================================
   移动端 H5（≤820px）：侧栏收进抽屉 + 底部 Tab + 表格转卡片
   ================================================================== */
@media (max-width: 820px) {
  .layout { display: block; min-height: 100dvh; }

  /* --- 抽屉式侧栏 --- */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 78vw; max-width: 306px; height: auto;
    transform: translateX(-100%); transition: transform .26s ease;
    box-shadow: 10px 0 36px rgba(0, 0, 0, .3);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(10, 27, 51, .5); z-index: 55; }
  .drawer-close { display: block; background: none; border: none; cursor: pointer;
    color: rgba(255, 255, 255, .65); font-size: 26px; line-height: 1; padding: 0 2px; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    margin-right: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy);
    cursor: pointer; padding: 0; }
  .icon-btn > svg { width: 20px; height: 20px; }
  .nav-item { padding: 11px 12px; font-size: 14px; }
  .nav-item > svg { width: 19px; height: 19px; }

  /* --- 顶栏 --- */
  .topbar { padding: 9px 14px; gap: 4px; }
  .topbar .title { flex: 1 1 auto; min-width: 0; text-align: center; font-size: 15px; }
  .icon-btn { flex-shrink: 0; margin-right: 0; }
  .me { flex-shrink: 0; }
  .me-txt { display: none; }
  .content { padding: 12px 12px calc(88px + env(safe-area-inset-bottom)); }

  /* --- 面板标题：长标题 + 右侧按钮改为可换行，避免撑破布局 --- */
  .panel > h3 { flex-wrap: wrap; row-gap: 8px; }
  .panel > h3 > span { flex-shrink: 0; }

  /* --- 底部 Tab 栏 --- */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
  }
  .tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; padding: 7px 2px 6px; font-size: 11px; color: var(--muted);
    cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tab > svg { width: 22px; height: 22px; flex-shrink: 0; }
  .tab > span { display: block; width: 100%; text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.active { color: var(--gold); font-weight: 600; }

  /* --- 表格 → 卡片（字段名由 data-label 前置） --- */
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 9px;
    background: #fff; padding: 2px 12px 6px; }
  .table-wrap td { border: none; border-bottom: 1px dashed var(--line); padding: 8px 0;
    display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
  .table-wrap td > * { min-width: 0; }
  .table-wrap tr td:last-child { border-bottom: none; }
  .table-wrap td:before { content: attr(data-label); color: var(--muted); font-size: 12px;
    flex: 0 0 76px; word-break: keep-all; }
  .table-wrap td:empty { display: none; }
  /* 操作列：不重复显示字段名，右对齐并换行 */
  @supports selector(:has(*)) {
    .table-wrap td:has(.row-actions):before { display: none; }
    .table-wrap td:has(.row-actions) { justify-content: flex-end; padding-top: 10px; flex-wrap: wrap; }
  }
  .table-wrap td .row-actions { flex-wrap: wrap; justify-content: flex-end; }

  /* --- 表单：字号 ≥16px 防 iOS 聚焦缩放 --- */
  .field label { font-size: 13px; margin-bottom: 6px; }
  .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; }

  /* --- 弹窗 → 底部抽屉 --- */
  .modal-mask { align-items: flex-end; }
  .modal { width: 100% !important; max-width: 100%; max-height: 88vh; border-radius: 14px 14px 0 0; }
  .modal > h3 { padding: 15px 18px; font-size: 16px; }
  .modal .body { padding: 14px 16px; }
  .modal .foot { position: sticky; bottom: 0; background: #fff; gap: 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal .foot .btn { flex: 1; padding: 12px 14px; font-size: 15px; }

  /* --- 其它适配 --- */
  .cards { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin-bottom: 14px; }
  .card { padding: 12px 13px; }
  .card .v { font-size: 20px; }
  .grid2 { grid-template-columns: 1fr; gap: 12px; }
  .panel { border-radius: 9px; margin-bottom: 12px; }
  .panel > h3 { padding: 11px 13px; }
  .panel .body { padding: 12px; }
  .kv { grid-template-columns: 96px 1fr; font-size: 13px; }
  .login-card { width: 92vw; padding: 30px 24px; border-radius: 12px; }
  .login-card h1 { font-size: 19px; }
  .btn { padding: 10px 15px; }
  .btn.sm { padding: 6px 11px; font-size: 12px; }
  .row-actions { gap: 8px; }
  .row-actions .btn { flex: 1; min-width: 72px; text-align: center; }
  .toast { right: 50%; transform: translateX(50%); bottom: calc(78px + env(safe-area-inset-bottom));
    width: max-content; max-width: 86vw; }
  .redline { font-size: 12px; padding: 9px 12px; }
  .timeline li { padding-left: 16px; }
}

@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card .v { font-size: 18px; }
  .tab > span { font-size: 10px; }
}
