/* 后台管理台样式 */
:root {
  --side: #101a2e;
  --side-2: #17233d;
  --brand: #1668dc;
  --brand-deep: #0e4fa8;
  --brand-soft: #eaf2ff;
  --ok: #12a86a;
  --warn: #f59e0b;
  --danger: #e5484d;
  --purple: #7c5cd6;
  --gray: #94a2b5;
  --text: #16202e;
  --text-2: #5a6b81;
  --text-3: #93a1b3;
  --line: #e6ecf5;
  --bg: #f4f7fb;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(16, 26, 46, 0.06);
}

* { box-sizing: border-box; }
/* [hidden] 必须强于组件自身的 display，否则 .login-wrap/.app 的 flex 会让它失效 */
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--brand); text-decoration: none; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f2347 0%, #1668dc 100%);
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 16px; padding: 34px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.login-box h1 { margin: 0 0 4px; font-size: 21px; }
.login-box .sub { margin: 0 0 24px; color: var(--text-3); font-size: 13px; }
.login-box .field { margin-bottom: 16px; }
.login-box label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-box input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; background: #fbfcfe;
}
.login-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 104, 220, 0.12); }
.btn {
  border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer;
  background: #eef2f8; color: var(--text-2); font-size: 13px; transition: all 0.15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: #fdecec; color: var(--danger); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* ============ 布局 ============ */
.app { display: flex; min-height: 100vh; }
.side {
  width: 200px; flex: none; background: var(--side); color: #c7d3e6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side .logo {
  padding: 20px 18px; font-size: 15px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07); line-height: 1.4;
}
.side .logo small { display: block; font-size: 11px; font-weight: 400; color: #7f8fa8; margin-top: 3px; }
.side nav { padding: 12px 10px; flex: 1; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 9px; color: #c7d3e6; margin-bottom: 3px; cursor: pointer; font-size: 14px;
}
.side nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; font-weight: 500; }
.side nav .ico { width: 18px; text-align: center; }
.side .foot { padding: 14px 18px; font-size: 11px; color: #6b7b93; border-top: 1px solid rgba(255, 255, 255, 0.07); }

.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; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { margin: 0; font-size: 16px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.content { padding: 20px 22px 40px; }
.view { display: none; }
.view.on { display: block; }

/* ============ 卡片与栅格 ============ */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 14px; font-size: 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.card h3 .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* KPI */
.kpi {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.kpi .t { font-size: 13px; color: var(--text-3); }
.kpi .v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }
.kpi .s { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }

/* ============ 表格 ============ */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type='text'], .toolbar input[type='date'], .toolbar select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px; color: var(--text-2);
}
.tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .n { opacity: 0.75; margin-left: 4px; font-size: 12px; }

.tbl-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
table.tbl th {
  background: #f8fafc; text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-2); white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fafcff; }
.tbl .nowrap { white-space: nowrap; }
.tbl .muted { color: var(--text-3); }
.empty { text-align: center; padding: 46px 0; color: var(--text-3); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 20px; white-space: nowrap;
}
.badge-pending { background: #fff5e6; color: #b45309; }
.badge-contacted { background: #e8f1ff; color: #1d4ed8; }
.badge-appointed { background: #f1eaff; color: #6d28d9; }
.badge-done { background: #e6f7ef; color: #0b7a4b; }
.badge-invalid { background: #f1f5f9; color: #64748b; }
.badge-visit { background: #fff1e8; color: #c2410c; }
.badge-walkin { background: #eef2ff; color: #4338ca; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 5px; }
.pager .pages button {
  min-width: 32px; height: 30px; border: 1px solid var(--line); background: #fff;
  border-radius: 7px; cursor: pointer; color: var(--text-2);
}
.pager .pages button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ============ 员工卡片 ============ */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.staff-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 14px; box-shadow: var(--shadow);
}
.staff-card.off { opacity: 0.62; }
.staff-card .qr {
  width: 104px; height: 104px; flex: none; border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; background: #fff; cursor: pointer;
}
.staff-card .qr img { width: 100%; height: 100%; display: block; }
.staff-card .info { flex: 1; min-width: 0; }
.staff-card .nm { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.staff-card .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.staff-card .code {
  margin-top: 6px; font-size: 12px; color: var(--brand-deep); background: var(--brand-soft);
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 600; letter-spacing: 1px;
}
.staff-card .nums { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.staff-card .nums b { color: var(--text); font-size: 14px; }
.staff-card .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ============ 图表 ============ */
.chart-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 170px; height: 170px; flex: none; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.donut-center .n { font-size: 24px; font-weight: 700; line-height: 1.1; }
.donut-center .t { font-size: 11px; color: var(--text-3); }
.legend { flex: 1; min-width: 180px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend .li .nm { flex: 1; color: var(--text-2); }
.legend .li .v { font-weight: 600; }

.rank .li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.rank .li .no {
  width: 20px; height: 20px; border-radius: 6px; background: #f1f5f9; color: var(--text-2);
  font-size: 12px; display: flex; align-items: center; justify-content: center; flex: none;
}
.rank .li.top1 .no { background: #fef3c7; color: #b45309; font-weight: 700; }
.rank .li.top2 .no { background: #e2e8f0; color: #475569; font-weight: 700; }
.rank .li.top3 .no { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.rank .li .nm { width: 90px; flex: none; font-size: 13px; }
.rank .li .bar { flex: 1; height: 9px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.rank .li .bar i { display: block; height: 100%; background: linear-gradient(90deg, #4f9bf5, var(--brand)); border-radius: 999px; }
.rank .li .v { width: 62px; text-align: right; font-size: 12px; color: var(--text-2); flex: none; }

.timeline { border-left: 2px solid var(--line); padding-left: 14px; margin-left: 4px; }
.timeline .tl { position: relative; padding-bottom: 14px; }
.timeline .tl::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brand-soft);
}
.timeline .tl .h { font-size: 13px; }
.timeline .tl .m { font-size: 12px; color: var(--text-3); }

/* ============ 弹窗 ============ */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.modal .hd {
  padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between;
}
.modal .hd h3 { margin: 0; font-size: 15px; }
.modal .bd { padding: 18px 20px; }
.modal .ft {
  padding: 14px 20px; border-top: 1px solid var(--line); display: flex;
  justify-content: flex-end; gap: 8px;
}
.modal .close { cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; background: none; border: 0; }
.f { margin-bottom: 14px; }
.f label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.f input, .f select, .f textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  outline: none; background: #fbfcfe;
}
.f input:focus, .f select:focus, .f textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 104, 220, 0.1); background: #fff;
}
.kv { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #eef2f7; font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { width: 82px; flex: none; color: var(--text-3); }
.kv .v { flex: 1; word-break: break-all; }

/* ============ Toast ============ */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast-item {
  background: #101a2e; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); animation: slide 0.2s ease;
}
.toast-item.ok { background: #0f8a55; }
.toast-item.err { background: #c22b30; }
@keyframes slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .side {
    width: 100%; height: auto; position: static; flex-direction: row;
    align-items: center; overflow-x: auto;
  }
  .side .logo { padding: 10px 14px; border-bottom: 0; font-size: 14px; }
  .side .logo small { display: none; }
  .side nav { display: flex; padding: 6px 8px; gap: 4px; }
  .side nav a { margin: 0; white-space: nowrap; padding: 7px 11px; font-size: 13px; }
  .side .foot { display: none; }
  .content { padding: 14px 12px 30px; }
  .topbar { padding: 0 14px; }
  .toolbar { gap: 8px; }
}
