:root {
  color-scheme: light;
  --page: #f5f6fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fe;
  --text: #15172a;
  --muted: #6c7288;
  --line: #e5e8f2;
  --primary: #5b4dff;
  --primary-deep: #4035d8;
  --cyan: #17a8e5;
  --danger: #ef4444;
  --success: #079669;
  --warning: #b66a00;
  --shadow: 0 14px 36px rgba(21, 23, 42, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 0%, rgba(91, 77, 255, 0.08), transparent 28rem),
    linear-gradient(180deg, #fbfcff 0%, var(--page) 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

body[dir="rtl"] {
  direction: rtl;
}

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

:focus-visible {
  outline: 3px solid rgba(91, 77, 255, 0.32);
  outline-offset: 3px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: rgba(91, 77, 255, 0.16);
  color: var(--primary-deep);
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.brand-mark,
.logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 950;
  background: linear-gradient(135deg, #ff6aa1 0%, #7b61ff 48%, #18aee9 100%);
  box-shadow: 0 10px 24px rgba(91, 77, 255, 0.2);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.locale-select {
  width: auto;
  min-width: 124px;
}

.button,
button {
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: white;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 22px rgba(91, 77, 255, 0.18);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(91, 77, 255, 0.24);
}

.button.secondary,
button.secondary {
  color: #29304a;
  background: #f0f2fa;
  box-shadow: none;
}

button.danger {
  color: #fff;
  background: #ef4444;
  box-shadow: 0 10px 22px rgba(239, 68, 68, 0.16);
}

button.secondary.danger {
  color: #b42318;
  background: #fff1f1;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(91, 77, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(91, 77, 255, 0.12);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 750;
  color: #3b425d;
}

.store-page {
  padding: 18px 0 42px;
}

.order-page {
  padding: clamp(24px, 6vw, 56px) 0;
}

.order-lookup-panel {
  max-width: 960px;
  margin: 0 auto;
}

.order-lookup-panel > h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  letter-spacing: -0.04em;
}

.notice-strip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid #e1e5f3;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 8px 22px rgba(21, 23, 42, 0.04);
}

.notice-strip > div {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.notice-strip strong {
  color: var(--primary-deep);
}

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

.notice-strip p {
  margin: 0;
  color: #39405c;
}

.trust-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--line);
}

.trust-strip > div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
}

.trust-strip strong {
  color: #303751;
  font-size: 13px;
}

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

.storefront {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  grid-template-areas: "side main";
  gap: 16px;
  align-items: start;
}

.catalog-sidebar {
  grid-area: side;
  position: sticky;
  top: 84px;
  display: grid;
  gap: 14px;
}

.side-block,
.search-panel,
.product,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.side-block {
  padding: 16px;
}

.side-block h2,
.section-head h2,
.search-panel h1 {
  margin: 0;
  letter-spacing: -0.03em;
}

.side-block h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

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

.category-pill {
  width: 100%;
  justify-content: space-between;
  color: #333b56;
  background: #f7f8fc;
  box-shadow: none;
  padding: 10px 12px;
  border: 1px solid transparent;
}

.category-pill::after {
  content: "›";
  color: #a0a7ba;
}

.category-pill.active,
.category-pill:hover {
  color: var(--primary-deep);
  background: #eeecff;
  border-color: rgba(91, 77, 255, 0.18);
}

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

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.stat-line strong {
  color: var(--text);
}

.catalog-main {
  grid-area: main;
  display: grid;
  gap: 14px;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(190px, 0.82fr) minmax(320px, 1.2fr);
  grid-template-areas:
    "copy search"
    "chips chips";
  gap: 12px 18px;
  align-items: center;
  padding: 18px;
}

.search-panel h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

.search-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.search-box {
  grid-area: search;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.search-box input {
  min-height: 44px;
}

.quick-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-row {
  grid-area: chips;
}

.chip {
  color: #35405f;
  background: #f3f5fb;
  border: 1px solid #e2e6f2;
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: none;
  font-size: 13px;
}

.chip.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

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

.section-head h2 {
  font-size: 22px;
}

.result-meta {
  color: var(--muted);
  font-weight: 750;
}

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

.product {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  min-height: 285px;
  padding: 14px;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.product:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(21, 23, 42, 0.11);
}

.cover {
  height: 96px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  white-space: pre-line;
  text-align: center;
  color: #fff;
  font-size: 24px;
  font-weight: 950;
  letter-spacing: -0.04em;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 40%),
    linear-gradient(135deg, #5a4bff 0%, #159fe1 100%);
}

.cover.has-image {
  display: block;
  background: #eef1f8;
  overflow: hidden;
}

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

.product h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.product p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-weight: 950;
  font-size: 24px;
}

.stock {
  color: var(--success);
  font-size: 13px;
  font-weight: 850;
}

.empty {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed #ccd2e4;
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--muted);
  text-align: center;
}

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

.panel {
  padding: 24px;
}

.panel h1,
.panel h2,
.panel p {
  margin-top: 0;
}

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

.stat {
  display: grid;
  gap: 8px;
  min-height: 104px;
  align-content: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
  box-shadow: 0 10px 26px rgba(21, 23, 42, 0.04);
}

.stat strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat span {
  color: var(--muted);
  font-weight: 750;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 180px;
}

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

.stack {
  display: grid;
  gap: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 20, 37, 0.5);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 34px 90px rgba(14, 18, 46, 0.28);
}

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

.modal-head h2 {
  margin: 0;
}

.paybox {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 16px;
  padding: 16px;
  overflow-wrap: anywhere;
}

.payment-status {
  display: grid;
  gap: 10px;
}

.payment-status-head {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid #dfe4f1;
  border-radius: 14px;
  background: #f6f8fd;
}

