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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}

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

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
}

.brand h1 {
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
}

.tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  transition: all .2s;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow);
  font-weight: 500;
}

main {
  flex: 1;
  padding: 24px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.panel { display: none; }
.panel.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title .hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.stat {
  text-align: left;
  border-left: 4px solid var(--primary);
}

.stat.success { border-left-color: var(--success); }
.stat.warn { border-left-color: var(--warn); }
.stat.info { border-left-color: var(--info); }

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
}

.stat.success .stat-value { color: var(--success); }
.stat.warn .stat-value { color: var(--warn); }
.stat.info .stat-value { color: var(--info); }

.qr-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.qr {
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr canvas, .qr img { width: 100%; height: 100%; }

.qr-info {
  flex: 1;
  min-width: 240px;
}

.qr-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.qr-info input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.qr-tip {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.8;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  font-family: inherit;
}

.btn:hover { border-color: var(--primary); color: var(--primary); }

.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
}

.btn.danger {
  color: var(--danger);
  border-color: #fecaca;
}

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

.btn.big {
  padding: 12px 24px;
  font-size: 15px;
  width: 100%;
  margin-top: 8px;
}

.form-row {
  margin-bottom: 14px;
}

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

.req { color: var(--danger); }
.hint-text { color: var(--muted); font-weight: 400; }

.form-row input, .form-row select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}

.form-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.import-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.import-row input[type="file"] {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
}

.search-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  min-width: 200px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.data-table thead {
  background: var(--bg);
}

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: visible;
}

.data-table tbody tr:hover { background: #fafbfc; }

.data-table .name-cell {
  white-space: normal;
  word-break: break-all;
  max-width: 200px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag.ok { background: #d1fae5; color: #065f46; }
.tag.wait { background: #fef3c7; color: #92400e; }
.tag.extra { background: #dbeafe; color: #1e40af; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  transition: transform .3s;
  z-index: 1000;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 签到页（手机） ===== */
.checkin-page {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.phone-wrap {
  width: 100%;
  max-width: 420px;
}

.phone-card {
  background: white;
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

.checkin-header {
  text-align: center;
  margin-bottom: 24px;
}

.checkin-logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: white;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 12px;
}

.checkin-header h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.checkin-meta {
  font-size: 13px;
  color: var(--muted);
}

.checkin-step { display: none; }
.checkin-step.active { display: block; }

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

.checkin-success, .checkin-error {
  text-align: center;
  padding: 24px 0;
}

.check-icon {
  width: 72px;
  height: 72px;
  background: #d1fae5;
  color: var(--success);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 16px;
}

.err-icon {
  width: 72px;
  height: 72px;
  background: #fee2e2;
  color: var(--danger);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: bold;
  margin-bottom: 16px;
}

.checkin-success h3 { font-size: 20px; margin-bottom: 8px; }
.checkin-error h3 { font-size: 20px; margin-bottom: 8px; color: var(--danger); }

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

.checkin-success .btn, .checkin-error .btn {
  margin-top: 20px;
}

.phone-foot {
  text-align: center;
  color: rgba(255,255,255,.7);
  font-size: 12px;
  margin-top: 16px;
}

@media (max-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  main { padding: 16px; }
  .tabs { width: 100%; overflow-x: auto; }
  .tab { white-space: nowrap; }
}

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

.form-hint code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.hidden { display: none !important; }

/* 数据备份提醒 */
.data-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.data-warning-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.data-warning-content {
  flex: 1;
  min-width: 0;
}

.data-warning-title {
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 4px;
}

.data-warning-text {
  font-size: 13px;
  color: #78350f;
  line-height: 1.6;
}

.data-warning-text strong {
  color: #92400e;
}

.data-warning-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #92400e;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  line-height: 1;
  flex-shrink: 0;
}

.data-warning-close:hover {
  background: rgba(146, 64, 14, 0.1);
}

.banner {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  padding: 12px 28px;
  color: #92400e;
  font-size: 13px;
}

.banner.banner-error {
  background: #fee2e2;
  border-bottom: 3px solid #dc2626;
  color: #991b1b;
  padding: 16px 28px;
  font-size: 14px;
}

.banner.banner-error strong {
  font-size: 16px;
  margin-bottom: 8px;
  display: block;
}

.banner.banner-error ol {
  margin: 8px 0 8px 20px;
}

.banner.banner-error code {
  background: #fecaca;
  color: #7f1d1d;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
}

.banner.banner-error a {
  color: #991b1b;
  font-weight: 600;
}

.banner strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.banner code {
  background: #fde68a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* ===== 二维码弹窗 ===== */
.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.qr-modal-content {
  background: white;
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.qr-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  line-height: 1;
  border-radius: 50%;
}

.qr-modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.qr-modal-content h3 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--text);
}

.qr-modal-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.qr-modal-qr canvas, .qr-modal-qr img {
  width: 280px;
  height: 280px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: white;
}

.qr-modal-url {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
}

.qr-modal-tip {
  font-size: 13px;
  color: var(--danger);
  margin: 0;
}

/* ===== 打印样式（PDF 报告） ===== */
@media print {
  .topbar, .tabs, .actions, .import-row, .search-input { display: none !important; }
  body { background: white; }
  .panel { display: block !important; page-break-after: always; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
