/* ============================================================
   门诊巡检系统 - 设计 token 与基础组件
   色彩: OKLCH, 中性微染蓝 (hue 245)
   字体: 系统栈 (本地运行无网络), 靠排版纪律而非花哨字体
   ============================================================ */

:root {
  /* --- 中性色: 微染蓝, chroma 随明度递减 --- */
  --bg-canvas: oklch(0.985 0.004 245);
  --bg-surface: oklch(1 0 0);
  --bg-sunken: oklch(0.965 0.004 245);
  --bg-sidebar: oklch(0.972 0.005 245);

  --border: oklch(0.918 0.006 245);
  --border-strong: oklch(0.88 0.008 245);

  --text-primary: oklch(0.22 0.015 245);
  --text-secondary: oklch(0.50 0.012 245);
  --text-tertiary: oklch(0.62 0.01 245);
  --text-inverse: oklch(0.99 0.002 245);

  /* --- 强调色: 克制墨蓝 --- */
  --accent: oklch(0.48 0.14 245);
  --accent-hover: oklch(0.42 0.15 245);
  --accent-active: oklch(0.38 0.15 245);
  --accent-soft: oklch(0.95 0.03 245);
  --accent-soft-text: oklch(0.40 0.13 245);

  /* --- 语义色: 低饱和软底 --- */
  --success: oklch(0.55 0.14 150);
  --success-soft: oklch(0.95 0.04 150);
  --success-text: oklch(0.38 0.12 150);
  --warning: oklch(0.68 0.15 75);
  --warning-soft: oklch(0.95 0.05 75);
  --warning-text: oklch(0.48 0.13 75);
  --danger: oklch(0.55 0.18 25);
  --danger-soft: oklch(0.95 0.04 25);
  --danger-text: oklch(0.42 0.16 25);
  --info: oklch(0.52 0.12 245);
  --info-soft: oklch(0.95 0.03 245);
  --info-text: oklch(0.42 0.11 245);

  /* --- 阴影: 克制分层 --- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 4px 14px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);

  /* --- 圆角阶梯 --- */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;

  /* --- 旧变量别名, 兼容 mobile/login 页面 --- */
  --primary: var(--accent);
  --primary-dark: var(--accent-hover);
  --text: var(--text-primary);
  --bg: var(--bg-canvas);
  --card: var(--bg-surface);

  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition-property: background-color, border-color, color, transform, box-shadow;
  transition-duration: 140ms;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
  white-space: nowrap;
}
button:active { transform: scale(0.97); }
@media (hover: hover) {
  button:hover { background: var(--bg-sunken); }
}

button.primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active { background: var(--accent-active); }

button.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
@media (hover: hover) {
  button.ghost:hover { background: var(--bg-sunken); color: var(--text-primary); border-color: var(--border-strong); }
}

button.danger {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: transparent;
}
@media (hover: hover) {
  button.danger:hover { background: var(--danger); color: var(--text-inverse); }
}

button.subtle {
  background: var(--bg-sunken);
  color: var(--text-secondary);
  border-color: transparent;
}
@media (hover: hover) {
  button.subtle:hover { background: var(--border); color: var(--text-primary); }
}

button.small { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  outline: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition-property: border-color, box-shadow;
  transition-duration: 140ms;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { width: auto; padding: 0; }
input[type="date"], input[type="time"] { font-variant-numeric: tabular-nums; }
::placeholder { color: var(--text-tertiary); }

/* --- 表格: 极细分隔线, 数字等宽 --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-surface);
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: transparent;
  font-weight: 500;
  color: var(--text-tertiary);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
td { color: var(--text-primary); }
tbody tr { transition: background-color 120ms; }
@media (hover: hover) {
  tbody tr:hover { background: var(--bg-sunken); }
}
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* --- 状态标签: 小圆点 + 文字 (克制) --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.6;
}
.tag::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.tag.pending { background: var(--warning-soft); color: var(--warning-text); }
.tag.ontime { background: var(--success-soft); color: var(--success-text); }
.tag.late { background: var(--warning-soft); color: var(--warning-text); }
.tag.missed { background: var(--danger-soft); color: var(--danger-text); }
.tag.makeup { background: var(--info-soft); color: var(--info-text); }
.tag.active { background: var(--success-soft); color: var(--success-text); }
.tag.inactive { background: var(--bg-sunken); color: var(--text-tertiary); }

/* --- 公共布局 --- */
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.container.mobile { max-width: 480px; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.empty .icon { font-size: 32px; margin-bottom: 10px; opacity: 0.6; }

/* --- toast --- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 10px 18px;
  border-radius: var(--radius);
  z-index: 1000;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- 弹窗 (CRUD 必需, 保留) --- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: saturate(120%);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
  animation: maskIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }

/* --- 表单 --- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group label input[type="checkbox"] { margin-right: 6px; vertical-align: -1px; }

/* --- 顶部栏 (mobile 用) --- */
.navbar {
  background: var(--accent);
  color: var(--text-inverse);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.navbar .right { display: flex; gap: 8px; align-items: center; }
.navbar .user-info { font-size: 12px; opacity: 0.9; font-variant-numeric: tabular-nums; }
