* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0f1419 100%);
  color: #e6e6e6;
  min-height: 100vh;
}

header {
  background: rgba(15, 20, 25, 0.95);
  border-bottom: 2px solid #d4a017;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 12px rgba(212, 160, 23, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

header .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #d4a017 0%, #f4c430 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #0f1419;
  font-size: 18px;
}

header h1 {
  font-size: 20px;
  color: #f4c430;
  letter-spacing: 1px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-area .nickname {
  color: #d4a017;
}

.btn {
  cursor: pointer;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #d4a017 0%, #f4c430 100%);
  color: #0f1419;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 160, 23, 0.4);
}

.btn-ghost {
  background: transparent;
  border: 1px solid #444;
  color: #ccc;
}

.btn-ghost:hover {
  border-color: #d4a017;
  color: #d4a017;
}

.btn-danger {
  background: #c0392b;
  color: #fff;
}

.btn-danger:hover {
  background: #e74c3c;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 5px 8px;
  font-size: 12px;
}

main {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.toolbar .search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #333;
  border-radius: 6px;
  color: #e6e6e6;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.toolbar .search input:focus {
  border-color: #d4a017;
  background: rgba(255, 255, 255, 0.08);
}

.toolbar .search::before {
  content: "🔍";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}

.toolbar .price-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: rgba(212, 160, 23, 0.06);
  border: 1px solid rgba(212, 160, 23, 0.25);
  border-radius: 6px;
}

.toolbar .price-filter-label {
  color: #d4a017;
  font-size: 13px;
  font-weight: 500;
}

.toolbar .price-filter input[type="number"],
.toolbar .price-filter select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
  border-radius: 5px;
  color: #e6e6e6;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
  width: 90px;
}

.toolbar .price-filter input[type="number"]:focus,
.toolbar .price-filter select:focus {
  border-color: #d4a017;
}

.toolbar .price-filter .dash {
  color: #888;
}

.toolbar .price-filter select {
  width: auto;
  cursor: pointer;
}

.toolbar .price-filter.active {
  border-color: #d4a017;
  background: rgba(212, 160, 23, 0.12);
}

.filter-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(212, 160, 23, 0.15);
  border: 1px solid rgba(212, 160, 23, 0.4);
  border-radius: 12px;
  font-size: 12px;
  color: #f4c430;
  margin-left: 6px;
}

/* ========== 类型管理面板 ========== */
.types-panel {
  background: rgba(20, 30, 40, 0.5);
  border: 1px solid #2a3540;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.types-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.types-panel-header h2 {
  font-size: 15px;
  color: #f4c430;
  font-weight: 600;
  margin-bottom: 4px;
}

.types-panel-header .hint {
  font-size: 12px;
  color: #888;
}

.type-search {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
  border-radius: 5px;
  color: #e6e6e6;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  width: 160px;
  transition: all 0.2s;
}

.type-search:focus {
  border-color: #d4a017;
  width: 200px;
}

.types-panel-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  background: rgba(212, 160, 23, 0.08);
  border: 1px solid rgba(212, 160, 23, 0.3);
  border-radius: 18px;
  font-size: 13px;
  color: #d4a017;
  transition: all 0.2s;
}

.type-chip:hover {
  background: rgba(212, 160, 23, 0.15);
  border-color: #d4a017;
}

.type-chip .count {
  background: rgba(212, 160, 23, 0.25);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  color: #f4c430;
}

.type-chip .chip-actions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid rgba(212, 160, 23, 0.3);
}

.type-chip .chip-btn {
  cursor: pointer;
  background: transparent;
  border: none;
  color: #888;
  font-size: 13px;
  padding: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.type-chip .chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.type-chip .chip-btn.edit:hover { color: #d4a017; }
.type-chip .chip-btn.delete:hover { color: #e74c3c; }

.types-panel-empty {
  color: #888;
  font-size: 13px;
  padding: 8px 0;
}

.types-panel-collapsed {
  margin-bottom: 20px;
}

.form-hint {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
}

.form-hint a {
  color: #d4a017;
  cursor: pointer;
  text-decoration: underline;
}

.form-hint a:hover {
  color: #f4c430;
}

/* 表格 */
.guns-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(20, 30, 40, 0.6);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.guns-table thead th {
  background: linear-gradient(180deg, #243140 0%, #1a2332 100%);
  color: #d4a017;
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #d4a017;
}

.guns-table tbody tr.cat-row {
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #2a3540;
}

.guns-table tbody tr.cat-row:hover {
  background: rgba(212, 160, 23, 0.08);
}

.guns-table tbody tr.cat-row.expanded {
  background: rgba(212, 160, 23, 0.12);
}

.guns-table tbody tr.cat-row td {
  padding: 14px 16px;
}

.cat-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: #f4c430;
}

.cat-name .arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 12px;
  color: #d4a017;
}

.cat-row.expanded .arrow {
  transform: rotate(90deg);
}

.code-count-badge {
  background: rgba(212, 160, 23, 0.2);
  color: #d4a017;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.cat-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 展开区域 */
.expand-row td {
  padding: 0 !important;
  background: rgba(10, 15, 20, 0.5);
}

.expand-wrap {
  padding: 16px 24px 20px 56px;
}

.sub-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(20, 28, 38, 0.7);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #2a3540;
}

.sub-table thead th {
  background: rgba(15, 22, 30, 0.9);
  color: #aaa;
  font-size: 12px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sub-table tbody td {
  padding: 12px;
  border-top: 1px solid #2a3540;
  font-size: 13px;
  vertical-align: middle;
}

.sub-table tbody tr:hover {
  background: rgba(212, 160, 23, 0.04);
}

.sub-code {
  font-family: "Consolas", "Monaco", monospace;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #2a3540;
  display: inline-block;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b0e0e6;
  font-size: 12px;
  vertical-align: middle;
}

.price-tag {
  color: #f4c430;
  font-weight: 600;
}

.sub-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.sub-empty {
  text-align: center;
  color: #888;
  padding: 24px;
  font-size: 14px;
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-mask.show {
  display: flex;
}

.modal {
  background: #1a2332;
  border: 1px solid #d4a017;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal h3 {
  color: #f4c430;
  margin-bottom: 16px;
  font-size: 18px;
  border-bottom: 1px solid #2a3540;
  padding-bottom: 10px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: #bbb;
  margin-bottom: 6px;
}

.form-row label .req { color: #e74c3c; }

.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
  border-radius: 5px;
  color: #e6e6e6;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: #d4a017;
}

.form-row textarea {
  resize: vertical;
  min-height: 90px;
  font-family: "Consolas", monospace;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #2a3540;
}

/* Auth modal */
.auth-modal {
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid #2a3540;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-size: 14px;
}

.auth-tab.active {
  color: #d4a017;
  border-bottom-color: #d4a017;
}

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: rgba(20, 30, 40, 0.95);
  border: 1px solid #d4a017;
  border-radius: 6px;
  color: #f4c430;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(8px);
}

.toast.error {
  border-color: #e74c3c;
  color: #ffb3b3;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* Login prompt */
.login-prompt {
  text-align: center;
  padding: 60px 20px;
  background: rgba(20, 30, 40, 0.4);
  border-radius: 8px;
  border: 1px dashed #444;
}

.login-prompt p {
  margin-bottom: 16px;
  color: #aaa;
}

@media (max-width: 768px) {
  header { padding: 12px 16px; flex-direction: column; gap: 10px; }
  main { padding: 0 12px; }
  .sub-code { max-width: 180px; }
  .sub-actions { flex-direction: column; }
}