:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #667085;
  --line: #d9dee8;
  --accent: #1f7a6d;
  --accent-strong: #145d54;
  --accent-soft: #e7f6f1;
  --blue: #3157a4;
  --warn: #b54708;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(28, 39, 64, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.95);
  backdrop-filter: blur(14px);
}

.topbar > div,
nav,
.album-title,
.album-title h3 {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1;
}

.topbar p,
.section-head span,
.muted {
  color: var(--muted);
}

nav,
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.nav,
.tab,
.ghost {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.nav.active,
.tab.active,
.primary {
  background: var(--ink);
  color: #fff;
}

.primary {
  min-height: 42px;
  padding: 0 18px;
  font-weight: 700;
  min-width: 132px;
}

.small {
  min-height: 36px;
  min-width: 104px;
  padding: 0 12px;
  font-size: 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary:hover {
  background: var(--blue);
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 26px auto 56px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.hero h2 {
  margin-top: 6px;
  font-size: clamp(24px, 5vw, 42px);
  line-height: 1.12;
}

.eyebrow {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.hero-stat {
  display: grid;
  place-items: center;
  min-width: 112px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6f4;
}

.hero-stat strong {
  color: var(--accent-strong);
  font-size: 34px;
}

.view,
.tab-view {
  display: none;
}

.view.active,
.tab-view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.album-card,
.panel,
.row,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.album-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cover {
  flex: 0 0 auto;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 0.72;
  min-height: 210px;
  overflow: hidden;
  background: linear-gradient(135deg, #dfe8f7, #e6efe9);
  color: var(--accent-strong);
  font-size: 48px;
  font-weight: 800;
}

.cover span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

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

.album-body,
.row,
.panel {
  padding: 16px;
}

.album-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  background: #fff;
}

.category-pill {
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.album-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.album-title h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.price {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: right;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
}

.desc {
  min-height: 0;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-link {
  width: fit-content;
  max-width: 100%;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.qty-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  color: var(--muted);
  font-size: 14px;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 72px 44px;
  width: 160px;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stepper input {
  min-height: 42px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 0 6px;
  text-align: center;
  font-weight: 800;
  appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.stepper-btn {
  min-width: 44px;
  min-height: 44px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 900;
}

.stepper-btn:active {
  background: #cfeae2;
}

.panel {
  margin-top: 18px;
}

.panel.narrow {
  max-width: 520px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

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

input:invalid {
  border-color: #d92d20;
}

.cropper {
  margin: 10px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.crop-frame {
  position: relative;
  width: min(280px, 100%);
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #dfe8f7;
  touch-action: none;
}

.crop-frame img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center;
}

.crop-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.crop-controls label {
  min-width: min(220px, 100%);
}

.cropper p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #eef6f4;
  color: var(--accent-strong);
  line-height: 1.55;
}

.result:empty {
  display: none;
}

.admin-result {
  border: 2px solid #52b788;
  background: #eaf7f0;
  color: #0b6b3a;
  font-size: 17px;
  font-weight: 700;
}

.admin-result span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 50;
  width: min(620px, calc(100% - 28px));
  transform: translateX(-50%);
  border-radius: 8px;
  padding: 18px 20px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.58);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(430px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.modal-mark {
  margin: 0 auto 12px;
}

.modal-card h2 {
  margin: 4px 0 16px;
  font-size: 28px;
}

.order-no-box {
  display: grid;
  gap: 6px;
  margin: 16px 0;
  padding: 16px;
  border: 2px solid #52b788;
  border-radius: 8px;
  background: #f0fbf6;
}

.order-no-box span {
  color: var(--muted);
  font-size: 14px;
}

.order-no-box strong {
  color: var(--accent-strong);
  font-size: 22px;
  overflow-wrap: anywhere;
}

.modal-note {
  margin-bottom: 18px;
  color: var(--muted);
}

.admin-area {
  margin-top: 20px;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.row {
  display: grid;
  gap: 10px;
}

.row-head,
.row-actions,
.order-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.flow-steps span,
.check-pill {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.flow-steps span.done,
.check-pill.checked {
  border-color: #52b788;
  background: #eaf7f0;
  color: var(--accent-strong);
}

.admin-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
}

.check-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.check-pill input {
  width: 16px;
  min-height: 16px;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  background: #e6efe9;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.badge.closed {
  background: #fff4e5;
  color: var(--warn);
}

.badge.status-active {
  background: #eef4ff;
  color: #2f5fb3;
}

.badge.status-done {
  background: #eaf7f0;
  color: var(--accent-strong);
}

.badge.status-cancelled {
  background: #f3f4f6;
  color: var(--muted);
}

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

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

.stat-flow span {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
}

.product-metrics span {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.stat-flow strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 18px;
}

.product-metrics strong {
  color: var(--ink);
}

.section-subhead {
  margin: 18px 0 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 150px);
  align-items: center;
  gap: 10px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.success-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  padding: 18px;
  border: 2px solid #52b788;
  border-radius: 8px;
  background: #f0fbf6;
  color: var(--ink);
}

.success-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1f7a6d;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}

.success-label {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.success-main h3 {
  margin: 4px 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.success-main p {
  color: var(--muted);
}

.payment-note {
  margin-top: 8px;
  padding: 10px;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  background: #fff7ed;
  color: #7a3b07 !important;
  font-weight: 700;
}

.copy-order {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #52b788;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 900;
}

.success-items {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid #cfeae2;
}

.success-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .nav,
  .tab {
    min-width: 0;
    padding: 0 8px;
  }

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

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

  .hero-stat {
    min-width: 100%;
    min-height: 80px;
    grid-template-columns: repeat(3, auto);
    gap: 8px;
  }

  main {
    width: min(100% - 18px, 1180px);
    margin-top: 14px;
  }

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

  .album-card {
    min-height: 0;
  }

  .cover {
    min-height: 0;
    aspect-ratio: 1 / 0.9;
  }

  .album-body {
    padding: 18px;
  }

  .album-title {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .album-title h3 {
    font-size: 19px;
  }

  .price {
    padding-top: 1px;
    font-size: 17px;
    text-align: left;
  }

  .qty-field {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stepper {
    width: 100%;
    grid-template-columns: 52px 1fr 52px;
    height: 48px;
  }

  .stepper-btn,
  .stepper input {
    min-height: 48px;
  }

  .success-card {
    grid-template-columns: 1fr;
  }

  .primary {
    width: 100%;
  }

  .flow-steps,
  .admin-flow,
  .stat-flow,
  .product-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-row {
    grid-template-columns: 1fr;
  }
}
