/* ============================================================
   SOHO Trade OS — 全局样式 (Dark Premium Theme)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080d1a;
  --bg2:       #0e1628;
  --bg3:       #141f35;
  --card:      rgba(255,255,255,0.04);
  --card-hov:  rgba(255,255,255,0.07);
  --border:    rgba(255,255,255,0.08);
  --accent:    #6366f1;
  --accent2:   #818cf8;
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Utilities ──────────────────────────────────── */
.hidden { display: none !important; }
.mt-4   { margin-top: 1.5rem; }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
  background: var(--bg3); color: var(--text);
  padding: .75rem 1.5rem; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: .9rem; pointer-events: none;
  animation: fadeInUp .3s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }
@keyframes fadeInUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ══════════════════════════════════════════════════
   气闸登录
   ══════════════════════════════════════════════════ */
.airlock-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.airlock-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 60% 40%, #1e1b4b 0%, #080d1a 70%);
}
.airlock-bg::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236366f1' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.airlock-center {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2rem;
}
.airlock-logo { text-align: center; }
.logo-icon { font-size: 3rem; margin-bottom: .5rem; filter: drop-shadow(0 0 20px #6366f1); }
.logo-title {
  font-size: 2rem; font-weight: 700; letter-spacing: -.5px;
  background: linear-gradient(135deg, #a5b4fc, #6366f1);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.logo-sub { color: var(--text2); font-size: .9rem; margin-top: .25rem; }

.btn-airlock {
  padding: 1rem 3rem; font-size: 1rem; font-weight: 600;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 50px; cursor: pointer;
  letter-spacing: .5px; transition: all .3s;
  box-shadow: 0 0 30px rgba(99,102,241,.4);
}
.btn-airlock:hover { transform: scale(1.05); box-shadow: 0 0 40px rgba(99,102,241,.6); }

/* 登录表单 */
.login-form-wrap {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 360px;
  animation: fadeInUp .4s ease;
  display: flex; flex-direction: column; gap: 1rem;
}
.login-tabs { display: flex; gap: .5rem; }
.tab-btn {
  flex: 1; padding: .5rem; background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: all .2s; font-size: .9rem;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-panel { display: flex; flex-direction: column; gap: .75rem; }
.login-input {
  width: 100%; padding: .75rem 1rem;
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: .95rem; outline: none; transition: border-color .2s;
}
.login-input:focus { border-color: var(--accent); }
.btn-login {
  width: 100%; padding: .85rem; font-size: 1rem; font-weight: 600;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
  transition: all .2s;
}
.btn-login:hover { opacity: .9; }
.btn-login:disabled { opacity: .5; cursor: not-allowed; }
.login-msg { font-size: .85rem; text-align: center; min-height: 1.2em; color: var(--danger); }
.login-msg.ok { color: var(--success); }

/* ══════════════════════════════════════════════════
   主应用布局
   ══════════════════════════════════════════════════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── 侧边栏 ──────────────────────────────────────── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1.25rem 0;
}
.sidebar-logo {
  font-size: 1.1rem; font-weight: 700; color: var(--accent2);
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.3px;
}
.sidebar-nav { flex: 1; padding: .75rem 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.25rem; color: var(--text2);
  text-decoration: none; border-radius: 0;
  transition: all .15s; position: relative; font-size: .9rem;
}
.nav-item:hover  { background: var(--card-hov); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.15); color: var(--accent2); font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 1rem; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; border-radius: 10px;
  padding: .1rem .4rem; min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .5rem;
}
.user-info { display: flex; align-items: center; gap: .5rem; }
.username-text { font-weight: 500; font-size: .9rem; }
.role-badge {
  font-size: .7rem; padding: .1rem .4rem;
  border-radius: 4px; background: rgba(99,102,241,.2); color: var(--accent2);
}
.btn-logout {
  width: 100%; padding: .5rem; background: transparent;
  color: var(--text3); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; font-size: .85rem; transition: all .2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── 主内容 ──────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 1.75rem; background: var(--bg); }
.page { display: none; }
.page.active { display: block; animation: fadeInUp .3s ease; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h2 { font-size: 1.4rem; font-weight: 600; }
.page-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ── 按钮 ──────────────────────────────────────── */
.btn-primary {
  padding: .5rem 1.25rem; background: var(--accent); color: #fff;
  border: none; border-radius: 7px; cursor: pointer; font-size: .9rem;
  font-weight: 500; transition: all .2s; white-space: nowrap;
}
.btn-primary:hover { background: #4f52d9; }
.btn-success {
  padding: .5rem 1.25rem; background: var(--success); color: #fff;
  border: none; border-radius: 7px; cursor: pointer; font-size: .9rem;
  font-weight: 500; transition: all .2s; white-space: nowrap;
}
.btn-success:hover { background: #0d9669; }
.btn-warning {
  padding: .5rem 1.25rem; background: var(--warning); color: #000;
  border: none; border-radius: 7px; cursor: pointer; font-size: .9rem;
  font-weight: 500; transition: all .2s; white-space: nowrap;
}
.btn-warning:hover { background: #d97706; }
.btn-ghost {
  padding: .5rem 1.25rem; background: transparent; color: var(--text2);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  font-size: .9rem; transition: all .2s; white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }
.btn-sm {
  padding: .3rem .7rem; font-size: .8rem;
}

/* ── 搜索/筛选 ──────────────────────────────────── */
.search-input, .filter-select {
  padding: .5rem .9rem; background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.search-input { min-width: 220px; }
.search-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-select option { background: var(--bg2); }

/* ── 预警栏 ──────────────────────────────────────── */
.alert-bar { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.alert-section { border-radius: 8px; padding: .75rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.alert-section.red    { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); }
.alert-section.yellow { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); }
.alert-label { font-weight: 600; font-size: .85rem; margin-right: .5rem; }
.alert-tag {
  padding: .2rem .7rem; border-radius: 20px; font-size: .8rem;
  cursor: pointer; transition: all .2s;
}
.alert-section.red    .alert-tag { background: rgba(239,68,68,.2); color: #fca5a5; }
.alert-section.red    .alert-tag:hover { background: rgba(239,68,68,.4); }
.alert-section.yellow .alert-tag { background: rgba(245,158,11,.2); color: #fcd34d; }
.alert-section.yellow .alert-tag:hover { background: rgba(245,158,11,.4); }

/* ── 表格 ──────────────────────────────────────── */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: .75rem 1rem; text-align: left; font-size: .8rem;
  font-weight: 600; color: var(--text3); text-transform: uppercase;
  letter-spacing: .05em; background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .7rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: .88rem; color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--card-hov); }
.data-table td:first-child { color: var(--text); font-weight: 500; }

/* ── 状态标签 ──────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 5px;
  font-size: .75rem; font-weight: 600;
}
.badge-unpaid   { background: rgba(100,116,139,.2); color: #94a3b8; }
.badge-partial  { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-paid     { background: rgba(16,185,129,.15); color: #34d399; }
.badge-shipped  { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-unshipped{ background: rgba(239,68,68,.12); color: #fca5a5; }
.badge-usd      { background: rgba(16,185,129,.1); color: #6ee7b7; }
.badge-rmb      { background: rgba(245,158,11,.1); color: #fcd34d; }

/* ── 分页 ──────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: 1rem; }
.page-btn {
  padding: .35rem .75rem; background: var(--bg2); color: var(--text2);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  font-size: .85rem; transition: all .2s;
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── 表单卡片 ──────────────────────────────────── */
.form-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .85rem; color: var(--text2); font-weight: 500; }
.req { color: var(--danger); }
.form-input {
  padding: .65rem .9rem; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  font-size: .9rem; outline: none; transition: border-color .2s;
  width: 100%;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; font-family: inherit; }
select.form-input option { background: var(--bg2); }
.section-title {
  font-size: .85rem; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.hint-text { color: var(--text3); font-size: .8rem; }
.input-inline { display: flex; gap: .5rem; }
.input-inline .form-input { flex: 1; }

/* ── 自动补全 ──────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 7px; margin-top: 2px; max-height: 200px; overflow-y: auto;
}
.suggestion-item {
  padding: .6rem .9rem; cursor: pointer; font-size: .9rem; color: var(--text2);
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--card-hov); color: var(--text); }
.matched-tag {
  padding: .3rem .7rem; background: rgba(16,185,129,.1);
  color: var(--success); border-radius: 5px; font-size: .82rem;
  border: 1px solid rgba(16,185,129,.2); margin-top: .4rem;
}

/* ── 产品行 ──────────────────────────────────────── */
.item-row {
  display: grid; grid-template-columns: 1.5fr 2fr .8fr 1.2fr 1.2fr auto;
  gap: .75rem; align-items: center;
  padding: .75rem; margin-bottom: .5rem;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
}
.item-row .form-input { margin: 0; }
.btn-remove {
  background: transparent; border: none; color: var(--danger);
  cursor: pointer; font-size: 1.1rem; padding: .25rem; border-radius: 4px;
  transition: background .2s;
}
.btn-remove:hover { background: rgba(239,68,68,.1); }

/* ── 金额预览 ──────────────────────────────────── */
.amount-preview {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem 1.25rem;
  margin: 1rem 0; max-width: 400px; margin-left: auto;
}
.amount-row {
  display: flex; justify-content: space-between;
  padding: .4rem 0; font-size: .9rem; color: var(--text2);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.amount-row:last-child { border-bottom: none; }
.amount-row.handling { color: var(--warning); }
.amount-row.total {
  font-size: 1rem; font-weight: 700; color: var(--text);
  margin-top: .25rem; padding-top: .5rem;
  border-top: 1px solid var(--border);
}

/* ── PI 详情 ──────────────────────────────────── */
.detail-content { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.detail-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.detail-card h4 { font-size: .8rem; color: var(--text3); text-transform: uppercase; margin-bottom: .75rem; letter-spacing: .05em; }
.detail-field { margin-bottom: .6rem; }
.detail-field .label { font-size: .8rem; color: var(--text3); }
.detail-field .value { font-size: .95rem; color: var(--text); font-weight: 500; }
.status-badges { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.tracking-link { color: var(--accent2); text-decoration: none; font-size: .85rem; }
.tracking-link:hover { text-decoration: underline; }

/* ── 财务统计卡 ──────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.stat-card .stat-label { font-size: .8rem; color: var(--text3); margin-bottom: .5rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-card .stat-sub { font-size: .8rem; color: var(--text3); margin-top: .25rem; }

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 2rem; min-width: 380px;
  max-width: 520px; width: 90vw; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1.25rem;
  animation: fadeInUp .3s ease;
}
.modal-wide { max-width: 780px; }
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ── 报价历史 ──────────────────────────────────── */
.quote-batch {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; margin-bottom: .75rem;
}
.quote-batch-date { font-size: .85rem; color: var(--text3); margin-bottom: .5rem; font-weight: 600; }
.quote-item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .35rem 0; font-size: .88rem; border-bottom: 1px solid rgba(255,255,255,.04);
}
.quote-item-row:last-child { border-bottom: none; }

/* ── 打印 ──────────────────────────────────────── */
@media print {
  .sidebar, .page-actions, #btn-confirm-pay, #btn-confirm-ship { display: none !important; }
  .main-content { padding: 0; }
  body { background: #fff; color: #000; }
  .detail-card { border: 1px solid #ddd; }
}
