/* 积分商城 - 移动优先样式 */
:root {
  --green: #1aad19;
  --green-dark: #169416;
  --green-light: #e8f8e8;
  --orange: #ff6a00;
  --text: #222;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #eee;
  --bg: #f5f5f5;
  --card: #fff;
  --danger: #e64340;
  --radius: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 48px;
  --tab-h: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100%;
}

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

img {
  max-width: 100%;
  display: block;
}

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

/* ===== 客户 H5 布局 ===== */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
}

.app-shell.no-tab {
  padding-bottom: 16px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.header .title {
  font-size: 16px;
  font-weight: 600;
}

.header .points-badge {
  background: rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header .back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-bar {
  padding: 10px 12px;
  background: #fff;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  background: var(--bg);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--green);
}

.tags {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.tags::-webkit-scrollbar { display: none; }

.tag {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.tag.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  cursor: pointer;
  transition: transform .15s;
}

.product-card:active {
  transform: scale(.98);
}

.product-thumb {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: #fff;
  position: relative;
}

.product-thumb .stock-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.product-body {
  padding: 8px 10px 12px;
}

.product-name {
  font-size: 13px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}

.product-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-row {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.points-price {
  color: var(--orange);
  font-weight: 700;
  font-size: 16px;
}

.points-price small {
  font-size: 11px;
  font-weight: 500;
}

.original-price {
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: line-through;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* Tab bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
}

.tab-item.active {
  color: var(--green);
  font-weight: 600;
}

.tab-item .ico {
  font-size: 20px;
  line-height: 1;
}

/* Product detail */
.detail-hero {
  aspect-ratio: 1;
  max-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
  color: #fff;
}

.detail-panel {
  background: #fff;
  padding: 16px;
  margin-bottom: 10px;
}

.detail-panel .points-price {
  font-size: 24px;
}

.detail-name {
  font-size: 18px;
  font-weight: 600;
  margin-top: 8px;
}

.detail-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 8px;
}

.spec-block {
  background: #fff;
  padding: 16px;
  margin-bottom: 10px;
}

.spec-block h3 {
  font-size: 14px;
  margin-bottom: 10px;
}

.spec-group {
  margin-bottom: 12px;
}

.spec-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.spec-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spec-opt {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.spec-opt.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-light);
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.qty-ctrl {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.qty-ctrl button {
  width: 36px;
  height: 32px;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 16px;
}

.qty-ctrl span {
  width: 40px;
  text-align: center;
  font-weight: 600;
}

.buy-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
}

.buy-bar .summary {
  flex: 1;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: opacity .15s;
}

.btn:active { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover { background: var(--green-dark); }

.btn-outline {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: var(--bg);
  color: var(--text-secondary);
}

.btn-block {
  width: 100%;
  border-radius: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 16px;
}

/* Forms */
.form-card {
  background: #fff;
  padding: 16px;
  margin-bottom: 10px;
}

.form-card h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--green);
}

.form-group textarea {
  min-height: 72px;
  resize: vertical;
}

.order-summary-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.order-summary-line.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 12px;
  font-weight: 700;
  font-size: 15px;
}

.order-summary-line.total .points-price {
  font-size: 18px;
}

/* Orders */
.status-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.status-tabs button {
  flex-shrink: 0;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.status-tabs button.active {
  color: var(--green);
  font-weight: 600;
}

.status-tabs button.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--green);
  border-radius: 1px;
}

.order-card {
  background: #fff;
  margin: 10px 12px;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.order-card .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.order-card .status-pill {
  color: var(--green);
  font-weight: 600;
  font-size: 13px;
}

.order-card .status-pill.warn { color: var(--orange); }
.order-card .status-pill.muted { color: var(--text-muted); }
.order-card .status-pill.danger { color: var(--danger); }

.order-goods {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.order-goods .thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  flex-shrink: 0;
}

.order-goods .info {
  flex: 1;
  min-width: 0;
}

.order-goods .info .name {
  font-weight: 500;
  font-size: 14px;
}

.order-goods .info .spec {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.tracking-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 12px;
}

.tracking-box .track-no {
  font-weight: 600;
  margin-bottom: 6px;
}

.logistics-list {
  margin-top: 6px;
}

.logistics-item {
  position: relative;
  padding-left: 14px;
  padding-bottom: 10px;
  border-left: 2px solid #ddd;
  margin-left: 4px;
}

.logistics-item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.logistics-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}

.logistics-item:first-child::before {
  background: var(--green);
}

.logistics-item .t {
  color: var(--text-muted);
  font-size: 11px;
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-mask.center {
  align-items: center;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
}

.modal-mask.center .modal {
  border-radius: 12px;
  margin: 16px;
  width: calc(100% - 32px);
  max-width: 400px;
}

.modal h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.modal .close-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 300;
  font-size: 14px;
  max-width: 80%;
  text-align: center;
  pointer-events: none;
}

.proof-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid var(--border);
}

