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

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tabular-nums,
.stat-value,
.badge-count {
  font-variant-numeric: tabular-nums;
}

.page-bg-glow {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, 100vw);
  height: 360px;
  background: radial-gradient(circle, rgba(23, 100, 237, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.portal-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* 顶部导航与主题切换 */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(23, 100, 237, 0.28);
  flex-shrink: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 按钮通用规范：min-height 44px 保障触控体验 */
.btn,
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(23, 100, 237, 0.24);
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: #ffffff;
}

.btn-danger {
  color: var(--danger-color);
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--danger-bg);
}

.btn-danger:hover,
.btn-danger.confirming {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: #ffffff;
}

.btn-sm {
  min-height: 44px;
  padding: 0 13px;
  font-size: 14px;
}

/* 主视觉卡片与统计栏 */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.hero-title {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.owner-line {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-value.online {
  color: var(--status-online);
}

.stat-value.building {
  color: var(--status-building);
}

/* 搜索与筛选栏 */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(130px, 1fr) minmax(130px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
}

.form-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-card);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-soft);
}

textarea.form-control {
  min-height: 88px;
  resize: vertical;
}

.fav-filter-btn[ aria-pressed="true" ] {
  background: var(--fav-bg);
  border-color: var(--fav-color);
  color: var(--text-primary);
}

/* 新增/编辑子站表单面板 */
.editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.editor-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.form-grid-5 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.span-2 {
  grid-column: span 2;
}

.form-field.span-3 {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.feedback-banner {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: none;
}

.feedback-banner.show {
  display: block;
}

.feedback-banner.ok {
  background: var(--status-online-bg);
  color: var(--status-online);
}

.feedback-banner.err {
  background: var(--danger-bg);
  color: var(--danger-color);
}

/* 子站卡片网格 */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.site-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(23, 100, 237, 0.35);
}

.site-card.is-favorite {
  border-color: rgba(245, 158, 11, 0.55);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.badge-online {
  background: var(--status-online-bg);
  color: var(--status-online);
}

.badge-building {
  background: var(--status-building-bg);
  color: var(--status-building);
}

.badge-fav {
  background: var(--fav-bg);
  color: var(--fav-color);
}

.card-title-link {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: inline-block;
  margin: 6px 0 4px;
  word-break: break-word;
}

.card-title-link:hover {
  color: var(--brand-primary);
}

.card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  word-break: break-word;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-card);
  flex-wrap: wrap;
}

.card-actions-left,
.card-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 空状态 */
.empty-card {
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  padding: 48px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto 20px;
}

/* 子站详情页（参与者隔离视图） */
.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.detail-meta-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 14px 16px;
}

.detail-meta-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-meta-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.portal-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

/* 响应式：移动端 375px 单列流式布局、零横向溢出 */
@media (max-width: 820px) {
  .portal-shell {
    padding: 18px 14px 48px;
  }

  .hero-card,
  .editor-card,
  .detail-card {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-box {
    padding: 12px 10px;
  }

  .stat-value {
    font-size: 22px;
  }

  .toolbar-card {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .form-grid-5 {
    grid-template-columns: 1fr;
  }

  .form-field.span-2,
  .form-field.span-3 {
    grid-column: 1 / -1;
  }

  .sites-grid {
    grid-template-columns: 1fr;
  }
}

/* 个人信息登记子站 (/sites/info & /sites/info/admin) 专用样式 */
.info-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.info-form-grid .form-field.span-full {
  grid-column: 1 / -1;
}

.info-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-card);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--status-online));
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.info-admin-toolbar {
  grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
}

.table-scroll-box {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-card);
  border-radius: 14px;
}

.info-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
  min-width: 760px;
}

.info-data-table th,
.info-data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-card);
  vertical-align: middle;
}

.info-data-table th {
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.info-data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.info-data-table tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 820px) {
  .info-form-grid {
    grid-template-columns: 1fr;
  }

  .info-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .info-admin-toolbar {
    grid-template-columns: 1fr;
  }
}

/* 纯净独立表单页 (/sites/info 等) 专用浅色样式 */
body.standalone-page-body {
  background-color: #f5f7fa;
  color: #1e293b;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.standalone-form-wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 36px 16px 48px;
}

.standalone-form-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

.standalone-form-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
}

.standalone-form-title {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
  line-height: 1.3;
}

.standalone-form-subtitle {
  font-size: 14px;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

.standalone-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.req-star {
  color: #ef4444;
  margin-left: 2px;
}

.standalone-submit-row {
  margin-top: 24px;
}

.standalone-submit-btn {
  width: 100%;
  min-height: 46px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
}

.standalone-success-box {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}

.standalone-success-title {
  font-size: 16px;
  font-weight: 700;
  color: #15803d;
}

.standalone-success-desc {
  font-size: 13px;
  color: #166534;
  margin-top: 4px;
}

.standalone-summary-list {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}

.standalone-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
}

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

.standalone-summary-label {
  color: #64748b;
  font-weight: 500;
  flex-shrink: 0;
}

.standalone-summary-val {
  color: #0f172a;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

@media (max-width: 540px) {
  .standalone-form-wrap {
    padding: 16px 12px 32px;
  }

  .standalone-form-card {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .standalone-form-title {
    font-size: 21px;
  }
}
