:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.12);
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --blue: #2563eb;
  --orange: #ea580c;
  --danger: #b91c1c;
  --shadow: 0 16px 44px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--blue);
}

button, input, textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

.status-pill.muted,
.badge-muted {
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
}

.badge-ok {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
}

.badge-error {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
}

.badge-warn {
  background: rgba(234, 88, 12, 0.12);
  color: var(--orange);
}

.btn {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  padding: 12px 18px;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #ffffff;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--blue), #60a5fa);
  color: #ffffff;
}

.btn-ghost {
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink);
}

.btn-danger {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
}

.btn-inline {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.06);
}

.dashboard-shell {
  width: min(1780px, calc(100% - 24px));
  margin: 12px auto 28px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.sidebar,
.page-topbar,
.panel-card,
.status-strip,
.filter-bar,
.current-group-card,
.bulk-card,
.table-card,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 24px 20px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  min-height: calc(100vh - 24px);
  position: sticky;
  top: 12px;
}

.brand-block {
  display: grid;
  gap: 10px;
}

.brand-block h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.brand-copy,
.page-description,
.panel-copy,
.stack-row p,
.trend-row p,
.empty-card,
.info-list dt,
.login-copy,
.helper-text {
  color: var(--muted);
}

.main-nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 18px;
  background: transparent;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(15, 118, 110, 0.08);
}

.nav-title {
  font-size: 17px;
  font-weight: 700;
}

.nav-copy {
  color: var(--muted);
  font-size: 13px;
}

.sidebar-foot {
  display: grid;
  gap: 12px;
}

.status-stack {
  display: grid;
  gap: 8px;
}

.content-shell {
  display: grid;
  gap: 18px;
  align-content: start;
}

.page-topbar {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.page-topbar h2 {
  margin: 6px 0 10px;
  font-size: 32px;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.view-panel {
  display: grid;
  gap: 18px;
}

.status-strip {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.status-chip {
  background: var(--panel-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid;
  gap: 8px;
}

.status-chip span {
  color: var(--muted);
  font-size: 13px;
}

.status-chip strong {
  font-size: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: grid;
  gap: 12px;
  min-height: 172px;
}

.metric-card-emphasis {
  background: linear-gradient(180deg, #f1fbf8 0%, #ffffff 100%);
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  font-size: clamp(32px, 3vw, 48px);
  line-height: 1;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.overview-main-grid,
.overview-bottom-grid,
.sync-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.panel-card {
  padding: 22px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 6px 0 0;
  font-size: 24px;
}

.stack-list,
.trend-list,
.history-stack {
  display: grid;
  gap: 10px;
}

.stack-row,
.trend-row,
.history-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.stack-row-action {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.stack-row strong,
.trend-row strong,
.history-row strong {
  display: block;
  margin-bottom: 6px;
}

.stack-row p,
.trend-row p,
.history-row p {
  margin: 0;
  line-height: 1.5;
}

.stack-number,
.trend-number,
.stack-time {
  white-space: nowrap;
  font-weight: 700;
}

.empty-card {
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 18px;
}

.empty-card.small {
  padding: 14px 16px;
}

.filter-bar {
  padding: 22px;
}

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

.add-card {
  padding: 22px;
}

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

.add-form-grid .span-2 {
  grid-column: span 2;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--ink);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-field.inline {
  display: inline-flex;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.products-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.group-panel {
  position: sticky;
  top: 12px;
}

.group-create-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.group-list {
  display: grid;
  gap: 10px;
  max-height: 70vh;
  overflow-y: auto;
}

.group-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.group-item-main {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.group-item-side {
  display: grid;
  justify-items: end;
  gap: 8px;
  flex-shrink: 0;
}

.group-edit-btn {
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
}

.group-item.is-active {
  border-color: rgba(15, 118, 110, 0.32);
  background: rgba(15, 118, 110, 0.08);
}

.group-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.products-main {
  display: grid;
  gap: 16px;
  min-width: 0;
  align-content: start;
}

.current-group-card {
  padding: 20px 22px;
}

.current-group-card h3 {
  margin: 6px 0 8px;
  font-size: 28px;
}

.bulk-card {
  padding: 16px 18px;
  min-height: auto;
}

.bulk-bar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.bulk-left,
.bulk-right,
.table-actions,
.sync-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.sync-actions.vertical {
  flex-direction: column;
  align-items: stretch;
}

.table-card {
  padding: 0;
  overflow: hidden;
  align-self: start;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
}

.product-table th,
.product-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.product-table th {
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.product-table tr.is-selected {
  background: rgba(37, 99, 235, 0.04);
}

.table-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  font-weight: 700;
}

.table-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: rgba(15, 23, 42, 0.06);
}

.table-thumb.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  padding: 14px 18px 18px;
}

.pagination-info {
  color: var(--muted);
}

.detail-panel {
  display: grid;
  gap: 18px;
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.detail-stat-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.detail-stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.detail-history-layout h4 {
  margin: 0 0 12px;
  font-size: 18px;
}

.sync-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sync-card {
  display: grid;
  gap: 14px;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.info-list div {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.info-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.info-list dt {
  font-size: 13px;
}

.info-list dd {
  margin: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, calc(100vw - 48px));
  padding: 30px;
}

.login-card h1 {
  margin: 8px 0 12px;
  font-size: 34px;
}

.login-form {
  display: grid;
  gap: 14px;
}

@media (max-width: 1380px) {
  .metric-grid,
  .sync-card-grid,
  .detail-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .products-layout,
  .add-grid,
  .overview-main-grid,
  .overview-bottom-grid,
  .sync-bottom-grid,
  .status-strip,
  .filter-grid,
  .add-form-grid {
    grid-template-columns: 1fr;
  }

  .page-topbar,
  .bulk-bar,
  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 760px) {
  .metric-grid,
  .sync-card-grid,
  .detail-stats-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-shell {
    width: calc(100% - 16px);
    margin: 8px auto 24px;
  }

  .sidebar,
  .page-topbar,
  .panel-card,
  .status-strip,
  .filter-bar,
  .current-group-card,
  .bulk-card,
  .table-card,
  .login-card {
    border-radius: 22px;
  }
}

.detail-inline-row td {
  padding: 0 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.inline-detail-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-soft);
  padding: 18px;
  display: grid;
  gap: 18px;
  margin-top: 8px;
}

.inline-detail-head h3 {
  margin: 6px 0 8px;
  font-size: 22px;
  line-height: 1.35;
}

.thumb-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.thumb-link-placeholder {
  text-decoration: none;
}
