/* ===================== 访客管理系统 全局样式 ===================== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --sidebar: #0f2540;
  --sidebar-active: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 37, 64, .08), 0 4px 14px rgba(15, 37, 64, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 14px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-link { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.btn-link.danger { color: var(--red); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-item label .req { color: var(--red); margin-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; transition: border .15s; font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { resize: vertical; min-height: 64px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-bar .input { width: 200px; }
.search-bar select.input { width: 140px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.purple { background: #ede9fe; }
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.table th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
table.table tbody tr:hover { background: #f8fafc; }
table.table .ops { display: flex; gap: 8px; }

/* ---------- 状态标签 ---------- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
}
.chip-green { background: #dcfce7; color: #15803d; }
.chip-gray { background: #f3f4f6; color: #6b7280; }
.chip-orange { background: #ffedd5; color: #c2410c; }
.chip-blue { background: #dbeafe; color: #1d4ed8; }
.chip-red { background: #fee2e2; color: #b91c1c; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600;
}
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translate(-50%, -80px);
  padding: 10px 22px; border-radius: 10px; color: #fff; font-size: 14px; z-index: 200;
  transition: transform .3s; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.toast.show { transform: translate(-50%, 0); }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* ---------- 图例 ---------- */
.pie-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.pie-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.pie-legend b { color: var(--text); }

/* ===================== 入口选择页 ===================== */
.entry-body {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f2540 0%, #1e3a6e 50%, #2563eb 100%); padding: 24px;
}
.entry-logo { color: #fff; text-align: center; margin-bottom: 40px; }
.entry-logo .logo-icon {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px;
  background: rgba(255, 255, 255, .12); display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.entry-logo h1 { font-size: 26px; letter-spacing: 2px; margin-bottom: 8px; }
.entry-logo p { color: rgba(255, 255, 255, .65); font-size: 14px; }
.entry-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.entry-card {
  width: 260px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 18px; padding: 32px 24px; cursor: pointer; text-align: center; color: #fff;
  transition: all .2s; backdrop-filter: blur(6px);
}
.entry-card:hover { background: rgba(255, 255, 255, .16); transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0, 0, 0, .25); }
.entry-card .icon { font-size: 44px; margin-bottom: 14px; }
.entry-card h2 { font-size: 20px; margin-bottom: 8px; }
.entry-card p { font-size: 13px; color: rgba(255, 255, 255, .65); line-height: 1.6; }

/* ===================== 登录页 ===================== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f2540, #2563eb); padding: 20px; }
.login-box { background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); width: 400px; max-width: 100%; padding: 36px; }
.login-box .logo { text-align: center; margin-bottom: 24px; }
.login-box .logo .logo-icon {
  width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #06b6d4); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.login-box .logo h1 { font-size: 20px; }
.login-box .form-item { margin-bottom: 16px; }
.login-box .btn { width: 100%; padding: 11px; font-size: 15px; }
.login-tip { margin-top: 14px; text-align: center; font-size: 12px; color: var(--muted); background: #f8fafc; border-radius: 8px; padding: 8px; }
.login-back { text-align: center; margin-top: 14px; font-size: 13px; }
.login-back a { color: var(--muted); }

/* ===================== 电脑版布局 ===================== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--sidebar); color: #cbd5e1; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px; color: #fff;
  font-size: 16px; font-weight: 600; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand .logo-icon {
  width: 34px; height: 34px; border-radius: 10px; font-size: 18px;
  background: linear-gradient(135deg, #2563eb, #06b6d4); display: flex; align-items: center; justify-content: center;
}
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  cursor: pointer; color: #cbd5e1; margin-bottom: 4px; font-size: 14px; transition: all .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar .side-foot { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #64748b; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 3px rgba(15, 37, 64, .06); position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .user-area { display: flex; align-items: center; gap: 14px; }
.topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}
.topbar .user-name { font-size: 13px; }
.topbar .user-role { font-size: 11px; color: var(--muted); }
.content { padding: 20px 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.chart-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.chart-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.quick-item {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.quick-item:hover { border-color: var(--primary); background: var(--primary-light); }
.quick-item .icon { font-size: 26px; margin-bottom: 8px; }
.quick-item .label { font-size: 13px; }

/* ===================== 手机版布局 ===================== */
.mobile-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.mobile-header {
  background: linear-gradient(135deg, #0f2540, #2563eb); color: #fff; padding: 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.mobile-header .title { font-size: 17px; font-weight: 600; }
.mobile-header .m-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; cursor: pointer;
}
.mobile-content { flex: 1; padding: 14px; padding-bottom: 76px; }
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px;
  background: #fff; display: flex; border-top: 1px solid var(--border); z-index: 50;
  box-shadow: 0 -2px 12px rgba(15, 37, 64, .06);
}
.tabbar .tab {
  flex: 1; padding: 8px 0 6px; text-align: center; cursor: pointer; color: var(--muted); font-size: 11px;
}
.tabbar .tab .icon { font-size: 20px; display: block; margin-bottom: 2px; }
.tabbar .tab.active { color: var(--primary); font-weight: 600; }
.m-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.m-stat { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.m-stat .num { font-size: 22px; font-weight: 700; }
.m-stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.m-card { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.m-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.m-card .head .name { font-size: 15px; font-weight: 600; }
.m-card .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 3px 0; }
.m-card .row .val { color: var(--text); }
.m-card .ops { display: flex; gap: 8px; margin-top: 10px; }
.m-card .ops .btn { flex: 1; padding: 7px; font-size: 13px; }
.m-form .form-item { margin-bottom: 13px; }
.m-form .btn { width: 100%; padding: 12px; font-size: 15px; }
.m-menu { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.m-menu-item {
  display: flex; align-items: center; justify-content: space-between; padding: 15px 16px;
  border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 14px;
}
.m-menu-item:last-child { border-bottom: none; }
.m-menu-item .left { display: flex; align-items: center; gap: 12px; }
.m-menu-item .left .icon { font-size: 18px; width: 22px; text-align: center; }
.m-menu-item .arrow { color: #cbd5e1; }
.m-profile { background: linear-gradient(135deg, #0f2540, #2563eb); border-radius: 14px; padding: 20px; color: #fff; margin-bottom: 14px; display: flex; align-items: center; gap: 14px; }
.m-profile .avatar { width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; }
.m-profile .name { font-size: 17px; font-weight: 600; }
.m-profile .role { font-size: 12px; opacity: .75; margin-top: 4px; }
.m-empty-hint { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row, .chart-row-2 { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar .brand span, .sidebar .nav-item span.txt, .sidebar .side-foot { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .search-bar .input { width: 100%; }
  .content { padding: 14px; }
}
