@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap');
:root{--primary:#1a3c6e;--accent:#e8a020;--bg:#f0f3f9;--card:#fff;--border:#d4dbe8;--text:#1e2533;--muted:#6b7a99;--green:#1a7a3a;--red:#c0392b;--radius:8px;--sidebar-w:210px;--navy:#0d2340;--gold:#e8a020;--gold2:#d4900a;--blue:#1e6fbf;--blue2:#1a5da0}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Space Grotesk','Noto Sans SC',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:var(--bg);color:var(--text);min-height:100vh}
header{background:#0d2340;color:#fff;padding:12px 20px;display:flex;align-items:center;gap:12px;border-bottom:1px solid rgba(255,255,255,0.08);position:relative;z-index:10}
.logo{font-size:24px}
header h1{font-size:16px;font-weight:700;line-height:1.3}
header p{font-size:10px;opacity:.8}
.header-right{margin-left:auto;display:flex;align-items:center;gap:10px}
.badge-update{background:rgba(255,255,255,.15);padding:4px 10px;border-radius:20px;font-size:10px;white-space:nowrap}
.lang-toggle{background:rgba(255,255,255,.2);border:1px solid rgba(255,255,255,.35);color:#fff;padding:4px 12px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600;transition:all .2s}
.lang-toggle:hover{background:rgba(255,255,255,.3)}

.app-layout{display:flex;min-height:calc(100vh - 52px)}
.sidebar{width:var(--sidebar-w);background:#fff;border-right:1px solid var(--border);overflow-y:auto;padding:8px 0;flex-shrink:0}
.sidebar-group{padding:8px 14px 4px;font-size:10px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.5px}
.sidebar-item{display:flex;align-items:center;gap:8px;padding:10px 14px;cursor:pointer;font-size:13px;color:var(--text);transition:all .15s;border-left:3px solid transparent;margin:1px 0}
.sidebar-item:hover{background:#f5f7ff;color:var(--primary)}
.sidebar-item.active{background:#eef2ff;color:var(--primary);border-left-color:var(--primary);font-weight:600}
.sidebar-item .icon{font-size:16px;width:22px;display:flex;align-items:center;justify-content:center}
.sidebar-item .tag{font-size:9px;background:var(--accent);color:#fff;padding:1px 5px;border-radius:4px;margin-left:auto}
.region-tag{font-size:9px;padding:1px 5px;border-radius:4px;margin-left:auto;font-weight:600;letter-spacing:.3px}
.region-us{background:rgba(30,111,191,.15);color:var(--primary);border:1px solid rgba(30,111,191,.25)}
.region-ca{background:rgba(212,168,67,.15);color:#b8860b;border:1px solid rgba(212,168,67,.25)}
.region-mx{background:rgba(90,158,111,.15);color:#3a7d4d;border:1px solid rgba(90,158,111,.25)}
.region-usca{background:rgba(107,155,210,.15);color:#4a7ab5;border:1px solid rgba(107,155,210,.25)}
.region-cn{background:rgba(212,76,76,.15);color:#b53b3b;border:1px solid rgba(212,76,76,.25)}

.main-content{flex:1;overflow-y:auto;padding:18px 22px}
.panel{display:none}.panel.active{display:block}

.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}

/* ═════════ UNIVERSAL SVG CONTAINMENT v13.3.10 ═════════ */
svg{max-width:100%;max-height:100%;overflow:hidden;vertical-align:middle}
.sidebar-item .icon svg{width:18px;height:18px}
.section-label svg{width:16px;height:16px;margin-right:4px;flex-shrink:0}
h3 svg{width:18px;height:18px;margin-right:6px;flex-shrink:0}
.result-panel svg{width:16px;height:16px;flex-shrink:0}
.line-item svg{width:14px;height:14px;flex-shrink:0;vertical-align:middle}
#afResult svg{width:16px;height:16px;flex-shrink:0}
#afSmartRoute svg{width:16px;height:16px;flex-shrink:0}
.parsed-fields svg{width:12px;height:12px}
.card svg{max-width:64px;max-height:64px}
button svg{width:14px;height:14px;margin-right:4px}
select svg{width:12px;height:12px}

@media(max-width:900px){.sidebar{width:180px}.grid2{grid-template-columns:1fr}}

.card{background:var(--card);border-radius:var(--radius);border:1px solid var(--border);padding:18px 20px}
.card h3{font-size:13px;font-weight:700;color:var(--navy);text-transform:uppercase;letter-spacing:.5px;border-bottom:2px solid var(--accent);padding-bottom:8px;margin-bottom:14px}
.section-label{font-size:10px;font-weight:700;color:var(--accent);text-transform:uppercase;letter-spacing:1px;margin:14px 0 8px;padding:4px 0;border-bottom:1px dashed var(--border)}

.field{margin-bottom:10px}
.field label{display:block;font-size:11px;font-weight:600;color:var(--muted);margin-bottom:3px}
.field input,.field select{width:100%;padding:8px 10px;border:1.5px solid var(--border);border-radius:7px;font-size:13px;background:#fafbfd;transition:border .2s,box-shadow .2s}
.field input:focus,.field select:focus{outline:none;border-color:var(--blue);box-shadow:0 0 0 3px rgba(30,111,191,.08)}
.field-row{display:flex;gap:8px}
.field-row .field{flex:1}

.result-panel{background:#0d2340;color:#fff;border-radius:var(--radius);padding:22px;min-height:200px;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,0.08)}
.result-panel h3{color:#fff;border-bottom-color:rgba(255,255,255,.25);font-size:13px}
.line-item{display:flex;justify-content:space-between;padding:5px 0;border-bottom:1px solid rgba(255,255,255,.1);font-size:12.5px;gap:8px}
.line-item .desc{flex:1;opacity:.9}
.line-item .amt{font-weight:700;white-space:nowrap}
.total-row{display:flex;justify-content:space-between;align-items:center;margin-top:auto;padding-top:12px;border-top:2px solid var(--accent)}
.total-row .lbl{font-size:14px;font-weight:700}
.total-row .val{font-size:24px;font-weight:800;color:var(--accent)}
.note{font-size:10px;opacity:.6;margin-top:8px;line-height:1.6}

.calc-btn{width:100%;margin-top:12px;padding:12px;background:var(--gold);color:#fff;border:none;border-radius:var(--radius);font-size:13px;font-weight:700;cursor:pointer;transition:all .2s;letter-spacing:.5px}
.calc-btn:hover{background:var(--gold2)}
.calc-btn:active{background:#b07808}
.calc-btn.secondary{background:var(--blue)}
.calc-btn.secondary:hover{background:var(--blue2)}

.alert-info{background:#e8f0ff;border:1px solid #b0c8ff;border-radius:8px;padding:9px 12px;font-size:11px;color:#1a3c8a;margin-bottom:10px}
.alert-warn{background:#fff7e0;border:1px solid #f5cc60;border-radius:8px;padding:9px 12px;font-size:11px;color:#7a5000;margin-bottom:10px}

table{width:100%;border-collapse:collapse;font-size:11.5px}
th{background:var(--primary);color:#fff;padding:6px 8px;text-align:left;font-size:10px;font-weight:600}
td{padding:5px 8px;border-bottom:1px solid var(--border)}
tr:hover td{background:#f7f8fc}
tr:nth-child(even) td{background:#f9fafd}
.badge{display:inline-block;padding:2px 7px;border-radius:10px;font-size:10px;font-weight:600}
.b-rmb{background:#fff3d6;color:#8a5500}.b-usd{background:#d4f0e2;color:#1a5c3a}.b-sell{background:#e8d0ff;color:#5a00aa}

.vas-row{display:flex;align-items:center;gap:6px;padding:6px 8px;border:1px solid var(--border);border-radius:7px;margin-bottom:4px;cursor:pointer;font-size:12px;transition:background .15s}
.vas-row:hover{background:#f5f7ff}
.vas-row input[type=checkbox]{width:14px;height:14px;cursor:pointer}
.vas-row .vas-price{margin-left:auto;font-size:10px;font-weight:700;color:var(--primary)}
.vas-qty{padding-left:22px;margin-bottom:7px;display:none}
.vas-qty label{font-size:10px;color:var(--muted)}
.vas-qty input{width:100%;padding:4px 6px;border:1px solid var(--border);border-radius:5px;font-size:12px;margin-top:2px}

@media print {
  body { background: #fff; }
  .sidebar, header, .calc-btn, .ai-fab, .ai-panel, .section-label { display: none !important; }
  .grid2 { grid-template-columns: 1fr; }
  .result-panel { box-shadow: none; border: 2px solid var(--navy); }
}

.bot-textarea{width:100%;height:80px;padding:9px;border:1.5px solid var(--border);border-radius:8px;font-size:13px;resize:vertical;font-family:inherit}
.bot-reply{background:#fff;border-radius:8px;border:1px solid var(--border);padding:14px;margin-top:10px;font-size:12px;white-space:pre-wrap;min-height:50px;line-height:1.7}
.api-box{background:#1a1f2e;color:#c9d1e0;border-radius:10px;padding:14px;font-family:Consolas,monospace;font-size:11px;line-height:1.7;overflow-x:auto}
.api-box .kw{color:#79c0ff}.api-box .str{color:#a5d6ff}.api-box .num{color:#f2cc60}.api-box .cmt{color:#556070}

.info-rows{font-size:12px;line-height:1.7}
.info-rows .ir{display:flex;justify-content:space-between;padding:3px 0;border-bottom:1px solid rgba(255,255,255,.08)}

/* ── Auto Fill-In FAB & Panel ── */
.autofill-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 54px; height: 54px; border-radius: var(--radius);
  background: var(--navy);
  border: 2px solid rgba(232,160,32,0.55);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.25s ease;
}
.autofill-fab svg { width: 30px; height: 30px; }
.autofill-fab:hover { background: #1a3d6b; border-color: rgba(232,160,32,0.85); }

/* ── One-Sentence Hint Balloon ── */
.autofill-hint {
  position: fixed; bottom: 28px; right: 76px; z-index: 9997;
  background: #fff;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(11,31,58,0.08);
  padding: 11px 16px; max-width: 300px; font-size: 12.5px; line-height: 1.6;
  color: #334155; animation: afHintIn 0.4s ease;
  font-weight: 500; letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 4px;
}
@keyframes afHintIn { from { opacity: 0; transform: translateX(10px) scale(0.96); } to { opacity: 1; transform: translateX(0) scale(1); } }
.autofill-hint::after {
  content: ''; position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  border-left: 7px solid #fff;
  filter: drop-shadow(2px 0 2px rgba(0,0,0,0.04));
}
.autofill-hint::before {
  content: ''; position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  border-left: 8px solid #e2e8f0;
}

/* ── Panel ── */
.autofill-panel {
  position: fixed; bottom: 84px; right: 24px; z-index: 9998;
  width: 370px; background: #fff;
  border-radius: var(--radius); border: 1.5px solid #e2e8f0;
  box-shadow: 0 8px 32px rgba(11,31,58,0.1);
  display: none; flex-direction: column; overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.autofill-panel.open { display: flex; animation: panelUp 0.3s ease; }
@keyframes panelUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.af-header {
  background: var(--navy);
  padding: 14px 18px; display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.af-header .af-icon { width: 28px; height: 28px; flex-shrink: 0; }
.af-header h3 { color: #fff; font-size: 14px; font-weight: 700; flex: 1; margin: 0; }
.af-header .af-close {
  background: none; border: none; color: rgba(255,255,255,0.55); cursor: pointer;
  font-size: 20px; padding: 2px 6px; line-height: 1; transition: color 0.15s;
}
.af-header .af-close:hover { color: #fff; }

.af-desc { margin: 12px 18px 0; font-size: 12px; color: #64748b; line-height: 1.5; }
.autofill-panel > textarea {
  margin: 10px 18px; width: calc(100% - 36px); resize: none;
  padding: 12px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px;
  font-size: 13px; line-height: 1.5; font-family: inherit;
  outline: none; transition: all 0.2s; min-height: 80px;
}
.autofill-panel > textarea:focus { border-color: #f4b942; box-shadow: 0 0 0 3px rgba(244,185,66,0.12); }
.autofill-panel > textarea::placeholder { color: #94a3b8; }

.af-go-btn {
  margin: 0 18px 12px; width: calc(100% - 36px);
  padding: 12px; border-radius: var(--radius); border: none; cursor: pointer;
  background: var(--gold); color: #0d2340;
  font-weight: 800; font-size: 13.5px; letter-spacing: 0.3px;
  transition: all 0.2s; text-align: center;
}
.af-go-btn:hover { background: var(--gold2); }
.af-go-btn:active { background: #b07808; }

/* Original Inquiry viewer (v13.7.0) */
.af-original-inquiry {
  margin: 0 18px 10px; border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(100,116,139,0.25); background: #f8fafc;
  animation: resultIn 0.3s ease;
}
.af-orig-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f1f5f9; border-bottom: 1px solid rgba(100,116,139,0.15);
}
.af-orig-label {
  font-size: 11px; font-weight: 700; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 4px;
}
.af-orig-label::before { content: '\1F4CB'; font-size: 12px; }
.af-orig-toggle {
  background: none; border: none; cursor: pointer; font-size: 10px;
  color: #64748b; padding: 2px 6px; border-radius: 4px; transition: all 0.15s;
}
.af-orig-toggle:hover { background: rgba(100,116,139,0.1); }
.af-orig-text {
  margin: 0; padding: 10px 12px; max-height: 180px; overflow-y: auto;
  font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
  font-size: 11.5px; line-height: 1.6; color: #334155;
  white-space: pre-wrap; word-break: break-word;
}
.af-original-inquiry.collapsed .af-orig-text { display: none; }
.af-original-inquiry.collapsed .af-orig-toggle { transform: rotate(-90deg); }

/* Cargo type prediction badge (v13.7.0) */
.cargo-prediction-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; margin-left: 6px; white-space: nowrap;
  animation: resultIn 0.2s ease;
}
.cargo-prediction-badge.battery { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.cargo-prediction-badge.sensitive { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.cargo-prediction-badge.dg { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.cargo-prediction-badge.general { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.qx-cargo-predicted {
  border-color: #f4b942 !important;
  box-shadow: 0 0 0 2px rgba(244,185,66,0.15) !important;
}

.af-result {
  margin: 0 18px 10px; display: none;
  padding: 12px 14px; border-radius: 10px;
  background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
  border: 1px solid #bbf7d0; font-size: 12px; line-height: 1.65; color: #166534;
}
.af-result.show { display: block; animation: resultIn 0.3s ease; }
@keyframes resultIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.af-result .parsed-fields { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.af-result .parsed-fields span {
  background: #dcfce7; color: #15803d; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 10px; white-space: nowrap;
}
.af-result .af-missing { font-size: 11px; color: #d63b2f; margin-top: 6px; }

/* Smart Route suggestion bar */
.af-smart-route {
  margin: 0 18px 10px; padding: 10px 14px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(244,185,66,0.08), rgba(200,149,10,0.05));
  border: 1px solid rgba(244,185,66,0.3); font-size: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  animation: resultIn 0.3s ease;
}
.af-smart-route .sr-icon { font-size: 18px; flex-shrink: 0; }
.af-smart-route .sr-text { font-size: 11px; color: var(--text); line-height: 1.5; }
.af-smart-route .sr-text strong { color: #d4a843; }
.af-smart-route .sr-btn {
  padding: 5px 12px; border-radius: 16px; border: 1px solid #d4a843;
  background: linear-gradient(135deg, #f4b942, #c9950a); color: #0d2340;
  font-weight: 700; font-size: 11px; cursor: pointer; white-space: nowrap;
  transition: all 0.15s; margin-left: auto;
}
.af-smart-route .sr-btn:hover { transform: scale(1.04); box-shadow: 0 4px 12px rgba(244,185,66,0.35); }

.af-actions { display: flex; gap: 8px; padding: 0 18px 16px; }
.af-action-primary {
  flex: 1; padding: 10px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #22c47b, #17a05c); color: #fff;
  font-weight: 700; font-size: 13px; transition: all 0.15s;
}
.af-action-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(34,196,123,0.35); }
.af-action-secondary {
  padding: 10px 16px; border-radius: 10px; border: 1px solid #e2e8f0; cursor: pointer;
  background: #fff; color: #64748b; font-weight: 600; font-size: 12px; transition: all 0.15s;
}
.af-action-secondary:hover { border-color: #cbd5e1; color: #334155; }

@media (max-width: 480px) {
  .autofill-hint { right: 64px; bottom: 24px; max-width: 200px; font-size: 11.5px; }
  .autofill-panel { width: calc(100vw - 32px); right: 16px; }
  .autofill-fab { right: 16px; bottom: 20px; }
}

/* ── Footer ── */
.footer { margin-top: auto; padding: 14px 22px; background: #fff; border-top: 1px solid var(--border); text-align: center; }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.footer-links a { color: var(--muted); font-size: 11px; text-decoration: none; cursor: pointer; transition: color .15s; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }
.copyright { font-size: 10px; color: var(--muted); opacity: .6; margin: 0; }
.footer-logo-row { margin-bottom: 8px; }
.footer-logo-row img { opacity: .6; }