:root {
  --brand: #c8102e;
  --brand-dark: #a00d24;
  --brand-soft: #fff0f2;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --header-h: 64px;
}

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

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

/* ========== 顶栏 ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3548 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.site-header-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.site-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #e8354d);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.site-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-brand-text strong {
  color: #f9fafb;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.site-brand-text span {
  color: #9ca3af;
  font-size: 12px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.is-active {
  color: #fff;
  background: var(--brand);
  font-weight: 600;
  pointer-events: none;
}

/* ========== 主内容 ========== */
.page-main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.page-title-bar {
  margin-bottom: 16px;
}

.page-title-bar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}

.page-desc {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px 20px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

.filter-item label {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  min-width: 4em;
  text-align: right;
}

.filter-select,
.filter-input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
  min-width: 180px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.filter-date { min-width: 150px; }
.filter-order { min-width: 180px; }
.filter-datetime { min-width: 220px; }

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

.filter-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 18px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-search {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-search:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-reset:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}

.table-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-scroll {
  overflow: auto;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 100%;
}

.data-table th,
.data-table td {
  padding: 11px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
  font-size: 13px;
  vertical-align: middle;
}

.data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

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

.data-table tbody tr:hover td {
  background: #fafbfc;
}

.data-table .col-time { min-width: 160px; white-space: nowrap; }
.data-table .col-left { text-align: left; }

.data-table th.sortable-col {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.data-table th.sortable-col:hover {
  color: var(--brand);
  background: var(--brand-soft);
}
.data-table th.sortable-col .col-title {
  display: inline-block;
  vertical-align: middle;
}
.data-table th.sortable-col .sort-indicator {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.35;
}
.data-table th.sortable-col.is-active .sort-indicator {
  opacity: 1;
}
.data-table th.sortable-col.is-desc .sort-indicator {
  border-top: 6px solid currentColor;
  border-bottom: 0;
}
.data-table th.sortable-col.is-asc .sort-indicator {
  border-bottom: 6px solid currentColor;
  border-top: 0;
}

.empty-row td {
  text-align: center;
  color: var(--text-secondary);
  padding: 56px 16px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.pagination-total {
  color: var(--text-secondary);
  font-size: 13px;
}

.pagination-size {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled):not(.active) {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}

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

.page-btn:disabled {
  color: #d1d5db;
  cursor: not-allowed;
  background: #f3f4f6;
}

.page-ellipsis {
  color: var(--text-secondary);
  padding: 0 4px;
}

.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}

.pagination-jump input {
  width: 52px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
}

.status-bar {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.status-bar .ok { color: #059669; }
.status-bar .fail { color: #dc2626; }
.status-bar .hint { color: var(--text-secondary); }

.loading-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.loading-mask.show { display: flex; }

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.daily-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.daily-link:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.daily-link.daily-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.daily-link.daily-pending .daily-pv {
  font-weight: 600;
  color: var(--text);
}
.daily-link.daily-pending .daily-tag {
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  color: #b45309;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-weight: 500;
}
.daily-link.daily-pending:hover .daily-pv {
  color: var(--brand-dark);
}

.daily-link.daily-waiting {
  color: #b45309;
  font-size: 12px;
  font-weight: 500;
}
.daily-link.daily-waiting:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.daily-loading {
  color: #94a3b8;
  font-size: 12px;
}
.daily-link.daily-loading-link {
  font-weight: 500;
  text-decoration: none;
}
.daily-link.daily-loading-link:hover .daily-loading {
  color: var(--brand);
  text-decoration: underline;
}

.summary-card {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.summary-item .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.summary-item .value {
  font-size: 18px;
  color: var(--text);
  font-weight: 700;
}

.summary-item.highlight .value {
  color: var(--brand);
  font-size: 26px;
}

.data-table tr.total-row td {
  background: #f9fafb;
  font-weight: 700;
  color: var(--text);
}

.col-right { text-align: right; }

/* ========== 统计页全屏布局 ========== */
body.stats-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stats-page-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
  overflow: hidden;
}

.stats-table-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.stats-table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.compact-summary {
  margin-bottom: 12px;
  flex-shrink: 0;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fafb;
}

@media (max-width: 768px) {
  .site-header-inner {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }

  .site-nav {
    width: 100%;
    justify-content: center;
  }

  .page-main {
    padding: 16px;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
}
