:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f0f5fb;
  --surface-3: #e8f0fa;
  --line: #dce5f0;
  --line-strong: #bdcde0;
  --text: #17283f;
  --muted: #61738a;
  --accent: #2867c9;
  --accent-strong: #174eab;
  --accent-ink: #ffffff;
  --warn: #a66500;
  --danger: #b33d35;
  --radius: 10px;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(40, 103, 201, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 103, 201, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-size: 16px;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  width: min(1580px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  padding: 0 2px 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.7vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(242, 189, 88, 0.12);
}

.sync-state.ready .sync-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(182, 240, 68, 0.12);
}

.sync-state.error .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 138, 122, 0.12);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 0.7fr)) minmax(180px, 1.3fr);
  gap: 10px;
  margin: 16px 0 12px;
}

.stat-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  padding: 16px 18px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  color: var(--accent-strong);
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 1.65rem;
}

.stat-card-wide strong {
  font-size: 1.08rem;
}

.workspace {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(23, 40, 63, 0.08);
}

.filters {
  display: grid;
  grid-template-columns: minmax(250px, 1.65fr) repeat(3, minmax(140px, 0.72fr)) auto auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.filters label {
  display: grid;
  gap: 6px;
}

.filters label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 12px;
}

input::placeholder {
  color: var(--muted);
}

button {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
}

.secondary-button:hover {
  border-color: #667871;
  background: var(--surface-3);
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 16px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.result-bar strong {
  color: var(--accent);
  font-family: Consolas, monospace;
  font-size: 1.05rem;
}

.result-bar p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  position: relative;
  max-height: calc(100vh - 315px);
  min-height: 320px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 11px 14px;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: left;
}

td {
  padding: 13px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover td {
  background: rgba(40, 103, 201, 0.045);
}

.gun-column {
  width: 15%;
}

.build-column {
  width: 14%;
}

.code-column {
  width: 36%;
}

.status-column {
  width: 15%;
}

.gun-name {
  display: block;
  font-weight: 800;
  line-height: 1.35;
}

.category,
.scheme-label,
.meta,
.source-link {
  color: var(--muted);
  font-size: 0.78rem;
}

.category,
.scheme-label {
  display: block;
  margin-top: 4px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 7px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
}

.tag.price {
  color: var(--accent-strong);
}

.description {
  color: var(--text);
  line-height: 1.45;
}

.code-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.code-text {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  user-select: all;
}

.copy-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--accent-strong);
  background: transparent;
  border: 1px solid var(--line-strong);
  font-size: 0.78rem;
}

.copy-button:hover {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.status {
  display: inline-flex;
  margin-bottom: 7px;
  padding: 3px 7px;
  color: var(--accent-strong);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status.pending {
  color: var(--warn);
  background: rgba(242, 189, 88, 0.1);
  border-color: rgba(242, 189, 88, 0.28);
}

.meta {
  display: block;
  margin-bottom: 5px;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
}

.source-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 3px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

footer p {
  margin: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(390px, calc(100vw - 48px));
  padding: 11px 15px;
  color: var(--accent-ink);
  background: var(--accent-strong);
  border-radius: 7px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  color: #250b07;
  background: var(--danger);
}

@media (max-width: 1050px) {
  .filters {
    grid-template-columns: 2fr repeat(3, 1fr);
  }

  .filters button {
    grid-column: span 2;
  }

  .gun-column {
    width: 18%;
  }

  .build-column {
    width: 17%;
  }

  .code-column {
    width: 31%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .topbar,
  .result-bar,
  footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .search-field {
    grid-column: 1 / -1;
  }

  .filters button {
    grid-column: auto;
  }

  .result-bar p {
    width: 100%;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    padding: 9px;
  }

  tbody tr {
    margin-bottom: 9px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  td {
    padding: 7px 0;
    border-bottom: 0;
  }

  tbody tr:hover td {
    background: transparent;
  }

  .code-box {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .copy-button {
    width: 100%;
  }
}

@media (max-width: 470px) {
  .stats,
  .filters {
    grid-template-columns: 1fr;
  }

  .search-field,
  .filters button {
    grid-column: auto;
  }

  .stat-card-wide {
    grid-column: auto;
  }
}

button {
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
button:active {
  transform: scale(0.97);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
html, body {
  overflow-x: clip;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

