:root {
  color-scheme: light;
  --purple: #7220d5;
  --purple-dark: #5d16b7;
  --purple-soft: #f4eafa;
  --orange: #ff9f24;
  --ink: #1f1f28;
  --muted: #70717d;
  --line: #e7e2ed;
  --panel: #ffffff;
  --canvas: #f6f5f8;
  --danger: #d33b3b;
  --ok: #159447;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 310px 1fr auto;
  align-items: center;
  min-height: 70px;
  padding: 0 22px;
  background: var(--purple);
  color: #fff;
  box-shadow: 0 3px 12px rgba(42, 18, 79, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.brand-text {
  color: #fff;
  font-size: 25px;
  font-weight: 900;
}

.app-topbar nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.app-topbar nav a {
  padding: 14px 20px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 700;
}

.app-topbar nav a.active,
.app-topbar nav a:hover {
  background: var(--purple-dark);
}

.language-select {
  min-width: 116px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 0 10px;
}

.language-select option {
  color: var(--ink);
}

.home-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 44px auto;
}

.hero-panel {
  min-height: 560px;
  padding: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff 0%, #fbf7ff 55%, #efe1ff 100%);
  box-shadow: 0 8px 30px rgba(33, 19, 50, 0.1);
}

.hero-panel p,
.panel-title p,
.admin-header p {
  margin: 0 0 8px;
  color: var(--purple);
  font-weight: 800;
}

.hero-panel h1 {
  margin: 0 0 36px;
  font-size: 38px;
}

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

.action-card {
  display: grid;
  gap: 34px;
  min-height: 190px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(46, 29, 68, 0.08);
}

.action-card span {
  color: var(--purple);
  font-size: 18px;
  font-weight: 800;
}

.action-card strong {
  font-size: 24px;
}

.action-card.primary {
  border: 2px solid var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 159, 36, 0.13);
}

.order-layout,
.admin-layout,
.mobile-order-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: calc(100vh - 70px);
}

.mobile-order-layout {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.side-menu {
  padding: 42px 0;
  background: #fff;
  border-right: 1px solid #eeeaf4;
}

.side-menu strong {
  display: block;
  margin: 0 38px 26px;
  color: var(--purple);
  font-size: 18px;
}

.side-menu a {
  display: block;
  margin: 0 6px 12px;
  padding: 20px 64px;
  border-radius: 8px;
  font-size: 18px;
}

.side-menu a.active,
.side-menu a:hover {
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 800;
}

.workbench,
.admin-workbench {
  padding: 20px 22px 80px;
}

.product-strip,
.admin-panel,
.query-panel {
  margin-bottom: 20px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 12px rgba(31, 31, 40, 0.08);
}

.product-strip {
  padding: 24px 28px;
}

.product-strip.simple-title {
  padding: 20px 24px;
}

.product-strip h1 {
  margin: 0 0 20px;
  font-size: 26px;
}

.product-cards {
  display: flex;
  gap: 40px;
}

.product-card {
  display: grid;
  place-items: center;
  gap: 18px;
  width: 326px;
  min-height: 136px;
  border: 1px solid #ddd9e4;
  border-radius: 6px;
  background: #fff;
}

.product-card.selected {
  position: relative;
  border: 2px solid var(--orange);
  color: var(--orange);
  box-shadow: 0 4px 10px rgba(255, 159, 36, 0.24);
}

.product-card.selected::after {
  content: "✓";
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  background: var(--orange);
  color: #fff;
  font-size: 26px;
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  padding-left: 20px;
  padding-bottom: 20px;
}

.timeline-form {
  border-radius: 8px;
  background: #fff;
  padding: 28px 28px 95px;
  box-shadow: 0 2px 12px rgba(31, 31, 40, 0.08);
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 760px);
  column-gap: 20px;
  padding-bottom: 28px;
}

.step::before {
  content: "";
  position: absolute;
  left: 23px;
  top: 48px;
  bottom: 0;
  width: 3px;
  border-radius: 999px;
  background: #c9c3d1;
}

.step:last-of-type::before {
  display: none;
}

