/* ─────────────────────────────────────────────────────────────
   ERP 样式表 — 一套代码同时适配 PC 与手机
   PC：左侧导航 + 顶部工具条 + 表格
   手机：底部 Tab + 卡片式列表（表格自动转卡片）
   ───────────────────────────────────────────────────────────── */
:root {
  --brand: #1d5fd8;
  --brand-dark: #17489f;
  --brand-light: #eaf1fe;
  --ink: #1b2431;
  --ink-2: #46536a;
  --muted: #8593a8;
  --line: #e3e8f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #17a34a;
  --ok-bg: #e8f7ee;
  --warn: #d97706;
  --warn-bg: #fef4e6;
  --danger: #dc2626;
  --danger-bg: #fdeaea;
  --info: #0891b2;
  --info-bg: #e5f6fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 6px 18px rgba(16, 30, 54, .05);
  --sidebar-w: 210px;
  --topbar-h: 56px;
  --tabbar-h: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── 登录页 ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #17489f 0%, #1d5fd8 45%, #23a0c9 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px;
  padding: 30px 26px; box-shadow: 0 20px 50px rgba(9, 24, 51, .28);
}
.login-logo { font-size: 22px; font-weight: 700; color: var(--brand-dark); letter-spacing: .5px; }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
.login-member {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer; transition: .15s;
}
.login-member:hover { border-color: var(--brand); background: var(--brand-light); }
.login-member .nm { font-weight: 600; }
.login-member .rl { font-size: 12px; color: var(--muted); }
.login-tip {
  margin-top: 16px; padding: 10px 12px; background: var(--warn-bg); color: #92400e;
  border-radius: 8px; font-size: 12.5px; line-height: 1.6;
}

/* ── 框架 ─────────────────────────────────────────────────── */
.app { display: none; }
.app.on { display: block; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: #10203a; color: #c7d3e6; padding: 0 0 20px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.side-brand { padding: 16px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); position: sticky; top: 0; z-index: 2; background: #10203a; }
.side-brand .t { color: #fff; font-weight: 700; font-size: 15.5px; letter-spacing: .3px; }
.side-brand .s { font-size: 11.5px; color: #7d90ad; margin-top: 2px; }
.side-group { padding: 14px 18px 6px; font-size: 11px; color: #62748f; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 18px; cursor: pointer;
  color: #c7d3e6; font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.on { background: rgba(29,95,216,.28); color: #fff; border-left-color: #4d8ef7; font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 9px; min-width: 18px; text-align: center;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 18px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 20px;
  background: var(--bg); cursor: pointer; font-size: 13px;
}
.user-chip .av {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.content { padding: 18px; flex: 1; max-width: 1400px; width: 100%; }

/* ── 通用组件 ─────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
.card-head .ttl { font-weight: 600; font-size: 14.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 14px 16px; }
.card-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: .15s; font-size: 13.5px;
}
.btn:hover { border-color: #c3cede; background: #fbfcfe; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f3c9c9; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 6px 8px; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.tag { display: inline-block; padding: 1.5px 8px; border-radius: 20px; font-size: 12px; line-height: 1.7; white-space: nowrap; }
.tag.gray { background: #eef1f6; color: #5b6779; }
.tag.blue { background: var(--brand-light); color: var(--brand-dark); }
.tag.green { background: var(--ok-bg); color: #12693a; }
.tag.orange { background: var(--warn-bg); color: #92510a; }
.tag.red { background: var(--danger-bg); color: #a52020; }
.tag.cyan { background: var(--info-bg); color: #0b6b82; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  outline: none; width: 100%; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,95,216,.1); }
textarea { min-height: 66px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form-grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── 表格 ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 9px 12px; background: #f8fafc; color: var(--ink-2);
  font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
table.data tbody tr:hover { background: #fafcff; }
table.data tr.clickable { cursor: pointer; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13.5px; }

/* ── 统计卡 ───────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.kpi .u { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi.b .v { color: var(--brand); }
.kpi.g .v { color: var(--ok); }
.kpi.o .v { color: var(--warn); }
.kpi.r .v { color: var(--danger); }

/* ── 进度条 ───────────────────────────────────────────────── */
.bar { height: 6px; background: #eef1f6; border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .3s; }
.bar > i.done { background: var(--ok); }

/* ── 详情页 ───────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; }
.detail-grid .item .lb { font-size: 12px; color: var(--muted); }
.detail-grid .item .vl { font-weight: 500; margin-top: 1px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: #fff; border: 2px solid var(--brand);
}
.timeline .tm { font-size: 12px; color: var(--muted); }
.timeline .tx { font-size: 13.5px; }

/* ── 模态 / 提示 ──────────────────────────────────────────── */
.mask {
  position: fixed; inset: 0; background: rgba(15, 25, 42, .45); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 16px;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(9,24,51,.3); }
.modal.wide { max-width: 900px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head .ttl { font-weight: 600; font-size: 15px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
#toast-box { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1b2431; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: tin .2s ease; max-width: 88vw;
}
.toast.ok { background: #146c39; }
.toast.err { background: #b32020; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.alert-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.alert-line:last-child { border-bottom: none; }

/* ── 移动端底部 Tab ───────────────────────────────────────── */
.tabbar { display: none; }
.mobile-only { display: none; }
.desktop-only { display: initial; }

/* ── 响应式：手机 / 窄屏 ──────────────────────────────────── */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { display: none; }
  .desktop-only { display: none !important; }
  .mobile-only { display: initial; }
  .content { padding: 12px 12px calc(var(--tabbar-h) + 18px); }
  .topbar { padding: 0 12px; }
  .topbar .page-title { font-size: 15px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h);
    background: #fff; border-top: 1px solid var(--line); z-index: 60;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--muted); font-size: 11px; cursor: pointer;
  }
  .tabbar .tab .ic { font-size: 19px; line-height: 1; }
  .tabbar .tab.on { color: var(--brand); font-weight: 600; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi .v { font-size: 20px; }
  .form-grid, .form-grid.wide { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-height: 92vh; border-radius: 12px; }
  .modal-foot .btn { flex: 1; }

  /* 表格 → 卡片 */
  table.data.responsive thead { display: none; }
  table.data.responsive tbody tr {
    display: block; border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: 10px; padding: 10px 12px; background: #fff; box-shadow: var(--shadow);
  }
  table.data.responsive tbody tr:hover { background: #fff; }
  table.data.responsive td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    border: none; padding: 3px 0; text-align: left !important;
  }
  table.data.responsive td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; flex: 0 0 auto;
  }
  table.data.responsive td.primary-cell {
    font-weight: 600; font-size: 14.5px; padding-bottom: 6px; margin-bottom: 4px;
    border-bottom: 1px dashed var(--line);
  }
  table.data.responsive td.primary-cell::before { content: none; }
  table.data.responsive td.act-cell { justify-content: flex-end; padding-top: 8px; }
  table.data.responsive td.act-cell::before { content: none; }
  table.data.responsive td.hide-mobile { display: none; }
}

/* 人员多选（审批人 / 团队成员） */
.picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px 12px; max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.picker-item { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.picker-item input { width: auto; flex: none; }
.picker-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 打印 */
@media print {
  .sidebar, .topbar, .tabbar, .toolbar, .btn { display: none !important; }
  .shell { display: block; }
}
