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

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  background: #f0f4f8;
  color: #1a202c;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: normal;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

header {
  background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
  color: #fff;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0, 102, 204, .25);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
}

.logo-icon svg {
  width: 22px;
  height: 22px;
}

.header-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.tabs {
  width: fit-content;
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 5px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.tab {
  border: none;
  border-radius: 9px;
  padding: 9px 22px;
  background: transparent;
  color: #6b7280;
  font-size: .9rem;
  font-weight: 500;
  line-height: normal;
  transition: all .2s;
}

.tab.active {
  background: #0066cc;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 102, 204, .3);
}

.tab:hover:not(.active) {
  background: #f3f4f6;
  color: #374151;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn .25s ease;
}

.search-section {
  margin-bottom: 20px;
  min-height: 136px;
  padding: 28px 28px 20px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
}

#panel-expand .search-section {
  min-height: 188px;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-input-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 13px 14px 13px 40px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
  background: #fafafa;
  color: #1a202c;
  font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
}

.search-input:focus {
  border-color: #0066cc;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, .1);
}

.search-input::placeholder {
  color: #9ca3af;
}

.select-sm {
  min-width: 105px;
  padding: 13px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
  background: #fafafa;
  color: #374151;
  font-size: .88rem;
  cursor: pointer;
  transition: border-color .2s;
}

.source-select {
  min-width: 94px;
}

.select-sm:focus {
  border-color: #0066cc;
  background: #fff;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 13px 26px;
  font-size: .95rem;
  font-weight: 600;
  line-height: normal;
  white-space: nowrap;
  transition: background .15s, opacity .15s, transform .1s, box-shadow .15s;
}

.btn-primary {
  background: #0066cc;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 102, 204, .3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: #0052a3;
  box-shadow: 0 4px 12px rgba(0, 102, 204, .4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  padding: 8px 16px;
  background: #f3f4f6;
  color: #374151;
  font-size: .85rem;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.mode-switcher {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 14px;
  padding: 3px;
  border-radius: 10px;
  background: #f3f4f6;
}

.mode-btn {
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  background: transparent;
  color: #6b7280;
  font-size: .82rem;
  font-weight: 500;
  transition: color .15s, background .15s, box-shadow .15s;
}

.mode-btn.active {
  background: #fff;
  color: #0066cc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.mode-btn:hover:not(.active) {
  color: #374151;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: #9ca3af;
  font-size: .88rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
  animation: fadeIn .3s ease;
}

.card {
  min-height: 94px;
  padding: 18px 16px;
  border-top: 3px solid #0066cc;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  transition: transform .2s, box-shadow .2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .1);
}

.card-new {
  border-top-color: #f59e0b;
}

.card-label {
  margin-bottom: 8px;
  color: #9ca3af;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
}

.card-value {
  color: #0066cc;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.card-value.keyword-text {
  color: #1a202c;
  font-size: 1rem;
  font-weight: 600;
  word-break: break-word;
}

.card-value.new-date {
  color: #92400e;
  font-size: 1rem;
}

.card-sub {
  margin-top: 6px;
  color: #9ca3af;
  font-size: .78rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 4px 12px;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-low {
  background: #059669;
}

.badge-medium {
  background: #d97706;
}

.badge-high {
  background: #dc2626;
}

.chart-section,
.table-section {
  margin-bottom: 20px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  animation: fadeIn .35s ease;
}

.chart-section {
  padding: 22px 22px 16px;
}

.section-title,
.table-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: .9rem;
  font-weight: 700;
}

.section-title::before,
.table-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: #0066cc;
}

.chart-title {
  margin-bottom: 20px;
  font-size: .88rem;
  font-weight: 600;
}

.bar-chart {
  position: relative;
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 30px;
}

.bar-col {
  position: relative;
  height: 100%;
  min-width: 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.bar {
  position: relative;
  width: 100%;
  min-height: 3px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #3b9eff 0%, #0066cc 100%);
  cursor: pointer;
  transition: filter .15s, transform .15s;
}

.bar:hover {
  filter: brightness(1.15);
  transform: scaleX(1.05);
}

.bar-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 10;
  display: none;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 7px;
  background: #1a202c;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  color: #fff;
  font-size: .72rem;
  white-space: nowrap;
  pointer-events: none;
}

.bar-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a202c;
}

.bar:hover .bar-tooltip {
  display: block;
}

.bar-label {
  position: absolute;
  bottom: -22px;
  color: #9ca3af;
  font-size: .62rem;
  white-space: nowrap;
}

.table-section {
  overflow: hidden;
}

.table-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafbfc;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-meta {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #9ca3af;
  font-size: .78rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.keyword-table {
  min-width: 920px;
}

th {
  padding: 11px 16px;
  border-bottom: 2px solid #e5e7eb;
  background: #f8f9fa;
  color: #6b7280;
  font-size: .75rem;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}

th:hover,
th.sorted {
  background: #eff6ff;
  color: #0066cc;
}

th .sort-arrow {
  margin-left: 4px;
  font-size: .7rem;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) td {
  background: #fafbfc;
}

tbody tr:hover td {
  background: #eff6ff !important;
}

.td-keyword {
  max-width: 260px;
  color: #1a202c;
  font-weight: 600;
  word-break: break-word;
}

.td-keyword strong {
  display: block;
  margin-bottom: 3px;
  font-size: .875rem;
  line-height: 1.25;
}

.td-num {
  color: #374151;
  font-variant-numeric: tabular-nums;
}

.latest-num {
  display: block;
  color: #374151;
  font-weight: 700;
}

.latest-month {
  display: block;
  margin-top: 2px;
  color: #9ca3af;
  font-size: .72rem;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 2px 8px;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-new svg {
  flex-shrink: 0;
}

.btn-gsearch {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  margin-top: 4px;
  padding: 2px 7px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #f9fafb;
  color: #6b7280;
  font-size: .7rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  transition: background .12s, color .12s, border-color .12s;
}

.btn-gsearch:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.action-button {
  min-height: 36px;
  padding: 0 15px;
  border: none;
  border-radius: 10px;
  background: #f3f4f6;
  color: #374151;
  font-size: .875rem;
  font-weight: 700;
  transition: background .15s, color .15s;
}

.action-button:hover {
  background: #e5e7eb;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f0f4f8;
  color: #374151;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-copy:hover {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.btn-copy.copied {
  border-color: #6ee7b7;
  background: #d1fae5;
  color: #065f46;
}

.empty-state {
  padding: 80px 20px;
  color: #9ca3af;
  text-align: center;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: .875rem;
}

.alert-info {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

@media (max-width: 640px) {
  header {
    padding: 0 16px;
  }

  .container {
    padding: 20px 12px 40px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    text-align: center;
  }

  .search-section {
    min-height: 293px;
    padding: 18px 16px 14px;
  }

  #panel-expand .search-section {
    min-height: 345px;
  }

  .search-row {
    flex-direction: column;
  }

  .mode-switcher {
    width: 100%;
    display: flex;
  }

  .mode-btn {
    flex: 1;
    text-align: center;
  }

  .btn,
  .select-sm {
    width: 100%;
  }

  .btn {
    justify-content: center;
  }

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

  th,
  td {
    padding: 9px 12px;
  }

  .table-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions {
    justify-content: space-between;
  }
}
