/* 外贸工作台 — 简约清新风格
   配色：浅米白底 + 薄荷绿主色 + 淡蓝辅色
   设计原则：留白多、圆角大、阴影柔和 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1f2937;
  background: linear-gradient(180deg, #f0fdf4 0%, #f7f9fc 100%);
  overscroll-behavior-y: contain;
}
a { color: #059669; text-decoration: none; }
a:hover { color: #047857; }
button { font-family: inherit; cursor: pointer; }

/* ===== Layout ===== */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 0 40px rgba(0,0,0,0.04);
}

/* 桌面端隐藏移动 topbar */
.topbar.mobile-only { display: none; }

/* ===== Side Nav (desktop) ===== */
.tabbar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
  border-right: 1px solid #e5e7eb;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  margin-bottom: 10px;
  border-bottom: 1px dashed #d1fae5;
}
.nav-brand .brand-mark { font-size: 24px; }
.nav-brand .brand-name { font-weight: 700; font-size: 16px; color: #064e3b; }
.tabbar .tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #6b7280;
  font-size: 14px;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: all 0.15s;
}
.tabbar .tab span {
  font-weight: 500;
  flex: 1;
}
.tabbar .tab:hover {
  background: rgba(16,185,129,0.06);
  color: #047857;
}
.tabbar .tab.active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.tabbar .tab.active span { color: #ffffff; font-weight: 600; }

.nav-footer {
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px dashed #e5e7eb;
}

/* 桌面端右侧主区域 */
main {
  flex: 1;
  padding: 22px 28px;
  padding-bottom: 30px;
  overflow-x: hidden;
  min-width: 0;
}

/* ===== Mobile Bottom Tab (≤ 768px) ===== */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
  }
  .topbar.mobile-only {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #e5e7eb;
    position: sticky; top: 0; z-index: 10;
  }
  .topbar.mobile-only .brand { display: flex; align-items: center; gap: 8px; }
  .topbar.mobile-only .brand-mark { font-size: 22px; }
  .topbar.mobile-only .brand-name { font-weight: 600; font-size: 16px; color: #064e3b; }

  /* tabbar 变成底部水平条 */
  .tabbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    flex-direction: row;
    height: auto;
    padding: 6px 0;
    border-right: none;
    border-top: 1px solid #e5e7eb;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
  }
  .tabbar .nav-brand,
  .tabbar .nav-footer { display: none; }
  .tabbar .tab {
    flex: 1;
    flex-direction: column;
    text-align: center;
    padding: 6px 2px;
    margin: 0;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.3;
    background: transparent;
    box-shadow: none;
  }
  .tabbar .tab span {
    display: block;
    margin-top: 2px;
    font-size: 10px;
  }
  .tabbar .tab.active {
    background: rgba(16,185,129,0.1);
    color: #10b981;
  }
  .tabbar .tab.active span { color: #10b981; }
  main {
    padding: 14px;
    padding-bottom: 80px;
  }
}

