/* 管理后台 — 商业化规范界面 */
:root {
  --admin-sidebar: #0f172a;
  --admin-sidebar-text: #94a3b8;
  --admin-sidebar-active: #ffffff;
  --admin-sidebar-hover: rgba(255, 255, 255, 0.08);
  --admin-accent: #2563eb;
  --admin-accent-2: #3b82f6;
  --admin-danger: #dc2626;
  --admin-page-bg: #f1f5f9;
  --admin-card-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
  --admin-radius: 12px;
  --admin-radius-sm: 8px;
}

.admin-portal {
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--admin-page-bg);
  min-height: 100vh;
}

.admin-app {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* —— 侧栏 —— */
.admin-sidebar {
  width: 260px;
  min-height: 100vh;
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
}

.admin-sidebar-brand {
  padding: 1.35rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-sidebar-brand a {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.admin-sidebar-brand .admin-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--admin-accent-2), var(--admin-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}

.admin-sidebar-sub {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #64748b;
  padding: 1rem 1.25rem 0.35rem;
  font-weight: 600;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  margin: 0.15rem 0.65rem;
  border-radius: var(--admin-radius-sm);
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: transparent;
  width: calc(100% - 1.3rem);
  text-align: left;
}

.admin-nav-link:hover {
  background: var(--admin-sidebar-hover);
  color: #e2e8f0;
}

.admin-nav-link.active {
  background: rgba(37, 99, 235, 0.22);
  color: var(--admin-sidebar-active);
  font-weight: 600;
}

.admin-nav-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.admin-nav-link.active svg {
  opacity: 1;
}

/* 主区 */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.admin-topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
  margin: 0;
}

.admin-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem 0.35rem 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #475569;
}

.admin-user-pill .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, var(--admin-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.admin-content {
  flex: 1;
  padding: 1.5rem 1.5rem 2.5rem;
}

@media (min-width: 992px) {
  .admin-content {
    padding: 1.75rem 2rem 3rem;
  }
}

/* 页面标题区 */
.admin-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

/* 避免标题区左侧标题过长挤占右侧「新增」等按钮 */
.admin-page-header > div:first-child,
.admin-page-header > h1:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.admin-page-header .btn,
.admin-page-header a.btn {
  flex-shrink: 0;
}

.admin-page-header h1,
.admin-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.02em;
}

.admin-page-desc {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
  max-width: 52rem;
  line-height: 1.55;
}

/* 卡片与表格 */
.admin-card {
  background: #fff;
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-card-shadow);
  border: 1px solid rgba(226, 232, 240, 0.9);
  overflow: hidden;
}

.admin-card-body {
  padding: 0;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-portal .table {
  margin-bottom: 0;
  vertical-align: middle;
}

.admin-portal .table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.admin-portal .table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #334155;
  border-color: #f1f5f9;
}

.admin-portal .table tbody tr:hover td {
  background: #fafbfc;
}

.admin-portal .table-secondary td {
  color: #94a3b8;
}

/* 表单卡片 */
.admin-form-card {
  background: #fff;
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-card-shadow);
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 1.75rem 1.75rem 1.5rem;
  max-width: min(100%, 640px);
}

.admin-form-card--wide {
  max-width: min(100%, 920px);
}

/* 与下方列表卡片同宽（如访问记录筛选条） */
.admin-form-card--full {
  max-width: none;
  width: 100%;
  padding: 1.1rem 1.25rem 1rem;
}

.admin-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.75rem;
}

.admin-filter-row .admin-filter-field {
  flex: 1 1 7.5rem;
  min-width: 7rem;
  max-width: 100%;
}

.admin-filter-row .admin-filter-field--time {
  flex: 0 1 11.5rem;
  min-width: 10.5rem;
}

.admin-filter-row .admin-filter-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.admin-filter-row .admin-filter-actions .form-label {
  display: block;
}

@media (max-width: 991.98px) {
  .admin-filter-row .admin-filter-actions {
    margin-left: 0;
    width: 100%;
  }
}

.admin-portal .form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #334155;
}

.admin-portal .form-control,
.admin-portal .form-select {
  border-radius: var(--admin-radius-sm);
  border-color: #cbd5e1;
  padding: 0.5rem 0.85rem;
}

