:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --text: #152033;
  --muted: #5b6c7d;
  --border: #d6e0e7;
  --soft: #edf3f6;
  --primary: #087c89;
  --primary-hover: #066672;
  --danger: #b73535;
  --success: #23754b;
  --warn: #916400;
  --shadow: 0 10px 26px rgba(21, 32, 51, 0.08);
}

* { box-sizing: border-box; }

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

h1, h2, h3, p { margin: 0; }

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

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

h1 {
  font-size: 23px;
  line-height: 1.15;
  font-weight: 850;
}

.subhead {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.nav-link {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
}

.nav-link:hover { background: var(--soft); }
.mapping-save-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
  position: sticky;
  bottom: 8px;
  z-index: 2;
}

.mapping-save-bar.is-dirty {
  border-color: var(--warn);
  background: #fff8e8;
}

.mapping-save-bar.is-saving {
  opacity: 0.75;
}

.nav-link.active {
  background: rgba(8, 124, 137, 0.1);
  border-color: rgba(8, 124, 137, 0.25);
  color: var(--primary);
}

.nav-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.page { display: none; }
.page.active { display: block; }

.api-box {
  width: min(430px, 100%);
  display: grid;
  gap: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.card {
  grid-column: span 6;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.card.wide { grid-column: span 12; }
.card.third { grid-column: span 4; }
.card.quarter { grid-column: span 3; }

.stat-value {
  font-size: 28px;
  font-weight: 850;
  line-height: 1.1;
  margin-top: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

h2 {
  font-size: 15px;
  font-weight: 850;
  line-height: 1.25;
}

h3 {
  color: #2d4055;
  font-size: 13px;
  font-weight: 850;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #c4d2dc;
  border-radius: 999px;
  padding: 3px 9px;
  color: #34495d;
  background: #f8fbfc;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.ok {
  border-color: #9fd4b0;
  background: #edf9f0;
  color: #1f6b3a;
}

.badge.warn {
  border-color: #e8d08a;
  background: #fff8e8;
  color: #7a5a12;
}

.badge.err {
  border-color: #e8a8a8;
  background: #fff0f0;
  color: #8a2a2a;
}

.badge-muted {
  opacity: 0.72;
  font-style: italic;
}

.badge-warn {
  border-color: #e8c88a;
  background: #fff8e8;
  color: #7a5a10;
}

.taxonomy-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 280px;
}

.taxonomy-badges-full {
  max-width: none;
}

.taxonomy-details {
  max-width: 300px;
}

.taxonomy-details-summary {
  cursor: pointer;
  color: #3d6b8a;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

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

.taxonomy-details[open] .taxonomy-details-summary {
  margin-bottom: 0.35rem;
}

.channel-id-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 72px;
}

.products-master-name {
  max-width: 200px;
  line-height: 1.35;
}

.products-master-move-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.products-master-move-cell select {
  max-width: 200px;
  font-size: 0.82rem;
}

.master-filter-row-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1fr) minmax(130px, 0.8fr) auto;
  gap: 0.65rem;
  align-items: end;
}

.master-filter-actions button {
  width: 100%;
}

.compact-head h3 {
  font-size: 13px;
}

.sku-catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sku-catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.sku-catalog-tab {
  border: 1px solid #c4d2dc;
  border-radius: 999px;
  background: #fff;
  color: #34495d;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.sku-catalog-tab.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.sku-catalog-panel {
  display: none;
}

.sku-catalog-panel.active {
  display: block;
}

.stack { display: grid; gap: 11px; }

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #2d4055;
  font-size: 12px;
  font-weight: 850;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 39px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

.channel-credentials {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.credential-panel { display: none; }
.credential-panel.active { display: grid; gap: 10px; }

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

button, .download-link, .text-link {
  min-height: 37px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.text-link {
  border: none;
  background: transparent;
  color: var(--primary);
  padding-left: 0;
  padding-right: 0;
  min-height: auto;
}

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

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

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

button.danger:hover {
  filter: brightness(1.08);
}
button:hover, .download-link:hover { border-color: #9caebb; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.status {
  min-height: 48px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f2f6f8;
  color: #2d4055;
  padding: 10px;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
}

.status.ok {
  border-color: rgba(35, 117, 75, 0.35);
  background: rgba(35, 117, 75, 0.08);
}

.status.err {
  border-color: rgba(183, 53, 53, 0.35);
  background: rgba(183, 53, 53, 0.08);
}

.status.warn {
  border-color: rgba(145, 100, 0, 0.35);
  background: rgba(145, 100, 0, 0.08);
}

.progress-wrap {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #dde6ec;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f6fed, #1f9d74);
  transition: width 0.35s ease;
}

.progress-bar.indeterminate {
  width: 40%;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

.progress-label {
  font-size: 12px;
  color: #4a6075;
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft);
  color: #2d4055;
  font-weight: 850;
}

tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fbfd; }

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
  z-index: 10;
}

.gate[hidden] { display: none; }

