:root {
  --primary: #2B6CB0;
  --primary-light: #4299E1;
  --bg: #F4F6F9;
  --card-bg: #FFFFFF;
  --text: #1A202C;
  --text-muted: #718096;
  --border: #E2E8F0;
  --danger: #E53E3E;
  --success: #38A169;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ---------- 登录页 ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #2B6CB0 0%, #4299E1 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  max-width: 360px;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.qr-box {
  width: 220px;
  height: 220px;
  margin: 0 auto 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-loading {
  color: var(--text-muted);
  font-size: 13px;
}

.qr-box.expired {
  position: relative;
}

.qr-expired-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-tip {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title .logo {
  font-size: 22px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-badge {
  background: #EBF8FF;
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-ghost:hover {
  background: var(--bg);
}

/* ---------- 主内容 ---------- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.quick-btns {
  display: flex;
  gap: 8px;
}

.btn-quick {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-quick:hover {
  background: var(--bg);
}

.btn-quick.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.range-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-sep {
  color: var(--text-muted);
  font-size: 13px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.select-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 7px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--primary-light);
}

/* ---------- 汇总卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}

.card-primary {
  border-left: 4px solid var(--primary);
}

.card-warn {
  border-left: 4px solid var(--danger);
}

.card-warn .card-value {
  color: var(--danger);
}

/* ---------- 列表容器（临期提醒 / 跟进事件） ---------- */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

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

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.list-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.list-item-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-tag {
  background: #EBF8FF;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.list-tag.danger {
  background: #FFF5F5;
  color: var(--danger);
}

.list-tag-risk {
  background: #FEF3C7;
  color: #B45309;
}

/* 一人多类型：额外的人员类型标签（紫色系，区别于风险级别标签） */
.list-tag-type {
  background: #F3E8FF;
  color: #7C3AED;
}

.list-item-days {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.list-item-days.danger {
  color: var(--danger);
}

/* 旧日期选择栏兼容（保留引用） */
.date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.btn-date {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
  line-height: 1;
}

.btn-date:hover {
  background: var(--bg);
}

.date-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
}

.loading {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- 汇总卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}

.card-primary {
  border-left: 4px solid var(--primary);
}

.card-label {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.card-unit {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ---------- 图表 ---------- */
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}

.chart-wide {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart {
  width: 100%;
  height: 320px;
}

/* ---------- 下钻明细 ---------- */
.drill-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
}

.drill-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drill-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.drill-group-head {
  background: #F7FAFC;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.drill-group-head:hover {
  background: #EDF2F7;
}

.drill-count {
  color: var(--primary);
  font-weight: 700;
}

.drill-body {
  padding: 8px 16px 12px;
}

.drill-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.drill-row:last-child {
  border-bottom: none;
}

.drill-row-name {
  flex: 1;
  color: var(--text);
}

.drill-row-bar {
  width: 200px;
  height: 14px;
  background: #EDF2F7;
  border-radius: 7px;
  margin: 0 16px;
  overflow: hidden;
}

.drill-row-bar-fill {
  height: 100%;
  background: var(--primary-light);
  border-radius: 7px;
  transition: width 0.3s;
}

.drill-row-num {
  width: 40px;
  text-align: right;
  font-weight: 600;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
  .charts {
    grid-template-columns: 1fr;
  }
  .chart-wide {
    grid-column: 1;
  }
}

/* ---------- 可点击条目 ---------- */
.list-item-clickable {
  cursor: pointer;
  transition: background 0.15s;
}

.list-item-clickable:hover {
  background: #F7FAFC;
  border-color: var(--primary-light);
}

.drill-row-clickable {
  cursor: pointer;
  transition: background 0.15s;
}

.drill-row-clickable:hover {
  background: #F7FAFC;
}

.drill-count {
  cursor: pointer;
  transition: color 0.15s;
}

.drill-count:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

/* ---------- 卡片标题行（标题 + 内联筛选） ---------- */
.chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title-row .chart-title {
  margin-bottom: 0;
}

.select-sm {
  padding: 4px 10px;
  font-size: 13px;
}

/* ---------- 明细弹层 ---------- */
.detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.detail-dialog {
  background: var(--card-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-title {
  font-size: 16px;
  font-weight: 600;
}

.detail-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.detail-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

.detail-count {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* 列表模式条目 */
.detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.detail-item:hover {
  background: #F7FAFC;
  border-color: var(--primary-light);
}

.detail-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.detail-item-event {
  font-weight: 600;
}

.detail-item-sub {
  color: var(--text-muted);
  font-size: 13px;
}

.detail-item-arrow {
  color: var(--primary);
  font-size: 13px;
  white-space: nowrap;
}

/* 详情模式 */
.detail-full {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-field {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.detail-field-label {
  flex-shrink: 0;
  width: 80px;
  color: var(--text-muted);
  font-size: 14px;
  padding-top: 1px;
}

.detail-field-value {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-photo {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

/* ===== 备案页脚（ICP 备案 + 公安联网备案，全站固定底部） ===== */
.beian-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  text-align: center;
  padding: 8px 12px;
  background: #F7F8FA;
  border-top: 1px solid #E5E7EB;
  font-size: 12px;
  color: #6B7280;
  line-height: 1.6;
}
.beian-footer a {
  color: #6B7280;
  text-decoration: none;
}
.beian-footer a:hover {
  color: #2B6CB0;
  text-decoration: underline;
}
.beian-sep {
  margin: 0 10px;
  color: #D1D5DB;
}

/* 主内容区底部留白，避免被固定备案页脚遮挡 */
.main {
  padding-bottom: 56px;
}
