:root {
  --ink: #111111;
  --ink-soft: #252525;
  --paper: #ffffff;
  --page: #f5f5f2;
  --line: #e2e2dc;
  --muted: #6f6f68;
  --yellow: #ffd43b;
  --yellow-deep: #e9b900;
  --red: #e43d30;
  --blue: #2155ff;
  --green: #128a52;
  --shadow: 0 18px 42px rgba(15, 15, 15, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #202020;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 212, 59, 0.18), transparent 34vw),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    #202020;
  background-size: auto, 30px 30px, 30px 30px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.device-label {
  position: fixed;
  left: max(24px, calc((100vw - 430px) / 2 - 210px));
  top: 28px;
  z-index: 1;
  display: grid;
  gap: 6px;
  color: #fff;
}

.device-label span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 900;
}

.device-label strong {
  color: var(--yellow);
  font-size: 18px;
  font-weight: 950;
}

.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100vw - 28px));
  height: min(900px, calc(100vh - 32px));
  margin: 16px auto;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: 24px 24px;
  border: 10px solid #0d0d0d;
  border-radius: 38px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.46);
}

.app-shell::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 30;
  width: 112px;
  height: 24px;
  background: #0d0d0d;
  border-radius: 0 0 16px 16px;
  transform: translateX(-50%);
  pointer-events: none;
}

.topbar {
  position: relative;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  gap: 12px;
  padding: 36px 14px 12px;
  color: #fff;
  background: #101010;
  border-bottom: 3px solid var(--yellow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid #fff;
  border-radius: 8px;
  font-weight: 950;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 900;
}

.brand-copy span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  white-space: nowrap;
}

.nav-tab svg,
button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  stroke-width: 2.35;
}

.nav-tab b {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.nav-tab.is-active {
  color: var(--ink);
  background: var(--yellow);
  border-color: var(--yellow);
}

.nav-tab.is-active b {
  background: #fff;
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  padding: 16px 12px 28px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 8px 0 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 950;
}

.route-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: #fff;
  background: var(--ink);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.head-price {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: left;
}

.head-price span,
.price-lock span,
.eyebrow,
.control-title span,
.admin-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.head-price span {
  color: rgba(17, 17, 17, 0.62);
}

.head-price strong {
  display: block;
  margin-top: 2px;
  font-size: 32px;
  line-height: 1;
  font-weight: 950;
}

.designer-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.preview-surface {
  order: 1;
}

.control-surface {
  order: 2;
}

.side-surface {
  order: 3;
}

.control-surface,
.preview-surface,
.side-surface,
.admin-panel,
.detail-shell,
.empty-state {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-surface {
  padding: 16px;
}

.control-title,
.preview-bar,
.section-title,
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.control-title {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.control-title h2,
.preview-bar h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.08;
  font-weight: 950;
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.icon-action:hover {
  border-color: var(--ink);
}

.control-group {
  margin-top: 18px;
}

.group-label {
  display: block;
  margin-bottom: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

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

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

.option-tile,
.swatch-tile,
.icon-tile,
.segment-btn {
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease, background 150ms ease;
}

.option-tile:hover,
.swatch-tile:hover,
.icon-tile:hover,
.segment-btn:hover {
  border-color: var(--ink);
}

.option-tile.is-selected,
.swatch-tile.is-selected,
.icon-tile.is-selected,
.segment-btn.is-selected {
  background: #fff8cc;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--yellow), 3px 3px 0 var(--ink);
}

.option-tile {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 78px;
  padding: 10px;
  text-align: left;
}

.option-tile svg {
  width: 18px;
  height: 18px;
}

.option-tile strong {
  display: block;
  font-size: 13px;
  line-height: 1.18;
  font-weight: 900;
}

.option-tile small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.text-input-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.text-input-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(255, 212, 59, 0.38);
}

.text-input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.text-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
  font-weight: 950;
}

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

.swatch-tile,
.icon-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 68px;
  padding: 8px;
  font-size: 12px;
  font-weight: 900;
}

.swatch {
  width: 26px;
  height: 26px;
  border: 2px solid var(--ink);
  border-radius: 999px;
}

.swatch[data-color="black"] {
  background: #111;
}

.swatch[data-color="white"] {
  background: #fff;
}

.swatch[data-color="yellow"] {
  background: var(--yellow);
}

.swatch[data-color="red"] {
  background: var(--red);
}

.swatch[data-color="blue"] {
  background: var(--blue);
}

.swatch[data-color="colorful"] {
  background: conic-gradient(from 90deg, #f44336, #ffd43b, #26a269, #2155ff, #f44336);
}

.icon-tile svg {
  width: 21px;
  height: 21px;
}

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

.segment-btn {
  min-height: 44px;
  font-weight: 900;
}

.preview-surface {
  overflow: hidden;
}

.preview-bar {
  align-items: stretch;
  flex-direction: column;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.price-lock {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 8px;
  text-align: left;
}

.price-lock span {
  color: rgba(17, 17, 17, 0.62);
}

.price-lock strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
}

.plate-stage {
  display: grid;
  place-items: center;
  min-height: 204px;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%) 0 0 / 18px 18px,
    #151515;
  border-bottom: 1px solid var(--line);
}

#plateCanvas {
  width: 100%;
  max-width: 860px;
  height: auto;
  aspect-ratio: 8 / 3;
  border-radius: 8px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 950;
}

