:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #8a919f;
  --line: #e6e9ef;
  --brand: #1a6dff;
  --brand-dark: #0f4fb8;
  --sidebar: #16202f;
  --ok: #07c160;
  --warn: #ff8f1f;
  --danger: #fa5151;
  --purple: #7d4dff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16202f 0%, #24406b 60%, #1a6dff 140%);
}
.login-card {
  width: 380px;
  padding: 34px 32px 28px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(10, 25, 50, .35);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card .hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 14px;
  background: linear-gradient(135deg, #1a6dff, #07c160);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex: none; background: var(--sidebar); color: #c8d1de;
  padding: 18px 0; display: flex; flex-direction: column;
}
.sidebar .logo { padding: 0 20px 18px; color: #fff; font-weight: 600; font-size: 15px; }
.sidebar .logo small { display: block; font-weight: 400; color: #7f8da0; font-size: 12px; margin-top: 4px; }
.nav-item {
  padding: 11px 20px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 10px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.active { background: rgba(26, 109, 255, .18); border-left-color: var(--brand); color: #fff; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 12px; line-height: 18px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 22px; gap: 14px;
}
.topbar h2 { margin: 0; font-size: 17px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.content { padding: 20px 22px 40px; }
.page { display: none; }
.page.active { display: block; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(16, 30, 54, .06); margin-bottom: 16px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .tag { font-size: 12px; color: var(--muted); font-weight: 400; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 窄屏（手机/侧边面板）也能看：导航转为横向滚动，卡片单列 */
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; overflow-x: auto; padding: 8px; gap: 6px; align-items: center; }
  .sidebar .logo { display: none; }
  .nav-item { border-left: none; border-radius: 8px; white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .nav-item.active { border-left: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 12px; }
  .kpi .value { font-size: 22px; }
  .drawer { width: 100%; }
}

.kpi { background: #fff; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(16, 30, 54, .06); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; }
.kpi .value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.kpi .foot { margin-top: 6px; font-size: 12px; color: var(--muted); }
.kpi.accent-blue { border-top: 3px solid var(--brand); }
.kpi.accent-warn { border-top: 3px solid var(--warn); }
.kpi.accent-ok { border-top: 3px solid var(--ok); }
.kpi.accent-danger { border-top: 3px solid var(--danger); }
.kpi.accent-purple { border-top: 3px solid var(--purple); }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: #c9d3e0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #ffd7d7; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26, 109, 255, .18); border-color: var(--brand); }
textarea { resize: vertical; min-height: 80px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 140px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; background: #fbfcfe; white-space: nowrap; }
tbody tr:hover { background: #f8fafd; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 18px; }
.pill.gray { background: #f1f3f6; color: #5b6472; }
.pill.blue { background: #e8f1ff; color: #1a6dff; }
.pill.orange { background: #fff1e3; color: #d9760a; }
.pill.red { background: #ffecec; color: #e33; }
.pill.green { background: #e7f8ee; color: #04994c; }
.pill.purple { background: #f1ebff; color: #6a3ff0; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }

/* 流程可视化 */
.flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flow-node {
  padding: 8px 12px; border-radius: 10px; background: #f5f7fb; border: 1px solid var(--line);
  min-width: 108px; text-align: center;
}
.flow-node .n { font-size: 12px; color: var(--muted); }
.flow-node .v { font-size: 17px; font-weight: 600; }
.flow-node.active { border-color: var(--brand); background: #eef4ff; }
.flow-arrow { color: #c3ccd9; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px #dbe6fb;
}
.tl-item .tl-head { display: flex; gap: 10px; align-items: baseline; }
.tl-item .tl-time { color: var(--muted); font-size: 12px; }
.tl-item .tl-note { color: #4c5563; font-size: 13px; white-space: pre-wrap; }

/* 抽屉 / 弹窗 */
.drawer-mask, .modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: none; z-index: 40;
}
.drawer-mask.open, .modal-mask.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 720px; max-width: 94vw; background: #fff;
  z-index: 41; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer header h3 { margin: 0; font-size: 16px; }
.drawer .body { padding: 18px 20px 40px; overflow: auto; }
.modal {
  position: fixed; z-index: 42; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 520px; max-width: 94vw; background: #fff; border-radius: 14px; padding: 20px 22px;
  display: none; max-height: 88vh; overflow: auto;
}
.modal.open { display: block; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.dispatch-fields { margin-top: 12px; }
.dispatch-hidden { display: none; }
.dispatch-tip { margin-bottom: 12px; padding: 10px 12px; background: #eff5ff; border-radius: 8px; }
#page-dispatch-planning .filters { justify-content: space-between; align-items: center; }
#page-dispatch-planning .filters h3 { margin: 0; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.spare-mini { font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(24, 32, 45, .92); color: #fff; padding: 10px 18px; border-radius: 10px;
  z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rank-row .idx { width: 20px; color: var(--muted); }
.rank-row .bar { flex: 1; height: 8px; background: #f1f3f6; border-radius: 999px; overflow: hidden; }
.rank-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, #1a6dff, #64b5ff); }

.notice { padding: 16px 20px; margin-bottom: 16px; border: 1px solid #dce7fa; border-radius: 10px; background: #eef5ff; color: #385477; line-height: 1.9; }
.muted { color: var(--muted); }
.catalog-node { padding: 12px 0; border-bottom: 1px solid var(--line); }
.catalog-node summary { cursor: pointer; font-weight: 600; }
.catalog-children { margin: 12px 0 0 22px; border-left: 2px solid #dce7fa; padding-left: 16px; }
.catalog-children > div { display: flex; gap: 18px; padding: 7px 0; }
.catalog-children code { color: #557091; min-width: 82px; }
.catalog-fields { display: flex; flex-wrap: wrap; gap: 8px; }
button:disabled { opacity: .5; cursor: default; }

/* 网站备案信息在登录页及后台底部均可查看。 */
.login-wrap, .layout { min-height:calc(100vh - 44px); }
.site-footer { min-height:44px; padding:12px 16px; text-align:center; background:#fff; border-top:1px solid var(--line); color:#697586; font-size:12px; }
.site-footer a { color:inherit; text-decoration:none; }
.site-footer a:hover { text-decoration:underline; }
