:root {
  color-scheme: light;
  --ink: #111111;
  --canvas: #ffffff;
  --bg: #f5f5f3;
  --panel: #ffffff;
  --panel-soft: #f0f0ed;
  --text: #1d1d1f;
  --muted: #707072;
  --line: #deded8;
  --line-strong: #c8c8c1;
  --accent: #14745f;
  --accent-soft: #e7f3ef;
  --accent-strong: #0d5e4c;
  --info: #315c8c;
  --info-soft: #e9f0f8;
  --warn: #a86612;
  --warn-soft: #fff3df;
  --bad: #a73434;
  --bad-soft: #fae9e9;
  --shadow: 0 14px 34px rgba(17, 17, 17, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login-brand {
  margin-bottom: 18px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.alert-error {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid #e0b1b1;
  border-radius: 8px;
  color: var(--bad);
  background: var(--bad-soft);
}

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #ededeb;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  padding: 4px 4px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand-name { font-weight: 800; letter-spacing: 0; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav-section {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 12px 10px 4px;
}

.nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 650;
}

.nav a:hover {
  background: #e2e2de;
  text-decoration: none;
}

.nav a.active {
  background: var(--ink);
  color: #fff;
}

.nav-meta {
  margin-top: auto;
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.main {
  min-width: 0;
  padding: 24px 28px 52px;
}

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

h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 5px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  margin: 24px 0 10px;
  letter-spacing: 0;
}

.muted { color: var(--muted); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.stats .card {
  min-height: 98px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

.stat-text {
  font-size: 22px;
}

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

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 16px;
  align-items: start;
}

.layout-even {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

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

.summary {
  font-size: 15px;
  line-height: 1.65;
}

.funnel,
.agent-list,
.todo-list,
.alert-list,
.compact-list {
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 58px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--panel-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.list-item {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.heat-cell {
  min-height: 72px;
  display: grid;
  gap: 3px;
  align-content: center;
  padding: 10px;
  border: 1px solid #a8d4c8;
  border-radius: 8px;
  background: var(--accent-soft);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  color: var(--muted);
  background: #eeeeeb;
  font-weight: 800;
  letter-spacing: 0;
}

tbody tr:hover td { background: #fafaf8; }
tr:last-child td { border-bottom: 0; }

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

button, .button {
  min-height: 34px;
  border: 1px solid var(--ink);
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  padding: 7px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover, .button:hover {
  background: #2b2b2b;
  text-decoration: none;
}

.button.secondary, button.secondary {
  background: var(--panel-soft);
  color: var(--ink);
  border-color: var(--panel-soft);
}

.button.secondary:hover, button.secondary:hover {
  background: #e3e3df;
}

.page-button {
  min-width: 34px;
  padding-left: 9px;
  padding-right: 9px;
}

.page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 34px;
  color: var(--muted);
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  background: var(--canvas);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(17, 17, 17, .14);
  border-color: var(--ink);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

form.inline { display: inline; }

.filter-card {
  background: #eeeeeb;
  border-color: #d8d8d1;
  margin-bottom: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.table-summary {
  align-items: center;
  margin-top: 6px;
}

.bulk-review-bar {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 180px) minmax(130px, 180px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.review-table {
  table-layout: fixed;
}

.review-table th:nth-child(1), .review-table td:nth-child(1) { width: 46px; }
.review-table th:nth-child(2), .review-table td:nth-child(2) { width: 98px; }
.review-table th:nth-child(3), .review-table td:nth-child(3) { width: 96px; }
.review-table th:nth-child(4), .review-table td:nth-child(4) { width: 96px; }
.review-table th:nth-child(5), .review-table td:nth-child(5) { width: 88px; }
.review-table th:nth-child(6), .review-table td:nth-child(6) { width: 64px; }
.review-table th:nth-child(7), .review-table td:nth-child(7) { width: 92px; }
.review-table th:nth-child(8), .review-table td:nth-child(8) { width: 68px; }
.review-table th:nth-child(9), .review-table td:nth-child(9) { width: 120px; }
.review-table th:nth-child(11), .review-table td:nth-child(11) { width: 270px; }

.thumb-cell { width: 98px; }
.check-cell { text-align: center; }
.check-cell input { width: 16px; min-height: 16px; padding: 0; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

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

.thumb img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.thumb-preview {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: zoom-in;
}

.thumb-preview:hover {
  background: transparent;
}

.thumb-body {
  padding: 10px;
  font-size: 13px;
}

.thumb-button {
  border: 0;
  padding: 0;
  background: transparent;
  width: 72px;
  min-height: 88px;
  cursor: zoom-in;
  border-radius: 8px;
}

.thumb-button:hover {
  background: transparent;
}

.thumb-button img {
  width: 72px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
  background: #ddd;
}

.thumb-button:focus-visible img {
  outline: 3px solid rgba(17, 17, 17, .18);
  outline-offset: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  background: #f3f3f0;
  white-space: nowrap;
}

.badge.approved {
  color: var(--accent);
  border-color: #a8d4c8;
  background: var(--accent-soft);
}

.badge.rejected {
  color: var(--bad);
  border-color: #e0b1b1;
  background: var(--bad-soft);
}

.badge.needs_regen {
  color: var(--warn);
  border-color: #edce9c;
  background: var(--warn-soft);
}

.badge.archived {
  color: var(--info);
  border-color: #bfd0e3;
  background: var(--info-soft);
}

.badge.pending_review {
  color: #5f5f60;
  border-color: #d3d3cc;
  background: #f4f4f1;
}

.badge.red,
.badge.bad {
  color: var(--bad);
  border-color: #e0b1b1;
  background: var(--bad-soft);
}

.badge.orange,
.badge.warn {
  color: var(--warn);
  border-color: #edce9c;
  background: var(--warn-soft);
}

.badge.yellow {
  color: var(--info);
  border-color: #bfd0e3;
  background: var(--info-soft);
}

.badge.good {
  color: var(--accent);
  border-color: #a8d4c8;
  background: var(--accent-soft);
}

.review-form {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(92px, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.review-action-cell { min-width: 270px; }

.commerce-stats {
  margin-bottom: 18px;
}

.product-table th:nth-child(1), .product-table td:nth-child(1) { width: 96px; }
.product-table th:nth-child(2), .product-table td:nth-child(2) { width: 92px; }
.product-table th:nth-child(3), .product-table td:nth-child(3) { min-width: 220px; }
.product-table th:nth-child(10), .product-table td:nth-child(10) { width: 150px; }

.strong-link {
  font-weight: 800;
}

.product-cover {
  width: 72px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.product-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-cover.empty {
  border-style: dashed;
}

.color-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid rgba(17, 17, 17, .18);
  vertical-align: -2px;
}

.product-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.product-summary > div:nth-child(n + 3) {
  grid-column: 1 / -1;
}

.csv-field-list {
  display: grid;
  gap: 0;
  max-height: 620px;
  overflow: auto;
}

.csv-field-row {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.csv-field-row:last-child {
  border-bottom: 0;
}

.csv-field-name {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.csv-field-value {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sales-note {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #d8d8d1;
  border-radius: 8px;
  background: #eeeeeb;
  color: var(--muted);
  font-size: 12px;
}

.sales-kpis {
  margin-bottom: 18px;
}

.sales-tab-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 14px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.sales-tab-item {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-weight: 750;
  white-space: nowrap;
}

.sales-tab-item:hover {
  text-decoration: none;
  background: #fafaf8;
}

.sales-tab-item.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.sales-filter-card {
  margin-bottom: 18px;
}

.sales-filter-card,
.sales-dashboard-grid > section,
.sales-detail-section {
  min-width: 0;
}

.sales-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.sales-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.sales-detail-section {
  margin-top: 20px;
}

.sales-order-table th,
.sales-order-table td,
.sales-refund-table th,
.sales-refund-table td {
  white-space: nowrap;
}

.sales-order-table th:nth-child(4),
.sales-order-table td:nth-child(4),
.sales-refund-table th:nth-child(5),
.sales-refund-table td:nth-child(5) {
  min-width: 220px;
  white-space: normal;
}

.sales-pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.sales-change.up { color: var(--accent); }
.sales-change.down { color: var(--bad); }

.sales-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sales-dashboard-grid.bottom {
  margin-top: 20px;
}

.sales-wide-grid {
  grid-template-columns: minmax(0, 1fr);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
  margin: 18px 0 10px;
}

.section-head:first-child {
  margin-top: 0;
}

.sales-product-table th,
.sales-product-table td,
.sales-platform-table th,
.sales-platform-table td {
  white-space: nowrap;
}

.sales-product-table th:first-child,
.sales-product-table td:first-child {
  min-width: 190px;
  white-space: normal;
}

.sales-table-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.sales-product-table {
  min-width: 920px;
}

.sales-platform-table {
  min-width: 720px;
}

.sales-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sales-status.增长,
.sales-status.稳定 {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sales-status.高退货,
.sales-status.断货风险 {
  background: var(--bad-soft);
  color: var(--bad);
}

.sales-status.下滑,
.sales-status.滞销 {
  background: var(--warn-soft);
  color: var(--warn);
}

.sales-trend-card {
  min-height: 240px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.sales-trend-bars {
  min-height: 190px;
  display: grid;
  grid-template-columns: repeat(30, minmax(8px, 1fr));
  gap: 5px;
  align-items: end;
}

.trend-day {
  position: relative;
  min-width: 0;
  height: 184px;
  display: flex;
  align-items: end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.trend-gmv,
.trend-refund {
  position: absolute;
  bottom: 22px;
  width: 100%;
  border-radius: 5px 5px 0 0;
}

.trend-gmv {
  max-height: 140px;
  background: var(--accent);
}

.trend-refund {
  max-height: 64px;
  background: var(--bad-soft);
  border: 1px solid rgba(167, 52, 52, .22);
}

.trend-day span {
  position: absolute;
  bottom: 0;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.legend.gmv { background: var(--accent); }
.legend.refund { background: var(--bad-soft); border: 1px solid rgba(167, 52, 52, .28); }

.refund-reasons {
  display: grid;
  gap: 12px;
}

.refund-reason-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.refund-reason-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.sales-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 18px;
  align-items: start;
}

.sales-chart-card {
  min-height: 260px;
  display: grid;
  gap: 14px;
}

.sales-chart-head,
.sales-chart-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.sales-chart-foot {
  color: var(--muted);
  font-size: 12px;
  align-items: center;
}

.sales-bars {
  min-height: 210px;
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 160px));
  gap: 22px;
  align-items: end;
  justify-content: center;
}

.sales-bar-item {
  min-width: 0;
  height: 204px;
  display: grid;
  grid-template-rows: 24px 1fr 22px;
  gap: 7px;
  align-items: end;
}

.sales-bar-value,
.sales-bar-label {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.sales-bar-track {
  height: 100%;
  min-height: 120px;
  display: flex;
  align-items: end;
  border-radius: 8px;
  background: var(--panel-soft);
  overflow: hidden;
}

.sales-bar-fill {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  background: var(--accent);
}

.sales-empty {
  min-height: 184px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fafaf8;
}

.sales-empty strong {
  color: var(--text);
}

.sales-table th:nth-child(1), .sales-table td:nth-child(1) { width: 96px; }
.sales-table th:nth-child(3), .sales-table td:nth-child(3),
.sales-table th:nth-child(4), .sales-table td:nth-child(4) { width: 116px; }
.sales-table th:nth-child(5), .sales-table td:nth-child(5),
.sales-table th:nth-child(6), .sales-table td:nth-child(6) { width: 96px; }

.sales-side {
  min-width: 0;
}

.sales-side h2 {
  overflow-wrap: anywhere;
}

.sales-alert-list {
  display: grid;
  gap: 10px;
}

.sales-alert {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--panel);
}

.sales-alert > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sales-alert:hover {
  text-decoration: none;
  background: #fafaf8;
}

.sales-alert.high { border-left-color: var(--bad); }
.sales-alert.medium { border-left-color: var(--warn); }
.sales-alert.low { border-left-color: var(--line-strong); }

.sales-alert small {
  color: var(--muted);
  line-height: 1.45;
}

.category-list,
.compact-list {
  display: grid;
  gap: 10px;
}

.category-row,
.compact-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.category-row > span,
.compact-list a > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.category-row > strong,
.compact-list a > strong {
  flex: 0 0 auto;
}

.category-row:last-child,
.compact-list a:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.category-metric {
  text-align: right;
  white-space: nowrap;
}

.publish-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.publish-preview-cta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.publish-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}

.promo-card {
  width: 100%;
  min-height: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  justify-items: start;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: zoom-in;
  font-weight: 800;
}

.promo-card:hover {
  background: transparent;
}

.promo-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ddd;
}

.promo-card span,
.promo-card small {
  padding: 0 2px;
}

.promo-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.publish-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #eeeeeb;
  border: 1px solid #d8d8d1;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 10px;
}

.publish-page {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.publish-editor,
.publish-preview-panel {
  display: grid;
  gap: 14px;
}

.publish-editor-head,
.publish-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
}

.publish-order-list {
  display: grid;
  gap: 10px;
}

.publish-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M4 3 L4 23 L9 18 L12 26 L16 24 L12.8 16.5 L19 16.5 Z' fill='white' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M24 4 L20 8 H23 V14 H20 L24 18 L28 14 H25 V8 H28 Z' fill='black'/%3E%3C/svg%3E") 4 3, ns-resize;
  user-select: none;
}

.publish-item.dragging {
  opacity: .55;
  cursor: ns-resize;
}

.publish-item.drop-before {
  box-shadow: inset 0 3px 0 var(--ink);
}

.publish-item.drop-after {
  box-shadow: inset 0 -3px 0 var(--ink);
}

.publish-thumb {
  width: 72px;
  height: 88px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.publish-item button,
.publish-item img {
  user-select: auto;
}

.publish-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.publish-item-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.publish-item-actions {
  display: flex;
  gap: 8px;
}

.publish-item-actions button {
  min-width: 56px;
}

.preview-mode.active {
  background: var(--ink);
  color: #fff;
}

.publish-scroll-shell {
  display: grid;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0;
  min-height: 68vh;
  overflow: hidden;
}

.publish-scroll-shell.web {
  width: 100%;
}

.publish-scroll-shell.mobile {
  width: 100%;
}

.publish-scroll-stack {
  width: 100%;
  max-height: 66vh;
  overflow-y: auto;
  display: grid;
  gap: 0;
  padding-right: 0;
  background: var(--panel);
}

.publish-scroll-shell.web .publish-scroll-stack {
  max-width: 860px;
}

.publish-scroll-shell.mobile .publish-scroll-stack {
  max-width: 420px;
}

.publish-preview-card {
  display: block;
  padding: 0;
  border-radius: 0;
  background: var(--panel);
  border: 0;
}

.publish-preview-art {
  background: var(--panel);
  border-radius: 0;
  overflow: hidden;
}

.publish-preview-art img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.publish-scroll-shell.mobile .publish-preview-card {
  max-width: 360px;
  margin: 0 auto;
}

.publish-scroll-shell.mobile .publish-preview-art img {
  width: 100%;
}

.publish-meta {
  display: grid;
  gap: 8px;
  padding-top: 6px;
}

.publish-meta div {
  display: grid;
  gap: 2px;
}

.commerce-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

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

.span-all {
  grid-column: 1 / -1;
}

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

.compact-form select {
  min-width: 110px;
}

.form-footer {
  margin-top: 12px;
}

.inventory-table {
  margin: 0;
}

.inventory-table input {
  max-width: 120px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.review-image {
  background: #181818;
  border-radius: 8px;
  min-height: 70vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.review-image img {
  max-width: 100%;
  max-height: 86vh;
  object-fit: contain;
  display: block;
}

.review-panel { position: sticky; top: 18px; }

.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px 10px;
  font-size: 13px;
}

.kv div:nth-child(odd) { color: var(--muted); }

.prompt-box {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f5f5f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font-size: 12px;
}

.image-modal[hidden] { display: none; }

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .74);
}

.image-modal-panel {
  position: absolute;
  inset: 28px;
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  box-shadow: var(--shadow);
}

.image-modal-panel img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  justify-self: center;
  align-self: center;
  background: #181818;
}

@media (min-width: 1680px) {
  .sales-dashboard-grid:not(.bottom):not(.sales-wide-grid),
  .sales-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  }
}

@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .sales-filter-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .bulk-review-bar { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .review-table { table-layout: auto; }
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .brand { width: 100%; margin-bottom: 6px; }
  .nav-section, .nav-meta { display: none; }
  .main { padding: 18px 14px 40px; }
  .topline { flex-direction: column; align-items: stretch; }
  .filter-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .sales-filter-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .sales-pagination {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-review-bar { grid-template-columns: 1fr; }
  .review-layout { grid-template-columns: 1fr; }
  .review-panel { position: static; }
  .publish-preview { grid-template-columns: 1fr; }
  .publish-preview-cta { grid-column: auto; flex-direction: column; align-items: flex-start; }
  .product-summary { grid-template-columns: 1fr; }
  .commerce-layout { grid-template-columns: 1fr; }
  .commerce-form { grid-template-columns: 1fr; }
  .publish-page { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .image-modal-panel { inset: 12px; }
}

@media (max-width: 560px) {
  .filter-grid { grid-template-columns: 1fr; }
  .sales-filter-grid { grid-template-columns: 1fr; }
  .sales-filter-actions,
  .sales-chart-foot {
    flex-wrap: wrap;
  }
  .sales-trend-bars {
    grid-template-columns: repeat(30, minmax(6px, 1fr));
    gap: 3px;
  }
  .trend-day span {
    display: none;
  }
  .trend-day:nth-child(5n + 1) span,
  .trend-day:last-child span {
    display: block;
  }
  .refund-reason-row,
  .compact-list a {
    align-items: flex-start;
  }
  .actions { width: 100%; }
  .actions > * { flex: 1 1 auto; }
  .review-form { grid-template-columns: 1fr; }
}

/* --- Competitors page --- */

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.tab-item:hover {
  color: var(--text);
  text-decoration: none;
}

.tab-item.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.competitor-collection-card {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.collection-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.collection-title {
  font-size: 15px;
  font-weight: 800;
}

.collection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.collection-task {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.collection-task.is-hidden,
.collection-qr.is-hidden {
  display: none;
}

.collection-task-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.collection-task-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.collection-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.collection-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}

.collection-qr {
  display: flex;
  gap: 12px;
  align-items: center;
}

.collection-qr button {
  white-space: nowrap;
}

.collection-qr-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.collection-qr-modal.is-hidden {
  display: none;
}

.collection-qr-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(17, 24, 39, .58);
}

.collection-qr-backdrop:hover {
  background: rgba(17, 24, 39, .58);
}

.collection-qr-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .26);
}

.collection-qr-dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.collection-qr-dialog-head > div {
  display: grid;
  gap: 4px;
}

.collection-qr-dialog img {
  display: block;
  width: auto;
  max-width: none;
  height: auto;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

body.modal-open {
  overflow: hidden;
}

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

.collection-metric {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.collection-metric strong {
  font-size: 14px;
}

.collection-metric span:not(.mono) {
  color: var(--muted);
  font-size: 12px;
}

.collection-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.collection-foot-link {
  color: var(--accent);
  font-weight: 800;
}

.collection-history-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.collection-history-panel,
.collection-detail-panel {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.collection-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.collection-section-head h2 {
  margin: 0;
  font-size: 15px;
}

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

.collection-run-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  color: var(--text);
}

.collection-run-item:hover {
  border-color: var(--line-strong);
  background: #f5f5f1;
}

.collection-run-item.active {
  border-color: #a8d4c8;
  background: var(--accent-soft);
}

.collection-run-item > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.collection-run-item strong,
.collection-run-item .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-run-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.collection-run-meta .muted {
  min-width: 0;
  max-width: 170px;
}

.collection-run-action {
  color: var(--accent);
  font-weight: 800;
}

.collection-run-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.collection-run-delete {
  min-height: 28px;
  padding: 4px 9px;
  color: var(--bad);
}

.collection-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.collection-detail-summary > div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.collection-detail-summary strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.collection-keyword-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.collection-keyword-row {
  display: grid;
  grid-template-columns: minmax(76px, 120px) minmax(90px, 1fr) 34px;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}

.collection-keyword-row:hover {
  border-color: var(--line-strong);
  background: #fff;
  text-decoration: none;
}

.collection-keyword-row.active {
  border-color: #a8d4c8;
  background: var(--accent-soft);
}

.collection-keyword-row.active .collection-keyword-name,
.collection-keyword-row.active .collection-keyword-count {
  color: var(--accent-strong);
}

.collection-keyword-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.collection-keyword-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.collection-keyword-bar span {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--accent);
}

.collection-keyword-count {
  color: var(--muted);
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.collection-active-keyword {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-table-wrap {
  max-height: 680px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.collection-table-wrap .product-kw-table {
  border: 0;
  border-radius: 0;
}

.collection-detail-table {
  min-width: 1180px;
  table-layout: fixed;
}

.collection-detail-table th:nth-child(1),
.collection-detail-table td:nth-child(1) {
  width: 56px;
  text-align: center;
}

.collection-detail-table th:nth-child(2),
.collection-detail-table td:nth-child(2) {
  width: 66px;
}

.collection-detail-table th:nth-child(4),
.collection-detail-table td:nth-child(4) {
  width: 120px;
}

.collection-detail-table th:nth-child(5),
.collection-detail-table td:nth-child(5) {
  width: 78px;
}

.collection-detail-table th:nth-child(6),
.collection-detail-table td:nth-child(6) {
  width: 100px;
}

.collection-detail-table th:nth-child(7),
.collection-detail-table td:nth-child(7) {
  width: 140px;
}

.collection-detail-table th:nth-child(8),
.collection-detail-table td:nth-child(8) {
  width: 190px;
}

.collection-detail-table .prod-title-cell {
  max-width: none;
}

.collection-detail-table .prod-title-text {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.collection-category-cell .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collection-shop-cell,
.collection-points-cell {
  overflow-wrap: anywhere;
}

.collection-table-note,
.collection-empty {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  font-size: 12px;
}

.collection-schedule-form {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.collection-toggle,
.collection-time {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  font-weight: 700;
}

.collection-time input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--panel);
  font: inherit;
}

.collection-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.collection-days label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
}

.good-text { color: var(--accent); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }

@media (max-width: 1180px) {
  .collection-history-grid { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-schedule-form { grid-template-columns: 1fr; }
  .collection-detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .collection-head { display: grid; }
  .collection-actions { justify-content: flex-start; }
  .collection-grid { grid-template-columns: 1fr; }
  .collection-keyword-breakdown,
  .collection-detail-summary { grid-template-columns: 1fr; }
  .collection-task-row,
  .collection-qr {
    display: grid;
  }
}

/* Overview strip */
.overview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.overview-item {
  display: grid;
  gap: 2px;
}

.overview-item .stat-sm {
  font-size: 18px;
  font-weight: 800;
}

/* Macro grid */
.macro-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}

.macro-col-main { min-width: 0; }
.macro-col-side {
  display: grid;
  align-content: start;
  gap: 0;
}

@media (max-width: 980px) {
  .macro-grid { grid-template-columns: 1fr; }
}

/* Brand tier chips */
.tier-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tier-chip {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.tier-label {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

.tier-count {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.tier-pct {
  font-size: 11px;
  margin-top: 2px;
}

/* Brand table */
.brand-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.brand-table th, .brand-table td {
  text-align: left;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
}

.brand-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  color: var(--muted);
  background: #eeeeeb;
  font-weight: 800;
}

.brand-table tbody tr:hover td { background: #fafaf8; }
.brand-table tbody tr:last-child td { border-bottom: 0; }
.rank-cell {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 36px;
}

/* Mini bar (live ratio in brand table) */
.mini-bar {
  width: 60px;
  height: 6px;
  background: var(--panel-soft);
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 3px;
}

/* Bar rows (channel, price, selling points) */
.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.bar-label {
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  background: var(--panel-soft);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 4px;
  transition: width .3s;
}

.bar-fill--accent {
  background: var(--accent);
}

.bar-fill--warn {
  background: var(--warn);
}

.bar-value {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Shop rows */
.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.shop-row:last-child { border-bottom: 0; }

.shop-name {
  font-size: 12px;
  font-weight: 650;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* Insights grid */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.insight-card h3 {
  font-size: 14px;
  margin: 0 0 6px;
}

.insight-card p {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.5;
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.insight-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.insight-action {
  margin-top: 6px;
  font-size: 12px;
  font-style: italic;
}

/* Category grid inside bar rows */
.bar-row-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

/* Keyword tabs */
.kw-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding-bottom: 0;
}

.kw-tab-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  border-radius: 8px 8px 0 0;
  transition: background .12s, color .12s;
}

.kw-tab-item:hover {
  background: #eeeeeb;
  text-decoration: none;
  color: var(--text);
}

.kw-tab-item.active {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-color: var(--panel);
  margin-bottom: -1px;
}

.kw-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #f0f0ed;
  padding: 1px 6px;
  border-radius: 999px;
}

.kw-tab-item.active .kw-count {
  background: var(--ink);
  color: #fff;
}

/* Keyword stats strip */
.kw-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}

.kw-sort {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sort-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--ink);
}

.sort-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Product keyword table */
.product-kw-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.product-kw-table th, .product-kw-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
}

.product-kw-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  color: var(--muted);
  background: #eeeeeb;
  font-weight: 800;
}

.product-kw-table tbody tr:hover td { background: #fafaf8; }
.product-kw-table tbody tr:last-child td { border-bottom: 0; }

.prod-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.prod-thumb--empty {
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 10px;
}

.prod-title-cell {
  max-width: 320px;
}

.prod-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.3;
  margin-bottom: 2px;
}

.prod-title-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}

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

.num-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Dashboard: today strip ===== */
.sp-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0ed;
  color: var(--muted);
  margin: 1px 2px 1px 0;
}

.today-strip {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  margin-bottom: 8px;
}

.today-item {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.today-stat {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.today-stat--accent { color: var(--accent); }
.today-stat--warn { color: var(--warn); }

/* ===== Dashboard workspace ===== */
.dashboard-page {
  display: grid;
  gap: 18px;
}

.dashboard-topline {
  margin-bottom: 0;
}

.dashboard-page h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 850;
}

.dashboard-page p {
  margin: 0;
}

.dashboard-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dashboard-section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.dashboard-section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-section-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(520px, 1.45fr) minmax(340px, .9fr);
  gap: 16px;
  align-items: stretch;
}

.ceo-task-list {
  display: grid;
  gap: 10px;
}

.ceo-task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 14px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fafaf8;
}

.ceo-task-row.high { border-left-color: var(--ink); }
.ceo-task-row.warn,
.ceo-task-row.orange,
.ceo-task-row.yellow { border-left-color: var(--warn); }
.ceo-task-row.bad,
.ceo-task-row.red { border-left-color: var(--bad); }
.ceo-task-row.normal { border-left-color: var(--line-strong); }

.ceo-task-content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.ceo-task-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ceo-task-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.ceo-task-title span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.ceo-task-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ceo-task-row form {
  display: block;
}

.ceo-task-row .button,
.ceo-task-row button {
  width: 112px;
  min-height: 32px;
  padding-left: 10px;
  padding-right: 10px;
  white-space: nowrap;
}

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

.signal-item {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.signal-item span,
.signal-item small,
.agent-role,
.agent-metric span {
  color: var(--muted);
  font-size: 12px;
}

.signal-item strong {
  font-size: 24px;
  line-height: 1;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.dashboard-summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

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

.agent-card {
  min-height: 224px;
  display: grid;
  grid-template-rows: auto minmax(42px, auto) auto auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: 8px;
  background: #fafaf8;
}

.agent-card.good { border-top-color: var(--accent); }
.agent-card.warn { border-top-color: var(--warn); }
.agent-card.bad { border-top-color: var(--bad); }

.agent-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
}

.agent-name {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 850;
}

.agent-card p {
  min-height: 38px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.agent-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.agent-metric {
  min-height: 62px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.agent-metric strong {
  font-size: 18px;
  line-height: 1;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.agent-metric.accent strong { color: var(--accent); }
.agent-metric.warn strong { color: var(--warn); }
.agent-metric.bad strong { color: var(--bad); }

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

.agent-actions .button {
  min-height: 32px;
  padding: 6px 11px;
}

.dashboard-lower {
  display: grid;
  grid-template-columns: minmax(380px, .9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.dashboard-funnel {
  display: grid;
  gap: 10px;
}

.dashboard-funnel .funnel-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
}

.dashboard-funnel .funnel-row strong,
.dashboard-funnel .funnel-row span {
  font-size: 12px;
}

.dashboard-funnel .funnel-row span {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.dashboard-funnel .bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  overflow: hidden;
}

.dashboard-funnel .bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.dashboard-alert-list {
  display: grid;
  gap: 10px;
}

.dashboard-alert {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
}

.dashboard-alert strong {
  font-size: 13px;
}

.dashboard-alert p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dashboard-alert-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.dashboard-alert-actions form {
  display: block;
}

.dashboard-alert-actions button {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--ink);
  background: var(--panel-soft);
  border-color: var(--panel-soft);
}

.activity-stream {
  display: grid;
}

.activity-item {
  display: grid;
  grid-template-columns: 78px 92px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity-label {
  font-weight: 800;
  white-space: nowrap;
}

.activity-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.dashboard-empty {
  min-height: 72px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fafaf8;
  font-size: 13px;
}

.dashboard-source-note {
  color: var(--muted);
  font-size: 12px;
}

/* ===== Inventory and returns workspace ===== */
.inventory-page {
  display: grid;
  gap: 18px;
}

.inventory-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.flow-step {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  color: var(--text);
}

.flow-step:hover {
  background: var(--panel);
  text-decoration: none;
  border-color: var(--line-strong);
}

.flow-step strong {
  font-size: 13px;
}

.flow-step span {
  color: var(--muted);
  font-size: 12px;
}

.flow-arrow {
  display: none;
}

.inventory-stats .stat-card {
  min-height: 104px;
}

.inventory-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.inventory-priority h2,
.inventory-priority p {
  margin: 0;
}

.inventory-queue-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.15fr) minmax(0, .95fr);
  gap: 14px;
  align-items: start;
}

.inventory-queue {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 30px;
}

.queue-head strong {
  font-size: 14px;
}

.queue-list {
  display: grid;
  gap: 10px;
}

.queue-item {
  min-width: 0;
  display: grid;
  gap: 10px;
  min-height: 98px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-left-color: var(--line-strong);
  border-radius: 8px;
  background: #fafaf8;
}

.queue-item.needs-decision {
  border-left-color: var(--warn);
}

.queue-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.queue-main strong,
.queue-main span,
.queue-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-main strong {
  font-size: 13px;
}

.queue-main span {
  color: var(--text);
  font-size: 13px;
}

.queue-main small {
  color: var(--muted);
  font-size: 12px;
}

.queue-form,
.queue-status-form,
.return-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 86px;
  gap: 8px;
  align-items: center;
}

.queue-form input,
.queue-form select,
.queue-status-form select,
.return-factory-form select {
  min-height: 32px;
  font-size: 12px;
}

.queue-form button,
.queue-status-form button,
.return-actions button {
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.queue-status-form {
  grid-template-columns: minmax(0, 1fr) 70px;
}

.return-actions {
  grid-template-columns: auto minmax(140px, 1fr) auto;
}

.return-factory-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
}

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

.inventory-workbench h2,
.inventory-sections h2 {
  margin-top: 0;
}

.inventory-workbench .muted {
  margin-bottom: 10px;
  font-size: 12px;
}

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

.inventory-form .span-all {
  grid-column: 1 / -1;
}

.inventory-sections {
  display: grid;
  gap: 18px;
}

.inventory-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.inventory-two-col .section-head {
  margin-top: 0;
}

.inventory-state-table th,
.inventory-state-table td {
  white-space: nowrap;
}

.inventory-state-table th:nth-child(2),
.inventory-state-table td:nth-child(2),
.inventory-state-table th:nth-child(3),
.inventory-state-table td:nth-child(3) {
  min-width: 150px;
  white-space: normal;
}

.supplier-card-grid {
  display: grid;
  gap: 10px;
}

.supplier-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.supplier-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.supplier-metrics span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 7px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .48;
}

.content-workflow {
  display: grid;
  gap: 18px;
  align-items: start;
}

.content-sku-filter {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.content-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.upload-ref-module {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.upload-ref-module .content-form {
  margin-bottom: 0;
}

.enhanced-ref-workbench {
  display: grid;
  gap: 14px;
}

.enhanced-ref-workbench .content-form {
  margin-bottom: 0;
}

.content-form-actions {
  align-self: end;
}

.checkbox-label {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.content-asset-list {
  display: grid;
  gap: 10px;
}

.original-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  align-items: start;
}

.original-ref-card {
  min-width: 0;
  display: grid;
  grid-template-rows: 96px auto;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.original-ref-preview {
  width: 100%;
  height: 96px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}

.original-ref-preview:hover {
  background: transparent;
}

.original-ref-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.original-ref-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
}

.content-asset {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.content-asset .mono {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-asset-preview {
  width: 78px;
  height: 96px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.content-asset-preview:hover {
  background: transparent;
}

.content-asset-preview img {
  width: 78px;
  height: 96px;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ddd;
}

.promo-generation-card {
  display: grid;
  gap: 14px;
}

.template-management {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.template-index-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.template-create-form {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(160px, 240px) auto;
  gap: 8px;
  align-items: center;
}

.promo-generation-form {
  display: grid;
  gap: 12px;
}

.promo-generation-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.promo-template-field {
  max-width: none;
}

.promo-template-field .content-section-head {
  margin-bottom: 6px;
}

.promo-generation-actions {
  justify-content: start;
}

.content-help {
  font-size: 12px;
}

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

.content-section-head-left {
  justify-content: flex-start;
  gap: 8px;
}

.content-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.template-image-picker {
  min-width: 0;
}

.template-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.template-index-card {
  display: grid;
  gap: 8px;
  color: var(--text);
}

.template-index-card:hover {
  text-decoration: none;
  background: #fafaf8;
}

.template-index-card h3 {
  margin: 0;
  font-size: 15px;
}

.template-image-toolbar {
  margin-bottom: 8px;
}

.template-image-toolbar button {
  min-height: 30px;
  padding: 5px 10px;
}

.template-image-list {
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-image-option {
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-align: left;
  display: grid;
  gap: 3px;
  align-content: center;
  max-width: 240px;
  white-space: normal;
}

.template-image-option:hover {
  border-color: var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.template-image-title {
  line-height: 1.25;
}

.template-image-detail {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
}

.template-image-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.template-image-option.is-selected:hover {
  border-color: var(--accent-strong);
  background: #dff0eb;
  color: var(--accent-strong);
}

.template-image-option.is-selected .template-image-detail {
  color: var(--accent-strong);
}

.template-image-option:hover .template-image-detail,
.template-image-option.is-selected:hover .template-image-detail {
  color: inherit;
}

.ref-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.enhanced-ref-grid {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}

.ref-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.enhanced-ref-card {
  grid-template-columns: 1fr;
}

.ref-card-select {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 12px;
}

.ref-option input,
.ref-card-select input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  margin-top: 2px;
}

.ref-card-preview {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.ref-card-preview:hover {
  background: transparent;
}

.ref-option img,
.ref-card-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ddd;
}

.enhanced-ref-card .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-card-form button {
  width: 100%;
}

.content-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.content-review-actions {
  margin-top: 8px;
}

/* --- Template editor --- */
.template-meta-card {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(180px, 320px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.template-save-actions {
  justify-content: end;
}

.template-editor-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(360px, .95fr) minmax(360px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.template-item-sidebar,
.template-canvas-card,
.template-fields-card {
  min-width: 0;
}

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

.template-item-button {
  min-height: 58px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafaf8;
  color: var(--text);
  text-align: left;
}

.template-item-button:hover {
  border-color: var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.template-item-button strong,
.template-item-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.template-item-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.template-item-button.is-selected:hover {
  border-color: var(--accent-strong);
  background: #dff0eb;
  color: var(--accent-strong);
}

.template-item-button:hover span,
.template-item-button.is-selected span,
.template-item-button.is-selected:hover span {
  color: inherit;
}

.template-canvas-shell {
  display: grid;
  justify-items: center;
}

.template-hotspot-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.template-hotspot-presets span {
  font-size: 12px;
  font-weight: 750;
}

.template-hotspot-presets button {
  min-height: 30px;
  padding: 5px 10px;
}

.template-canvas {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px),
    linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
    #fbfbf8;
  background-size: 10% 10%;
  overflow: hidden;
}

.template-hotspot {
  position: absolute;
  z-index: 1;
  min-width: 44px;
  min-height: 34px;
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 6px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(20, 116, 95, .15);
  color: var(--accent-strong);
  text-align: left;
  cursor: move;
  touch-action: none;
  overflow: visible;
}

.template-hotspot.category-model {
  border-color: #14745f;
  background: rgba(20, 116, 95, .15);
  color: #0f5b4a;
}

.template-hotspot.category-product {
  border-color: #3267a8;
  background: rgba(50, 103, 168, .14);
  color: #244f82;
}

.template-hotspot.category-text {
  border-color: #8a5a12;
  background: rgba(188, 139, 43, .17);
  color: #68420a;
}

.template-hotspot.category-logo {
  border-color: #7a4c9e;
  background: rgba(122, 76, 158, .14);
  color: #5d367c;
}

.template-hotspot.category-background {
  border-color: #6b7280;
  background: rgba(107, 114, 128, .13);
  color: #4b5563;
}

.template-hotspot strong,
.template-hotspot span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.template-hotspot strong {
  font-size: 12px;
}

.template-hotspot span {
  font-size: 11px;
}

.template-hotspot small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.12;
  opacity: .86;
  pointer-events: none;
}

.template-hotspot-resize {
  position: absolute;
  z-index: 2;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .22);
  opacity: .96;
  pointer-events: auto;
}

.template-hotspot-resize.handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.template-hotspot-resize.handle-n { top: -7px; left: calc(50% - 6px); cursor: ns-resize; }
.template-hotspot-resize.handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.template-hotspot-resize.handle-e { top: calc(50% - 6px); right: -7px; cursor: ew-resize; }
.template-hotspot-resize.handle-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.template-hotspot-resize.handle-s { bottom: -7px; left: calc(50% - 6px); cursor: ns-resize; }
.template-hotspot-resize.handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.template-hotspot-resize.handle-w { top: calc(50% - 6px); left: -7px; cursor: ew-resize; }

.template-hotspot.is-derived {
  border-style: dashed;
  background: rgba(186, 145, 64, .16);
  color: #6f5014;
  cursor: default;
}

.template-hotspot.is-selected {
  z-index: 3;
  border-color: var(--ink);
  background: rgba(39, 39, 36, .14);
  color: var(--ink);
}

.template-editor-hint {
  margin-top: 10px;
}

.template-hotspot-form,
.template-field-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.template-hotspot-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.template-hotspot-form label[hidden] {
  display: none;
}

.template-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.template-field-module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 4px 0 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.template-field-module-tab {
  min-height: 30px;
  padding: 5px 10px;
  border-color: var(--line);
  background: #f8f8f5;
  color: var(--text);
  font-size: 12px;
}

.template-field-module-tab:hover {
  border-color: var(--ink);
  background: #ffffff;
  color: var(--ink);
}

.template-field-module-tab.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.template-field-source-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 30px;
  align-items: center;
  margin-top: 10px;
}

.template-field-source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8f8f5;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.template-field-source-pill.status-derived,
.template-field-source-pill.status-strategy {
  border-color: rgba(20, 116, 95, .28);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.template-field-source-pill.status-override {
  border-color: rgba(50, 103, 168, .30);
  background: rgba(50, 103, 168, .10);
  color: #244f82;
}

.template-field-source-pill.status-legacy {
  border-color: rgba(138, 90, 18, .28);
  background: rgba(188, 139, 43, .13);
  color: #68420a;
}

.template-field-source-pill.status-warning {
  border-color: rgba(138, 90, 18, .30);
  background: rgba(255, 196, 87, .16);
  color: #6f4708;
}

.template-field-source-pill.status-conflict {
  border-color: rgba(174, 48, 48, .34);
  background: rgba(174, 48, 48, .12);
  color: #8a2424;
}

.template-field-groups {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.template-field-group {
  min-width: 0;
  margin: 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.template-field-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.template-field-group[hidden] {
  display: none;
}

.template-field-group legend {
  padding: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}

.template-field-group .template-field-grid {
  margin-top: 8px;
}

.template-field-grid .span-all {
  grid-column: 1 / -1;
}

.template-field-grid textarea {
  resize: vertical;
}

.template-field-grid input[list] {
  padding-right: 8px;
}

.template-field-grid label.is-derived-field input,
.template-field-grid label.is-derived-field select,
.template-field-grid label.is-derived-field textarea {
  border-style: dashed;
  background: #f6f6f2;
  color: var(--muted);
}

.template-confirm-backdrop[hidden] {
  display: none;
}

.template-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 18, 16, .42);
}

.template-confirm-dialog {
  width: min(520px, 100%);
  max-height: min(620px, calc(100vh - 40px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0,0,0,.24);
}

.template-confirm-dialog h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
}

.template-confirm-message {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.template-confirm-message p {
  margin: 0;
}

.template-confirm-message .template-confirm-gap {
  min-height: 6px;
}

.template-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.template-field-status {
  float: right;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eeeeeb;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.template-strategy-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  align-items: stretch;
}

.template-strategy-help {
  grid-column: 1 / -1;
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.template-strategy-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: flex-start;
  gap: 6px;
  min-height: 0;
  padding: 3px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
}

.template-strategy-option:has(input:checked) {
  color: var(--accent-strong);
}

.template-strategy-option input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 1px 0 0;
  padding: 0;
}

.template-strategy-option-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.template-strategy-option-title {
  font-weight: 750;
  line-height: 1.25;
}

.template-strategy-option-description {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.final-json-field textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  background: #f8f8f5;
  color: #31312d;
}

.final-json-field textarea[readonly] {
  cursor: text;
}

@media (max-width: 1180px) {
  .inventory-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inventory-queue-grid {
    grid-template-columns: 1fr;
  }

  .inventory-workbench,
  .inventory-two-col,
  .content-workflow,
  .template-editor-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .inventory-flow,
  .inventory-form,
  .content-form,
  .content-sku-filter,
  .promo-generation-head,
  .template-create-form,
  .template-meta-card,
  .template-hotspot-form,
  .template-field-grid,
  .template-strategy-checks {
    grid-template-columns: 1fr;
  }

  .inventory-page table {
    display: block;
    overflow-x: auto;
  }

  .queue-form,
  .queue-status-form,
  .return-actions,
  .return-factory-form,
  .supplier-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) {
  .dashboard-hero,
  .dashboard-lower {
    grid-template-columns: 1fr;
  }

  .agent-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .ceo-task-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .ceo-task-row .button,
  .ceo-task-row button {
    width: 100%;
  }

  .agent-board,
  .signal-grid {
    grid-template-columns: 1fr;
  }

  .activity-item {
    grid-template-columns: 76px minmax(0, 1fr) 42px;
    align-items: start;
  }

  .activity-label {
    grid-column: 2;
  }

  .activity-detail {
    grid-column: 2 / -1;
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .dashboard-panel {
    padding: 13px;
  }

  .dashboard-section-head {
    display: grid;
  }

  .agent-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-alert {
    grid-template-columns: 1fr;
  }

  .dashboard-alert-actions {
    justify-items: start;
  }
}

/* --- Toast notifications --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  animation: toast-in .3s ease;
}

.toast.toast-out {
  animation: toast-out .3s ease forwards;
}

.toast-success { border-left: 4px solid var(--accent); }
.toast-error { border-left: 4px solid var(--bad); }
.toast-info { border-left: 4px solid var(--info); }
.toast-warning { border-left: 4px solid var(--warn); }

.toast-icon { flex-shrink: 0; font-size: 18px; line-height: 1; }
.toast-body { flex: 1; }
.toast-body strong { display: block; margin-bottom: 2px; }
.toast-body small { color: var(--muted); font-size: 12px; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; padding: 0 2px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* --- Content generation queue panel --- */
.content-queue-panel {
  margin-top: 14px;
}

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

.content-queue-head h2 {
  margin: 0;
}

.content-queue-item {
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 62px 96px minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-soft);
  font-size: 13px;
}

.content-queue-item:last-child { border-bottom: none; }

.content-queue-time {
  color: var(--muted);
  font-size: 12px;
  line-height: 22px;
  white-space: nowrap;
}

.content-queue-type {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 800;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-queue-detail {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--text);
}

.content-queue-detail strong,
.content-queue-detail small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-queue-detail small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.content-queue-status {
  justify-self: end;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.content-queue-status .badge { font-size: 11px; padding: 2px 8px; }

.queue-item-delete {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.queue-item-delete:hover {
  color: var(--bad);
  border-color: var(--bad);
  background: var(--bad-soft);
}

.task-progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.task-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}

.content-queue-running {
  background: var(--info-soft);
}

.content-queue-completed {
  background: var(--accent-soft);
}

.content-queue-failed {
  background: var(--bad-soft);
}

/* Upload form overlay spinner */
.content-form { position: relative; }

.content-form .upload-spinner {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.92);
  z-index: 10;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  border-radius: inherit;
  padding: 18px;
}

.content-form.uploading .upload-spinner {
  display: flex;
}

.upload-spinner .spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.upload-spinner .spinner-text {
  font-size: 14px;
  color: var(--text);
  font-weight: 750;
}

.upload-progress {
  width: min(360px, 84%);
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}

.upload-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .16s ease;
}

.upload-progress-meta {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Disable button while uploading */
.content-form.uploading button[type="submit"] {
  pointer-events: none;
  opacity: .5;
}
