:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --primary: #111827;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --warn-soft: #fef3c7;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: relative;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
}

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

.topbar-actions,
.content-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-nav {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 4px;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.app-nav-link:hover {
  background: #eef2f7;
  color: var(--text);
}

.app-nav-link.active {
  background: var(--primary);
  color: #fff;
}

.button {
  min-height: 38px;
  border-radius: var(--radius);
  padding: 0 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.secondary {
  background: #fff;
  color: #334155;
  border-color: var(--line);
}

.button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button:hover {
  filter: brightness(0.97);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(560px, 1fr) 380px;
  height: calc(100vh - 74px);
  min-height: 620px;
}

.sidebar,
.details {
  background: var(--panel);
  padding: 20px;
  overflow: auto;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.details {
  border-left: 1px solid var(--line);
}

.search-panel {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.search {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  outline: none;
}

.search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.search-relation {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.relation-select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.relation-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.category-list {
  display: grid;
  gap: 4px;
}

.category-button {
  min-height: 36px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #334155;
  cursor: pointer;
  padding: 0 10px;
  text-align: left;
}

.category-button.active {
  background: var(--primary);
  color: #fff;
}

.category-button:not(.active):hover {
  background: #f1f5f9;
}

.content {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content-head {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.table-wrap {
  margin: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 13px 16px;
  border-top: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

.select-col {
  width: 58px;
}

.row-check {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

thead th {
  border-top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #f8fafc;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.thumb {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  object-fit: cover;
  background: #e2e8f0;
}

.product-name {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.tag {
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 11px;
}

.tag.accent {
  background: var(--accent-soft);
  color: #115e59;
}

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

.cell-sub {
  margin-top: 3px;
  color: var(--muted-soft);
  font-size: 12px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: var(--radius);
  object-fit: cover;
  background: #e2e8f0;
  margin: 16px 0;
}

.detail-stack {
  display: grid;
  gap: 14px;
  font-size: 13px;
}

.selection-summary {
  display: grid;
  gap: 12px;
}

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

.selection-count {
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

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

.sku-input {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  font: inherit;
  font-size: 13px;
}

.sku-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.selection-message {
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.selected-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.selected-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px;
  background: #fff;
}

.selected-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: cover;
  background: #e2e8f0;
}

.selected-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.remove-button {
  border: 0;
  border-radius: var(--radius);
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  padding: 7px 9px;
}

.remove-button:hover {
  background: #e2e8f0;
}

.detail-label {
  color: var(--muted-soft);
  margin-bottom: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.point-list {
  display: grid;
  gap: 8px;
}

.point {
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 10px 12px;
  color: #475569;
}

.sub-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sub-images img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  object-fit: cover;
}

.empty {
  padding: 64px 16px;
  text-align: center;
  color: var(--muted-soft);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
    height: auto;
  }

  .details {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .topbar,
  .content-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-nav {
    position: static;
    transform: none;
    width: 100%;
  }

  .app-nav-link {
    flex: 1;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap {
    margin: 14px;
  }
}
