/* ========== 基础重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
code { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; color: #334155; }

.hidden { display: none !important; }
.screen { width: 100%; }

/* ========== 登录界面 ========== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 50%, #fef9c3 100%);
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
}
.login-bg-shape.s1 { width: 420px; height: 420px; background: #93c5fd; top: -120px; left: -120px; }
.login-bg-shape.s2 { width: 360px; height: 360px; background: #6ee7b7; bottom: -100px; right: -80px; }
.login-bg-shape.s3 { width: 260px; height: 260px; background: #fcd34d; top: 35%; right: 18%; }

.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  padding: 36px 36px 28px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 400px;
  max-width: calc(100vw - 32px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  text-align: center;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  text-align: center;
}

.login-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  text-align: center;
}

.logo-dot {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 60%, #38bdf8 100%);
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}
.logo-dot::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid white;
  border-radius: 5px;
  border-bottom-color: transparent;
  border-right-color: transparent;
  transform: rotate(45deg);
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-group input:disabled,
.form-group select:disabled {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}

.form-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ========== 按钮 ========== */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; opacity: 0.6; }

.btn-secondary {
  background: white;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #f1f5f9; border-color: #cbd5e1; }

.btn-danger {
  background: white;
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover { background: #fef2f2; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

.btn-block { width: 100%; padding: 12px; font-size: 15px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* ========== 主界面布局 ========== */
.app-screen {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  min-height: 56px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.brand-icon::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid white;
  border-radius: 5px;
  border-bottom-color: transparent;
  border-right-color: transparent;
  transform: rotate(45deg);
}

.brand-text h2 { font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand-text p { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover {
  background: #f1f5f9;
  color: var(--text);
}

.nav-link.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.nav-icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.logout-btn {
  margin-top: 16px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
  transition: all 0.15s;
}
.logout-btn:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 18px 32px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 600; }

.content {
  padding: 24px 32px 40px;
  flex: 1;
}

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--info);
}

.stat-card.warn::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.primary::before { background: var(--primary); }

.stat-card .stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.primary .stat-value { color: var(--primary); }

.stat-card .stat-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ========== Section 容器 ========== */
.section {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fbfbfd;
}
.section-header h2 { font-size: 15px; font-weight: 600; }

.section-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 13px;
  min-width: 200px;
  outline: none;
  font-family: inherit;
  color: var(--text);
}
.search-input:focus { border-color: var(--primary); }

.section-body { padding: 16px 18px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

th {
  font-weight: 600;
  color: var(--muted);
  background: #fafbfc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* ========== Tag ========== */
.tag {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
}
.tag.success { background: #d1fae5; color: #065f46; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.warning { background: #ffedd5; color: #9a3412; }
.tag.danger { background: #fee2e2; color: #991b1b; }
.tag.info { background: #cffafe; color: #155e75; }
.tag.primary { background: #dbeafe; color: #1e40af; }

/* ========== 颜色色块（用对应色 + 12% alpha 背景） ========== */
.color-chip {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  margin: 2px 2px 2px 0;
  white-space: nowrap;
  letter-spacing: 1px;
}

/* ========== 行操作 ========== */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.icon-btn {
  background: white;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.icon-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.icon-btn.danger { color: var(--danger); border-color: #fecaca; }
.icon-btn.danger:hover { background: #fef2f2; }
.icon-btn.sort-btn {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  border-color: #dbeafe;
  font-family: inherit;
  min-width: 28px;
}
.icon-btn.sort-btn:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ========== 库存表格：商品名称表头与内容均左对齐，其余居中 ========== */
.inv-table th,
.inv-table td { text-align: center; }
.inv-table th:nth-child(2),
.inv-table td:nth-child(2) { text-align: left; }

/* ========== 销售明细表格：商品概要内容左对齐，其余（含表头）居中 ========== */
.sales-table th,
.sales-table td { text-align: center; }
.sales-table td:nth-child(3) { text-align: left; }

/* ========== 用户列表：表头与内容居中 ========== */
.user-table th,
.user-table td { text-align: center; }

/* ========== 考勤月份选择器：圆润外观 ========== */
.att-month-picker {
  border-radius: 999px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  font-family: inherit;
}
.att-month-picker:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ========== 序号单元格 ========== */
.seq-input {
  width: 56px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: white;
  color: var(--primary);
  font-family: inherit;
  transition: all 0.15s;
}
.seq-input:hover { border-color: var(--primary); background: var(--primary-soft); }
.seq-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.seq-input::-webkit-outer-spin-button,
.seq-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.seq-input { -moz-appearance: textfield; appearance: textfield; }

.seq-static {
  display: inline-block;
  width: 32px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

/* ========== 表单分组（编辑商品界面） ========== */
.form-section {
  margin-bottom: 18px;
  padding: 16px 18px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.form-section:hover { border-color: #cbd5e1; }
.form-section:last-child { margin-bottom: 0; }

.form-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
}

.form-group .req {
  color: var(--danger);
  margin-left: 2px;
}
.form-group .form-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.form-grow { flex: 2; }
.form-narrow { flex: 1; max-width: 130px; }
.form-narrow input { width: 100%; }

/* ========== 模态框 ========== */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s ease;
}

.modal-card.large { max-width: 760px; }

@keyframes pop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fbfbfd;
}

/* ========== Form rows ========== */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 0;
}

.form-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-grid-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ========== 销售明细行 ========== */
.sale-line-header {
  display: grid;
  grid-template-columns: 1fr 90px 110px 110px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 0 4px;
}

.sale-line {
  display: grid;
  grid-template-columns: 1fr 90px 110px 110px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.sale-line select,
.sale-line input {
  padding: 8px 10px;
  font-size: 13px;
}

.sale-line .line-subtotal-cell {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  padding: 0 4px;
}

/* 课时费（自定义名称）行：第一列变纵向布局容纳名称输入 */
.sale-line .line-pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.sale-line .line-pick-select { width: 100%; }
.sale-line .line-custom-name {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.05);
}
.sale-line.sale-line-custom {
  background: rgba(99, 102, 241, 0.04);
  border-radius: 6px;
  padding: 4px;
}
tr.row-custom td { background: rgba(99, 102, 241, 0.04); }

.sale-total {
  padding: 14px 18px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #dbeafe;
}
.sale-total .total-label { color: var(--muted); font-size: 13px; }
.sale-total .total-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

/* ========== 空状态 ========== */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.4; }

/* ========== Toast ========== */
.toast-root {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: white;
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 240px;
  font-size: 13px;
  border-left: 4px solid var(--info);
  animation: slideIn 0.2s ease;
  pointer-events: auto;
}
.toast.success { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast.fade-out { opacity: 0; transition: opacity 0.3s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== 详情 ========== */
.detail-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px 16px;
  font-size: 13px;
}
.detail-grid dt { color: var(--muted); }
.detail-grid dd { font-weight: 500; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: 16px 8px; }
  .sidebar-brand > .brand-text,
  .nav-link .nav-label,
  .logout-btn {
    display: none;
  }
  .nav-link { justify-content: center; padding: 12px 8px; }
  .sidebar-brand { justify-content: center; padding-bottom: 16px; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .login-card { padding: 28px 24px; }
  .sale-line, .sale-line-header { grid-template-columns: 1fr 70px 36px; }
  .sale-line .price-col, .sale-line-header .price-col { display: none; }
  .form-grid-row, .form-grid-row.cols-3 { grid-template-columns: 1fr; }
}

@media print {
  body { background: #ffffff !important; padding: 0; }
  .sidebar, .topbar, .section-toolbar { display: none !important; }
  .content { padding: 0 !important; }
}

/* ========== 业绩归属统计 ========== */
.perf-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.perf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.perf-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.perf-empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--border-soft);
  border-radius: var(--radius-sm);
}
.perf-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.perf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.perf-table th,
.perf-table td {
  padding: 10px 14px;
  text-align: center;
  white-space: nowrap;
}
.perf-table th {
  background: var(--border-soft);
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.perf-table tbody tr + tr td { border-top: 1px solid var(--border-soft); }
.perf-table tr.perf-me {
  background: linear-gradient(90deg, #eff6ff 0%, transparent 60%);
}
.perf-table tr.perf-me td { color: var(--text); font-weight: 500; }
.perf-table tr.perf-total td {
  background: var(--border-soft);
  font-weight: 600;
  color: var(--text);
  border-top: 2px solid var(--border);
}

.perf-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
  vertical-align: middle;
}
.perf-rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.perf-rank-2 { background: linear-gradient(135deg, #d1d5db, #9ca3af); color: #fff; }
.perf-rank-3 { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }

.perf-bar-wrap {
  position: relative;
  min-width: 110px;
  height: 18px;
  background: var(--border-soft);
  border-radius: 9px;
  overflow: hidden;
}
.perf-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #93c5fd, var(--primary));
  border-radius: 9px;
  transition: width 0.4s ease;
}
.perf-bar-text {
  position: relative;
  display: block;
  line-height: 18px;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text);
  text-align: right;
  font-weight: 500;
}

@media (max-width: 768px) {
  .perf-table th, .perf-table td { padding: 8px 8px; font-size: 12px; }
  .perf-bar-wrap { min-width: 70px; }
}


/* ========== 考勤模块 ========== */
.att-legend {
  display: flex;
  gap: 16px;
  margin: 0 0 12px 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--border-soft);
  border-radius: var(--radius-sm);
  align-items: center;
  flex-wrap: wrap;
}
.att-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.att-legend-box {
  width: 22px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}
.att-legend-box.rest     { background: #fef2f2; color: #dc2626; }
.att-legend-box.overtime { background: #dbeafe; color: #1d4ed8; }

.att-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}
.att-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  font-size: 13px;
}
.att-table th,
.att-table td {
  border: 1px solid #edf2f7;
  padding: 0;
  text-align: center;
  white-space: nowrap;
}
.att-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  position: sticky;
  top: 0;
  z-index: 2;
  height: 40px;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.att-weekday-header { background: #f3f4f6; }
.att-friday-header  { background: #fef3c7; color: #b45309; }
.att-weekday-sub    { font-size: 11px; font-weight: 400; height: 22px; padding: 0; }
.att-friday-sub     { background: #fde68a; color: #92400e; font-size: 11px; font-weight: 400; height: 22px; padding: 0; }

.att-name-header { background: #f8fafc; position: sticky; left: 0; z-index: 3; }
.att-name-cell {
  background: #f8fafc;
  font-weight: 500;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 110px;
  max-width: 140px;
  height: 42px;
}
.att-name-cell input {
  border: none;
  background: transparent;
  text-align: center;
  width: 100%;
  height: 100%;
  font-size: 13px;
  padding: 4px 2px;
  font-family: inherit;
}
.att-name-cell input:focus {
  background: #fff;
  outline: 1px solid var(--primary);
  border-radius: 4px;
}

.att-day {
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  width: 36px;
  height: 42px;
  line-height: 40px;
  font-size: 14px;
  vertical-align: middle;
}
.att-day:hover { background: #e0f2fe; }
.att-day.rest {
  color: #dc2626;
  font-weight: 700;
  background: #fef2f2;
}
.att-day.rest:hover { background: #fee2e2; }
.att-day.overtime {
  color: #1d4ed8;
  font-weight: 700;
  background: #dbeafe;
}
.att-day.overtime:hover { background: #bfdbfe; }
.att-friday-cell { background: #fffbeb; }
.att-day.att-friday-cell.rest     { background: #fee2e2; }
.att-day.att-friday-cell.overtime { background: #dbeafe; }

.att-stats-cell {
  background: #f8fafc;
  font-weight: 600;
  min-width: 60px;
  height: 42px;
  line-height: 40px;
  font-size: 14px;
  vertical-align: middle;
  border-left: 2px solid #e2e8f0;
}
.att-work-count     { color: #059669; }
.att-rest-count     { color: #dc2626; }
.att-overtime-count { color: #1d4ed8; }
.att-attend-count   { color: #7c3aed; font-weight: 700; }
.att-pending {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

.att-rest-dates {
  background: #fef2f2;
  color: #991b1b;
  text-align: left;
  padding: 6px 10px;
  font-size: 12px;
  min-width: 180px;
  max-width: 280px;
  white-space: normal;
  word-break: break-all;
  line-height: 1.5;
  vertical-align: middle;
}

.att-remove-btn {
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.att-remove-btn:hover { background: #f3f4f6; color: var(--danger); }

.att-empty {
  padding: 30px;
  color: #9ca3af;
  text-align: center;
  font-size: 13px;
}

.att-summary {
  margin-top: 14px;
  padding: 12px 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #1e40af;
}

/* 打印：考勤模块保留全部表格，工具栏/侧栏隐藏，单元格着色保留 */
@media print {
  .att-legend,
  .att-summary { display: none !important; }
  .att-table-wrap {
    overflow: visible;
    max-height: none;
    border: 1px solid #000;
  }
  .att-table { min-width: auto; }
  .att-table th,
  .att-table td { font-size: 11px; }
  .att-day { width: 28px; height: 30px; line-height: 28px; }
  .att-stats-cell,
  .att-name-cell,
  .att-rest-dates { height: 30px; line-height: normal; padding: 4px 6px; }
  .att-table th { height: 28px; }
  .att-day.rest {
    color: #c00000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .att-day.overtime {
    color: #1d4ed8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .att-name-header,
  .att-name-cell { position: static; }
}

