/* ============================================================
   Bento 极简 · 服务清单
   ============================================================ */

:root {
  /* 表面 */
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf9;

  /* 字 */
  --ink: #0a0a0a;
  --ink-2: #525258;
  --ink-3: #8a8a92;

  /* 线 */
  --line: rgba(10, 10, 10, 0.06);
  --line-strong: rgba(10, 10, 10, 0.12);

  /* 强调 */
  --accent: #07c160;
  --accent-ink: #04793c;
  --accent-soft: #e8f8ee;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* 几何 */
  --r-card: 24px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-pill: 999px;

  /* 阴影（diffusion） */
  --shadow: 0 1px 2px rgba(10, 10, 10, .04), 0 12px 32px -16px rgba(10, 10, 10, .10);
  --shadow-hover: 0 1px 2px rgba(10, 10, 10, .06), 0 24px 48px -20px rgba(10, 10, 10, .18);

  /* 动效 */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* 安全 */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ----------- 字体 ----------- */
/* Geist via Google Fonts，引入在 HTML <link> 完成 */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Geist', 'Inter', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--bg); }

/* ============================================================
   Layout shell
   ============================================================ */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px calc(56px + var(--safe-bottom));
}
@media (max-width: 640px) {
  .container { padding: 28px 16px calc(40px + var(--safe-bottom)); }
}

/* ============================================================
   Header (左对齐，eyebrow + 大字 + subtitle)
   ============================================================ */

.header { margin-bottom: 36px; }
.header .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.header .eyebrow::before {
  content: '';
  width: 18px; height: 1px;
  background: currentColor;
}
.header h1 {
  margin: 0;
  font-size: clamp(28px, 4.2vw, 40px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.header .subtitle {
  color: var(--ink-2);
  margin: 12px 0 0;
  font-size: 14px;
  max-width: 60ch;
}

/* ============================================================
   Bento grid · 商品卡
   ============================================================ */

.products {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 24px;
}
@media (min-width: 640px)  { .products { grid-template-columns: 1fr 1fr; gap: 16px; } }
@media (min-width: 1024px) { .products { grid-template-columns: 1fr 1fr; gap: 20px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .2s var(--ease);
  position: relative;
  overflow: hidden;
}
@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--line-strong);
  }
}
.card .name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.card .desc {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
  flex: 1;
  /* 限两行更整齐 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.card .price {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.card .price .currency {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  margin-right: 2px;
}
.card .buy {
  background: var(--ink);
  color: #fff;
  padding: 9px 16px 9px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .15s var(--ease), background .2s var(--ease);
}
.card .buy:hover { background: #1a1a1a; }
.card .buy:active { transform: scale(0.97); }
.card .buy .arrow {
  width: 14px; height: 14px;
  transition: transform .25s var(--ease);
}
.card .buy:hover .arrow { transform: translateX(2px); }

/* loading skeleton */
.products[aria-busy="true"] .card-skeleton {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  height: 168px;
  position: relative;
  overflow: hidden;
}
.card-skeleton::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(10,10,10,.04) 50%, transparent 100%);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }

/* empty */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
}

/* ============================================================
   Modal (bottom sheet on mobile, centered card on desktop)
   ============================================================ */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(10, 10, 10, .42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: maskIn .25s var(--ease);
}
.modal-mask.open { display: flex; }
@media (min-width: 640px) { .modal-mask { align-items: center; } }
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 28px 24px calc(24px + var(--safe-bottom));
  max-height: 92dvh;
  overflow: auto;
  box-shadow: 0 -12px 48px -12px rgba(10, 10, 10, .25);
  animation: sheetIn .35s var(--ease);
}
@media (min-width: 640px) {
  .modal { border-radius: 24px; box-shadow: 0 24px 64px -16px rgba(10, 10, 10, .25); }
}
@keyframes sheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.modal .modal-desc {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 60ch;
}
.modal .price-line {
  color: var(--ink);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
  font-variant-numeric: tabular-nums;
}
.modal .price-line .currency { font-size: 14px; color: var(--ink-3); margin-right: 2px; font-weight: 500; }

.modal label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.005em;
}
.modal input,
.modal textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  transition: border-color .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
  font-size: 14.5px;
}
.modal input:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(10, 10, 10, .06);
}
.modal textarea { resize: vertical; min-height: 88px; }