.payment-status-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.payment-status-copy span,
.payment-status-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.payment-status-copy small {
  font-size: 12px;
}

.payment-status-head.success {
  border-color: #bcebd8;
  background: #e9faf3;
  color: #087653;
}

.payment-status-head.waiting {
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  border-color: #d8d4ff;
  background: #f4f2ff;
}

.payment-spinner {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 3px solid #d9d5ff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: payment-spin 720ms linear infinite;
}

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

.delivery-code {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: #101321;
  color: #fff;
}

.delivery-code span {
  color: #aeb7d0;
  font-size: 12px;
}

.delivery-code strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
  user-select: all;
}

.code {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: #101321;
  color: #d9fff2;
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
}

.stock-code-input {
  min-width: 360px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.stock-code-input[readonly] {
  color: #6c7288;
  background: #f5f6fb;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eef1fa;
  color: #4b587c;
  font-weight: 850;
  font-size: 12px;
}

.pill.success {
  background: #ddf8ed;
  color: var(--success);
}

.pill.warn {
  background: #fff2d7;
  color: var(--warning);
}

.admin-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  min-height: 100dvh;
  padding: 24px;
  align-items: start;
}

.admin-layout > .stack {
  min-width: 0;
}

.auth-shell {
  width: min(520px, calc(100vw - 28px));
  margin: clamp(42px, 10vh, 96px) auto;
}

.admin-login-head,
.panel-heading,
.order-toolbar,
.operations-strip,
.detail-grid,
.detail-list-row {
  display: flex;
  align-items: center;
}

.admin-login-head,
.panel-heading {
  justify-content: space-between;
  gap: 18px;
}

.admin-login-head + .muted,
.panel-heading p {
  margin: 5px 0 0;
}

.panel-heading h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.035em;
}

.operations-strip {
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f6f8fd;
  color: #46506f;
}

.operations-strip strong {
  color: var(--text);
}

.image-field {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px;
  gap: 12px 16px;
  align-items: start;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-soft);
}

.editor-form {
  padding: 18px;
  border-radius: 16px;
  background: #f8f9fd;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-field > .muted {
  grid-column: 1 / -1;
  margin: 0;
}

.image-preview {
  aspect-ratio: 4 / 3;
  border: 1px dashed #cfd5e5;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

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

.product-cell {
  display: grid;
  grid-template-columns: 56px minmax(180px, 1fr);
  gap: 12px;
  align-items: center;
}

.product-thumb {
  width: 56px;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #eeecff;
  color: var(--primary-deep);
  font-weight: 900;
}

.order-toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.order-toolbar input {
  flex: 1 1 280px;
}

.order-toolbar select {
  width: min(220px, 100%);
}

.order-toolbar .muted {
  margin-left: auto;
  white-space: nowrap;
}

#ordersTable {
  min-width: 900px;
}

#ordersTable th:nth-child(3),
#ordersTable td:nth-child(3),
#ordersTable th:nth-child(4),
#ordersTable td:nth-child(4),
#ordersTable th:last-child,
#ordersTable td:last-child {
  white-space: nowrap;
}

.table-wrap .code {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.detail-modal-card {
  width: min(780px, 100%);
}

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

.detail-item {
  min-width: 0;
  padding: 13px 14px;
  border-radius: 14px;
  background: #f7f8fc;
}

.detail-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-item strong {
  overflow-wrap: anywhere;
}

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

.detail-list-row {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.detail-list-row time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.loading-line {
  height: 88px;
  border-radius: 14px;
  background: linear-gradient(100deg, #f1f3f8 20%, #fafbfe 45%, #f1f3f8 70%);
  background-size: 220% 100%;
  animation: loading-sweep 1.15s ease-in-out infinite;
}

@keyframes loading-sweep {
  to { background-position-x: -220%; }
}

.sidebar {
  min-height: calc(100vh - 36px);
  position: sticky;
  top: 24px;
}

.nav {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.nav button {
  justify-content: flex-start;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.nav button.active {
  background: #eeebff;
  color: #4d3aff;
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }

  .payment-spinner {
    animation-duration: 1.8s;
  }
}

@media (max-width: 980px) {
  .storefront,
  .search-panel,
  .grid,
  .form-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .storefront {
    grid-template-areas:
      "main"
      "side";
  }

  .search-panel {
    grid-template-areas:
      "copy"
      "search"
      "chips";
  }

  .catalog-sidebar {
    position: static;
  }

  .catalog-sidebar {
    grid-template-columns: 1fr 1fr;
  }

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

  .admin-layout {
    padding: 14px;
    gap: 14px;
  }

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

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .notice-strip,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-inner {
    min-height: 60px;
    display: flex;
    gap: 8px;
  }

  .notice-strip {
    grid-template-columns: auto 1fr;
    padding: 10px 12px;
    gap: 10px;
  }

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

  .trust-strip > div {
    padding: 9px 8px;
    text-align: center;
  }

  .trust-strip span,
  #localeBadge {
    display: none;
  }

  .nav-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
  }

  .locale-select {
    width: 112px;
    min-width: 0;
  }

  .nav-actions .button {
    padding: 9px 10px;
    white-space: nowrap;
  }

  .catalog-sidebar {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .category-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-box {
    grid-template-columns: 1fr;
  }

  .search-panel {
    padding: 14px;
  }

  .search-panel h1 {
    font-size: 24px;
  }

  .chip {
    padding: 7px 10px;
  }

  .product {
    min-height: auto;
  }

  .modal-card {
    padding: 20px;
  }

  .panel {
    padding: 18px;
  }

  .panel-heading,
  .admin-login-head,
  .operations-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .image-field,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .image-preview {
    width: min(220px, 100%);
  }

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

  .nav button {
    justify-content: center;
  }

  .order-toolbar select {
    width: 100%;
  }
}
