:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --sidebar: #1f2440;
  --sidebar-hover: #2c3257;
  --primary: #6d5ce7;
  --primary-dark: #5a49d6;
  --primary-light: #efedff;
  --text: #23263a;
  --text-2: #6b6f83;
  --text-3: #9a9eb0;
  --border: #e8e9f0;
  --green: #2fae7a;
  --green-bg: #e6f7ef;
  --blue: #3b82f6;
  --blue-bg: #e8f1ff;
  --amber: #e8962c;
  --amber-bg: #fdf3e4;
  --red: #dc4c4c;
  --red-bg: #fdecec;
  --shadow: 0 1px 3px rgba(30, 34, 60, .06), 0 6px 18px rgba(30, 34, 60, .04);
  --radius: 12px;
}

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

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

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.layout { display: flex; min-height: 100vh; }

/* ============ 侧边栏 ============ */
.sidebar {
  width: 232px;
  flex: none;
  background: var(--sidebar);
  color: #c9cce0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 20px 28px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #7c6cf0, #5a49d6);
  display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #fff; font-size: 15px; font-weight: 600; }
.brand-text span { font-size: 11px; color: #8f93b0; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border: 0; border-radius: 9px;
  background: transparent; color: #b9bdd4; cursor: pointer;
  font-size: 14px; text-align: left; font-family: inherit;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(109, 92, 231, .35); }
.nav-item svg { width: 19px; height: 19px; }

.sidebar-footer { padding: 16px; }
.tip-card {
  background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 14px;
}
.tip-title { color: #eceefb; font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
.tip-desc { color: #979bb8; font-size: 11px; line-height: 1.55; margin-bottom: 10px; }
.tip-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tip-actions .btn { flex: 1 1 auto; }
.db-status { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #b9bdd4; margin-top: 4px; }
.db-dot { width: 7px; height: 7px; border-radius: 50%; background: #e8962c; display: inline-block; flex: none; }
.db-dot.online { background: #43d18a; }
.db-dot.offline { background: #e05a5a; }
.btn-ghost { background: rgba(255,255,255,.1); color: #e4e6f5; border: 1px solid rgba(255,255,255,.14); }
.btn-ghost:hover { background: rgba(255,255,255,.18); }

/* ============ 主区域 ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 76px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 30px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-left h1 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.topbar-left p { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.today-badge {
  display: flex; align-items: center; gap: 7px; color: var(--text-2);
  font-size: 12.5px; background: var(--bg); padding: 8px 12px; border-radius: 8px;
}
.today-badge svg { width: 15px; height: 15px; }
.content { padding: 24px 30px 40px; flex: 1; }

.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-family: inherit; cursor: pointer; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-text { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn-text:hover { background: var(--primary-light); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fbdada; }
.btn-light { background: var(--bg); color: var(--text-2); border-color: var(--border); }
.btn-light:hover { background: #ebecf3; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }

/* ============ 首页 ============ */
.birthday-banner {
  display: flex; gap: 20px; align-items: flex-start;
  background: linear-gradient(110deg, #fff5f8 0%, #fef8f3 55%, #fff 100%);
  border: 1px solid #f6e2ea; border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.birthday-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, #ff8fa8, #f5678f); color: #fff;
  display: grid; place-items: center;
}
.birthday-icon svg { width: 28px; height: 28px; stroke-width: 1.6; }
.birthday-content { flex: 1; min-width: 0; }
.birthday-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.birthday-heading h2 { font-size: 16px; font-weight: 600; }
.birthday-count { background: #f5678f; color: #fff; font-size: 11px; padding: 2px 9px; border-radius: 20px; }
.birthday-list { display: flex; flex-wrap: wrap; gap: 10px; }
.birthday-chip {
  display: flex; align-items: center; gap: 9px; background: #fff;
  border: 1px solid #f3d9e3; border-radius: 9px; padding: 8px 12px;
}
.birthday-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 500; flex: none;
}
.birthday-chip .b-name { font-weight: 500; font-size: 13px; }
.birthday-chip .b-meta { font-size: 11px; color: var(--text-3); }
.birthday-empty { color: var(--text-3); font-size: 13px; padding: 8px 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 18px 20px;
  display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat-icon svg { width: 21px; height: 21px; }
.s-purple { background: var(--primary-light); color: var(--primary); }
.s-green { background: var(--green-bg); color: var(--green); }
.s-blue { background: var(--blue-bg); color: var(--blue); }
.s-gray { background: #f0f1f5; color: #8b8fa3; }
.stat-info { display: flex; flex-direction: column; }
.stat-info span { font-size: 12px; color: var(--text-3); }
.stat-info strong { font-size: 24px; font-weight: 600; line-height: 1.2; margin-top: 2px; }

/* ============ 面板 / 表格 ============ */
.panel { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { font-size: 15px; font-weight: 600; }
.section-title { display: flex; align-items: center; gap: 10px; }
.section-title span { font-size: 12px; color: var(--text-3); background: var(--bg); padding: 3px 9px; border-radius: 20px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 12px 20px; color: var(--text-3); font-weight: 500; font-size: 12px;
  background: #fafbfe; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 13px 20px; border-bottom: 1px solid #f1f2f7; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafaff; }
.data-table .cell-name { font-weight: 500; }
.data-table .cell-muted { color: var(--text-2); }
.data-table .cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-row td { text-align: center; color: var(--text-3); padding: 36px 20px; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; height: 36px; min-width: 240px;
}
.search-box svg { width: 16px; height: 16px; color: var(--text-3); }
.search-box input { border: 0; outline: 0; background: transparent; font-size: 13px; font-family: inherit; width: 100%; color: var(--text); }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 9px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-booked { background: var(--amber-bg); color: var(--amber); }
.tag-arrived { background: var(--green-bg); color: var(--green); }
.tag-cancelled { background: #f0f1f5; color: #8b8fa3; }
.tag-active { background: var(--green-bg); color: var(--green); }
.tag-inactive { background: #f0f1f5; color: #8b8fa3; }
.tag-birthday { background: #fdeaf0; color: #e0507d; }

/* ============ 预约看板 ============ */
.board-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-input {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; height: 34px;
}
.board-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.board-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-booked { background: var(--amber); }
.dot-arrived { background: var(--green); }
.dot-cancelled { background: #b6b9c8; }

.board-wrap { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 210px); }
.board { display: grid; min-width: 640px; }
.board-corner, .board-staff-head {
  position: sticky; top: 0; z-index: 5; background: #fafbfe;
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 12px; text-align: center; font-size: 13px; font-weight: 600; min-height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.board-staff-head .staff-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.board-time {
  border-bottom: 1px solid #f1f2f7; border-right: 1px solid var(--border);
  padding: 8px 10px 0; font-size: 11.5px; color: var(--text-3); text-align: right;
  height: 64px; position: relative;
}
.board-cell {
  border-bottom: 1px solid #f1f2f7; border-right: 1px solid #f4f5f9;
  height: 64px; position: relative; padding: 4px;
}
.board-cell { cursor: pointer; }
.board-cell:hover { background: #f3f1ff; }
.board-cell:not(.has-appt):hover::after {
  content: '+'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); color: var(--primary);
  font-size: 20px; font-weight: 400; opacity: .45; line-height: 1;
  pointer-events: none;
}
.appt-card {
  position: absolute; left: 5px; right: 5px; border-radius: 7px; padding: 6px 9px;
  cursor: pointer; overflow: hidden; border-left: 3px solid;
  transition: transform .1s, box-shadow .1s; font-size: 11.5px;
}
.appt-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,34,60,.12); z-index: 3; }
.appt-card.booked { background: var(--amber-bg); border-color: var(--amber); }
.appt-card.arrived { background: var(--green-bg); border-color: var(--green); }
.appt-card.cancelled { background: #f2f3f7; border-color: #b6b9c8; opacity: .72; }
.appt-card.cancelled .appt-name { text-decoration: line-through; }
.appt-name { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.appt-service { color: var(--text-2); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-time { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.board-empty { padding: 50px 20px; text-align: center; color: var(--text-3); }

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(22, 25, 45, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close { border: 0; background: transparent; color: var(--text-3); cursor: pointer; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.form-field label .req { color: var(--red); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,92,231,.12);
}
.form-field textarea { resize: vertical; min-height: 68px; }
.form-hint { font-size: 11px; color: var(--text-3); }

.confirm-text { font-size: 14px; color: var(--text-2); line-height: 1.7; }
.confirm-text strong { color: var(--text); }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #23263a; color: #fff; padding: 11px 20px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .sidebar { width: 68px; }
  .brand-text, .nav-item span, .sidebar-footer { display: none; }
  .brand { justify-content: center; padding: 20px 0 26px; }
  .nav-item { justify-content: center; padding: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px; }
  .topbar { padding: 0 20px; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-left p { display: none; }
  .today-badge { display: none; }
}

/* ============ 登录 ============ */
.login-mask {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #20254a 0%, #3a3170 55%, #6d5ce7 100%);
  padding: 20px;
}
.login-mask[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  padding: 38px 36px 26px; box-shadow: 0 24px 60px rgba(15, 12, 45, .35);
}
.login-brand { text-align: center; margin-bottom: 30px; }
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #8d7ff0); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; letter-spacing: 1px;
}
.login-brand h1 { font-size: 22px; color: var(--text); margin-bottom: 4px; }
.login-brand p { font-size: 13px; color: var(--text-3); }
.login-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 16px 0 7px; }
.login-input-wrap {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 13px;
  border: 1px solid var(--border); border-radius: 10px; background: #fafbfe;
  transition: border-color .2s, box-shadow .2s;
}
.login-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-input-wrap svg { width: 17px; height: 17px; color: var(--text-3); }
.login-input-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text); font-family: inherit;
}
.login-remember { display: flex; align-items: center; gap: 7px; margin: 16px 0 0; font-size: 13px; color: var(--text-2); cursor: pointer; }
.login-remember input { accent-color: var(--primary); cursor: pointer; }
.login-error {
  margin-top: 14px; padding: 9px 12px; border-radius: 8px;
  background: var(--red-bg); color: var(--red); font-size: 13px;
}
.login-error[hidden] { display: none; }
.login-submit {
  width: 100%; height: 46px; margin-top: 22px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; letter-spacing: 2px; transition: background .2s, opacity .2s;
}
.login-submit:hover { background: var(--primary-dark); }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }
.login-foot { text-align: center; margin-top: 22px; font-size: 12px; color: var(--text-3); }

.logout-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 10px;
  padding: 10px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px;
  background: rgba(255,255,255,.05); color: #b9bdd6; font-size: 13px;
  cursor: pointer; transition: background .2s, color .2s;
}
.logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.logout-btn svg { width: 16px; height: 16px; }

@media (max-width: 900px) {
  .logout-btn { justify-content: center; }
  .logout-btn span { display: none; }
}