.marker {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #67717f;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.step.active .marker,
.step.active::before {
  background: var(--purple);
}

.content label {
  display: block;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
}

.step.active .content label {
  color: var(--purple);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #d7d3dd;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input,
select {
  min-height: 44px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 110px;
  padding: 14px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(114, 32, 213, 0.12);
}

.field-hint,
.error {
  min-height: 20px;
  margin: 8px 0 0;
  font-size: 14px;
}

.field-hint.ok {
  color: var(--ok);
}

.field-hint.danger,
.error {
  color: var(--danger);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 10px -28px -95px;
  padding: 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.submit-button,
.ghost-button,
.query-form button,
.filter-grid button,
.merchant-form button,
.token-row button,
.export-link,
.table-action {
  min-height: 44px;
  border: 1px solid var(--purple);
  border-radius: 7px;
  padding: 0 34px;
  font-weight: 800;
  cursor: pointer;
}

.submit-button,
.query-form button,
.filter-grid button,
.merchant-form button,
.token-row button,
.export-link,
.table-action {
  background: var(--purple);
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--purple);
}

.submit-button:disabled {
  border-color: #a9a2b3;
  background: #a9a2b3;
}

.form-message {
  margin: 18px 0 0 68px;
  color: var(--purple);
  font-size: 16px;
}

.form-message.compact {
  margin: 10px 0 18px;
}

.query-shell {
  width: min(900px, calc(100% - 32px));
  margin: 42px auto;
}

.query-panel {
  padding: 32px;
}

.query-panel h1 {
  margin: 0 0 22px;
}

.query-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.result-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.result-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-card strong {
  color: var(--purple);
  font-size: 20px;
}

.empty {
  color: var(--muted);
}

.admin-account {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
}

.admin-workbench {
  overflow-x: hidden;
}

.admin-panel {
  padding: 24px;
}

.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-title h1 {
  margin: 0;
  font-size: 26px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 10px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 800;
}

.admin-login {
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(31, 31, 40, 0.08);
}

.admin-login label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.token-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
}

.filter-grid,
.merchant-form,
.import-form,
.password-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.merchant-form {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
}

.import-form,
.password-form {
  grid-template-columns: minmax(220px, 360px) auto;
}

.filter-grid label,
.merchant-form label,
.import-form label,
.password-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.success-dialog {
  width: min(360px, calc(100vw - 36px));
  border: 0;
  border-radius: 14px;
  padding: 26px;
  text-align: center;
  box-shadow: 0 18px 70px rgba(35, 18, 52, 0.28);
}

.edit-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: 90vh;
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 18px 70px rgba(35, 18, 52, 0.28);
}

.edit-dialog::backdrop {
  background: rgba(27, 17, 40, 0.42);
}

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

.edit-dialog h2,
.dialog-actions,
.edit-dialog .form-message {
  grid-column: 1 / -1;
}

.edit-dialog h2 {
  margin: 0 0 6px;
  color: var(--purple);
}

.edit-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.edit-dialog textarea {
  min-height: 84px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.success-dialog::backdrop {
  background: rgba(27, 17, 40, 0.42);
}

.success-dialog h2 {
  margin: 0 0 12px;
  color: var(--purple);
}

.success-dialog button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--purple);
  color: #fff;
  font-weight: 800;
}

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

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #eeeaf4;
  text-align: left;
  vertical-align: top;
}

th {
  background: #faf8fd;
  color: var(--purple);
  font-size: 14px;
}

td {
  font-size: 14px;
}

@media (max-width: 900px) {
  .app-topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px 16px;
  }

  .brand-text {
    font-size: 20px;
  }

  .app-topbar nav {
    display: none;
  }

  .app-topbar nav a {
    padding: 8px 12px;
    font-size: 15px;
  }

  .home-actions,
  .order-layout,
  .mobile-order-layout,
  .admin-layout,
  .filter-grid,
  .merchant-form,
  .import-form,
  .password-form,
  .query-form {
    grid-template-columns: 1fr;
  }

  .side-menu {
    display: none;
  }

  .workbench,
  .admin-workbench {
    padding: 12px;
  }

  .home-shell,
  .query-shell {
    width: min(100%, calc(100% - 24px));
    margin: 18px auto;
  }

  .hero-panel {
    padding: 26px;
    min-height: auto;
  }

  .hero-panel h1 {
    font-size: 25px;
  }

  .action-card {
    min-height: 128px;
    gap: 18px;
    padding: 22px;
  }

  .action-card strong {
    font-size: 20px;
  }

  .product-strip {
    padding: 18px;
  }

  .product-strip h1 {
    font-size: 22px;
    margin-bottom: 0;
  }

  .product-cards {
    display: none;
  }

  .product-card {
    width: 100%;
  }

  .step {
    grid-template-columns: 42px 1fr;
    column-gap: 14px;
  }

  .step::before {
    left: 20px;
  }

  .marker {
    width: 42px;
    height: 42px;
  }

  .timeline-form {
    padding: 18px 14px 92px;
    box-shadow: none;
  }

  .content label {
    font-size: 17px;
  }

  input,
  select {
    min-height: 48px;
  }

  .sticky-actions {
    margin-inline: -14px;
    padding: 14px;
  }

  .submit-button,
  .ghost-button {
    flex: 1;
    padding-inline: 12px;
  }

  .admin-account {
    flex-wrap: wrap;
  }

  .edit-dialog form {
    grid-template-columns: 1fr;
    padding: 18px;
  }
}
