/* ============================================
   访客管理平台 · 设计系统
   极简白 + 少量蓝 · Linear / Notion / Apple 风
   ============================================ */

:root {
  /* 颜色 */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f4f5f7;
  --bg-active: #eef2ff;
  --border: #e7e8ec;
  --border-strong: #d5d7dc;

  --text: #17181c;
  --text-2: #5b5e66;
  --text-3: #9aa0a8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(37, 99, 235, 0.18);

  --success: #16a34a;
  --success-soft: #ecfdf3;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* 圆角 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  /* 尺寸 */
  --sidebar-w: 232px;
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

#app { height: 100%; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1.4;
  font-family: var(--font);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-ghost { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); border-color: #c3c6cc; }

.btn-text { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn-text:hover:not(:disabled) { background: var(--primary-soft); }

.btn-danger-text { background: transparent; color: var(--danger); padding: 6px 8px; }
.btn-danger-text:hover:not(:disabled) { background: var(--danger-soft); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

/* 输入框 */
.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.textarea { resize: vertical; min-height: 80px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0a8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 卡片 */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* 标签/徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  line-height: 1.6;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: var(--bg-hover); color: var(--text-2); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-subtle); }
.tbl .td-actions { display: flex; gap: 2px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 14px 20px; font-size: 13px; color: var(--text-2); }
.pager .page-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: #fff; cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: all .15s;
}
.pager .page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 空状态 */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .empty-icon { font-size: 36px; margin-bottom: 10px; opacity: .6; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 17, 21, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .15s ease;
}
.modal {
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 480px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  animation: popIn .18s ease;
}
.modal.wide { width: 640px; }
.modal-head { padding: 18px 20px 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }

/* 提示 toast */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 10px 18px; border-radius: var(--r-md);
  font-size: 13px; color: #fff; box-shadow: var(--shadow-md);
  animation: toastIn .25s ease;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 400px at 20% 10%, var(--primary-soft), transparent 60%),
    radial-gradient(500px 400px at 85% 90%, #f0f7ff, transparent 60%);
}
.login-box {
  position: relative;
  width: 380px; max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .mark {
  width: 48px; height: 48px; margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 700;
}
.login-logo h1 { font-size: 18px; font-weight: 600; }
.login-logo p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.login-box .field { margin-bottom: 18px; }
.login-box .btn { width: 100%; justify-content: center; height: 40px; font-size: 14px; }

/* ---------- 主布局 ---------- */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar .brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar .brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.sidebar .brand .name { font-size: 14px; font-weight: 600; }
.sidebar .nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  transition: all .12s ease;
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  flex-shrink: 0;
}
.header .page-title { font-size: 15px; font-weight: 600; }
.header .user {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; position: relative;
}
.header .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.header .user-name { font-size: 13px; color: var(--text-2); }
.header .dropdown {
  position: absolute; top: 40px; right: 0;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  min-width: 140px; padding: 6px; z-index: 100;
  display: none;
}
.header .dropdown.open { display: block; }
.header .dropdown .dd-item {
  padding: 8px 12px; border-radius: var(--r-sm);
  font-size: 13px; cursor: pointer; color: var(--text-2);
}
.header .dropdown .dd-item:hover { background: var(--bg-hover); color: var(--text); }
.header .dropdown .dd-item.danger { color: var(--danger); }

.content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg-subtle); }
.content-inner { max-width: 1200px; margin: 0 auto; }

/* 首页仪表盘 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
  box-shadow: var(--shadow-xs);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 30px; font-weight: 650; letter-spacing: -.5px; }
.stat-card .stat-value .unit { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.stat-card .stat-trend { font-size: 12px; margin-top: 6px; color: var(--text-3); }
.stat-card.accent .stat-value { color: var(--primary); }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar .search-input { width: 200px; }

/* 详情描述列表 */
.desc-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
.desc-list .desc-item .dl { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.desc-list .desc-item .dv { font-size: 13px; color: var(--text); word-break: break-all; }

/* 图片 */
.img-preview { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--border); }

/* 加载 */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-3); }
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border-strong);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 500; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .desc-list { grid-template-columns: 1fr; }
}
