:root {
  --accent: #ec2b91;
  --accent-soft: rgba(236, 43, 145, 0.12);
  --accent-faint: rgba(236, 43, 145, 0.06);
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #fff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 22% 0%, rgba(236, 43, 145, 0.08), transparent 30%),
    linear-gradient(180deg, #fbfbfd 0%, var(--bg) 42%, #f1f1f4 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

body.route-loading .app-shell {
  visibility: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(22px);
}

.sidebar {
  position: relative;
  min-height: calc(100vh - 48px);
  padding: 28px 18px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(246, 246, 248, 0.72);
  backdrop-filter: blur(24px);
}

.brand-block {
  padding: 0 10px 24px;
}

.brand-mark {
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.brand-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.admin-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.admin-tabs button {
  height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #3a3a3c;
  text-align: left;
  font-weight: 700;
}

.admin-tabs button.active {
  background: var(--panel-solid);
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.home-workbench-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.home-workbench-tabs button {
  height: 36px;
  min-width: 110px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.home-workbench-tabs button.active {
  background: var(--panel-solid);
  color: var(--accent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.product-workbench-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.order-workbench-tabs {
  grid-template-columns: repeat(2, 1fr);
}

.hidden {
  display: none !important;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px rgba(236, 43, 145, 0.22);
}

.primary-btn.compact {
  width: auto;
  padding: 0 18px;
}

.ghost-btn.compact {
  height: 42px;
  width: auto;
  padding: 0 18px;
}

.primary-btn.small {
  height: 34px;
  width: auto;
  padding: 0 12px;
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-btn.small {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
}

.ghost-btn.neutral {
  background: #fff;
}

.danger-btn {
  padding: 0 14px;
  background: #fff0f6;
  color: #c91873;
}

.module-list {
  display: flex;
  gap: 8px;
}

.module-strip {
  padding: 0 0 4px;
  overflow-x: auto;
}

.home-module-card .card-title {
  margin-bottom: 14px;
}

.home-module-card .card-title p {
  margin-top: 4px;
  font-size: 13px;
}

.module-edit-area {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.module-item {
  width: 210px;
  flex: 0 0 210px;
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--text);
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 4px 10px;
  text-align: left;
}

.module-item:hover,
.module-item.active {
  border-color: rgba(236, 43, 145, 0.28);
  background: #fff;
  box-shadow: 0 10px 28px rgba(236, 43, 145, 0.08);
}

.module-index {
  grid-row: 1 / span 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.module-name {
  font-weight: 750;
}

.module-type {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  max-width: 1180px;
  width: 100%;
  justify-self: center;
  padding: 38px 42px 48px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.status {
  min-width: 92px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.status.saved {
  background: rgba(52, 199, 89, 0.14);
  color: #21833f;
}

.status.error {
  background: rgba(255, 45, 85, 0.12);
  color: #d70038;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(340px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.product-admin-layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(340px, 0.66fr);
  gap: 18px;
  align-items: start;
}

.product-editor-shell {
  max-width: 1120px;
}

.editor-card,
.order-metric {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  font-size: 18px;
  font-weight: 800;
}

.title-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid,
.visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.visual-editor {
  margin-top: 22px;
}

.product-editor-shell .visual-editor {
  display: grid;
  gap: 16px;
  margin-top: 0;
}

.product-edit-section,
.product-editor-shell .list-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.product-editor-shell .list-section {
  margin-top: 0;
}

.product-section-head {
  margin-bottom: 14px;
}

.product-section-head h3,
.product-editor-shell .list-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #3a3a3c;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(236, 43, 145, 0.52);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

input:disabled {
  color: #8e8e93;
  background: #f2f2f4;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 390px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.list-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

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

.list-head h3 {
  margin: 0;
  font-size: 17px;
}

.list-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

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

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

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

.sku-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

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

.sku-card-head strong {
  font-size: 17px;
}

.sku-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
  align-items: start;
}

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

.sku-fields label:first-child {
  grid-column: 1 / -1;
}

.sku-card .upload-dropzone {
  min-height: 96px;
  padding: 12px;
}

.sku-card .image-preview {
  max-width: 100%;
}

.product-table {
  overflow: auto;
}

.product-table table {
  width: 100%;
  border-collapse: collapse;
}

.product-table th,
.product-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  color: #3a3a3c;
  text-align: left;
  white-space: nowrap;
}

.product-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.product-cell strong,
.product-cell span {
  display: block;
}

.product-cell strong {
  color: var(--text);
  font-size: 14px;
}

.product-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.product-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, var(--accent-faint), rgba(255, 255, 255, 0.88)),
    #f5f5f7;
  background-size: cover;
  background-position: center;
}

.price-cell {
  color: var(--accent) !important;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.pill.muted {
  background: rgba(118, 118, 128, 0.12);
  color: var(--muted);
}

.text-btn,
.text-danger {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.text-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.text-danger {
  background: #fff0f6;
  color: #c91873;
}

.inline-check {
  min-height: 42px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 24px;
}

.inline-check input,
.toggle-line input {
  width: 18px;
  height: 18px;
}

.image-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.image-file-input {
  display: none;
}

.upload-dropzone {
  width: 100%;
  min-height: 86px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
}

.upload-dropzone.dragging,
.upload-dropzone:hover {
  border-color: rgba(236, 43, 145, 0.5);
  background: var(--accent-faint);
}

.upload-dropzone strong,
.upload-dropzone span {
  display: block;
}

.upload-dropzone strong {
  font-weight: 800;
}

.upload-dropzone span {
  color: var(--muted);
  font-size: 13px;
}

.image-preview {
  width: 100%;
  aspect-ratio: 16 / 7;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(135deg, #fafafa, #f1f1f4);
  background-size: cover;
  background-position: center;
}

.square-preview {
  max-width: 160px;
  aspect-ratio: 1;
}

.image-gallery-uploader {
  display: grid;
  gap: 14px;
}

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

.image-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f7;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  cursor: grab;
  transition: border-color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.image-gallery-item.dragging {
  opacity: 0.52;
  cursor: grabbing;
}

.image-gallery-item.drag-over {
  border-color: rgba(236, 43, 145, 0.75);
  transform: scale(0.98);
}

.image-index-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.78);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.image-gallery-item .remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 28px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: #fff0f6;
  color: #c91873;
  font-size: 12px;
  font-weight: 800;
}

.hint {
  padding: 18px;
  border-radius: 8px;
  background: rgba(118, 118, 128, 0.09);
  color: var(--muted);
  font-weight: 750;
}

.toggle-line {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  height: 42px;
}

pre {
  min-height: 640px;
  max-height: calc(100vh - 154px);
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: #1d1d1f;
  color: #f5f5f7;
  line-height: 1.5;
  font-size: 12px;
}

.product-publish-bar {
  position: sticky;
  bottom: 18px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(20px);
}

.product-publish-bar button {
  min-width: 128px;
}

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

.order-metric span,
.order-metric strong {
  display: block;
}

.order-metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.order-metric strong {
  margin-top: 8px;
  font-size: 34px;
}

.order-note {
  grid-column: 1 / -1;
}

.compact-select {
  width: auto;
  min-width: 138px;
}

.table-select,
.table-input {
  min-width: 138px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
}

.table-input {
  min-width: 180px;
}

.admin-order-list {
  display: grid;
  gap: 14px;
}

.admin-order-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-order-head,
.admin-order-grid,
.admin-order-controls,
.after-sale-actions {
  display: flex;
  gap: 12px;
}

.admin-order-head {
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.admin-order-head strong,
.admin-order-head span {
  display: block;
}

.admin-order-head strong {
  color: var(--text);
  font-size: 15px;
}

.admin-order-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-order-amount {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.admin-order-grid {
  align-items: flex-start;
  padding-top: 14px;
}

.admin-order-block {
  flex: 1;
  min-width: 0;
}

.admin-order-block > span,
.after-sale-box > strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-order-block strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.admin-order-block p,
.after-sale-box p {
  margin: 6px 0 0;
  color: #5f5f66;
  font-size: 12px;
  line-height: 1.55;
  white-space: normal;
}

.admin-order-items {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  white-space: normal;
}

.admin-order-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.admin-order-item-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f3dbe9, #d7f0ff);
  background-position: center;
  background-size: cover;
}

.admin-order-item-info {
  min-width: 0;
}

.admin-order-item-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-order-item-info span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-order-controls {
  flex-wrap: wrap;
}

.admin-order-controls .table-select,
.admin-order-controls .table-input {
  min-width: 150px;
}

.admin-order-controls button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.order-status-pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.order-status-pending {
  background: rgba(255, 149, 0, 0.14);
  color: #a45b00;
}

.order-status-paid {
  background: rgba(236, 43, 145, 0.12);
  color: var(--accent);
}

.order-status-shipped {
  background: rgba(0, 122, 255, 0.12);
  color: #006fd6;
}

.order-status-completed {
  background: rgba(52, 199, 89, 0.14);
  color: #1d7f3d;
}

.order-status-refunding {
  background: rgba(175, 82, 222, 0.14);
  color: #7d31a6;
}

.order-status-refunded,
.order-status-closed {
  background: rgba(118, 118, 128, 0.14);
  color: #5f5f66;
}

.after-sale-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #fff6fb;
}

.after-sale-actions {
  margin-top: 10px;
}

.stacked-cell {
  min-width: 170px;
}

.stacked-cell strong,
.stacked-cell span {
  display: block;
}

.stacked-cell strong {
  color: var(--text);
  font-size: 14px;
}

.stacked-cell span {
  max-width: 260px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .app-shell {
    width: min(100% - 24px, 860px);
    min-height: auto;
    margin: 12px auto;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .editor-layout,
  .product-admin-layout,
  .order-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
  }

  .workspace {
    padding: 24px 16px;
  }

  .workspace-header,
  .card-title,
  .title-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .visual-grid,
  .row-grid,
  .product-form-grid,
  .sku-card-body,
  .sku-fields {
    grid-template-columns: 1fr;
  }
}
