:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #8b5cf6;
  --accent2: #ec4899;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #06b6d4;
  --bg: #eef1f7;
  --card: #f6f8fd;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar-w: 230px;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-light: rgba(255,255,255,.9);
  --shadow-dark: rgba(163,177,198,.6);
  --neumo: 7px 7px 14px var(--shadow-dark), -7px -7px 14px var(--shadow-light);
  --neumo-sm: 4px 4px 9px var(--shadow-dark), -4px -4px 9px var(--shadow-light);
  --neumo-inset: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(160deg, #eef1f7 0%, #e8ecf6 55%, #f3ecfa 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #312e81 0%, #4c1d95 60%, #6d28d9 100%);
  color: #e0e7ff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 20px 16px;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand .logo { font-size: 20px; }
.sidebar .nav-group { padding: 12px 0 6px; }
.sidebar .nav-group-title {
  padding: 6px 16px;
  font-size: 11px;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  color: #c7d2fe;
  font-size: 14px;
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
  margin: 1px 0;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(255,255,255,.22), rgba(255,255,255,.06));
  color: #fff;
  border-left-color: #fbbf24;
}
.sidebar .nav-link .badge {
  background: var(--danger); color: #fff; font-size: 11px;
  padding: 0 6px; border-radius: 9px; margin-left: auto;
}
.sidebar .side-footer { margin-top: auto; padding: 14px 16px; font-size: 12px; color: #a5b4fc; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar .side-footer .logout { color: #fca5a5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.6);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .menu-btn { display: none; font-size: 20px; background: none; border: none; cursor: pointer; color: var(--text); }
.topbar .page-title { font-size: 16px; font-weight: 700; background: linear-gradient(90deg, var(--primary), var(--accent2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
}
.topbar .user-chip .role-tag {
  background: linear-gradient(135deg, #ede9fe, #e0e7ff); color: var(--primary);
  padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.content { padding: 22px; flex: 1; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--neumo);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; text-decoration: none;
  box-shadow: var(--neumo-sm);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(0); box-shadow: var(--neumo-inset); }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.lg { padding: 11px 24px; font-size: 15px; }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: var(--neumo-sm); }
.btn.ghost:hover { background: #fff; }
.btn.danger { background: linear-gradient(135deg, #f43f5e, var(--danger)); }
.btn.danger:hover { filter: brightness(1.05); }
.btn.success { background: linear-gradient(135deg, #34d399, var(--success)); }
.btn.warning { background: linear-gradient(135deg, #fbbf24, var(--warning)); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); }
.tbl th {
  background: linear-gradient(180deg, #f3f4fb, #eef0f8);
  text-align: left; padding: 11px 12px;
  font-weight: 700; color: #475569;
  border-bottom: 2px solid #e2e6f2;
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid #e8ebf5; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #eef1fb; }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag.pending { background: #fef3c7; color: #92400e; }
.tag.approved { background: #d1fae5; color: #065f46; }
.tag.rejected { background: #fee2e2; color: #991b1b; }
.tag.voided { background: #e2e8f0; color: #475569; }
.tag.corrected { background: #fae8ff; color: #86198f; }
.tag.done { background: #d1fae5; color: #065f46; }

.status-pending { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-voided { background: #e2e8f0; color: #475569; }
.status-corrected { background: #fae8ff; color: #86198f; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border: none; border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--neumo);
}
.stat-card .num { font-size: 28px; font-weight: 800; }
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card.danger .num { background: linear-gradient(135deg, #f43f5e, #ef4444); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card.success .num { background: linear-gradient(135deg, #34d399, #059669); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card.info .num { background: linear-gradient(135deg, #22d3ee, #0891b2); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- 联系电话 ---------- */
.phone-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--primary); font-weight: 600; font-size: 13px;
  padding: 1px 8px; border-radius: 8px; background: #eef2ff;
  text-decoration: none; white-space: nowrap;
}
.phone-link:hover { background: #e0e7ff; text-decoration: none; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 13px; font-weight: 600; color: #334155; }
.form-item label .req { color: var(--danger); }
.form-item .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: none;
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--text); outline: none;
  box-shadow: var(--neumo-inset);
  transition: box-shadow .15s;
}
input:focus, select:focus, textarea:focus { box-shadow: var(--neumo-inset), 0 0 0 3px rgba(79,70,229,.18); }
textarea { resize: vertical; min-height: 76px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkbox-line input { width: 16px; height: 16px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .form-item { flex: 0 1 180px; }
.filter-bar .form-item.flex { flex: 1 1 200px; }

/* ---------- 待办/列表 ---------- */
.todo-list { display: flex; flex-direction: column; gap: 10px; }
.todo-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: none; border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--neumo-sm);
}
.todo-item .ic { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.todo-item .ic.danger { background: linear-gradient(135deg, #fee2e2, #ffd6d6); }
.todo-item .ic.info { background: linear-gradient(135deg, #e0e7ff, #ede9fe); }
.todo-item .ic.success { background: linear-gradient(135deg, #d1fae5, #ccfbf1); }
.todo-item .body { flex: 1; min-width: 0; }
.todo-item .body .t { font-weight: 600; font-size: 14px; }
.todo-item .body .d { font-size: 12px; color: var(--muted); }
.todo-item a.btn { flex-shrink: 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 45%, #a855f7 100%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 65%);
  top: -120px; right: -100px;
}
.login-page::after {
  content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(251,191,36,.22), transparent 65%);
  bottom: -100px; left: -80px;
}
.login-box {
  background: var(--card); border-radius: 22px; padding: 36px 32px;
  width: 100%; max-width: 400px; position: relative; z-index: 1;
  box-shadow: 12px 12px 28px rgba(49,46,129,.45), -6px -6px 18px rgba(255,255,255,.25);
}
.login-box .logo { font-size: 42px; text-align: center; }
.login-box h1 { text-align: center; font-size: 22px; margin: 10px 0 4px; background: linear-gradient(90deg, var(--primary), var(--accent2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-box .subtitle { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-box .form-item { margin-bottom: 14px; }

/* ---------- 消息 ---------- */
.flashes { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 16px; border-radius: 12px; font-size: 13px; color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 340px;
  animation: slideIn .25s ease; font-weight: 500;
}
.flash.ok { background: linear-gradient(135deg, #34d399, #059669); }
.flash.error { background: linear-gradient(135deg, #f43f5e, #ef4444); }
.flash.info { background: linear-gradient(135deg, #22d3ee, #0891b2); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30,27,75,.55); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--card); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto; padding: 24px;
  box-shadow: var(--neumo), 0 10px 40px rgba(30,27,75,.25);
  animation: slideIn .2s ease;
}
.modal h3 { font-size: 16px; margin-bottom: 12px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- 图表 ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 18px; padding: 20px 8px 0; min-height: 200px; }
.chart-bars .bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.chart-bars .bar {
  width: 100%; max-width: 60px;
  background: linear-gradient(180deg, #a78bfa, var(--primary));
  border-radius: 8px 8px 0 0; min-height: 4px; transition: height .4s ease;
}
.chart-bars .bar-label { font-size: 12px; color: var(--muted); text-align: center; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bars .bar-val { font-size: 12px; font-weight: 600; }

.img-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.img-thumb {
  width: 92px; height: 92px; object-fit: cover; border-radius: 12px;
  border: 1px solid #e2e6f2; cursor: zoom-in; box-shadow: var(--neumo-sm);
}
.img-preview-modal .img-full { max-width: 100%; max-height: 76vh; border-radius: 12px; }

/* ---------- 排名表 ---------- */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: none; border-radius: 12px; padding: 12px 14px; box-shadow: var(--neumo-sm);
}
.rank-item .rk {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.rank-item .rk.r1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 0 12px rgba(245,158,11,.5); }
.rank-item .rk.r2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); }
.rank-item .rk.r3 { background: linear-gradient(135deg, #fb923c, #b45309); }
.rank-item .rk.other { background: #cbd5e1; color: #475569; }
.rank-item .name { flex: 1; font-weight: 600; font-size: 14px; }
.rank-item .score { font-weight: 800; font-size: 15px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -260px; z-index: 100; transition: left .25s ease; width: 240px;
  }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topbar .menu-btn { display: block; }
  .content { padding: 12px; }
  .card { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar .form-item { flex: 1 1 100%; }
  .todo-item { flex-wrap: wrap; }
  .todo-item a.btn { width: 100%; justify-content: center; }
  .table-overflow { overflow-x: auto; }
  .topbar .user-chip .role-tag { display: none; }
  .login-box { padding: 26px 20px; }
  .flashes { left: 16px; }
}

@media (max-width: 480px) {
  html { font-size: 15px; }
  .stat-card .num { font-size: 22px; }
  .img-thumb { width: 72px; height: 72px; }
}

.mask { display: none; }
.mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }

.print-only { display: none; }
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .no-print { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
}
