:root {
  --red: #c0392b;
  --red-dark: #922b21;
  --red-light: #e74c3c;
  --gold: #d4af37;
  --gold-light: #f1c40f;
  --bg: #fff8f5;
  --card: #ffffff;
  --text: #2c1810;
  --text-light: #8b7268;
  --border: #f4e1d4;
  --success: #27ae60;
  --danger: #e74c3c;
  --shadow: 0 2px 12px rgba(192, 57, 43, 0.08);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding-bottom: 70px;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px;
}

/* ===== 顶部头图 ===== */
.header {
  background: linear-gradient(135deg, var(--red-dark) 0%, var(--red) 50%, var(--red-light) 100%);
  color: #fff;
  padding: 24px 16px 20px;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '囍';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 140px;
  color: rgba(255, 255, 255, 0.08);
  font-weight: bold;
}

.header-inner {
  position: relative;
  z-index: 1;
}

.header h1 {
  font-size: 22px;
  margin-bottom: 4px;
  font-weight: 600;
}

.subtitle {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 12px;
}

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

.btn-ghost {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
}

/* ===== 预算条 ===== */
.budget-bar {
  background: var(--card);
  margin: 8px 12px 0;
  padding: 14px 12px 10px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  position: relative;
  z-index: 2;
}

.budget-info {
  text-align: center;
}

.budget-info .label {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.budget-info .amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--red);
}

.budget-info .amount.clickable {
  cursor: pointer;
  border-bottom: 1px dashed var(--gold);
  padding-bottom: 1px;
  transition: color 0.15s;
}

.budget-info .amount.clickable:hover,
.budget-info .amount.clickable:active {
  color: var(--gold);
}

.progress-track {
  margin: 8px 12px 0;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  width: 0%;
  transition: width 0.3s;
  border-radius: 3px;
}

.progress-fill.over {
  background: linear-gradient(90deg, var(--red), var(--danger));
}

/* ===== Tab ===== */
.tabs {
  display: flex;
  margin: 16px 12px 0;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 13px;
  color: var(--text-light);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s;
}

.tab.active {
  background: linear-gradient(135deg, var(--red), var(--red-light));
  color: #fff;
}

.tab-icon {
  font-size: 18px;
}

.tab-count {
  font-size: 10px;
  background: var(--gold);
  color: #fff;
  border-radius: 8px;
  padding: 0 6px;
  margin-top: 2px;
}

.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== 面板 ===== */
.panel {
  display: none;
  padding: 16px 12px;
}

.panel.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 16px;
  color: var(--text);
}

.btn-add {
  background: var(--red);
  color: #fff;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
}

.btn-share {
  background: var(--gold);
  color: #fff;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
}

/* ===== 商品卡片网格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.item-card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.item-card.selected {
  border-color: var(--red);
}

.item-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  z-index: 2;
}

.item-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--border);
  display: block;
}

.item-img-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #fce4ec, #ffe0b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.item-info {
  padding: 8px 10px 10px;
}

.item-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-price {
  font-size: 14px;
  color: var(--red);
  font-weight: 700;
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding: 0 10px 10px;
}

.item-actions button {
  flex: 1;
  padding: 5px;
  font-size: 11px;
  border-radius: 6px;
  background: var(--border);
  color: var(--text);
}

.item-actions .btn-edit {
  background: #fef3e7;
  color: var(--gold);
}

.item-actions .btn-delete {
  background: #fee;
  color: var(--danger);
  border: 1px solid #fcc;
}

/* 数量调整 */
.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 10px;
  gap: 6px;
}

.qty-label {
  font-size: 11px;
  color: var(--text-light);
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-control button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.qty-control span {
  min-width: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

.empty-hint {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
  font-size: 13px;
}

/* ===== 清单 ===== */
.summary-list {
  margin-bottom: 12px;
}

.summary-item {
  background: var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

.summary-item img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--border);
}

.summary-item .si-img-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: linear-gradient(135deg, #fce4ec, #ffe0b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.summary-item .si-info {
  flex: 1;
  min-width: 0;
}

.summary-item .si-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item .si-meta {
  font-size: 11px;
  color: var(--text-light);
}

.summary-item .si-subtotal {
  font-size: 13px;
  color: var(--red);
  font-weight: 700;
}

.summary-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #fce4ec;
  color: var(--red);
  margin-right: 4px;
}

.summary-tag.pack {
  background: #fff3e0;
}

.summary-total {
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
}

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

.summary-total .row.total {
  border-top: 1px dashed var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
}

.summary-total .row.over {
  color: var(--danger);
}

.summary-total .row.under {
  color: var(--success);
}

.summary-empty {
  text-align: center;
  color: var(--text-light);
  padding: 30px 0;
  font-size: 13px;
}

/* ===== 在线指示 ===== */
.online-indicator {
  position: fixed;
  top: 10px;
  right: 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 5px;
}

