/* ============ 外贸管理系统 样式 ============ */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-soft: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #f59e0b;
  --side: #0f172a;
  --side-text: #cbd5e1;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }
/* 让标准 HTML hidden 属性胜过 .login-shell / #app 的 display:flex */
[hidden] { display: none !important; }

/* ========== 登录页 ========== */
.login-shell { position: fixed; inset: 0; background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%); display: flex; align-items: center; justify-content: center; }
.login-card { width: 380px; background: white; border-radius: 16px; padding: 32px 32px 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .logo { width: 56px; height: 56px; margin: 0 auto 12px; background: linear-gradient(135deg, #2563eb, #06b6d4); border-radius: 14px; color: white; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.login-brand h1 { margin: 0 0 4px; font-size: 20px; }
.login-brand .en { color: var(--text-soft); font-size: 12px; margin: 0; }
.login-form h2 { font-size: 16px; margin: 0 0 4px; }
.login-form .muted { color: var(--text-soft); font-size: 12px; margin: 0 0 16px; }
.login-form label { display: block; font-size: 12px; color: var(--text-soft); margin: 12px 0 4px; }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.btn-primary { width: 100%; padding: 11px; margin-top: 18px; background: var(--primary); color: white; border: 0; border-radius: 6px; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.login-hint { margin-top: 10px; min-height: 18px; font-size: 12px; }
.login-hint.err { color: var(--danger); }
.login-foot { text-align: center; color: var(--text-soft); font-size: 11px; margin: 16px 0 0; }

/* ========== 布局 ========== */
#app { display: flex; height: 100vh; }
.sidebar { width: 232px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; flex-shrink: 0; }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px; border-bottom: 1px solid #1e293b; }
.sb-brand .logo-mini { width: 38px; height: 38px; background: linear-gradient(135deg, #2563eb, #06b6d4); border-radius: 10px; color: white; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(37,99,235,0.4); }
.sb-title { color: white; font-weight: 700; font-size: 14px; letter-spacing: 0.5px; }
.sb-sub { color: var(--side-text); font-size: 11px; margin-top: 2px; opacity: 0.8; }
.sb-nav { flex: 1; padding: 8px 0 16px; overflow-y: auto; }
.sb-nav .sb-section { padding: 14px 18px 6px; font-size: 11px; color: #64748b; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; }
.sb-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 18px; margin: 1px 8px; color: var(--side-text); text-decoration: none; font-size: 13px; border-left: 3px solid transparent; border-radius: 6px; cursor: pointer; user-select: none; transition: background 0.12s, color 0.12s; }
.sb-nav a:hover { background: #1e293b; color: white; }
.sb-nav a.active { color: white; background: linear-gradient(90deg, rgba(37,99,235,0.18), rgba(37,99,235,0.02)); border-left-color: var(--primary); font-weight: 600; }
.sb-nav .ico { width: 18px; text-align: center; font-size: 14px; }
.sb-foot { padding: 14px 18px; border-top: 1px solid #1e293b; background: #0b1220; }
.sb-user { font-size: 12px; color: var(--side-text); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.sb-user::before { content: ''; display: inline-block; width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 6px #10b981; }
.btn-logout { width: 100%; padding: 8px; background: #1e293b; color: var(--side-text); border: 0; border-radius: 6px; font-size: 12px; transition: background 0.12s, color 0.12s; }
.btn-logout:hover { background: var(--danger); color: white; }

.content { flex: 1; overflow: auto; background: var(--bg); }
.page { padding: 22px 28px; }

/* ========== 通用组件 ========== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-header h1 { font-size: 18px; margin: 0; }
.page-header .sub { color: var(--text-soft); font-size: 12px; margin-top: 2px; }

.card { background: white; border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); margin-bottom: 16px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.field { display: flex; flex-direction: column; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.10); }
.field-inline { display: flex; gap: 8px; }
.field-inline input, .field-inline select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; flex: 1; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); background: white; border-radius: 6px; font-size: 13px; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; border: 0; padding: 4px 8px; }

/* 段控件（国内市场/国外市场切换等） */
.seg { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 3px; }
.seg .seg-btn { padding: 6px 14px; font-size: 12px; color: var(--text-soft); border-radius: 6px; cursor: pointer; user-select: none; transition: background 0.12s, color 0.12s; }
.seg .seg-btn:hover { color: var(--text); }
.seg .seg-btn.active { background: white; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* 市场标签 */
.mkt-tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.mkt-tag.mkt-domestic { background: #fef3c7; color: #b45309; }
.mkt-tag.mkt-foreign { background: #dbeafe; color: #1d4ed8; }

table.tbl { width: 100%; border-collapse: collapse; background: white; border-radius: 6px; overflow: hidden; font-size: 13px; }
table.tbl th { background: #f9fafb; text-align: left; padding: 10px 12px; font-weight: 600; color: var(--text-soft); font-size: 12px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
table.tbl tr:hover td { background: #f9fafb; }
table.tbl .badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
table.tbl .badge-green { background: #dcfce7; color: #15803d; }
table.tbl .badge-blue { background: #dbeafe; color: #1d4ed8; }
table.tbl .badge-gray { background: #f3f4f6; color: #475569; }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input, .search-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.search-bar input { flex: 1; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: white; border-radius: var(--radius); padding: 14px 16px; }
.kpi .lab { color: var(--text-soft); font-size: 12px; }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 4px; }

/* ========== Modal ========== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 9000; }
.modal { background: white; border-radius: 10px; padding: 22px 24px; width: 92%; max-width: 720px; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal.modal-wide { max-width: 1000px; }
.modal .m-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal h2 { margin: 0; font-size: 16px; }
.modal .m-close { background: transparent; border: 0; font-size: 20px; color: var(--text-soft); cursor: pointer; }
.modal .m-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ========== Toast ========== */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: white; padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 9999; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }
#toast.ok { background: var(--success); }

/* ========== 可搜索下拉 ========== */
.sd { position: relative; }
.sd-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.sd-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 6px 6px; max-height: 220px; overflow-y: auto; z-index: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.sd-list .opt { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.sd-list .opt:hover, .sd-list .opt.focus { background: #eff6ff; }
.sd-list .opt .en { color: var(--text-soft); font-size: 11px; }
.sd-list .empty { padding: 16px; text-align: center; color: var(--text-soft); font-size: 12px; }
.sd-list .hl { background: #fef08a; }

/* ========== 报价单页面 ========== */
.quotation { display: flex; gap: 16px; height: calc(100vh - 44px); }
.quote-side { width: 280px; flex-shrink: 0; background: white; border-radius: var(--radius); padding: 12px; overflow-y: auto; }
.quote-side .step { display: flex; align-items: center; gap: 8px; padding: 9px 10px; margin-bottom: 6px; border-radius: 6px; cursor: pointer; font-size: 13px; user-select: none; }
.quote-side .step:hover { background: #f9fafb; }
.quote-side .step.active { background: var(--primary); color: white; }
.quote-side .step.done { color: var(--text-soft); }
.quote-side .step .num { width: 22px; height: 22px; border-radius: 50%; background: #e5e7eb; color: #475569; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.quote-side .step.active .num { background: white; color: var(--primary); }
.quote-side .step.done .num { background: var(--success); color: white; }
.quote-side .step .lbl { flex: 1; }
.quote-side .step .badge { background: #dcfce7; color: #15803d; padding: 1px 6px; border-radius: 999px; font-size: 10px; }
.quote-side .step.active .badge { background: white; color: var(--primary); }

.quote-main { flex: 1; background: white; border-radius: var(--radius); padding: 18px; overflow-y: auto; }
.quote-side2 { width: 360px; flex-shrink: 0; background: white; border-radius: var(--radius); padding: 12px; overflow: hidden; display: flex; flex-direction: column; }
.quote-side2 .doc { flex: 1; overflow-y: auto; padding: 8px; background: #fafafa; border-radius: 6px; }

.step-panel h3 { font-size: 14px; margin: 0 0 12px; }
.step-panel .help { font-size: 12px; color: var(--text-soft); margin-bottom: 12px; }

/* 产品行(多商品) */
.product-row { display: grid; grid-template-columns: 50px 1fr 110px 110px 36px; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; background: #f9fafb; }
.product-row .seq { text-align: center; font-weight: 700; color: var(--primary); }
.product-row .qty input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; }
.product-row .price { font-weight: 600; }
.product-row .remove { background: transparent; border: 0; color: var(--danger); cursor: pointer; font-size: 16px; }
.product-row.add-row { display: block; text-align: center; padding: 10px; cursor: pointer; background: #f3f4f6; }
.product-row.add-row:hover { background: #e5e7eb; }

/* 加工/包装: 左对齐两列布局 */
.option-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
.option-row:hover { background: #f9fafb; }
.option-row .cb { width: 16px; height: 16px; }
.option-row .name { flex: 1; }
.option-row .name .cn { font-weight: 500; }
.option-row .name .en { color: var(--text-soft); font-size: 11px; display: block; }
.option-row .price { color: var(--text-soft); font-size: 12px; }

/* 报价单 表格 */
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.preview-table th, .preview-table td { border: 1px solid #e5e7eb; padding: 5px 7px; }
.preview-table th { background: linear-gradient(180deg, #f8fafc, #f1f5f9); text-align: left; font-weight: 600; color: var(--text); font-size: 11px; letter-spacing: 0.5px; }
.preview-table .right { text-align: right; font-variant-numeric: tabular-nums; }
.preview-table .center { text-align: center; }
.preview-table .group-title { background: linear-gradient(90deg, #eff6ff, transparent); font-weight: 700; color: var(--primary); border-top: 2px solid var(--primary); }
.preview-table .total-row { background: linear-gradient(180deg, #fef9c3, #fde68a); font-weight: 700; }
.preview-table input[type="number"] { width: 70px; padding: 2px 4px; border: 1px solid #e5e7eb; border-radius: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.preview-table input.invalid { border-color: var(--danger); background: #fef2f2; }
.preview-table .changed { background: #fffbeb; }
.preview-table .changed::after { content: "改"; font-size: 9px; color: white; background: var(--danger); border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
