/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #4A6CF7;
  --primary-dark: #3B5BDB;
  --primary-light: #EDF2FF;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --bg-page: #F5F6FA;
  --bg-card: #FFFFFF;
  --border: #E5E7EB;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg-page);
}

/* ===== 页面切换 ===== */
.page {
  display: none;
  min-height: 100vh;
}
.page.active {
  display: block;
}

/* ===== 登录页 ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
  color: #fff;
}

.logo-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-logo p {
  font-size: 14px;
  opacity: 0.85;
}

.login-form {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

/* ===== 表单 ===== */
.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.input-group input,
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.2s;
  font-family: inherit;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
}

.input-group textarea {
  resize: none;
}

.input-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-family: inherit;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text-secondary);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin-top: 8px;
  min-height: 20px;
}

/* ===== 顶部栏 ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 17px;
  font-weight: 700;
}

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

.user-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== 内容区 ===== */
.content {
  padding: 16px;
  padding-bottom: 80px;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: var(--success); }
.stat-orange .stat-value { color: var(--warning); }
.stat-purple .stat-value { color: #8B5CF6; }

/* ===== 操作卡片 ===== */
.action-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}

.action-card:active {
  transform: scale(0.98);
}

.action-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
  flex-shrink: 0;
}

.action-text {
  flex: 1;
}

.action-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.action-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.action-arrow {
  font-size: 20px;
  color: var(--text-light);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 20px 0 10px;
  padding-left: 4px;
}

/* ===== 表单分区 ===== */
.form-section {
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid var(--primary);
}

.order-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

/* ===== 视图头部 ===== */
.view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-back {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  font-weight: 600;
}

.view-header h2 {
  font-size: 18px;
  font-weight: 700;
}

/* ===== 成功页 ===== */
.success-container {
  text-align: center;
  padding: 40px 24px;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.success-container h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.order-number-display {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 24px 16px;
  margin-bottom: 16px;
}

.order-number-display .number-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.order-number-display .number-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

.success-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.8;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.success-actions .btn {
  width: 100%;
  max-width: 240px;
}

/* ===== 订单列表 ===== */
.search-bar {
  margin-bottom: 12px;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  background: #fff;
}

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

.order-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
}

.order-card:active {
  transform: scale(0.98);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.order-number {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Courier New', monospace;
}

.status-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.status-pending { background: #FEF3C7; color: #92400E; }
.status-designing { background: #DBEAFE; color: #1E40AF; }
.status-submitted { background: #D1FAE5; color: #065F46; }
.status-completed { background: #E0E7FF; color: #3730A3; }

.order-card-info {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.order-card-info span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.order-card-time {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
  font-size: 14px;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ===== 经销商列表 ===== */
.dealer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dealer-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dealer-info {
  flex: 1;
}

.dealer-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.dealer-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

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

.dealer-actions button {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text-secondary);
}

.dealer-actions .btn-reset { color: var(--warning); border-color: var(--warning); }
.dealer-actions .btn-delete { color: var(--danger); border-color: var(--danger); }

/* ===== 二维码 ===== */
.qrcode-container {
  text-align: center;
  padding: 20px;
}

.qrcode-box {
  display: inline-block;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
}

.qrcode-box img {
  width: 280px;
  height: 280px;
}

.qrcode-url {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.qrcode-tip {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s;
}

.tab-item.active {
  color: var(--primary);
}

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

.tab-label {
  font-size: 11px;
  margin-top: 2px;
}

/* ===== 弹窗 ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* ===== 订单详情 ===== */
.detail-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.detail-label {
  width: 90px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.detail-value {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.detail-value.highlight {
  color: var(--primary);
  font-weight: 700;
  font-family: 'Courier New', monospace;
  font-size: 16px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

/* ===== 状态选择 ===== */
.status-select-wrap {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.status-select-wrap label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.status-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== 登录页底部链接 ===== */
.login-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* ===== 登录页二维码 ===== */
.login-qrcode {
  margin-top: 28px;
  text-align: center;
}

.qrcode-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.qrcode-divider::before,
.qrcode-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.login-qr-box {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.login-qr-box img {
  width: 160px;
  height: 160px;
}

.login-qr-tip {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 10px;
}

/* ===== 前缀预览 ===== */
.prefix-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

.prefix-preview span {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
}

/* ===== 欢迎卡片 + 首页新建订单 ===== */
.home-top {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.welcome-card {
  flex: 1;
  background: linear-gradient(135deg, #4A6CF7 0%, #7B2FF7 100%);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: #fff;
  display: flex;
  align-items: center;
}

.home-new-order {
  width: 90px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s;
  color: var(--text-primary);
}

.home-new-order:active {
  transform: scale(0.96);
}

.home-new-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 10px;
}

.home-new-label {
  font-size: 13px;
  font-weight: 600;
}

.home-new-arrow {
  font-size: 18px;
  color: var(--text-light);
  line-height: 1;
}

.welcome-company {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-prefix {
  font-size: 13px;
  opacity: 0.9;
}

.welcome-prefix span {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ===== 经销商前缀标签 ===== */
.dealer-prefix-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ===== 订单总表样式 ===== */
.btn-export-top {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.summary-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-top: 8px;
}

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

.summary-table thead tr {
  background: var(--primary);
}

.summary-table th {
  color: #fff;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.summary-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.summary-table tbody tr:last-child td {
  border-bottom: none;
}

.summary-table tbody tr:active {
  background: #f8f9ff;
}

.td-number {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.td-time {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.summary-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.st-pending { background: #FEF3C7; color: #92400E; }
.st-designing { background: #DBEAFE; color: #1E40AF; }
.st-submitted { background: #E0E7FF; color: #4338CA; }
.st-completed { background: #D1FAE5; color: #065F46; }