.modal .actions { display: flex; gap: 10px; margin-top: 24px; }
.modal .actions button {
  flex: 1;
  padding: 13px;
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: 14px;
  transition: background .2s var(--ease), transform .12s var(--ease), opacity .2s;
}
.modal .actions button:active { transform: scale(0.98); }
.modal .cancel { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.modal .cancel:hover { background: #f0f0ee; }
.modal .confirm { background: var(--accent); color: #fff; }
.modal .confirm:hover { background: var(--accent-ink); }
.modal .confirm:disabled { opacity: .5; cursor: not-allowed; }

/* QR */
.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0 4px;
}
.qr-wrap img {
  width: 220px; height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--surface);
}
.qr-wrap .hint {
  color: var(--ink-2);
  font-size: 13px;
  text-align: center;
}
.qr-wrap .hint.mono {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: var(--ink-3);
}

/* success */
.success {
  text-align: center;
  padding: 24px 0 8px;
}
.success .icon-wrap {
  width: 56px; height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.success .icon-wrap svg { width: 26px; height: 26px; }
.success .title {
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0 4px;
  letter-spacing: -0.015em;
}
.success .order-no {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  display: inline-block;
  margin: 10px 0 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.success .tip { color: var(--ink-3); font-size: 13px; margin-top: 12px; }

/* error */
.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  display: none;
  padding: 8px 12px;
  background: var(--danger-soft);
  border-radius: var(--r-sm);
}
.error.show { display: block; }

/* ============================================================
   Admin · 共用
   ============================================================ */

.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: var(--r-pill);
  margin: 28px 0 24px;
}
.tab {
  padding: 8px 18px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: var(--r-pill);
  font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--ink);
  color: #fff;
}

/* table → bento 行卡 */
.data-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
th, td {
  padding: 14px 18px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
tr:last-child td { border-bottom: 0; }
th {
  background: var(--surface-2);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
td.amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.status-pill.paid { background: var(--accent-soft); color: var(--accent-ink); border-color: rgba(7,193,96,.18); }

@media (max-width: 640px) {
  .data-card { border-radius: var(--r-card); padding: 8px; box-shadow: none; background: transparent; border: 0; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
  }
  td { border: 0; padding: 4px 0; font-size: 13.5px; display: flex; gap: 10px; }
  td::before {
    content: attr(data-label);
    color: var(--ink-3);
    font-size: 12px;
    min-width: 56px;
    flex-shrink: 0;
    line-height: 1.7;
  }
}

/* ============================================================
   Admin · 商品 tab
   ============================================================ */

.product-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.product-toolbar .hint {
  color: var(--ink-3);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.product-toolbar .hint svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .2s var(--ease), transform .12s var(--ease);
}
.btn-primary:hover { background: #1a1a1a; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary svg { width: 14px; height: 14px; }

.product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.product-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow);
  transition: border-color .2s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
}
.product-row:hover { border-color: var(--line-strong); }
.product-row.dragging { opacity: .4; cursor: grabbing; }
.product-row.drop-target { border-color: var(--accent); border-style: dashed; }

.product-handle {
  color: var(--ink-3);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  flex-shrink: 0;
  transition: color .2s var(--ease);
}
.product-handle:hover { color: var(--ink); }
.product-handle svg { width: 14px; height: 14px; }

.product-info { flex: 1; min-width: 0; }
.product-info .pname {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}
.product-info .pdesc {
  color: var(--ink-3);
  font-size: 12.5px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-row .pprice {
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  flex-shrink: 0;
}
.product-row .pacts {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.product-row .pacts button {
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--line);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.product-row .pacts button:hover { background: #f0f0ee; color: var(--ink); }
.product-row .pacts .danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220,38,38,.15);
}
.product-row .pacts .danger:hover { background: #fde7e6; }

@media (max-width: 640px) {
  .product-row { flex-wrap: wrap; }
  .product-info { flex-basis: calc(100% - 60px); order: 1; }
  .product-handle { order: 0; }
  .product-row .pprice { order: 2; margin-left: auto; }
  .product-row .pacts { order: 3; flex-basis: 100%; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
}

.archived-toggle {
  margin: 32px 0 12px;
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s var(--ease);
}
.archived-toggle:hover { color: var(--ink-2); }
.archived-toggle svg {
  width: 12px; height: 12px;
  transition: transform .25s var(--ease);
}
.archived-toggle.open svg { transform: rotate(90deg); }

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover { transform: none; }
}
