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

body.query-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============ Layout ============ */
.query-header {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.query-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-back {
  font-size: 14px;
  color: #1a56db;
  text-decoration: none;
}

.btn-back:hover {
  text-decoration: underline;
}

.query-brand {
  font-size: 20px;
  font-weight: 700;
  color: #1a56db;
}

.query-main {
  min-height: calc(100vh - 200px);
}

.query-footer {
  background: #1f2937;
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
}

/* ============ Hero ============ */
.query-hero {
  background: linear-gradient(135deg, rgba(26,86,219,0.85) 0%, rgba(59,130,246,0.75) 50%, rgba(96,165,250,0.7) 100%);
  padding: 50px 0 40px;
  text-align: center;
}

.query-title {
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
}

.query-subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 15px;
}

/* ============ Category Filter ============ */
.category-filter {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 7px 22px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  background: #fff;
  color: #374151;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-btn:hover {
  border-color: #1a56db;
  color: #1a56db;
}

.category-btn.active {
  background: #1a56db;
  color: #fff;
  border-color: #1a56db;
  font-weight: 600;
}

/* ============ Content ============ */
.query-content {
  padding: 30px 0 60px;
}

/* ============ Search Bar ============ */
.query-search-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  gap: 10px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.search-input:focus {
  border-color: #1a56db;
}

.search-input-wrap {
  flex: 0 0 60%;
  position: relative;
  display: flex;
  min-width: 0;
}

.q-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  display: none;
  user-select: none;
}

.q-clear-btn:hover {
  color: #4b5563;
}

.q-clear-btn.visible {
  display: block;
}

.q-result-info {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

/* ============ Buttons ============ */
.btn {
  padding: 10px 24px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:hover {
  border-color: #1a56db;
  color: #1a56db;
}

.btn-primary {
  background: #1a56db;
  color: #fff;
  border-color: #1a56db;
}

.btn-primary:hover {
  background: #1547b0;
  border-color: #1547b0;
  color: #fff;
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
  position: relative;
}

.btn-secondary:hover {
  border-color: #f59e0b;
  color: #d97706;
  background: #fffbeb;
}

/* ============ Favorites Badge ============ */
.q-fav-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 4px;
}

.btn-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

/* ============ Results Table ============ */
.results-table-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  background: #f9fafb;
  padding: 12px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.results-table th:first-child {
  width: 5%;
}

.results-table th:nth-child(2) {
  width: 25%;
}

.results-table th:nth-child(3) {
  width: 18%;
}

.results-table th:nth-child(4) {
  width: 10%;
}

.results-table th:nth-child(5) {
  width: 8%;
}

.results-table th:nth-child(6) {
  width: 14%;
}

.results-table th:nth-child(7) {
  width: 10%;
}

.results-table th:last-child {
  width: 10%;
}

.results-table td {
  padding: 11px 14px;
  font-size: 13px;
  color: #4b5563;
  border-bottom: 1px solid #f3f4f6;
}

.results-table tbody tr:hover {
  background: #f9fafb;
}

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

.tc {
  text-align: center;
}

.results-table .q-note-col {
  white-space: nowrap;
}

.results-table .q-note-th,
.results-table .q-note-col {
  display: none;
}

.results-table.q-note-visible .q-note-th,
.results-table.q-note-visible .q-note-col {
  display: table-cell;
}

/* ============ Tags ============ */
.q-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.q-tag-general {
  background: #e0f2fe;
  color: #0369a1;
}

.q-tag-precursor {
  background: #fef3c7;
  color: #92400e;
}

.q-tag-explosive {
  background: #fee2e2;
  color: #991b1b;
}

/* ============ Row Action Buttons ============ */
.q-row-add-btn,
.q-row-remove-btn {
  padding: 3px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.q-row-add-btn {
  color: #d97706;
  border-color: #fcd34d;
}

.q-row-add-btn:hover {
  background: #fffbeb;
  border-color: #f59e0b;
}

.q-row-remove-btn {
  color: #dc2626;
  border-color: #fca5a5;
}

.q-row-remove-btn:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

/* ============ Highlight ============ */
.q-hl {
  background: #fef08a;
  color: #854d0e;
  padding: 1px 2px;
  border-radius: 2px;
}

/* ============ Pagination ============ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
}

.q-page-btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.q-page-btn:hover {
  border-color: #1a56db;
  color: #1a56db;
}

.q-page-btn.active {
  background: #1a56db;
  color: #fff;
  border-color: #1a56db;
}

.q-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.q-page-info {
  padding: 0 4px;
  color: #999;
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  display: none;
  background: transparent;
  overflow: hidden;
}

.modal.show {
  display: flex !important;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 0;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 70%;
  max-width: 2400px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
  padding: 24px;
  overflow: hidden;
  box-sizing: border-box;
}

.modal-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 16px;
  cursor: grab;
  user-select: none;
}

.modal-content h3:active {
  cursor: grabbing;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #374151;
}

.favorites-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.favorites-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.favorites-list .results-table {
  box-shadow: none;
  border-radius: 0;
}

.favorites-list .results-table th:first-child {
  width: 6%;
}

.favorites-list .results-table th:nth-child(2) {
  width: 28%;
}

.favorites-list .results-table th:nth-child(3) {
  width: 22%;
}

.favorites-list .results-table th:nth-child(4) {
  width: 14%;
}

.favorites-list .results-table th:nth-child(5) {
  width: 12%;
}

.favorites-list .results-table th:last-child {
  width: 8%;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .query-title {
    font-size: 24px;
  }
  .query-search-bar {
    flex-wrap: wrap;
  }
  .search-input {
    width: 100%;
  }
}
