/* ============================================
   暖邻长者 · 管理后台样式
   桌面端宽屏布局，克制配色，�� information-dense
   ============================================ */

:root {
  --brand: #FF7A45;
  --brand-light: #FFF1EB;
  --brand-dark: #E85D2A;
  --green: #17A67C;
  --blue: #3B82D6;
  --amber: #E39A16;
  --red: #E0483D;
  --purple: #7C5CE0;

  --ink: #17171B;
  --ink-2: #4A4A55;
  --ink-3: #85858F;
  --ink-4: #B4B4BD;

  --bg: #F4F5F7;
  --panel: #FFFFFF;
  --line: #E8E8ED;
  --line-soft: #F0F0F3;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;

  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 2px 6px rgba(20, 20, 30, 0.06), 0 12px 32px rgba(20, 20, 30, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2B2B33 0%, #3D3A45 50%, #4A4038 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, rgba(255,122,69,0.18), transparent 70%);
  border-radius: 50%;
}
.login-card {
  width: 400px;
  background: var(--panel);
  border-radius: var(--r-lg);
  padding: 44px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FF9A6B, var(--brand));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
  margin-bottom: 22px;
}
.login-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 30px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.login-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  background: #FAFAFB;
  transition: border-color .15s, background .15s;
}
.login-field input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}
.login-btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}
.login-btn:hover { background: var(--brand-dark); }
.login-btn:disabled { background: #FFCDB5; cursor: not-allowed; }
.login-err {
  background: #FEF2F2;
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

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

.sidebar {
  width: 216px;
  background: #1F1F26;
  color: #B8B8C2;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}
.sidebar-logo {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid #2C2C36;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #FF9A6B, var(--brand));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-size: 15px; font-weight: 600; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-group-label {
  font-size: 11px;
  color: #6C6C78;
  padding: 14px 10px 6px;
  letter-spacing: .04em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  color: #B8B8C2;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: #2A2A34; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 9px;
  font-weight: 500;
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid #2C2C36;
  font-size: 12px;
  color: #6C6C78;
}

.main {
  flex: 1;
  margin-left: 216px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-admin { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9A6B, var(--brand));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.link-btn {
  background: none; border: none;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.link-btn:hover { color: var(--red); background: #FEF2F2; }

.content { padding: 24px 28px 48px; flex: 1; }

/* ============ 统计卡片 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--brand);
}
.stat-card.green::after { background: var(--green); }
.stat-card.blue::after { background: var(--blue); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.red::after { background: var(--red); }
.stat-card.purple::after { background: var(--purple); }

.stat-label { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.stat-value .unit { font-size: 15px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.stat-sub { font-size: 12px; color: var(--ink-4); margin-top: 6px; }

/* ============ 面板 ============ */
.panel {
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 20px; }

/* ============ 筛选栏 ============ */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.input, .select {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: #fff;
  color: var(--ink);
}
.input:focus, .select:focus { outline: none; border-color: var(--brand); }
.input.search { width: 220px; }

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  display: flex; align-items: center;
  transition: all .12s;
}
.chip:hover { border-color: var(--ink-4); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  background: #FAFAFB;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:hover { background: #FCFCFD; }
tbody tr:last-child td { border-bottom: none; }

.cell-primary { font-weight: 500; color: var(--ink); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); }
.cell-num { font-variant-numeric: tabular-nums; text-align: right; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #F0F0F2;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--ink-3);
  flex-shrink: 0;
  object-fit: cover;
}
.avatar.brand { background: var(--brand-light); color: var(--brand); }

/* ============ 标签 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-gray { background: #F0F0F3; color: var(--ink-2); }
.badge-orange { background: #FEF4E5; color: #B8750C; }
.badge-blue { background: #EDF4FD; color: #2A6BBF; }
.badge-green { background: #E6F7F1; color: #0F7A5A; }
.badge-red { background: #FEF0EF; color: #C33A30; }
.badge-purple { background: #F2EDFE; color: #6040C0; }

/* ============ 按钮 ============ */
.btn {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s;
}
.btn:hover { border-color: var(--ink-4); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #F5C6C2; }
.btn-danger:hover { background: #FEF0EF; border-color: var(--red); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }

/* ============ 趋势图 ============ */
.trend-chart { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding-top: 16px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.trend-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.trend-bar {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, #FFA176, var(--brand));
  border-radius: 5px 5px 0 0;
  min-height: 4px;
  transition: opacity .15s;
  position: relative;
}
.trend-col:hover .trend-bar { opacity: .82; }
.trend-value {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.trend-label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ============ 分页 ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-3);
}
.page-btns { display: flex; gap: 6px; }

/* ============ 空态与加载 ============ */
.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}
.empty-icon { font-size: 40px; opacity: .4; margin-bottom: 12px; }

.loading { text-align: center; padding: 40px; color: var(--ink-3); font-size: 13px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 28, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  width: 440px;
  max-width: 92vw;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
}
.modal-body { padding: 22px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #FAFAFB;
}
.modal textarea {
  width: 100%;
  height: 96px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.modal textarea:focus { outline: none; border-color: var(--brand); }

/* ============ Toast ============ */
#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: var(--r-sm);
  background: #2A2A33;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
  .sidebar { width: 64px; }
  .sidebar-logo-text, .nav-item span:not(.nav-icon):not(.nav-badge), .nav-group-label { display: none; }
  .main { margin-left: 64px; }
  .nav-item { justify-content: center; }
}