.admin-portal .form-control:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 按钮（管理区内强化） */
.admin-portal .btn {
  border-radius: var(--admin-radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s;
}

.admin-portal .btn:active {
  transform: translateY(1px);
}

.admin-portal .btn-primary {
  background: linear-gradient(135deg, var(--admin-accent-2) 0%, var(--admin-accent) 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.admin-portal .btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.admin-portal .btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.admin-portal .btn-outline-secondary {
  border-color: #cbd5e1;
  color: #475569;
  background: #fff;
}

.admin-portal .btn-outline-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #334155;
}

.admin-portal .btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.admin-portal .btn-outline-primary {
  color: var(--admin-accent);
  border-color: rgba(37, 99, 235, 0.45);
}

.admin-portal .btn-outline-primary:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--admin-accent);
  color: #1d4ed8;
}

.admin-portal .btn-outline-danger {
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--admin-danger);
}

.admin-portal .btn-outline-danger:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: var(--admin-danger);
  color: #b91c1c;
}

/* 表格内操作按钮 */
.admin-table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* 提示条 */
.admin-portal .alert {
  border-radius: var(--admin-radius-sm);
  border: none;
  font-size: 0.9rem;
}

.admin-portal .alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.admin-portal .alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* 控制台统计 */
.admin-stat-section {
  background: #fff;
  border-radius: var(--admin-radius);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: var(--admin-card-shadow);
  padding: 1.1rem 1.2rem 1.25rem;
}

.admin-stat-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.85rem;
  margin-bottom: 0.95rem;
}

.admin-stat-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.admin-stat-section-sub {
  font-size: 0.78rem;
  color: #64748b;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-stat-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 991.98px) {
  .admin-stat-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .admin-stat-grid,
  .admin-stat-grid--4 {
    grid-template-columns: 1fr;
  }
}

.admin-stat-card {
  border-radius: var(--admin-radius-sm);
  background: linear-gradient(160deg, #f8fafc 0%, #eff6ff 100%);
  border: 1px solid rgba(191, 219, 254, 0.7);
  padding: 0.9rem 1rem;
}

.admin-stat-card--arrived {
  background: linear-gradient(160deg, #f8fafc 0%, #ecfdf5 100%);
  border-color: rgba(167, 243, 208, 0.8);
}

.admin-stat-card--left {
  background: linear-gradient(160deg, #f8fafc 0%, #fffbeb 100%);
  border-color: rgba(253, 230, 138, 0.85);
}

.admin-stat-card--duration {
  background: linear-gradient(160deg, #f8fafc 0%, #f5f3ff 100%);
  border-color: rgba(221, 214, 254, 0.85);
}

.admin-stat-label {
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.admin-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.admin-stat-value--sm {
  font-size: 1.35rem;
}

.admin-chart-card {
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--admin-radius-sm);
  padding: 0.75rem 0.85rem 0.5rem;
}

/* 控制台入口卡片 */
.admin-dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.admin-dash-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  background: #fff;
  border-radius: var(--admin-radius);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: var(--admin-card-shadow);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
}

.admin-dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  border-color: rgba(37, 99, 235, 0.25);
  color: inherit;
}

.admin-dash-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--admin-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.35rem;
}

.admin-dash-card-icon.blue {
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  color: var(--admin-accent);
}

.admin-dash-card-icon.slate {
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  color: #475569;
}

.admin-dash-card-icon.amber {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  color: #b45309;
}

.admin-dash-card-icon.emerald {
  background: linear-gradient(135deg, #d1fae5, #ecfdf5);
  color: #047857;
}

.admin-dash-card-icon.violet {
  background: linear-gradient(135deg, #ede9fe, #f5f3ff);
  color: #6d28d9;
}

.admin-dash-card-icon.rose {
  background: linear-gradient(135deg, #ffe4e6, #fff1f2);
  color: #be123c;
}

.admin-dash-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: #0f172a;
}

.admin-dash-card p {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
}

.admin-dash-card.admin-dash-card-highlight {
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

/* 登录页 */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 45%, #1e3a5f 100%);
}

.admin-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  padding: 2.25rem 2rem 2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.admin-login-brand .mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
}

.admin-login-brand h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.35rem;
}

.admin-login-brand p {
  margin: 0;
  font-size: 0.875rem;
  color: #64748b;
}

.admin-login-page .btn-primary {
  padding: 0.65rem 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--admin-accent-2) 0%, var(--admin-accent) 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  border-radius: var(--admin-radius-sm);
}

