/* 海关编码查询组件样式 — 所有规则限定在 .hs-app 内，避免污染宿主页面 */
.hs-app {
    --btd-header-h: 76px;
    --hs-hero-h: 88px;
    --page-width: 1400px;
    --primary: #0066cc;
    --primary-dark: #004799;
    --primary-light: #e8f2fc;
    --accent: #00a3e0;
    --text: #1a2332;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --bg: #f0f4f8;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(15, 40, 80, 0.08);
    --shadow-sm: 0 2px 8px rgba(15, 40, 80, 0.06);
    --transition: 0.2s ease;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    padding-top: var(--btd-header-h);
}
.hs-app * { box-sizing: border-box; }

.hs-app .hs-container {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.hs-app .hs-hero {
    position: fixed;
    top: var(--btd-header-h);
    left: 0; right: 0;
    z-index: 90;
    background: linear-gradient(120deg, #0066cc 0%, #0052a3 45%, #003d7a 100%);
    box-shadow: 0 4px 20px rgba(0, 60, 140, 0.18);
}
.hs-app .hs-hero-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: var(--hs-hero-h);
    padding: 10px 24px;
}
.hs-app .hs-hero-left { flex: 1; min-width: 0; }
.hs-app .hs-hero h1 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
    line-height: 1.3;
    margin: 0;
}
.hs-app .hs-hero-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.78);
    margin-top: 4px;
}

