:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }

/* 页面容器 */
.page { max-width: 480px; margin: 0 auto; padding: 16px; }
.page-wide { max-width: 960px; margin: 0 auto; padding: 16px; }

/* 头部 */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--primary); color: white;
  position: sticky; top: 0; z-index: 100;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header a, .header button {
  color: white; background: none; border: none; font-size: 14px; cursor: pointer;
}

/* 卡片 */
.card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--gray-700); }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--gray-500); margin-bottom: 4px; font-weight: 500; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius); font-size: 15px; transition: border-color 0.2s;
  background: white; color: var(--gray-800);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-textarea { min-height: 80px; resize: vertical; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: var(--radius); font-size: 15px; font-weight: 500;
  border: none; cursor: pointer; transition: all 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline {
  background: transparent; border: 1px solid var(--gray-300); color: var(--gray-600);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* 进度条 */
.progress-bar {
  height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; margin: 8px 0;
}
.progress-bar-fill {
  height: 100%; border-radius: 4px; transition: width 0.3s;
}
.progress-bar-fill.low { background: var(--success); }
.progress-bar-fill.mid { background: var(--warning); }
.progress-bar-fill.high { background: var(--danger); }

/* 状态标签 */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 500;
}
.badge-booked { background: #dbeafe; color: #1d4ed8; }
.badge-arrived { background: #d1fae5; color: #065f46; }
.badge-finished { background: #e5e7eb; color: #374151; }
.badge-noshow { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #9ca3af; }

/* 通知 */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--radius); color: white;
  font-size: 14px; z-index: 999; animation: toastIn 0.3s;
  max-width: 90%;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; } }

/* 科室看板 */
.dept-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 10px; cursor: pointer;
  border-left: 4px solid var(--primary);
}
.dept-card.disabled { border-left-color: var(--gray-300); opacity: 0.7; }
.dept-card .dept-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;
}
.dept-card .dept-name { font-weight: 600; font-size: 16px; }
.dept-card .dept-count { font-size: 14px; color: var(--gray-500); }
.dept-card .dept-count strong { color: var(--primary); font-size: 18px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gray-100); }
th { font-weight: 600; color: var(--gray-500); font-size: 12px; text-transform: uppercase; }
tr:hover { background: var(--gray-50); }

/* 浮动按钮 */
.fab {
  position: fixed; bottom: 20px; right: 20px; width: 56px; height: 56px;
  border-radius: 50%; background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: var(--shadow-lg); border: none; cursor: pointer;
  z-index: 99; transition: transform 0.2s;
}
.fab:hover { transform: scale(1.1); }

/* 分页 */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 0;
}
.pagination .btn { min-width: 36px; }

/* 标签/页签 */
.tabs {
  display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 16px;
}
.tabs a {
  padding: 8px 16px; font-size: 14px; color: var(--gray-500); border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer; white-space: nowrap;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 顶部导航栏 */
.navbar {
  display: flex; align-items: center; padding: 0 16px;
  background: var(--primary); color: white; height: 48px; gap: 16px;
}
.navbar a { color: white; font-size: 14px; opacity: 0.85; }
.navbar a:hover, .navbar a.active { opacity: 1; font-weight: 600; }
.navbar .spacer { flex: 1; }

/* 管理员布局 */
.admin-layout { display: flex; min-height: calc(100vh - 48px); }
.admin-sidebar {
  width: 180px; background: var(--gray-800); color: white; padding: 8px 0;
  flex-shrink: 0;
}
.admin-sidebar a {
  display: block; padding: 10px 16px; color: var(--gray-300); font-size: 14px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: var(--gray-700); color: white; }
.admin-main { flex: 1; padding: 16px; overflow-x: auto; }

/* 响应式 */
@media (max-width: 640px) {
  .admin-sidebar { display: none; }
  .admin-main { padding: 12px; }
  .page { padding: 12px; }
  .fab { bottom: 16px; right: 16px; }
}

/* 工具 */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-gray { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.hidden { display: none; }
.relative { position: relative; }
.loading { text-align: center; padding: 40px; color: var(--gray-400); font-size: 14px; }