.admin-login-page .btn-primary:hover {
  filter: brightness(1.06);
}

.admin-login-card .form-control {
  border-radius: var(--admin-radius-sm);
  border-color: #cbd5e1;
  font-size: 0.95rem;
}

.admin-login-card .form-control:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.admin-login-card .form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #334155;
}

.admin-login-card .alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--admin-radius-sm);
}

/* —— 移动端侧栏（自建抽屉，关闭时 hidden → 不参与命中，避免 Bootstrap Offcanvas 挡死整页） —— */
.admin-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.45);
}

.admin-mobile-backdrop[hidden] {
  display: none !important;
}

.admin-mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  width: min(280px, 88vw);
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  box-shadow: 8px 0 32px rgba(15, 23, 42, 0.35);
}

.admin-mobile-drawer[hidden] {
  display: none !important;
}

.admin-mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-mobile-drawer-title {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.admin-mobile-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1.5rem;
}

body.admin-mobile-drawer-open {
  overflow: hidden;
}

/* 桌面端：不依赖 Bootstrap 的 d-lg-none，强制隐藏移动端遮罩与抽屉（避免 hidden 或工具类未生效时整页无法点击） */
@media (min-width: 992px) {
  #adminMobileBackdrop,
  #adminSideMenu {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }
}

/* 移动端：关闭时彻底不参与命中 */
@media (max-width: 991.98px) {
  #adminMobileBackdrop[hidden],
  #adminSideMenu[hidden] {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }
}

.admin-menu-toggle {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: var(--admin-radius-sm);
  padding: 0.4rem 0.65rem;
  color: #475569;
}

.admin-menu-toggle:hover {
  background: #f8fafc;
}

/* 访问记录编辑 — 只读照片横向展示 */
.visit-record-photo-thumb {
  max-height: 220px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
}

/* 访问记录 — 状态标签颜色 */
.vr-status {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.vr-status--pending {
  background: #fef3c7;
  color: #92400e;
}
.vr-status--approved {
  background: #dbeafe;
  color: #1e40af;
}
.vr-status--arrived {
  background: #d1fae5;
  color: #065f46;
}
.vr-status--ended {
  background: #e2e8f0;
  color: #334155;
}
.vr-status--rejected {
  background: #fee2e2;
  color: #991b1b;
}
.vr-status--left {
  background: #f1f5f9;
  color: #475569;
}
.vr-status--cancelled {
  background: #fee2e2;
  color: #b91c1c;
}

/* ���� ��Ա�б�����֯�� + �Ҳ��б� ���� */
.members-org-layout {
  align-items: stretch;
}
.members-org-tree {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
}
.members-org-tree-head {
  padding: 0.85rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.members-org-tree-body {
  overflow: auto;
  padding: 0.5rem 0.35rem 0.75rem;
  flex: 1;
}
.members-tree-all,
.members-tree-company-link,
.members-tree-dept-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-decoration: none;
  color: #334155;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  line-height: 1.3;
}
.members-tree-all:hover,
.members-tree-company-link:hover,
.members-tree-dept-link:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.members-tree-all.active,
.members-tree-company-link.active,
.members-tree-dept-link.active {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-weight: 600;
}
.members-tree-all {
  margin: 0 0.25rem 0.35rem;
  font-weight: 600;
}
.members-tree-company {
  margin-bottom: 0.35rem;
}
.members-tree-company-link {
  font-weight: 600;
}
.members-tree-depts {
  list-style: none;
  margin: 0.15rem 0 0.25rem;
  padding: 0 0 0 0.85rem;
  border-left: 2px solid #e2e8f0;
  margin-left: 0.85rem;
}
.members-tree-depts li {
  margin: 0;
}
.members-tree-dept-link {
  font-size: 0.86rem;
  color: #475569;
}
.members-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.members-tree-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  min-width: 1.5rem;
  text-align: center;
}
.members-tree-company-link.active .members-tree-count,
.members-tree-dept-link.active .members-tree-count,
.members-tree-all.active + .members-tree-count {
  background: rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
}
@media (max-width: 991.98px) {
  .members-org-tree {
    position: static;
    max-height: 16rem;
    margin-bottom: 0.25rem;
  }
}
