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

:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-3: #a855f7;
  --accent: #f59e0b;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1e2433;
  --muted: #7c8496;
  --border: #e8eaf3;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(30,36,51,.06), 0 1px 2px rgba(30,36,51,.04);
  --shadow-md: 0 6px 20px rgba(99,102,241,.12);
  --shadow-lg: 0 18px 50px rgba(99,102,241,.18);
  --radius: 14px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(168,85,247,.10), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, rgba(99,102,241,.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #eef0f8;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  transition: all .18s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-md); }
.btn.primary:hover { box-shadow: var(--shadow-lg); filter: brightness(1.04); }
.btn.ghost { background: #fff; border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: #f6f7fd; border-color: #d9ddf0; }
.btn.block { width: 100%; justify-content: center; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }

/* ---------- 登录 ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  width: 100%; max-width: 400px;
  padding: 44px 36px; border-radius: 22px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.6);
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 18px; background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 24px; text-align: center; margin-bottom: 4px; font-weight: 700; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 13px; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; outline: none; transition: all .16s;
}
.form-row input:hover { border-color: #d5d9ee; }
.form-row input:focus, .form-row textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-row textarea { resize: vertical; }
.form-row input::placeholder, .form-row textarea::placeholder { color: #b3b9cc; }

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

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 13px 26px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-size: 18px; font-weight: 700; }
.topbar .brand .logo-emoji { margin-right: 6px; }
.brand-accent {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.top-right { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); margin-right: 4px; font-size: 13px; }

/* ---------- 容器 ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 24px 20px; }
.toolbar { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.toolbar .hint { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
  border: 1px solid var(--border);
}
.card h3 { font-size: 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.tip {
  border-left: 4px solid var(--accent); color: #9a6b00; background: #fffbeb;
  border-radius: 10px;
}

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 330px 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

/* ---------- 日历 ---------- */
.calendar-card, .records-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 16px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-day {
  padding: 9px 0; border-radius: 10px; cursor: pointer;
  transition: all .14s; font-size: 14px; position: relative;
}
.cal-day:hover { background: #eef0fb; }
.cal-day.today { background: #eef0fb; color: var(--primary); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-day.selected { background: var(--grad); color: #fff; font-weight: 700; box-shadow: var(--shadow-md); }
.calendar-card .btn.small { margin-top: 12px; }

/* 统计卡片 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat-item {
  background: #f8f9ff; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 8px; text-align: center; transition: all .18s;
}
.stat-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d9ddf0; }
.stat-num {
  font-size: 26px; font-weight: 800; line-height: 1.1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { font-size: 12px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* ---------- 记录表 ---------- */
.records-card h3 { font-size: 15px; margin-bottom: 4px; }
.records-card h3 .date-chip {
  color: var(--primary); font-weight: 700;
}
.records-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.records-head h3 { margin-bottom: 0; }
.search-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-bar input {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none; width: 230px;
  transition: all .16s;
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.table-wrap { overflow-x: auto; border-radius: 10px; }
.cards-mobile { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f7f8fd; color: var(--muted); font-weight: 600; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f8f9ff; }
/* 已确认工作的高亮行 */
tbody tr.row-confirmed { background: #f0fdf4; }
tbody tr.row-confirmed:hover { background: #dcfce7; }
tbody tr.row-confirmed td:first-child { border-left: 3px solid var(--ok); }
.work-badge.ok { color: var(--ok); font-weight: 600; }
.work-badge.pending { color: var(--warn); font-weight: 600; }
.work-badge { display: inline-flex; align-items: center; gap: 4px; }
td.notes { white-space: normal; min-width: 150px; }
td.empty { text-align: center; color: var(--muted); padding: 36px; }
td.empty .empty-emoji { font-size: 34px; display: block; margin-bottom: 8px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 16px; }
.page-info { color: var(--muted); font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23,26,40,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fadeIn .18s ease;
}
.modal {
  background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: popIn .22s ease;
}
.modal h3 { font-size: 18px; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .form-row.full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 开关 ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: #d3d7e6; border-radius: 24px; transition: .2s;
}
.switch span::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- 新增用户 ---------- */
.add-user { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.add-user input[type="text"] {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
  outline: none; width: 185px; transition: all .16s;
}
.add-user input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.nu-select {
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
  outline: none; background: #fff; color: var(--text); cursor: pointer; transition: all .16s; font-family: inherit;
}
.nu-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
td .nu-select { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--primary); width: 16px; height: 16px; }

/* ---------- 选项管理 ---------- */
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.opt-col h4 { margin: 0 0 12px; font-size: 14px; color: var(--text); }
.opt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.opt-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fafbfe;
}
.opt-val { flex: 1; font-size: 14px; color: var(--text); }
.opt-color-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px; border: 1px solid rgba(0,0,0,.12); }
.opt-color-input {
  width: 34px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; flex: 0 0 34px;
}
.opt-add input[type="color"] {
  flex: 0 0 42px; width: 42px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; background: #fff;
}
.opt-add { display: flex; gap: 8px; }
.opt-add input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; outline: none;
  transition: all .16s;
}
.opt-add input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
@media (max-width: 768px) {
  .opt-grid { grid-template-columns: 1fr; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #2a2f3f; color: #fff; padding: 12px 22px; border-radius: 12px;
  z-index: 200; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  transition: opacity .2s; display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: linear-gradient(135deg, #16a34a, #22c55e); }
.toast.bad { background: linear-gradient(135deg, #dc2626, #ef4444); }

/* ============================================================
   移动端响应式适配
   ============================================================ */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .container { padding: 14px 12px 30px; }

  /* 顶栏 */
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .brand { font-size: 15px; }
  .who { display: none; }
  .top-right { gap: 6px; }
  .top-right .btn { padding: 7px 10px; font-size: 12px; }

  /* 工具栏 */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .hint { text-align: center; }

  /* 登录卡片 */
  .login-card { padding: 32px 22px; }

  /* 弹窗 */
  .modal { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }

  /* 搜索栏 */
  .search-bar input { width: 100%; flex: 1 1 100%; }

  /* 统计卡片字号 */
  .stat-num { font-size: 22px; }

  /* 卡片标题与日期 */
  .card { padding: 16px; }
}

@media (max-width: 560px) {
  /* 移动端：隐藏表格，显示卡片 */
  .table-wrap { display: none; }
  .cards-mobile { display: block; }

  /* 移动端一行卡片 */
  .card-mobile {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
    cursor: pointer; transition: background .12s, transform .12s;
  }
  .card-mobile:active { background: #eef0fb; transform: scale(.99); }
  .card-mobile.row-confirmed { background: #f0fdf4; border-left: 3px solid var(--ok); }
  .card-mobile.row-confirmed:active { background: #bbf7d0; }
  .card-mobile.empty { cursor: default; text-align: center; color: var(--muted); padding: 28px 14px; }
  .card-mobile .empty-emoji { font-size: 32px; display: block; margin-bottom: 8px; }
  .cm-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .cm-main { margin-bottom: 4px; }
  .cm-name { font-weight: 700; font-size: 15px; color: var(--text); }
  .cm-gender { color: var(--muted); font-size: 13px; }
  .cm-age { color: var(--muted); font-size: 13px; }
  .cm-work { font-size: 13px; }

  /* 手机号拨号链接 */
  .phone-link {
    color: var(--primary); font-weight: 600; text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
  }
  .phone-link:active { opacity: .7; }

  /* 详情弹窗列表 */
  .detail-list { display: flex; flex-direction: column; }
  .detail-row {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 10px 0; border-bottom: 1px dashed #eef0f6;
  }
  .detail-row:last-child { border-bottom: none; }
  .detail-label { color: var(--muted); font-size: 13px; flex-shrink: 0; min-width: 72px; }
  .detail-val { font-size: 14px; color: var(--text); text-align: right; word-break: break-all; }

  /* 旧的 td 卡片化规则不再需要，保留兼容但覆盖 */
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 4px 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
    white-space: normal;
  }
  tbody tr.row-confirmed { background: #f0fdf4; border-left: 3px solid var(--ok); }
  tbody tr.row-confirmed td:first-child { border-left: none; }
  tbody tr { transition: background .12s; }
  tbody tr:hover { background: #f8f9ff; }
  tbody tr:active { background: #eef0fb; }
  tbody tr.row-confirmed:hover { background: #dcfce7; }
  tbody tr.row-confirmed:active { background: #bbf7d0; }
  td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 8px 0; border-bottom: 1px dashed #eef0f6; white-space: normal; text-align: right;
  }
  td:last-child { border-bottom: none; }
  td::before {
    content: attr(data-label);
    color: var(--muted); font-weight: 600; font-size: 12px;
    flex-shrink: 0; text-align: left; min-width: 72px;
  }
  td.notes { min-width: 0; }
  td.empty { display: block; text-align: center; padding: 28px 0; }
  td.ops { flex-wrap: wrap; justify-content: flex-end; }
  td.ops::before { display: none; }

  /* 分页居中 */
  .pager { justify-content: center; }

  /* 新增用户表单 */
  .add-user input[type="text"], .add-user .nu-select { width: 100%; flex: 1 1 100%; }
  .add-user .btn { width: 100%; }

  /* 顶栏品牌 */
  .topbar .brand .brand-accent { font-size: 14px; }
}