.online-indicator .dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== 底部固定栏 ===== */
.footer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  z-index: 40;
  border-top: 1px solid var(--border);
}

.footer-total {
  display: flex;
  flex-direction: column;
}

.footer-total .ft-label {
  font-size: 11px;
  color: var(--text-light);
}

.footer-total .ft-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
}

.btn-checkout {
  background: linear-gradient(135deg, var(--red), var(--red-light));
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
}

/* ===== 弹层 ===== */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--vh, 100vh);
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}

.modal-mask.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 500px;
  border-radius: 16px 16px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-head h3 {
  font-size: 15px;
  color: var(--text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-light);
}

.modal-body {
  padding: 16px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-row input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 16px;
}

.form-row input:focus {
  outline: none;
  border-color: var(--red);
}

.img-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}

.img-upload img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
}

.img-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  background: var(--bg);
}

.quick-budget {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.quick-budget button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 12px;
  color: var(--text);
}

.modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: #fff;
}

.modal-foot button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-light));
  color: #fff;
  flex: 2;
}

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

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

/* ===== 删除确认弹窗 ===== */
#confirmModal {
  align-items: center;
}

.modal-confirm {
  max-width: 280px;
  width: calc(100% - 48px);
  text-align: center;
  border-radius: 14px;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-confirm .modal-body {
  padding: 22px 18px 16px;
}

.confirm-msg {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

.modal-confirm .modal-foot {
  border-top: none;
  padding: 4px 18px 18px;
  position: static;
  display: flex;
  gap: 10px;
}

.modal-confirm .modal-foot button {
  flex: 1;
  padding: 10px 0;
}

.modal-confirm .btn-danger {
  background: var(--danger);
  color: #fff;
  flex: 1 !important;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* 大屏适配 */
@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .header h1 {
    font-size: 26px;
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== 婚礼倒计时 ===== */
.countdown {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 10px;
  border-radius: 14px;
  display: inline-flex;
  border: 1px solid rgba(212, 175, 55, 0.5);
}

.countdown .cd-label {
  opacity: 0.85;
}

.countdown .cd-days {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-light);
  margin: 0 2px;
}

.countdown .cd-unit {
  opacity: 0.85;
  margin-right: 4px;
}

.countdown .cd-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

/* ===== 搜索栏 ===== */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  font-size: 16px;
}

.search-input:focus {
  outline: none;
  border-color: var(--red);
}

.btn-sample {
  padding: 8px 12px;
  border-radius: 18px;
  background: #fff3e0;
  color: var(--gold);
  font-size: 12px;
  white-space: nowrap;
}

/* ===== 头部按钮组 ===== */
.head-actions {
  display: flex;
  gap: 6px;
}

.head-actions .btn-share {
  padding: 6px 10px;
  font-size: 11px;
}

/* ===== 图片懒加载 ===== */
.item-img {
  transition: opacity 0.3s;
}

.item-img.lazy-loading {
  opacity: 0.3;
}

/* ===== 可点击的图片勾选区 ===== */
.item-media {
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

/* 右上角勾选圆点 */
.item-media::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.3);
  z-index: 2;
  transition: all 0.15s;
  box-sizing: border-box;
}

.item-card.selected .item-media::after {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
}

/* 左上角删除按钮 */
.item-card.disabled {
  opacity: 0.45;
}

.item-card.disabled .item-media {
  cursor: not-allowed;
}

.item-card.disabled .btn-delete {
  opacity: 0.5;
}

/* ===== 卡片规格行 ===== */
.item-spec {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
  line-height: 1.4;
}

/* ===== 编辑弹层：整袋规格行 ===== */
.form-hint {
  font-size: 11px;
  color: var(--text-light);
  font-weight: normal;
}

.pack-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pack-cell {
  position: relative;
}

.pack-cell input {
  padding-right: 44px;
}

.pack-unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-light);
  pointer-events: none;
}

/* ===== 烟回礼：合并填写行 ===== */
.cig-combo {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.cig-combo input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

.cig-sep {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 360px) {
  .cig-combo {
    gap: 4px;
  }
  .cig-sep {
    font-size: 11px;
  }
}

/* ===== 清单分节 ===== */
.summary-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  margin: 14px 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--red);
}

/* ===== 采购计算 ===== */
.purchase-box {
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.purchase-hint {
  font-size: 11px;
  color: var(--text-light);
  margin: -4px 0 10px;
}

.purchase-table .pt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
  gap: 6px;
}

.purchase-table .pt-row:last-child {
  border-bottom: none;
}

.pt-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-calc {
  color: var(--text-light);
  font-size: 11px;
}

.pt-bags {
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
}

.pt-cost {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.purchase-empty {
  text-align: center;
  color: var(--text-light);
  padding: 16px 0;
  font-size: 12px;
}

.purchase-grand {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px solid var(--red);
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
}

.purchase-grand.hide {
  display: none;
}
