:root {
  /* ============ 苹果风格配色：纯净黑白灰 ============ */
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-secondary: #f5f5f7;
  --surface-tertiary: #fafafa;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --text: #1d1d1f;
  --text-secondary: #424245;
  --text-muted: #86868b;
  --text-faint: #aeaeb2;

  /* 侧边栏：苹果深灰，非纯黑 */
  --sidebar-bg: #1d1d1f;
  --sidebar-hover: #2c2c2e;
  --sidebar-active: #0071e3;

  /* 链接/强调色：苹果蓝 */
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-light: #e8f1fd;

  /* 状态色：低饱和，融入整体 */
  --green: #1d8a57;
  --green-bg: #e3f6ec;
  --red: #d24545;
  --red-bg: #fdecec;
  --amber: #b8842a;
  --amber-bg: #fbf3e0;
  --gray-bg: #f5f5f7;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.08);

  /* 苹果字体栈 */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { color: #f5f5f7; font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand-sub { font-size: 10px; color: #6e6e73; letter-spacing: 0.5px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
  flex: 1;
}
.nav-group {
  font-size: 11px;
  color: #6e6e73;
  padding: 8px 12px 6px;
  font-weight: 400;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: #d2d2d7;
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.2s ease;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #f5f5f7;
}
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 11px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #3a3a3c;
  color: #f5f5f7;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #f5f5f7; font-weight: 500; font-size: 13px; }
.user-role { font-size: 11px; color: #6e6e73; }
.logout-btn {
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: 9px;
  color: #ff6b6b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: background 0.2s;
}
.logout-btn:hover { background: rgba(255,107,107,0.12); }

.main { flex: 1; min-width: 0; background: var(--bg); }
.content { padding: 40px 48px; max-width: 1320px; }
.content.standalone { max-width: 440px; margin: 0 auto; padding: 12vh 24px 48px; }

/* ============ 页面标题：苹果式大标题 + 细描述 ============ */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.page-title {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text);
}
.page-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin: 6px 0 0;
  font-weight: 400;
}

/* ============ 提示条 ============ */
.flash {
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 400;
}
.flash.success { background: var(--green-bg); color: #0a6b3e; }
.flash.error { background: var(--red-bg); color: #9b2c2c; }

/* ============ 统计卡片：苹果式纯净大数字 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 10px;
  display: block;
}
.stat-value {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1;
}
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.indigo .stat-value { color: var(--primary); }

/* ============ 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-head {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-light);
}
.card-head h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.card-head-hint {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}
.card-body { padding: 28px; }

/* ============ 表单：苹果式极简 ============ */
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}
input, select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s;
  font-family: inherit;
  width: 100%;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  align-items: end;
}

