:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d8e0ea;
  --text: #172033;
  --muted: #667085;
  --accent: #1f7ae0;
  --accent-2: #0f9f6e;
  --danger: #b42318;
}

* { box-sizing: border-box; }

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

.shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
  min-height: 40px;
  padding: 0 16px;
}

button:disabled {
  cursor: wait;
  opacity: .7;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-grid div,
.notice,
.toolbar,
.summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-grid div {
  padding: 14px;
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.status-grid strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.notice {
  margin-bottom: 16px;
  padding: 18px;
  border-color: #f9d89a;
  background: #fff8eb;
}

.notice h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.notice p {
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 260px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 16px;
}

.summary div {
  padding: 16px;
  background: white;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.tree {
  display: grid;
  gap: 10px;
}

.node {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.node-header {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
}

.toggle {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  background: #eaf2fd;
  color: var(--accent);
}

.toggle.empty {
  visibility: hidden;
}

.node-title {
  min-width: 0;
}

.node-title a {
  color: var(--text);
  display: block;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.node-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.sku-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}

.sku-fields span {
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 7px;
}

.badge {
  border-radius: 999px;
  background: #eef7f3;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
}

.children {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px 40px;
}

.level-1 { border-left: 4px solid #1f7ae0; }
.level-2 { border-left: 4px solid #0f9f6e; }
.level-3 { border-left: 4px solid #b7791f; }
.level-4 { border-left: 4px solid #7c3aed; }

.hidden {
  display: none;
}

.empty-state,
.error-state {
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.error-state {
  color: var(--danger);
  border-color: #f3b5ad;
  background: #fff5f4;
}

@media (max-width: 820px) {
  .shell { padding: 14px; }
  .topbar,
  .toolbar { align-items: stretch; flex-direction: column; }
  .status-grid,
  .summary { grid-template-columns: 1fr; }
  input,
  select { width: 100%; }
}
