/* ============================================================
   资金流水归集 · 黑白极简设计系统
   约束：无彩色（仅 #111/#666/#999/#eee/#fff 与灰阶）、单列 960px 居中、
         圆角 0、无阴影、无渐变、金额等宽右对齐、负数用「−」不用红色
   ============================================================ */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --faint: #999999;
  --line: #eeeeee;
  --line-2: #e5e5e5;
  --warn-bg: #f5f5f5;
  --maxw: 960px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 20px; }
.num, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 顶栏 ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 16px;
  height: 56px; display: flex; align-items: center; gap: 20px;
}
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a {
  padding: 6px 10px; font-size: 13.5px; color: var(--muted); white-space: nowrap;
}
.nav a:hover { color: var(--fg); text-decoration: none; }
.nav a.active { color: var(--fg); font-weight: 600; }
.nav a .badge { margin-left: 4px; }
.topbar-user { color: var(--muted); font-size: 13px; white-space: nowrap; }
.topbar-user a { margin-left: 12px; }

/* ---------- 容器 ---------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 64px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.section { margin-bottom: 28px; }
.section-title {
  font-size: 15px; font-weight: 600; padding-left: 10px; border-left: 3px solid var(--fg);
  margin-bottom: 12px;
}

/* ---------- 卡片 / 统计 ---------- */
.card { border: 1px solid var(--line); padding: 16px; background: #fff; }
.stat-row { display: flex; gap: 0; border: 1px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.stat {
  flex: 1 1 0; min-width: 200px; padding: 16px 18px; border-right: 1px solid var(--line);
}
.stat:last-child { border-right: none; }
.stat .k { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat .v { font-size: 26px; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; }
.stat .v.sm { font-size: 20px; }

/* ---------- 表格 ---------- */
/* 表格横向滚动容器：容器宽时表格铺满，内容更宽时容器内部滚动，页面本身不横向滚动 */
.tw { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table, .grid { width: 100%; border-collapse: collapse; }
.table th, .grid th {
  text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600;
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td, .grid td {
  padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: top;
}
.table td.num, .grid td.num { text-align: right; font-family: ui-monospace, Menlo, Consolas, monospace; }
.table tr:hover td, .grid tr:hover td { background: #fafafa; }
.table .empty, .grid .empty { text-align: center; color: var(--faint); padding: 36px; }
.grid .ops a, .table .ops a { margin-right: 12px; font-size: 13px; color: var(--muted); }
.grid .ops a:hover, .table .ops a:hover { color: var(--fg); }
.nowrap { white-space: nowrap; }

/* ---------- 徽标 / 状态（灰阶） ---------- */
.badge {
  display: inline-block; padding: 1px 8px; border: 1px solid var(--line-2);
  font-size: 12px; line-height: 1.7; color: var(--fg); background: #fff; white-space: nowrap;
}
.badge.on { background: #f0f0f0; border-color: #cfcfcf; font-weight: 600; }
.badge.off { background: #fff; color: var(--faint); }
.badge.warn { background: var(--warn-bg); border-color: #cfcfcf; font-weight: 600; }
.badge.info { background: #fafafa; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 1px solid var(--line-2); font-size: 12px; font-weight: 600;
  background: #fafafa; margin-right: 4px;
}
.dir { font-family: ui-monospace, Menlo, Consolas, monospace; }
.neg { background: var(--warn-bg); padding: 0 2px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); background: #fff; color: var(--fg); cursor: pointer;
  font-size: 13.5px; font-family: inherit; white-space: nowrap;
}
.btn:hover { background: #f5f5f5; text-decoration: none; }
.btn.primary { background: var(--fg); color: #fff; border-color: var(--fg); }
.btn.primary:hover { background: #333; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.danger { color: var(--fg); }
.btn:disabled { color: var(--faint); cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form { border: 1px solid var(--line); }
.form-row { display: flex; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.form-row:last-child { border-bottom: none; }
.form-row > label { width: 150px; flex: 0 0 150px; padding-top: 7px; color: var(--muted); font-size: 13.5px; }
.form-row .req { font-style: normal; margin-left: 2px; }
.form-control { flex: 1; min-width: 0; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; max-width: 520px; height: 34px; border: 1px solid var(--line-2);
  background: #fff; color: var(--fg); padding: 0 10px; font-size: 14px; font-family: inherit;
}
textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); }
input[readonly] { background: #fafafa; color: var(--faint); }
.form-actions { padding: 16px; display: flex; gap: 10px; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 20px; background: #d8d8d8; position: relative; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; transition: .15s; }
.switch input:checked + .track { background: var(--fg); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- 搜索 / 筛选 ---------- */
.filters { border: 1px solid var(--line); padding: 12px 16px; margin-bottom: 16px; }
.filters .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.filters .row:last-child { margin-bottom: 0; }
.filters label { color: var(--muted); font-size: 13px; }
.filters input[type=text], .filters input[type=date], .filters select, .filters input[type=number] {
  width: auto; min-width: 120px; max-width: 180px; height: 32px;
}
.filters .sep { color: var(--faint); }
.search { display: flex; gap: 8px; }
.search input { height: 34px; width: 220px; }

/* ---------- 分页 ---------- */
.pager { margin-top: 16px; display: flex; gap: 8px; align-items: center; }
.pager a, .pager .disabled, .pager .info { padding: 6px 12px; border: 1px solid var(--line-2); font-size: 13px; }
.pager a:hover { background: #f5f5f5; text-decoration: none; }
.pager .disabled { color: var(--faint); }
.pager .info { border: none; color: var(--muted); }

/* ---------- 提示条 ---------- */
.alert { padding: 10px 14px; background: var(--warn-bg); border: 1px solid var(--line-2); font-size: 13.5px; margin-bottom: 16px; }
.alert.ok { background: #fafafa; }
.empty { text-align: center; color: var(--faint); padding: 48px 16px; }

/* ---------- 导入向导步骤条 ---------- */
.steps { display: flex; gap: 8px; align-items: center; color: var(--faint); font-size: 13px; }
.steps .on { color: var(--fg); font-weight: 600; }
.steps .dash { color: var(--line-2); }

/* ---------- 复核工作台分组 ---------- */
.group { border: 1px solid var(--line); margin-bottom: 16px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.group-head .name { font-weight: 600; }
.group-head .meta { color: var(--muted); font-size: 13px; }
.group-body { padding: 10px 16px; }
.group-body table { width: 100%; border-collapse: collapse; }
.group-body table td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.inline-assign { display: flex; gap: 8px; align-items: center; }
.inline-assign select { width: auto; min-width: 180px; height: 32px; }

/* ---------- 月度走势条（纯 CSS，无 JS 图表库） ---------- */
.trend { padding: 4px 0; }
.trend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.trend-row .m { width: 64px; color: var(--muted); flex: 0 0 64px; }
.trend-row .bar { flex: 1; height: 14px; background: #f2f2f2; position: relative; }
.trend-row .bar i { display: block; height: 100%; background: #bbb; }
.trend-row .bar i.in { background: #555; }
.trend-row .v { width: 140px; text-align: right; font-family: ui-monospace, Menlo, Consolas, monospace; flex: 0 0 140px; }

/* ---------- 登录页（不套后台布局） ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 360px; max-width: 100%; }
.login-box .title { text-align: center; font-size: 22px; font-weight: 600; letter-spacing: 4px; }
.login-box .rule { width: 160px; height: 2px; background: var(--fg); margin: 14px auto 28px; }
.login-box form { border: 1px solid var(--line); }
.login-box .form-row > label { width: 72px; flex: 0 0 72px; }
.login-box .form-actions { border-top: 1px solid var(--line); }
.login-box .form-actions .btn { width: 100%; justify-content: center; }
.login-error { background: var(--warn-bg); border: 1px solid var(--line-2); padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.login-foot { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 20px; }

/* ---------- 明细抽屉 / 次要块 ---------- */
.sub-block { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }

/* ============================================================
   移动端（≤640px）：单列竖屏适配
   原则：顶栏压住、导航一行可滑、表格在容器内横滑（页面本身不滚）、
         表单标签在上控件在下、筛选/搜索铺满。
   不引入任何颜色/圆角/阴影/渐变/动画。
   ============================================================ */
@media (max-width: 640px) {
  /* ----- 顶栏：压缩内边距与间距，导航改为一行横向滑动 ----- */
  .topbar-inner { padding: 0 12px; gap: 12px; }
  .brand { font-size: 15px; }
  .nav {
    min-width: 0;               /* flex 项默认 min-width:auto 会拒绝收缩，压住顶栏的关键 */
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox 隐藏滚动条 */
  }
  .nav::-webkit-scrollbar { display: none; }
  .topbar-user { font-size: 12.5px; }
  .topbar-user a { margin-left: 8px; }

  /* ----- 容器 ----- */
  .page { padding: 14px 12px 48px; }
  .page-head { align-items: flex-start; }

  /* ----- 表格内边距收紧 ----- */
  .table th, .grid th { padding: 8px 8px; font-size: 12px; }
  .table td, .grid td { padding: 8px 8px; font-size: 13px; }

  /* ----- 表单：标签在上、控件在下 -----
     仅限后台 .page 内；登录页 .login-box 不在 .page 中，72px label 特例保持原样。
     align-items:stretch 让控件（.form-control）在竖向布局下铺满整行宽度 */
  .page .form-row { flex-direction: column; align-items: stretch; padding: 12px 14px; }
  .page .form-row > label { width: auto; flex: none; padding-top: 0; margin-bottom: 6px; }

  /* ----- 统计条：单列堆叠 ----- */
  .stat { flex: 1 1 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: none; }

  /* ----- 筛选区：输入框放开限宽并铺满 ----- */
  .page .filters input[type=text], .page .filters input[type=date],
  .page .filters select, .page .filters input[type=number] {
    width: 100%; min-width: 0; max-width: none;
  }
  .filters .row { gap: 8px; }

  /* ----- 搜索框铺满 ----- */
  .search { flex: 1; }
  .search input { width: 100%; }

  /* ----- 月度走势条：金额列自适应，避免撑破 ----- */
  .trend-row .v { flex: 0 0 auto; width: auto; }

  /* ----- 复核工作台 ----- */
  .inline-assign { flex-wrap: wrap; }          /* 不换行会在 320px 顶破页面 */
  .inline-assign select { min-width: 0; flex: 1 1 auto; }
  .group-head { padding: 10px 12px; }
  .group-body { padding: 8px 12px; }

  /* ----- 表单操作区：多按钮时允许换行 ----- */
  .page .form-actions { flex-wrap: wrap; }
}

/* ============================================================
   超窄屏（≤420px）：顶栏进一步压缩
   「您好，管理员」约 110px，会把 .nav 挤到只剩 31~71px（320px 时最宽导航项显示不全）。
   故隐藏问候语（.greet 用 display:none，不占位），保留「退出」链接；并收紧 nav 项内边距，
   让更多导航项同屏可见。不引入任何颜色/圆角/阴影/动画。
   ============================================================ */
@media (max-width: 420px) {
  .topbar-user .greet { display: none; }
  .brand { font-size: 14px; }
  .topbar-inner { padding: 0 10px; gap: 8px; }
  .nav a { padding: 6px 8px; font-size: 13px; }
}