.file-btn {
  display: inline-block;
  padding: 10px 16px;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  border: 1px dashed var(--border);
}

.file-btn input { display: none; }

/* ===== Admin ===== */
.admin-body {
  background: #f0f2f5;
  min-height: 100vh;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 200px;
  background: #1a1a1a;
  color: #fff;
  flex-shrink: 0;
  padding: 20px 0;
}

.admin-sidebar .brand {
  padding: 0 20px 24px;
  font-size: 16px;
  font-weight: 700;
  color: #7dffa0;
}

.admin-nav button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: 14px;
}

.admin-nav button:hover,
.admin-nav button.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.admin-nav button.active {
  border-left: 3px solid var(--green);
  padding-left: 17px;
}

.admin-main {
  flex: 1;
  padding: 24px;
  overflow-x: auto;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-top h1 {
  font-size: 20px;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.admin-toolbar input,
.admin-toolbar select {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
}

.table-wrap {
  background: #fff;
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

table.data tr:hover td {
  background: #fafafa;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

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

.admin-form-grid .full {
  grid-column: 1 / -1;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--green-light);
  color: var(--green);
}

.badge.warn { background: #fff3e0; color: var(--orange); }
.badge.danger { background: #ffebee; color: var(--danger); }
.badge.muted { background: #f0f0f0; color: #666; }

.proof-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.batch-area {
  width: 100%;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.link-admin {
  font-size: 12px;
  opacity: .85;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
  }
  .admin-sidebar {
    width: 100%;
    padding: 12px 0;
  }
  .admin-sidebar .brand {
    padding-bottom: 12px;
  }
  .admin-nav {
    display: flex;
    overflow-x: auto;
  }
  .admin-nav button {
    white-space: nowrap;
  }
  .admin-nav button.active {
    border-left: none;
    border-bottom: 2px solid var(--green);
    padding-left: 20px;
  }
  .admin-form-grid {
    grid-template-columns: 1fr;
  }
  .admin-main {
    padding: 16px;
  }
}

.hidden { display: none !important; }

/* ===== 登录页 ===== */
.login-wrap {
  max-width: 420px;
  margin: 40px auto;
  padding: 0 16px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.login-card h1 {
  font-size: 20px;
  margin-bottom: 6px;
}
.login-card .hint {
  color: #999;
  font-size: 12px;
  margin-bottom: 18px;
}

/* ===== 快团团风格：添加商品表单 ===== */
.ktt-form {
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 88px;
}
.ktt-section {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  padding: 8px 0 16px;
}
.ktt-section-title {
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px 8px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 4px;
}
.ktt-row {
  display: flex;
  gap: 16px;
  padding: 14px 20px;
  align-items: flex-start;
}
.ktt-label {
  width: 96px;
  flex-shrink: 0;
  color: #666;
  font-size: 13px;
  line-height: 36px;
  text-align: right;
}
.ktt-label.required::before {
  content: '*';
  color: var(--danger);
  margin-right: 2px;
}
.ktt-field {
  flex: 1;
  min-width: 0;
}
.ktt-field input[type="text"],
.ktt-field input[type="number"],
.ktt-field select,
.ktt-field textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
}
.ktt-field textarea {
  resize: vertical;
  min-height: 88px;
}
.ktt-input-wrap {
  position: relative;
}
.ktt-input-wrap input {
  padding-right: 64px;
}
.ktt-counter {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #999;
}
.ktt-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ktt-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
  white-space: nowrap;
}
.ktt-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ktt-img-item {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  border: 1px solid #eee;
  position: relative;
  overflow: hidden;
  background: #fafafa;
  cursor: grab;
}
.ktt-img-item.dragging { opacity: .5; }
.ktt-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ktt-img-rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
}
.ktt-cover {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(26,173,25,.9);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 2px 0;
}
.ktt-img-add {
  width: 88px;
  height: 88px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #999;
  border-style: dashed !important;
  margin: 0;
  padding: 0 !important;
}
.ktt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}
.ktt-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f5f5f5;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}
.ktt-tag button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #999;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.ktt-spec-card {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}
.ktt-spec-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.ktt-spec-name {
  flex: 1;
  min-width: 140px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
}
.ktt-spec-actions {
  display: flex;
  gap: 4px;
}
.ktt-spec-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ktt-opt-input {
  width: 140px;
  border: 1px dashed #ccc;
  border-radius: 4px;
  padding: 4px 8px;
  background: #fff;
  font-size: 12px;
}
.ktt-footer {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #eee;
  padding: 14px 20px;
  display: flex;
  gap: 12px;
  margin: 0 -24px -24px;
  box-shadow: 0 -2px 8px rgba(0,0,0,.04);
  z-index: 5;
}
@media (max-width: 768px) {
  .ktt-row {
    flex-direction: column;
    gap: 6px;
  }
  .ktt-label {
    text-align: left;
    line-height: 1.4;
    width: auto;
  }
  .ktt-footer {
    margin: 0 -16px -16px;
  }
}
