/* ===== CSS 变量 / 主题 ===== */
:root {
  --hw-red: #C7000B;
  --hw-red-light: #e8334a;
  --hw-red-dark: #9e0009;
  --hw-red-bg: #fef0f1;
  --hw-blue: #1e3a5f;
  --hw-blue-light: #2c5282;

  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
  --border-hover: #d1d5db;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-red: 0 4px 16px rgba(199, 0, 11, 0.25);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
button, input, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ===== 顶部标题栏 ===== */
.app-header {
  background: linear-gradient(135deg, var(--hw-blue) 0%, var(--hw-blue-light) 100%);
  color: #fff;
  padding: 0 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.header-title { display: flex; align-items: center; gap: 12px; }
.header-logo { font-size: 28px; }
.header-title h1 { font-size: 20px; font-weight: 600; letter-spacing: 0.5px; }
.header-actions { display: flex; gap: 8px; }

/* ===== 按钮 ===== */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary {
  background: var(--hw-red);
  color: #fff;
}
.btn-primary:hover {
  background: var(--hw-red-light);
  box-shadow: var(--shadow-red);
  transform: translateY(-1px);
}
.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn-danger {
  color: var(--hw-red);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.btn-danger:hover { background: var(--hw-red-bg); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ===== 套餐选择区 ===== */
.package-section {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 24px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title h2 { font-size: 17px; font-weight: 600; }
.section-hint { font-size: 13px; color: var(--text-tertiary); }

.package-cards {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 0 14px;
  scroll-behavior: smooth;
}
.package-cards::-webkit-scrollbar { height: 6px; }
.package-cards::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.pkg-card {
  flex: 0 0 200px;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.pkg-card:hover {
  border-color: var(--hw-red-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.pkg-card.selected {
  border-color: var(--hw-red);
  background: var(--hw-red-bg);
  transform: scale(1.03);
  box-shadow: var(--shadow-red);
}
.pkg-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: var(--hw-red);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
}
.pkg-id {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}
.pkg-spec {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.pkg-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  color: var(--text-secondary);
}
.pkg-detail span { display: flex; align-items: center; gap: 4px; }
.pkg-fee {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  font-size: 18px;
  font-weight: 700;
  color: var(--hw-red);
}

/* ===== 主体布局 ===== */
.main-layout {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  align-items: start;
}
.left-panel, .right-panel { display: flex; flex-direction: column; gap: 20px; }

/* ===== 面板通用 ===== */
.panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}
.panel:hover { box-shadow: var(--shadow-md); }
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}
.panel-header h2 { font-size: 16px; font-weight: 600; }
.panel-body { padding: 20px; }
.badge {
  background: var(--hw-red-bg);
  color: var(--hw-red);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.range-hint { font-size: 12px; color: var(--text-tertiary); font-weight: 400; margin-left: 6px; }

.operation-types { display: flex; gap: 8px; }
.op-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  background: #fff;
}
.op-btn:hover { border-color: var(--hw-red-light); color: var(--hw-red); }
.op-btn.active {
  border-color: var(--hw-red);
  background: var(--hw-red);
  color: #fff;
}
.op-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.form-select, .form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-select:focus, .form-input:focus { border-color: var(--hw-red); box-shadow: 0 0 0 3px var(--hw-red-bg); }

.duration-input { display: flex; align-items: center; gap: 12px; }
.duration-input input[type="range"] {
  flex: 1;
  accent-color: var(--hw-red);
  height: 6px;
}
.duration-input input[type="number"] {
  width: 70px;
  text-align: center;
  font-weight: 600;
}

.renew-spec {
  padding: 10px 14px;
  background: #f8f9fb;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.upgrade-info-text {
  padding: 8px 12px;
  background: rgba(199, 0, 11, 0.08);
  border-radius: 8px;
  color: #C7000B;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* 费用预览 */
.form-preview {
  background: linear-gradient(135deg, #f8f9fb 0%, #f0f2f5 100%);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}
.preview-row .label { color: var(--text-secondary); }
.preview-row .value { font-weight: 600; }
.preview-row.total {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 16px;
}
.preview-row.total .value { color: var(--hw-red); font-size: 20px; }
.preview-row.deduct .value { color: #16a34a; }

/* ===== 时间线 / 步骤列表 ===== */
.timeline { display: flex; flex-direction: column; gap: 12px; }

.step-item {
  background: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  animation: slideIn 0.35s ease;
  position: relative;
}
.step-item:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.step-item::before {
  content: '';
  position: absolute;
  left: -1.5px;
  top: 16px;
  bottom: 16px;
  width: 4px;
  border-radius: 2px;
  background: var(--hw-red);
}
.step-item[data-op="upgrade"]::before { background: #f59e0b; }
.step-item[data-op="renew"]::before { background: #3b82f6; }

.step-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.step-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.step-tag.initial { background: var(--hw-red-bg); color: var(--hw-red); }
.step-tag.upgrade { background: #fef3c7; color: #b45309; }
.step-tag.renew { background: #dbeafe; color: #1e40af; }
.step-seq { font-size: 13px; font-weight: 600; color: var(--text-tertiary); }

.step-spec {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.spec-chip {
  background: #f3f4f6;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}
.spec-chip.fee { background: var(--hw-red-bg); color: var(--hw-red); font-weight: 600; }

.step-cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  border-top: 1px dashed var(--border-color);
}
.step-cost-row .cost-label { color: var(--text-secondary); }
.step-cost-row .cost-value { font-weight: 600; }
.step-cost-row.paid .cost-value { color: var(--hw-red); font-size: 16px; }
.step-cost-row.deduct .cost-value { color: #16a34a; }
.step-voucher-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ===== 汇总面板 ===== */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.summary-card {
  background: #f8f9fb;
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  transition: var(--transition);
}
.summary-card.highlight {
  background: linear-gradient(135deg, var(--hw-red) 0%, var(--hw-red-dark) 100%);
  grid-column: 1 / -1;
}
.summary-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.summary-card.highlight .summary-label { color: rgba(255,255,255,0.85); }
.summary-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.summary-card.highlight .summary-value { color: #fff; font-size: 28px; }
.summary-card.total-deduct .summary-value { color: #16a34a; }

.final-spec {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--hw-blue);
  border-radius: var(--radius);
  color: #fff;
}
.final-label { font-size: 14px; opacity: 0.85; }
.final-value { font-size: 15px; font-weight: 600; }

/* ===== 代金券管理 ===== */
.voucher-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.voucher-form .checkbox-label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.voucher-form .checkbox-label input { accent-color: var(--hw-red); }
.voucher-form .btn { grid-column: 3; }

.voucher-list { display: flex; flex-direction: column; gap: 10px; }
.voucher-item {
  background: #f8f9fb;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: var(--transition);
  animation: slideIn 0.3s ease;
}
.voucher-item:hover { border-color: var(--border-hover); }
.voucher-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.voucher-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.voucher-single-tag {
  font-size: 10px;
  background: #fef3c7;
  color: #b45309;
  padding: 1px 6px;
  border-radius: 3px;
}
.voucher-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.voucher-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hw-red), var(--hw-red-light));
  border-radius: 3px;
  transition: width 0.4s ease;
}
.voucher-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.voucher-stats .consumed { color: var(--hw-red); }
.voucher-stats .remaining { color: #16a34a; }

/* ===== 代金券消耗明细 ===== */
.voucher-detail-list { display: flex; flex-direction: column; gap: 10px; }
.detail-item {
  background: #f8f9fb;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border-left: 3px solid var(--hw-red);
}
.detail-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.detail-name { font-size: 14px; font-weight: 600; }
.detail-amount { font-size: 13px; color: var(--text-secondary); }
.detail-steps { font-size: 12px; color: var(--text-tertiary); line-height: 1.8; }
.detail-step-line { display: flex; justify-content: space-between; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
}
.empty-state.small { padding: 20px 16px; }
.empty-icon { font-size: 36px; display: block; margin-bottom: 8px; }
.empty-state.small .empty-icon { font-size: 28px; }
.empty-state p { font-size: 14px; }

/* ===== 动画 ===== */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.value-changed { animation: pulse 0.4s ease; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .header-title h1 { font-size: 16px; }
  .package-section, .main-layout { padding: 0 12px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card.highlight { grid-column: auto; }
  .voucher-form { grid-template-columns: 1fr; }
  .voucher-form .btn { grid-column: auto; }
  .operation-types { flex-direction: column; }
  .pkg-card { flex: 0 0 170px; }
}