/* 让每个表单字段内部对齐一致 */
.grid-form > label,
.grid-form > div {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.grid-form .form-actions {
  align-self: end;       /* 按钮与其他输入框底部对齐 */
  padding-bottom: 0;
}

/* 日期输入框：保证完整显示 + 占位符格式 */
input[type="date"] {
  min-width: 150px;
  font-family: inherit;
  text-align: left;
}
input[type="date"]::-webkit-datetime-edit {
  color: var(--text);
  text-align: left;
}
input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}
/* 未选日期时的占位文字 */
input[type="date"]::-webkit-datetime-edit-year-field,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field {
  color: var(--text-faint);
}
input[type="date"]::-webkit-datetime-edit-year-field:focus,
input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus {
  color: var(--primary);
}
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-clear-button {
  display: none;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  padding: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* 日期时间输入框（精确到时分秒） */
input[type="datetime-local"] {
  min-width: 220px;
  font-family: inherit;
  text-align: left;
}
input[type="datetime-local"]::-webkit-datetime-edit {
  color: var(--text);
  text-align: left;
}
input[type="datetime-local"]::-webkit-inner-spin-button {
  display: none;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  padding: 4px;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* 表单字段下方的小提示 */
.field-hint {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
  margin-top: 2px;
  text-align: left;
  line-height: 1.3;
}
.stack-form { display: flex; flex-direction: column; gap: 18px; }
.form-actions { display: flex; gap: 10px; }

/* ============ 按钮：苹果蓝胶囊 ============ */
button, .btn {
  padding: 11px 22px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  font-family: inherit;
  transition: all 0.2s ease;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:active { transform: scale(0.98); }
button:disabled { background: var(--border); cursor: not-allowed; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b83838; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #167a4d; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-secondary); }
.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline-primary:hover { background: var(--primary-light); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  padding: 16px 28px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
th {
  background: var(--surface-secondary);
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: var(--surface-tertiary); }
.strong { font-weight: 500; color: var(--text); }
.muted { color: var(--text-muted); }
.mono {
  font-family: "SF Mono", SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============ 徽章：低调药丸 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: #0a6b3e; }
.badge-red { background: var(--red-bg); color: #9b2c2c; }
.badge-amber { background: var(--amber-bg); color: #8a6420; }
.badge-gray { background: var(--gray-bg); color: #515154; }
.badge-indigo { background: var(--primary-light); color: #0058b0; }

/* ============ 操作区 ============ */
.actions { display: inline-flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.inline { display: inline-flex; align-items: center; }

/* ============ 弹窗 ============ */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  min-width: 380px;
  max-width: 90vw;
  /* 居中定位 */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.modal[open] {
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
.modal::backdrop { background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
}
.modal-body { padding: 24px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-secondary);
}

/* ============ 登录页：苹果式居中极简 ============ */
.login-box {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
}
.login-logo {
  text-align: center;
  font-size: 48px;
  margin-bottom: 16px;
}
.login-title {
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.022em;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  margin: 8px 0 32px;
  font-weight: 400;
}
.login-box form { display: flex; flex-direction: column; gap: 18px; }
.login-box label { gap: 8px; }
.login-box button { margin-top: 8px; padding: 13px; font-size: 16px; }

/* ============ token 显示 ============ */
.token-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-secondary);
  border-radius: 10px;
  padding: 8px 12px;
  max-width: 300px;
}
.token-box code {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
  flex: 1;
  color: var(--text-secondary);
}

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
  font-size: 15px;
}

.hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--surface-secondary);
  border-radius: var(--radius);
  line-height: 1.5;
}

/* ============ 密码切换 ============ */
.input-with-toggle {
  position: relative;
}
.input-with-toggle input {
  width: 100%;
  padding-right: 38px;
}
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  user-select: none;
  font-size: 16px;
  opacity: 0.45;
  line-height: 1;
}
.toggle-password:hover { opacity: 1; }

@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .brand-text, .nav-group, .sidebar-nav a span:last-child, .user-meta, .logout-btn { display: none; }
  .content { padding: 24px; }
  .page-title { font-size: 26px; }
}

/* ============ 日期选择器 ============ */
input.datepicker {
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'></rect><line x1='16' y1='2' x2='16' y2='6'></line><line x1='8' y1='2' x2='8' y2='6'></line><line x1='3' y1='10' x2='21' y2='10'></line></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}
input.datepicker:focus {
  cursor: text;
}

.dtp-panel {
  position: absolute;
  z-index: 9999;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
}
.dtp-panel.dtp-open {
  opacity: 1;
  transform: translateY(0);
}

.dtp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.dtp-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dtp-nav {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 6px;
  line-height: 1;
  box-shadow: none;
}
.dtp-nav:hover {
  background: var(--surface-secondary);
  transform: none;
  box-shadow: none;
}

.dtp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.dtp-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  padding: 4px 0;
}

.dtp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dtp-day {
  background: none;
  border: none;
  padding: 7px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 7px;
  font-family: inherit;
  font-weight: 400;
  box-shadow: none;
  transition: background 0.12s;
}
.dtp-day:hover {
  background: var(--primary);
  color: #fff;
  transform: none;
  box-shadow: none;
}
.dtp-empty { visibility: hidden; }
.dtp-today-cell {
  font-weight: 600;
  color: var(--primary);
}
.dtp-today-cell:hover { color: #fff; }
.dtp-selected {
  background: var(--primary);
  color: #fff !important;
}

.dtp-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  gap: 8px;
}

/* 时间选择行 */
.dtp-time-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}
.dtp-time-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 6px;
  white-space: nowrap;
}
.dtp-time-row select {
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  width: auto;
  cursor: pointer;
}
.dtp-colon {
  font-size: 13px;
  color: var(--text-muted);
}
.dtp-footer button {
  flex: 1;
  background: var(--surface-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 7px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 400;
  box-shadow: none;
}
.dtp-footer button:hover {
  background: var(--surface-secondary);
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}
