:root {
  --bg: #0b1220;
  --card: rgba(255, 255, 255, 0.06);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --border: rgba(255, 255, 255, 0.12);
  --primary: #4f8cff;
  --danger: #ff4f6d;
}

* {
  box-sizing: border-box;
}

html {
  background: radial-gradient(1200px 600px at 20% 0%, rgba(79, 140, 255, 0.2), transparent 60%),
    radial-gradient(900px 500px at 80% 10%, rgba(255, 79, 109, 0.18), transparent 55%), var(--bg);
  background-repeat: no-repeat;
  background-attachment: fixed;
  min-height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
  background: transparent;
  min-height: 100vh;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 18px;
}

.sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

main {
  padding: 18px 0 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
}

.auth-card {
  max-width: 420px;
  margin: 32px auto;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-label {
  font-size: 13px;
  color: var(--muted);
}

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

.input {
  flex: 1;
  min-width: 260px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  outline: none;
}

.select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.input-sm {
  min-width: 180px;
  padding: 8px 10px;
}

.input-xs {
  min-width: 90px;
  width: 90px;
  padding: 6px 8px;
}

.note-input {
  min-width: 160px;
  width: 200px;
}

.note-input.saving {
  border-color: rgba(79, 140, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.18);
}

.select-sm {
  padding: 6px 8px;
  border-radius: 8px;
}

.btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.btn.sm {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  text-decoration: none;
}

.btn.primary {
  background: rgba(79, 140, 255, 0.24);
  border-color: rgba(79, 140, 255, 0.5);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: rgba(255, 79, 109, 0.18);
  border-color: rgba(255, 79, 109, 0.5);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.85);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex: 0 0 auto;
}

.spinner.sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.btn .spinner {
  margin-right: 8px;
  vertical-align: -2px;
}

.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  user-select: none;
}

.error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 79, 109, 0.16);
  border: 1px solid rgba(255, 79, 109, 0.35);
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
}

.muted {
  color: var(--muted);
}

.sites {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}

.site {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.site-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.site-summary::-webkit-details-marker {
  display: none;
}

.site-summary-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.site-summary-meta {
  font-size: 12px;
  color: var(--muted);
}

.site-summary-meta.bad {
  color: rgba(255, 79, 109, 0.95);
}

.site-summary-more {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.site-summary-more::after {
  content: "展开";
}

.site[open] .site-summary-more::after {
  content: "收起";
}

.site-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.site-title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-actions {
  display: flex;
  gap: 10px;
}

.site-url {
  display: inline-block;
  margin-top: 6px;
  color: rgba(79, 140, 255, 0.95);
  text-decoration: none;
  font-size: 13px;
}

.site-url:hover {
  text-decoration: underline;
}

.site-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.site-meta.bad {
  color: rgba(255, 79, 109, 0.95);
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table.table-sm th,
.table.table-sm td {
  padding: 8px 10px;
  font-size: 12px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.04);
}

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

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .col-price {
  width: 90px;
  min-width: 90px;
  text-align: right;
  white-space: nowrap;
}

.table .col-stock {
  width: 70px;
  min-width: 70px;
  text-align: right;
  white-space: nowrap;
}

.table .col-wholesale {
  min-width: 140px;
}

.wholesale-cell {
  min-width: 140px;
}

.wholesale {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wholesale-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wholesale-group + .wholesale-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.wholesale-label {
  font-size: 11px;
  color: var(--muted);
}

.wholesale-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wholesale-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.wholesale-price {
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.category-list,
.category-admin-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}

.item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.category-table {
  width: 100%;
}

.compact-list {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.compact-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
}

.compact-item summary {
  list-style: none;
  cursor: pointer;
}

.compact-item summary::-webkit-details-marker {
  display: none;
}

.compact-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compact-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-name {
  font-weight: 600;
}

.compact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.compact-more {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.2px;
}

.compact-extra {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.compact-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.compact-label {
  color: var(--muted);
  min-width: 44px;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-note {
  width: 100%;
  min-width: 0;
}

.admin-compact {
  display: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
}

.admin-compact summary {
  list-style: none;
  cursor: pointer;
}

.admin-compact summary::-webkit-details-marker {
  display: none;
}

.admin-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-summary-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-summary-name {
  font-weight: 600;
}

.admin-summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.admin-summary-more {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.2px;
}

.admin-extra {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.16);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.admin-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.admin-label {
  color: var(--muted);
  min-width: 44px;
}

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

.category-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.category-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  line-height: 1.2;
}

.tag-wholesale {
  background: rgba(255, 176, 92, 0.2);
  border-color: rgba(255, 176, 92, 0.5);
  color: rgba(255, 233, 200, 0.95);
}

.link {
  color: rgba(79, 140, 255, 0.95);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .container {
    width: min(100%, calc(100% - 24px));
  }
}

@media (max-width: 720px) {
  .container {
    width: calc(100% - 20px);
  }

  .topbar-row {
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .card {
    padding: 12px;
  }

  .row {
    flex-direction: column;
  }

  .row .input,
  .row .select,
  .row .btn {
    width: 100%;
    min-width: 0;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .table {
    min-width: 0;
  }

  .table th,
  .table td {
    font-size: 12px;
    padding: 8px 10px;
  }

  .wholesale-label {
    font-size: 10px;
  }

  .category-table {
    display: none;
  }

  .compact-list {
    display: flex;
  }

  .admin-hide-mobile {
    display: none !important;
  }

  .admin-compact {
    display: block;
  }

  .admin-name {
    display: none;
  }
}
