:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #212529;
  --text-secondary: #6c757d;
  --border: #dee2e6;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 1.5rem; font-weight: 600; }
.header-controls { display: flex; gap: 0.5rem; }

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.btn:hover { background: #e9ecef; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.main-container {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1.5rem;
}

.filter-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 300px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.filter-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.filter-actions-top { margin-bottom: 1rem; }
.filter-group { margin-bottom: 1.2rem; }
.filter-group > label {
  font-weight: 500;
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.range-inputs { display: flex; align-items: center; gap: 0.3rem; }
.range-inputs input { width: 100%; }
.range-separator { flex-shrink: 0; }

input[type="number"],
input[type="text"],
select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  width: 100%;
}

.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.scrollable {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem;
}

.content { flex: 1; min-width: 0; }
.result-info { margin-bottom: 0.8rem; font-size: 0.95rem; color: var(--text-secondary); }

.table-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  background: #f8f9fa;
  padding: 0.7rem 0.5rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
}
thead th:hover { background: #e9ecef; }
thead th.sorted-asc::after { content: " ▲"; font-size: 0.7rem; }
thead th.sorted-desc::after { content: " ▼"; font-size: 0.7rem; }
tbody td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f1f3f5; }

.detail-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: auto;
  background: rgba(0,0,0,0.4);
}
.modal-content {
  background: var(--card-bg);
  margin: 3% auto;
  padding: 1.5rem;
  border-radius: var(--radius);
  width: 80%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* 高级筛选弹窗更大 */
.advanced-modal-content {
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.advanced-col h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}
.close:hover { color: #000; }

.detail-section { margin-bottom: 1.2rem; }
.detail-section h3 { border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; margin-bottom: 0.6rem; }
.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 0.8rem; }
.detail-table td { padding: 0.25rem 0.5rem; border: 1px solid var(--border); }

@media (max-width: 768px) {
  .main-container { flex-direction: column; }
  .filter-panel { width: 100%; max-height: none; }
  .advanced-grid { grid-template-columns: 1fr; }
}

#viewRawBtn {
  float: right;
  margin-bottom: 0.5rem;
  background-color: #0d6efd;
  color: white;
  border-color: #0d6efd;
}
#viewRawBtn:hover {
  background-color: #0b5ed7;
  border-color: #0b5ed7;
}