.primary-action {
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-action:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.secondary-action {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.secondary-action:hover {
  border-color: var(--ink);
}

.compact {
  min-height: 40px;
  width: auto;
}

.price-breakdown {
  padding: 16px 18px 18px;
}

.section-title {
  justify-content: flex-start;
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
}

.section-title svg {
  width: 18px;
  height: 18px;
}

.price-details {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.price-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  padding: 0 10px;
  background: #f8f8f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.price-line strong {
  white-space: nowrap;
}

.side-surface {
  display: none;
  gap: 14px;
  padding: 14px;
}

.mini-phone {
  overflow: hidden;
  color: #fff;
  background: #0f0f10;
  border: 8px solid #111;
  border-radius: 28px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.mini-status,
.mini-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 850;
}

.mini-nav {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mini-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 154px;
  padding: 14px;
  background: #1c1c1c;
}

.mini-preview img {
  display: none;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mini-preview.has-image img {
  display: block;
}

.mini-preview.has-image .generated-empty {
  display: none;
}

.generated-empty {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 118px;
  color: rgba(255, 255, 255, 0.56);
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  font-weight: 900;
}

.mini-spec {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.mini-spec-row,
.latest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  font-size: 12px;
}

.mini-spec-row span,
.latest-row span {
  color: rgba(255, 255, 255, 0.58);
}

.mini-spec-row strong,
.latest-row strong {
  text-align: right;
  font-weight: 950;
}

.latest-order {
  padding: 12px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
}

.latest-order .section-title {
  color: #fff;
}

.latest-card {
  margin-top: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.latest-card button {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  color: var(--ink);
  background: var(--yellow);
  border: 0;
  border-radius: 8px;
  font-weight: 950;
}

.orders-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.order-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.order-card button {
  display: grid;
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.order-thumb {
  display: grid;
  place-items: center;
  min-height: 168px;
  padding: 16px;
  background: #151515;
}

.order-thumb img,
.detail-preview img {
  width: 100%;
  max-width: 460px;
  border-radius: 8px;
}

.order-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

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

.order-no {
  font-size: 15px;
  font-weight: 950;
}

.order-price {
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
}

.order-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.status-pending {
  color: #6d4b00;
  background: #fff2b8;
}

.status-making {
  color: #15448f;
  background: #dce8ff;
}

.status-ready {
  color: #0b6c3d;
  background: #d9f5e7;
}

.status-done {
  color: #2d2d2d;
  background: #e8e8e8;
}

.status-cancel {
  color: #a12018;
  background: #ffe0dc;
}

.detail-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
}

.detail-preview {
  display: grid;
  place-items: center;
  min-height: 238px;
  padding: 18px;
  background: #151515;
}

.detail-info {
  padding: 24px;
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-title h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
}

.detail-fields {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.detail-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  padding: 0 12px;
  background: #f8f8f4;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.detail-field strong {
  text-align: right;
  font-weight: 950;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.admin-panel {
  overflow: hidden;
}

.admin-toolbar {
  align-items: stretch;
  flex-direction: column;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-toolbar strong {
  display: block;
  font-size: 18px;
  font-weight: 950;
}

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.stat-chip strong {
  font-size: 16px;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  background: #f8f8f4;
  font-size: 12px;
  font-weight: 950;
}

.admin-table td {
  font-size: 13px;
  font-weight: 800;
}

.admin-config {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-config img {
  width: 90px;
  height: 42px;
  object-fit: cover;
  background: #111;
  border-radius: 6px;
}

.admin-status-select {
  min-height: 36px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 950;
}

.empty-state p {
  max-width: 360px;
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 760;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100% - 44px));
  padding: 13px 15px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .designer-layout {
    grid-template-columns: 1fr;
  }

  .side-surface {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  body {
    display: block;
    background:
      linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
      linear-gradient(180deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px),
      var(--page);
    background-size: 24px 24px;
  }

  .device-label {
    display: none;
  }

  .app-shell {
    width: 100%;
    height: auto;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .app-shell::before {
    display: none;
  }

  .topbar {
    position: relative;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .brand {
    min-width: 0;
  }

  .main {
    width: min(100% - 24px, 680px);
    padding-top: 16px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-price {
    width: 100%;
    text-align: left;
  }

  .designer-layout,
  .side-surface,
  .detail-shell {
    grid-template-columns: 1fr;
  }

  .option-grid.trio,
  .swatch-grid,
  .icon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plate-stage {
    min-height: 260px;
    padding: 14px;
  }

  .action-row,
  .orders-grid {
    grid-template-columns: 1fr;
  }

  .detail-preview {
    min-height: 260px;
  }
}

@media (max-width: 480px) {
  .nav-tab {
    flex: 1 0 auto;
  }

  .option-grid,
  .option-grid.trio,
  .swatch-grid,
  .icon-grid {
    grid-template-columns: 1fr;
  }

  .preview-bar,
  .admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .price-lock {
    width: 100%;
    text-align: left;
  }
}
