/* ==========================================================================
   折扣情报站 · Design System
   ========================================================================== */

:root {
  /* 色彩 */
  --brand: #FF5722;
  --brand-dark: #E64A19;
  --brand-light: #FFE9E1;
  --accent: #0EA5E9;
  --accent-dark: #0284C7;
  --accent-light: #E0F2FE;

  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;

  /* 中性色 */
  --bg: #F7F8FA;
  --bg-soft: #FAFBFC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  --text: #0F172A;
  --text-2: #475569;
  --text-3: #94A3B8;

  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);

  /* 圆角 */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
}

/* 基础重置 */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* 移除 emoji 字体的fallback堆叠 */
[data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: middle;
  stroke-width: 2;
}

/* ==========================================================================
   顶部导航
   ========================================================================== */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.85);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.25);
}

.brand-mark [data-lucide] {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}

.ghost-link:hover {
  background: var(--bg);
  color: var(--text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--success-light);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: #047857;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  background: linear-gradient(135deg, #FFF7F4 0%, #F0F9FF 100%);
  border-bottom: 1px solid var(--border);
  padding: 56px 24px 72px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 87, 34, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.eyebrow [data-lucide] {
  width: 14px;
  height: 14px;
}

.hero-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 16px;
}

.grad-text {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 520px;
}

.hero-stats {
  display: flex;
  gap: 36px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat strong {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.hero-stat span {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

.hero-card {
  background: white;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: rotate(-1deg);
  transition: transform 0.3s;
}

.hero-card:hover {
  transform: rotate(0);
}

.hero-card-head {
  padding: 14px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.hero-card-head [data-lucide] {
  width: 16px;
  height: 16px;
  color: var(--brand);
}

.hero-card-body {
  padding: 20px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  gap: 16px;
}

.preview-row:last-of-type {
  border-bottom: none;
}

.preview-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-price {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-price .old {
  font-size: 11px;
  color: var(--text-3);
  text-decoration: line-through;
}

.preview-price .new {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
}

.preview-meta {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.chip-warn {
  background: var(--warning-light);
  color: #92400E;
}

.chip-success {
  background: var(--success-light);
  color: #065F46;
}

/* ==========================================================================
   主体容器
   ========================================================================== */

.container {
  max-width: 1280px;
  margin: -36px auto 60px;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   双栏布局
   ========================================================================== */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* ==========================================================================
   卡片通用样式
   ========================================================================== */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ==========================================================================
   表单
   ========================================================================== */

.form-card .field,
.log-card .field {
  padding: 16px 24px 0;
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 24px 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.field-label [data-lucide] {
  width: 14px;
  height: 14px;
  color: var(--text-2);
}

.field-hint {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.required {
  color: var(--brand);
  font-weight: 700;
}

.input-wrap {
  position: relative;
}

.text-input,
.select-input,
.textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  transition: all 0.15s;
  outline: none;
}

.text-input:focus,
.select-input:focus,
.textarea:focus {
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.1);
}

.text-input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.select-input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px !important;
  height: 16px !important;
  color: var(--text-3);
  pointer-events: none;
}

.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 12px;
  padding: 20px 24px 24px;
  align-items: center;
}

/* ==========================================================================
   按钮
   ========================================================================== */

.btn-primary,
.btn-success,
.btn-warning,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 87, 34, 0.25);
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--border);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #D97706;
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost.icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
}

/* ==========================================================================
   日志流
   ========================================================================== */

.log-card {
  display: flex;
  flex-direction: column;
}

.log-stream {
  flex: 1;
  padding: 20px 24px;
  min-height: 360px;
  max-height: 460px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--bg-soft);
}

.log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}

.log-empty [data-lucide] {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.log-empty p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}

.log-empty small {
  font-size: 12px;
  color: var(--text-3);
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 3px 0;
  align-items: flex-start;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.log-time {
  color: var(--text-3);
  flex-shrink: 0;
  font-size: 11px;
  padding-top: 2px;
}

.log-msg {
  flex: 1;
  word-break: break-word;
  color: var(--text-2);
}

.log-info .log-msg { color: var(--text-2); }
.log-success .log-msg { color: var(--success); }
.log-warning .log-msg { color: var(--warning); }
.log-error .log-msg { color: var(--danger); }
.log-step .log-msg { color: var(--accent); font-weight: 600; }

.log-progress {
  padding: 16px 24px;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 36px;
  text-align: right;
}

.indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.indicator.idle {
  background: var(--bg);
  color: var(--text-3);
}

.indicator.idle .indicator-dot {
  background: var(--text-3);
}

.indicator.running {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.indicator.running .indicator-dot {
  background: var(--brand);
  animation: pulse 1s infinite;
}

.indicator.success {
  background: var(--success-light);
  color: #047857;
}

.indicator.success .indicator-dot {
  background: var(--success);
}

.indicator.error {
  background: var(--danger-light);
  color: #991B1B;
}

.indicator.error .indicator-dot {
  background: var(--danger);
}

/* ==========================================================================
   结果区
   ========================================================================== */

.result-card .card-head {
  flex-wrap: wrap;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 20px 24px;
}

.stat-card {
  padding: 16px;
  border-radius: var(--r);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card.brand::before { background: var(--brand); }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 6px;
}

.table-wrap {
  margin: 0 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: auto;
  max-height: 600px;
}

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

.result-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  z-index: 10;
}

.result-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table tbody tr:hover {
  background: var(--brand-light);
}

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

.expiry-warn {
  color: var(--danger);
  font-weight: 600;
}

.expiry-ok {
  color: var(--text-2);
}

.discount-tag {
  display: inline-block;
  background: var(--brand);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* ==========================================================================
   帮助区
   ========================================================================== */

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px 24px 24px;
}

.help-block {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
}

.help-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.help-icon [data-lucide] {
  width: 18px;
  height: 18px;
  color: var(--brand);
}

.help-block h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.help-block ul {
  list-style: none;
}

.help-block li {
  padding: 4px 0 4px 14px;
  position: relative;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}

.help-block li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 4px;
  height: 4px;
  background: var(--brand);
  border-radius: 50%;
}

.help-block strong {
  color: var(--text);
  font-weight: 600;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-dot {
  color: var(--text-3);
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 960px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .hero-title {
    font-size: 32px;
  }

  .hero-card {
    transform: rotate(0);
    max-width: 480px;
    margin: 0 auto;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    gap: 24px;
  }

  .hero-stat strong {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  .hero {
    padding: 32px 16px 56px;
  }

  .topbar-inner {
    padding: 12px 16px;
  }

  .brand-tag {
    display: none;
  }

  .ghost-link span {
    display: none;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    flex: 0;
  }

  .result-actions {
    flex-direction: column;
    width: 100%;
  }

  .result-actions button {
    width: 100%;
  }

  .hero-stats {
    gap: 16px;
  }
}

/* ==========================================================================
   滚动条美化
   ========================================================================== */

.log-stream::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.log-stream::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.log-stream::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.log-stream::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}