/* ===== Desktop env badge (in nav-footer) ===== */
.env-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #d1fae5;
  color: #065f46;
  font-weight: 500;
  display: inline-block;
}
.env-badge.live { background: #d1fae5; color: #065f46; }
.env-badge.error { background: #fee2e2; color: #991b1b; }

.icon-btn {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 7px 12px;
  color: #4b5563;
  font-size: 16px;
  transition: all 0.15s;
}
.icon-btn:hover { background: #f3f4f6; }

/* ===== Cards ===== */
.card {
  background: #ffffff;
  border: 1px solid #f3f4f6;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.2s;
}
.card.clickable:hover { box-shadow: 0 4px 12px rgba(16,185,129,0.08); border-color: #d1fae5; }
.card.clickable:active { transform: scale(0.99); }
.card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: #111827; }
.card .meta { font-size: 12px; color: #9ca3af; }
.card .body { font-size: 14px; color: #4b5563; margin-top: 8px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin: 20px 0 10px;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #374151;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(16,185,129,0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #059669 0%, #047857 100%); }
.btn-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.btn-success:hover { background: #a7f3d0; }
.btn-danger { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; margin-top: 14px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  color: #1f2937;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #10b981;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ===== Badges / Status ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
/* 客户状态 — 清新柔和色 */
.badge-lead        { background: #dbeafe; color: #1e40af; }
.badge-contacted   { background: #ede9fe; color: #6d28d9; }
.badge-quoted      { background: #fef3c7; color: #92400e; }
.badge-negotiating { background: #ffedd5; color: #c2410c; }
.badge-won         { background: #d1fae5; color: #065f46; }
.badge-lost        { background: #fee2e2; color: #991b1b; }
.badge-draft       { background: #f3f4f6; color: #4b5563; }
.badge-sent        { background: #dbeafe; color: #1e40af; }
.badge-accepted    { background: #d1fae5; color: #065f46; }
.badge-rejected    { background: #fee2e2; color: #991b1b; }
.badge-ready       { background: #d1fae5; color: #065f46; }
.badge-published   { background: #dbeafe; color: #1e40af; }

/* ===== Lists ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.15s;
}
.list-item.clickable:hover { box-shadow: 0 4px 12px rgba(16,185,129,0.08); }
.list-item.clickable:active { transform: scale(0.99); }
.list-item .avatar {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #047857;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .title { font-weight: 600; font-size: 14px; color: #111827; margin-bottom: 3px; }
.list-item .info .sub { font-size: 12px; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== KPI ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.kpi .label { font-size: 12px; color: #6b7280; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; color: #064e3b; }
.kpi .delta { font-size: 11px; color: #10b981; margin-top: 2px; }

/* ===== Empty ===== */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: #9ca3af;
}
.empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  padding: 11px 22px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  max-width: 80%;
  box-shadow: 0 8px 24px rgba(16,185,129,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 8px 24px rgba(239,68,68,0.3); }
.toast.success { background: linear-gradient(135deg, #10b981, #059669); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-card {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  max-width: 900px;
  margin: 0 auto;
  max-height: 85vh;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
}
@media (min-width: 600px) {
  .modal-card {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    border-radius: 20px;
    width: 520px;
    max-height: 82vh;
  }
}

/* ===== Detail rows ===== */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .key { color: #9ca3af; }
.detail-row .val { color: #1f2937; font-weight: 500; text-align: right; }

/* ===== FX Card ===== */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.fx-tile {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #d1fae5;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  transition: transform 0.15s;
}
.fx-tile:hover { transform: translateY(-2px); }
.fx-tile .ccy { font-size: 11px; color: #6b7280; font-weight: 500; }
.fx-tile .rate { font-size: 19px; font-weight: 700; margin-top: 4px; color: #047857; }

/* ===== Listing Card ===== */
.listing-card {
  background: #ffffff;
  border: 1px solid #f3f4f6;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.listing-card .platform-tag {
  display: inline-block;
  padding: 3px 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}
.listing-card .title { font-weight: 600; font-size: 15px; margin: 6px 0; color: #111827; line-height: 1.4; }
.listing-card .bullets { font-size: 13px; color: #4b5563; padding-left: 20px; margin: 8px 0; }
.listing-card .bullets li { margin: 4px 0; line-height: 1.5; }
.listing-card .keywords {
  font-size: 12px;
  color: #6b7280;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  word-break: break-word;
}

/* ===== Trend Card ===== */
.trend-rank {
  display: inline-block;
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #ffffff;
  border-radius: 8px;
  text-align: center;
  line-height: 30px;
  font-weight: 700;
  font-size: 13px;
  margin-right: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}
.trend-rank.change-up { background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 2px 6px rgba(16,185,129,0.3); }

/* ===== Mobile ===== */
@media (max-width: 480px) {
  main { padding: 14px; padding-bottom: 90px; }
  .card { padding: 14px; }
  .kpi .value { font-size: 22px; }
  .brand-name { font-size: 16px; }
  .modal-card { padding: 18px; }
}

/* ===== Loading ===== */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid #e5e7eb;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  text-align: center; padding: 40px;
  color: #9ca3af;
}
.loading-overlay .spinner { width: 32px; height: 32px; border-width: 3px; }

/* ===== Theme color (mobile browser chrome) ===== */
meta.theme-color, :root {
  --theme-color: #ffffff;
}