.hs-app .search-box { position: relative; flex-shrink: 0; }
.hs-app .search-box input {
    width: 400px;
    max-width: 42vw;
    padding: 12px 18px 12px 44px;
    border: none;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    outline: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transition: box-shadow var(--transition);
}
.hs-app .search-box input:focus {
    box-shadow: 0 6px 24px rgba(0,0,0,0.16), 0 0 0 3px rgba(255,255,255,0.3);
}
.hs-app .search-box input::placeholder { color: #94a3b8; }
.hs-app .search-box .icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    font-size: 15px; opacity: 0.5;
}
.hs-app .search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-height: 400px; overflow-y: auto;
    z-index: 200; display: none;
}
.hs-app .search-results.show { display: block; }
.hs-app .search-results .r-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid #f1f5f9;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.hs-app .search-results .r-item:last-child { border-bottom: none; }
.hs-app .search-results .r-item:hover { background: var(--primary-light); }
.hs-app .search-results .r-item .code {
    color: var(--primary);
    font-weight: 600;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 13px;
}
.hs-app .search-results .r-item .level-tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}
.hs-app .level-section { background: #fff7ed; color: #c2410c; }
.hs-app .level-chapter { background: #ecfdf5; color: #047857; }
.hs-app .level-heading { background: #eff6ff; color: #1d4ed8; }
.hs-app .level-subheading { background: #f5f3ff; color: #6d28d9; }
.hs-app .level-goods { background: #fff7ed; color: #c2410c; }

.hs-app .hs-body {
    padding-top: calc(var(--hs-hero-h) + 10px);
    padding-bottom: 16px;
}
.hs-app .hs-workspace {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    height: calc(100vh - var(--btd-header-h) - var(--hs-hero-h) - 26px);
    min-height: 480px;
}

.hs-app .left-panel {
    width: 360px;
    min-width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafbfc;
    border-right: 1px solid var(--border);
}
.hs-app .left-panel-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
}
.hs-app .left-panel-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.hs-app .left-panel-header h2::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 16px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 2px;
}
.hs-app .left-panel-header .info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}
.hs-app .tree-container { flex: 1; overflow-y: auto; padding: 8px 0; }

.hs-app .tree-node { user-select: none; }
.hs-app .tree-node-content {
    display: flex;
    align-items: center;
    padding: 8px 16px 8px 12px;
    margin: 2px 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition);
    border: 1px solid transparent;
}
.hs-app .tree-node-content:hover {
    background: #fff;
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.hs-app .tree-node-content.active {
    background: var(--primary-light);
    border-color: #bfdbfe;
}
.hs-app .tree-toggle {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
    border: none;
    border-radius: 6px;
    margin-right: 8px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all var(--transition);
}
.hs-app .tree-toggle:hover { background: var(--primary-light); }
.hs-app .tree-toggle.leaf { visibility: hidden; }
.hs-app .tree-code {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    margin-right: 8px;
    flex-shrink: 0;
    font-family: "SF Mono", Consolas, monospace;
}
.hs-app .code-section { background: #fff7ed; color: #c2410c; }
.hs-app .code-chapter { background: #ecfdf5; color: #047857; }
.hs-app .code-heading { background: #eff6ff; color: #1d4ed8; }
.hs-app .code-subheading { background: #f5f3ff; color: #6d28d9; }
.hs-app .tree-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    line-height: 1.4;
}
.hs-app .tree-badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 6px;
    flex-shrink: 0;
    font-weight: 500;
}
.hs-app .badge-data { background: #dcfce7; color: #15803d; }
.hs-app .badge-no-data { background: #f1f5f9; color: #94a3b8; }
.hs-app .tree-children { display: none; }
.hs-app .tree-children.expanded { display: block; }
.hs-app .tree-loading {
    padding: 10px 16px 10px 40px;
    color: var(--text-secondary);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hs-app .tree-loading .mini-spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: hs-spin 0.8s linear infinite;
}

.hs-app .right-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.hs-app .breadcrumb {
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.hs-app .breadcrumb .crumb {
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition);
}
.hs-app .breadcrumb .crumb:hover { background: var(--primary-light); text-decoration: none; }
.hs-app .breadcrumb .sep { color: #cbd5e1; font-size: 12px; }
.hs-app .breadcrumb .current {
    color: var(--text);
    font-weight: 600;
    padding: 4px 10px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.hs-app .note-bar {
    margin: 16px 0 12px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #fffbeb 0%, #fef9c3 100%);
    border: 1px solid #fde68a;
    font-size: 13px;
    color: #78350f;
    display: none;
    overflow: hidden;
}
.hs-app .note-bar.show { display: block; }
.hs-app .note-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}
.hs-app .note-chip:hover { background: rgba(255,255,255,0.4); }
.hs-app .note-chip .note-label { font-weight: 600; color: #b45309; font-size: 13px; }
.hs-app .note-chip .note-toggle { color: #92400e; font-size: 11px; margin-left: auto; opacity: 0.6; }
.hs-app .note-body {
    padding: 12px 0 0;
    white-space: pre-wrap;
    line-height: 1.7;
    font-size: 13px;
    max-height: 260px;
    overflow-y: auto;
    color: #78350f;
    border-top: 1px solid #fde68a;
    margin: 0 16px 14px;
}

.hs-app .info-bar {
    padding: 12px 24px;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    font-size: 13px;
    color: #b45309;
    display: none;
    align-items: center;
    gap: 10px;
}
.hs-app .info-bar.show { display: flex; }
.hs-app .info-bar .info-icon { font-size: 18px; }
.hs-app .info-bar .info-text { flex: 1; }
.hs-app .info-bar .info-stats { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.hs-app .product-table-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px 16px;
}
.hs-app .table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 16px;
    background: #fff;
}
.hs-app .product-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    table-layout: auto;
}
.hs-app .product-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
    color: var(--text);
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    letter-spacing: 0.3px;
}
.hs-app .product-table tbody td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    transition: background var(--transition);
    vertical-align: top;
}
.hs-app .product-table .col-code,
.hs-app .product-table .col-std,
.hs-app .product-table .col-unit,
.hs-app .product-table .col-super,
.hs-app .product-table .col-insp,
.hs-app .product-table .col-status {
    white-space: nowrap;
    width: 1%;
}
.hs-app .product-table .col-code,
.hs-app .product-table .col-std {
    vertical-align: middle;
}
.hs-app .product-table .col-name {
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
    width: auto;
    min-width: 200px;
}
.hs-app .product-table .col-unit,
.hs-app .product-table .col-super,
.hs-app .product-table .col-insp {
    font-size: 12px;
    color: var(--text-secondary);
    padding-left: 8px;
    padding-right: 8px;
}
.hs-app .product-table .col-status {
    text-align: center;
    vertical-align: middle;
}
.hs-app .product-table tbody tr:hover td { background: #f8fafc; }
.hs-app .product-table tbody tr:last-child td { border-bottom: none; }
.hs-app .badge-blue {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: #eff6ff;
    color: #1d4ed8;
    font-family: "SF Mono", Consolas, monospace;
    white-space: nowrap;
}
.hs-app .badge-green {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: #dcfce7;
    color: #15803d;
}
.hs-app .badge-red {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: #fee2e2;
    color: #b91c1c;
}
.hs-app .std-code {
    font-family: "SF Mono", Consolas, monospace;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}
.hs-app .goods-name {
    font-weight: 500;
    color: #1a2332;
    display: inline;
}
.hs-app a.badge-blue.code-link {
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.hs-app a.badge-blue.code-link:hover {
    background: #0066cc;
    color: #fff;
}

.hs-app .pagination-bar {
    padding: 14px 24px;
    background: #fafbfc;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;
}
.hs-app .pg-left { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.hs-app .pg-right { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hs-app .pg-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    background: #fff;
    color: var(--text);
    transition: all var(--transition);
}
.hs-app .pg-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: #93c5fd;
    color: var(--primary);
}
.hs-app .pg-btn:disabled { opacity: 0.4; cursor: default; }
.hs-app .pg-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,102,204,0.3);
}
.hs-app .pg-sel, .hs-app .pg-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    outline: none;
    transition: border-color var(--transition);
}
.hs-app .pg-sel:focus, .hs-app .pg-input:focus { border-color: var(--primary); }
.hs-app .pg-input { width: 52px; text-align: center; }

.hs-app .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 280px;
    color: var(--text-secondary);
    padding: 40px;
}
.hs-app .empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.35;
    filter: grayscale(0.3);
}
.hs-app .empty-state .title { font-size: 17px; font-weight: 600; color: var(--text); }
.hs-app .empty-state .desc { font-size: 14px; margin-top: 8px; text-align: center; line-height: 1.6; }
.hs-app .loading { display: flex; align-items: center; justify-content: center; padding: 48px; }
.hs-app .spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: hs-spin 0.8s linear infinite;
}
@keyframes hs-spin { to { transform: rotate(360deg); } }

.hs-app ::-webkit-scrollbar { width: 6px; height: 6px; }
.hs-app ::-webkit-scrollbar-track { background: transparent; }
.hs-app ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.hs-app ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

@media (max-width: 1200px) {
    .hs-app .hs-workspace {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - var(--btd-header-h) - var(--hs-hero-h) - 26px);
    }
    .hs-app .left-panel {
        width: 100%;
        min-width: 0;
        max-height: 320px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .hs-app .right-panel { min-height: 480px; }
}
@media (max-width: 768px) {
    .hs-app { --hs-hero-h: 120px; }
    .hs-app .hs-hero-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 16px;
    }
    .hs-app .hs-hero h1 { font-size: 17px; }
    .hs-app .search-box input { width: 100%; max-width: 100%; }
    .hs-app .hs-container { padding: 0 16px; }
    .hs-app .hs-body { padding-top: calc(var(--hs-hero-h) + 8px); padding-bottom: 12px; }
    .hs-app .breadcrumb { padding: 12px 16px; font-size: 12px; }
    .hs-app .product-table-container { padding: 0 12px 12px; }
    .hs-app .pagination-bar { padding: 12px 16px; justify-content: center; }
    .hs-app .pg-left { width: 100%; justify-content: center; }
}

/* ===== 嵌入模式：供原网站嵌套，无国贸通顶栏 ===== */
.hs-app.hs-embed {
    --btd-header-h: 0;
    padding-top: 0;
}
.hs-app.hs-embed .hs-hero {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
}
.hs-app.hs-embed .hs-body {
    padding-top: 10px;
}
.hs-app.hs-embed .hs-workspace {
    height: calc(100vh - var(--hs-hero-h) - 40px);
}

/* ===== 原站整页 hscode.html（与线上 hs-app 模式一致，非 embed） ===== */
.hs-app:not(.hs-embed) .search-box input[type="text"] {
    display: block !important;
    float: none !important;
    width: 400px;
    max-width: 42vw;
    height: auto;
    margin: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
    appearance: none;
    -webkit-appearance: none;
}
@media (max-width: 768px) {
    .hs-app:not(.hs-embed) .search-box input[type="text"] {
        width: 100%;
        max-width: 100%;
    }
}
