:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --shadow: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.12), 0 8px 10px -6px rgba(0,0,0,.06);
  --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.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); font-size: 13px; }
.req { color: var(--danger); }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all .18s;
  background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-mini { padding: 5px 10px; font-size: 12px; background: var(--primary-light); color: var(--primary); border-color: transparent; }
.btn-mini.danger { background: var(--danger-light); color: var(--danger); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer; transition: all .18s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-light); }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f1f5f9 50%, #e0e7ff 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 880px; background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-lg); overflow: hidden; display: grid; grid-template-columns: 1fr 1fr;
}
.login-brand {
  background: linear-gradient(160deg, #4f46e5 0%, #3730a3 100%); color: #fff;
  padding: 56px 44px; display: flex; flex-direction: column; align-items: flex-start;
}
.brand-icon {
  width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.18); margin-bottom: 28px;
}
.brand-icon .ico { width: 30px; height: 30px; }
.brand-icon.sm { width: 38px; height: 38px; border-radius: 10px; margin: 0; background: var(--primary); }
.brand-icon.sm .ico { width: 21px; height: 21px; }
.login-brand h1 { font-size: 32px; font-weight: 700; letter-spacing: 1px; }
.login-brand > p { margin-top: 8px; opacity: .85; font-size: 15px; }
.brand-features { list-style: none; margin-top: 40px; display: grid; gap: 16px; }
.brand-features li { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: .95; }
.brand-features .ico { width: 18px; height: 18px; color: #a5f3fc; }
.login-form { padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { font-size: 24px; margin-bottom: 28px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; font-family: inherit; transition: border-color .18s, box-shadow .18s;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 4px; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.8; }

/* ============ 主框架 ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30;
}
.side-brand {
  height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 22px;
  border-bottom: 1px solid var(--border); font-size: 18px; font-weight: 700;
}
.side-nav { flex: 1; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px;
  border: none; border-radius: 9px; background: transparent; color: var(--muted);
  font-size: 14px; font-family: inherit; cursor: pointer; transition: all .15s; text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item.logout { color: var(--muted); }
.nav-item.logout:hover { background: var(--danger-light); color: var(--danger); }
.side-footer { border-top: 1px solid var(--border); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 8px 14px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}
.avatar.xs { width: 28px; height: 28px; font-size: 12px; }
.user-meta { min-width: 0; display: flex; flex-direction: column; }
.user-meta strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-overlay { display: none; }
.main-wrap { flex: 1; margin-left: 236px; min-width: 0; }
.topbar {
  height: 68px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 20px; font-weight: 600; flex-shrink: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 9px;
  padding: 0 12px; height: 38px; color: var(--muted);
}
.search-box input { border: none; background: none; outline: none; font-size: 13px; font-family: inherit; width: 180px; color: var(--text); }
.menu-btn { display: none; }
.content { padding: 26px 28px 60px; max-width: 1280px; margin: 0 auto; }

/* ============ 工具栏 & 统计 ============ */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ============ 日程卡片 ============ */
.schedule-list { display: flex; flex-direction: column; gap: 12px; }
.schedule-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; gap: 18px; align-items: flex-start; box-shadow: var(--shadow);
  transition: border-color .18s, transform .18s;
}
.schedule-card:hover { border-color: #c7d2fe; transform: translateY(-1px); }
.schedule-card.cancelled { opacity: .6; }
.schedule-card.cancelled h3 { text-decoration: line-through; }
.sc-date {
  width: 74px; flex-shrink: 0; text-align: center; background: var(--primary-light);
  border-radius: 9px; padding: 8px 4px; color: var(--primary);
}
.sc-day { display: block; font-size: 13px; font-weight: 600; }
.sc-time { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; }
.sc-main { flex: 1; min-width: 0; }
.sc-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sc-head h3 { font-size: 16px; font-weight: 600; }
.sc-end { font-size: 12px; color: var(--muted); }
.sc-desc { color: var(--muted); font-size: 13px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.sc-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.attendees { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.attendee { background: var(--bg); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.sc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.section-title { font-size: 15px; color: var(--muted); margin: 28px 0 12px; }
.empty {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 60px 20px; text-align: center; color: var(--muted);
}
.empty .ico { width: 40px; height: 40px; opacity: .4; margin-bottom: 12px; }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px;
  background: var(--bg); color: var(--muted); font-size: 12px; white-space: nowrap;
}
.badge.bell { background: var(--warn-light); color: var(--warn); }
.badge.bell .ico { width: 12px; height: 12px; }
.badge.ok { background: var(--success-light); color: var(--success); }
.badge.off { background: var(--bg); color: var(--muted); }
.badge.all { background: var(--primary-light); color: var(--primary); }

/* ============ 表格 ============ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 13px 16px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
.cell-user { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.ops { display: flex; gap: 6px; }
.ops .icon-btn { width: 30px; height: 30px; }

/* ============ 角色卡片 ============ */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.role-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.role-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.role-head h3 { font-size: 16px; }
.role-name { display: inline-block; background: var(--bg); padding: 2px 8px; border-radius: 5px; font-size: 12px; color: var(--primary); }
.role-card p { margin: 12px 0; }
.role-perms { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; min-height: 28px; }
.role-perms .badge { font-size: 11px; }
.role-ops { display: flex; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }

/* ============ 表单 ============ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
  transition: border-color .18s, box-shadow .18s; font-weight: 400;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input:disabled { background: var(--bg); color: var(--muted); }
.form-group textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.flex1 { flex: 1; }
.voice-btn { height: 42px; width: 46px; color: var(--primary); }
.voice-btn.listening { background: var(--danger-light); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.check-chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 400; transition: all .15s;
}
.check-chip:hover { border-color: var(--primary); }
.check-chip:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.check-chip input { accent-color: var(--primary); }
.check-chip small { display: block; font-size: 11px; color: var(--muted); }
.reminder-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.reminder-head label { font-size: 13px; font-weight: 500; }
.reminder-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.reminder-row select { width: 100px; padding: 8px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 13px; }
.r-before, .r-at { display: flex; align-items: center; gap: 6px; flex: 1; font-size: 13px; color: var(--muted); }
.r-before input { width: 80px; padding: 8px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; }
.r-at input { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; }
.r-del { width: 30px; height: 30px; }
.perm-group { margin-bottom: 16px; }
.perm-group h4 { font-size: 13px; color: var(--primary); margin-bottom: 8px; }

/* ============ 冲突提示 ============ */
.conflict-box {
  background: var(--warn-light); border: 1px solid #fcd34d; border-radius: 9px;
  padding: 12px 14px; margin-bottom: 16px; color: #92400e; font-size: 13px;
}
.conflict-box strong { display: flex; align-items: center; gap: 6px; }
.conflict-box .ico { width: 16px; height: 16px; }
.conflict-box ul, .conflict-list { margin: 8px 0 0 18px; }
.conflict-box li, .conflict-list li { margin-bottom: 4px; }
.confirm-msg { font-size: 14px; line-height: 1.8; }
.confirm-msg ul { margin-left: 18px; }

/* ============ 模态框 ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 600px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slideUp .2s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ============ Toast ============ */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--success);
  padding: 12px 16px; border-radius: 9px; box-shadow: var(--shadow-lg);
  font-size: 13px; min-width: 240px; max-width: 360px; animation: toastIn .25s;
}
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .3s; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .login-card { grid-template-columns: 1fr; max-width: 460px; }
  .login-brand { padding: 32px; }
  .login-brand h1 { font-size: 26px; }
  .brand-features { margin-top: 24px; grid-template-columns: 1fr 1fr; gap: 10px; }
  .login-form { padding: 32px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 25; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .topbar h1 { font-size: 18px; }
  .search-box input { width: 100px; }
  .content { padding: 18px 14px 50px; }
  .stats-row { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-num { font-size: 22px; }
  .schedule-card { gap: 12px; padding: 14px; }
  .sc-date { width: 60px; }
  .sc-time { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  #toast-root { left: 14px; right: 14px; top: 14px; }
  .toast { max-width: none; min-width: 0; }
}
@media (max-width: 480px) {
  .search-box { display: none; }
  .toolbar-left { width: 100%; flex-wrap: wrap; }
  .toolbar-left .btn { flex: 1 1 calc(50% - 5px); min-width: 120px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { display: none; }
  .schedule-card { flex-wrap: wrap; }
  .sc-actions { margin-left: auto; }
  .check-grid { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: 16px 16px 0 0; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 14px 18px; }
  .reminder-row { flex-wrap: wrap; }
}