.gate-card {
  width: min(430px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--panel);
  padding: 22px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.tab.active {
  border-color: rgba(8, 124, 137, 0.35);
  background: rgba(8, 124, 137, 0.08);
  color: var(--primary);
}

.channel-filter-row {
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  background: #fff;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.filter-pill.active {
  border-color: rgba(8, 124, 137, 0.35);
  background: rgba(8, 124, 137, 0.08);
  color: var(--primary);
}

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

.selection-banner {
  padding: 10px 14px;
  border: 1px solid rgba(8, 124, 137, 0.28);
  border-radius: 8px;
  background: rgba(8, 124, 137, 0.08);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.selection-banner .linklike {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.selection-banner .linklike:hover {
  color: var(--primary-hover);
}

.table-wrap-wide table {
  min-width: 960px;
}

.matrix-table th:nth-child(n+2),
.matrix-table td:nth-child(n+2) {
  width: 22%;
}

.attr-cell {
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 280px;
}

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

.attr-cell .matrix-meta {
  color: var(--muted);
  font-size: 10px;
}

.attr-cell .matrix-meta strong {
  font-weight: 600;
  color: var(--muted);
}

.primary-link {
  font-weight: 850;
}

@media (max-width: 940px) {
  .topbar { display: grid; }
  .api-box { width: 100%; }
  .card, .card.third, .card.quarter { grid-column: span 12; }
  .thirds { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1240px); padding-top: 18px; }
  .split { grid-template-columns: 1fr; }
  .card-head { display: grid; }
  button, .download-link { width: 100%; }
}

.hub-actions {
  gap: 16px;
  flex-wrap: wrap;
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.35rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  vertical-align: middle;
}

.target-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 2rem;
}

.target-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--border);
  font-size: 0.92rem;
}

.target-chip-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}

.target-chip-remove:hover {
  color: var(--danger);
}

.taxonomy-pick-panel[hidden] {
  display: none !important;
}

.taxonomy-pick-row {
  width: 100%;
}

.optional-panel > summary {
  cursor: pointer;
  list-style: none;
}

.optional-panel > summary::-webkit-details-marker {
  display: none;
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

a.hub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  padding: 14px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

.page-back-link {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.taxonomy-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
}

.menu-dropdown {
  position: relative;
}

.menu-dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  background: var(--surface, #fff);
  font-weight: 600;
}

.menu-dropdown > summary::-webkit-details-marker {
  display: none;
}

.menu-dropdown-body {
  position: absolute;
  z-index: 20;
  min-width: 220px;
  margin-top: 4px;
  padding: 6px;
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  background: var(--surface, #fff);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-dropdown-body button {
  text-align: left;
}

.taxonomy-tree-toolbar {
  margin: 0.25rem 0 0.5rem;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.taxonomy-tree-toolbar .hint {
  font-size: 0.88rem;
}

.taxonomy-panels {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  margin-top: 0.5rem;
}

.taxonomy-panel {
  flex: 1 1 280px;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  border: 1px solid var(--border, #d8e2e8);
}

.taxonomy-panel-category {
  background: #f2f7fa;
  border-color: #c8dae6;
}

.taxonomy-panel-skus {
  flex: 1.4 1 320px;
  background: #faf6f1;
  border-color: #e2d6c8;
}

.taxonomy-panel-merge {
  background: #f4f0fa;
  border: 1px solid #d8cfe8;
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-top: 0.5rem;
}

.taxonomy-tree-wrap {
  max-height: 420px;
}

.taxonomy-tree-table tr.selected {
  background: rgba(0, 120, 130, 0.08);
}

.taxonomy-tree-table tr.dragging {
  opacity: 0.55;
}

.taxonomy-conflict-dialog {
  max-width: 34rem;
  border: 1px solid var(--border, #c8dae6);
  border-radius: 10px;
  padding: 0;
}

.taxonomy-conflict-dialog::backdrop {
  background: rgba(12, 24, 32, 0.45);
}

.taxonomy-conflict-dialog form {
  padding: 1.1rem 1.25rem;
}

.taxonomy-conflict-candidate {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border, #d8e2e8);
  border-radius: 8px;
  background: #f8fbfc;
}

.taxonomy-merge-dialog {
  max-width: 36rem;
  border: 1px solid var(--border, #c8dae6);
  border-radius: 10px;
  padding: 0;
}

.taxonomy-merge-dialog::backdrop {
  background: rgba(12, 24, 32, 0.45);
}

.taxonomy-merge-dialog form {
  padding: 1.1rem 1.25rem;
}

.taxonomy-merge-group {
  padding: 0.75rem;
  border: 1px solid var(--border, #d8e2e8);
  border-radius: 8px;
  background: #f8fbfc;
}

.taxonomy-merge-keep {
  border-left: 3px solid #2a8f5c;
  padding-left: 0.65rem;
  margin-bottom: 0.55rem;
}

.taxonomy-merge-remove {
  border-left: 3px solid #c45c3e;
  padding-left: 0.65rem;
}

.taxonomy-merge-keep label,
.taxonomy-merge-remove label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.taxonomy-tree-table tr.drop-target {
  outline: 2px dashed var(--primary, #0a7);
}

.taxonomy-drag-handle {
  cursor: grab;
  user-select: none;
  color: #888;
  padding: 0 4px;
}

.taxonomy-name-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.taxonomy-tree-toggle {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #556;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.taxonomy-tree-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

.taxonomy-tree-spacer {
  display: inline-block;
  width: 22px;
  flex: 0 0 22px;
}

.taxonomy-create-channel {
  font-size: 11px;
  padding: 2px 8px;
}

.taxonomy-tree-table tr.taxonomy-row-hidden {
  display: none;
}
.master-reconcile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line, #d7e0e7);
  border-radius: 10px;
  background: #f7fbfc;
}

.master-reconcile-bar p { margin: 4px 0 0; }

@media (max-width: 900px) {
  .master-reconcile-bar { align-items: flex-start; flex-direction: column; }
}
