/* 易HS — 海关编码智能查询 MVP */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1e86fc;
  --brand-dark: #1565c0;
  --brand-soft: #e8f3ff;
  --accent: #1e86fc;
  --accent-soft: #e8f3ff;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}
.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  gap: 0.1rem;
}
.logo-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.logo-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  flex-wrap: wrap;
}
.nav button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.nav button:hover { background: var(--bg); color: var(--ink); }
.nav button.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.header-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.hero {
  background: linear-gradient(135deg, #1565c0 0%, #1565c0 55%, #0369a1 100%);
  color: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.35rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.hero h1 {
  margin: 0 0 0.2rem;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  font-weight: 700;
}
.hero p {
  margin: 0 0 0.7rem;
  opacity: 0.9;
  max-width: 36rem;
  font-size: 0.9rem;
}


/* HS查询：搜索区固定，下方结果列表单独滚动 */
body.home-lock {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.home-lock .app-header {
  flex-shrink: 0;
}
body.home-lock .main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
}
body.home-lock .footer {
  flex-shrink: 0;
  padding: 0.7rem 1.25rem;
}
body.home-lock .view[data-view="home"].active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: none;
}
body.home-lock .view[data-view="home"] .hero {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
body.home-lock .view[data-view="home"] .card.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.home-lock .view[data-view="home"] .panel-head,
body.home-lock .view[data-view="home"] .pager {
  flex-shrink: 0;
}
body.home-lock .view[data-view="home"] .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-top: 0.5rem;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  background: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.3rem;
  box-shadow: none;
}
.search-box input:focus {
  border: none;
  box-shadow: none;
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.55rem 0.8rem;
  font-size: 0.95rem;
  color: var(--ink);
  min-width: 0;
}
.search-box button.primary {
  flex-shrink: 0;
}
.chip {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.chip:hover { background: rgba(255,255,255,.22); }

/* Action buttons — forced 28px to match 收藏夹 toolbar; brand #1e86fc */
.btn {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.28rem 0.7rem;
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.3;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  cursor: pointer;
  transition: .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  background: var(--surface);
  color: var(--ink);
  box-sizing: border-box;
  flex: 0 0 auto;
  align-self: center;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}
.btn.primary:active:not(:disabled) {
  background: #0d4f9e;
  border-color: #0d4f9e;
}
/* ghost = outline secondary (blue border + blue text) */
.btn.ghost,
.btn.outline {
  background: #fff;
  border-color: var(--brand);
  color: var(--brand);
}
.btn.ghost:hover:not(:disabled),
.btn.outline:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}
.btn.ghost:active:not(:disabled),
.btn.outline:active:not(:disabled) {
  background: #d6eaff;
  border-color: var(--brand-dark);
  color: var(--brand-dark);
}
/* .btn.sm / .btn.lg: same forced 28px as base (no oversized variant) */
.btn.sm,
.btn.lg {
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 4px;
  line-height: 1.3;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
}
.btn.danger-ghost {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}
.btn.danger-ghost:hover:not(:disabled) {
  background: #fef2f2;
  border-color: var(--danger);
  color: var(--danger);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}
.card .sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: -0.4rem 0 1rem;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.5rem 0 0.75rem;
  gap: 1rem;
}
.results-head h2 { margin: 0; font-size: 1.05rem; }
.results-head .muted { color: var(--muted); font-size: 0.85rem; }

.result-list { display: flex; flex-direction: column; gap: 0.65rem; }
.result-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.result-item:hover {
  border-color: #99f6e4;
  box-shadow: var(--shadow);
}
.result-item .code {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.result-item .name { font-weight: 600; margin-top: 0.15rem; }
.result-item .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
}
.tag.teal { background: var(--brand-soft); border-color: #99f6e4; color: var(--brand-dark); }
.tag.blue { background: var(--accent-soft); border-color: #bae6fd; color: var(--accent); }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  justify-content: center;
}
.fav-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.fav-btn.on { color: #eab308; border-color: #fde68a; background: #fffbeb; }

/* Classify */
.form-grid { display: grid; gap: 0.85rem; }
label.field { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
label.field span.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
textarea, input[type="text"], input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: #fff;
  outline: none;
}
textarea:focus, input:focus { border-color: #5eead4; box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
textarea { min-height: 120px; resize: vertical; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.25rem;
  align-items: center; /* prevent stretch-to-select making 收藏夹 taller than 私有云 */
}

.suggest-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.suggest-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #fff;
  display: grid;
  gap: 0.55rem;
}
.suggest-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.confidence {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--brand-dark);
}
.confidence.low { color: var(--warn); }
.reason {
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
}
.bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3e95f9, #0ea5e9);
  border-radius: inherit;
}

/* Batch table */
.table-wrap { overflow-x: auto; margin-top: 1rem; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
table.data th {
  background: var(--bg);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
table.data tr:hover td { background: #f8fafc; }
table.data .code { font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans SC", sans-serif; font-weight: 400; color: var(--brand); width: 9.6rem; min-width: 9.2rem; white-space: nowrap; vertical-align: middle; }
table.data .code a { color: var(--brand); }
table.data .code a:hover { color: var(--brand-dark); }
[data-view="batch"] table.data th:nth-child(1),
[data-view="batch"] table.data td:first-child {
  width: 7.2rem;
  min-width: 7.2rem;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: #d1fae5; color: #047857; }
.badge.no { background: #fee2e2; color: #b91c1c; }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty .icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100%);
  height: 100%;
  background: #fff;
  z-index: 60;
  transform: translateX(105%);
  transition: transform .25s ease;
  box-shadow: -8px 0 32px rgba(15,23,42,.12);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.drawer-head h3 { margin: 0; font-size: 1.05rem; }
.drawer-body {
  padding: 1.1rem 1.25rem 2rem;
  overflow-y: auto;
  flex: 1;
}
.close-btn {
  border: none;
  background: var(--bg);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--muted);
}
.detail-code {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: 0.03em;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
}
.kv {
  background: var(--bg);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}
.kv .k { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
.kv .v { font-weight: 600; font-size: 0.95rem; }
.kv.full { grid-column: 1 / -1; }

/* Compact HS detail modal — fit all fields without scroll on typical desktops */
#modal.modal-detail {
  width: min(860px, calc(100vw - 1.25rem));
  max-height: min(94vh, 820px);
}
#modal.modal-detail .modal-head {
  padding: 0.55rem 0.9rem;
}
#modal.modal-detail .modal-head h3 { font-size: 0.95rem; }
#modal.modal-detail .modal-body {
  padding: 0.55rem 0.9rem 0.4rem;
  overflow-y: auto;
}
#modal.modal-detail .modal-foot {
  padding: 0.35rem 0.9rem;
  gap: 0.35rem;
}
#modal.modal-detail .modal-foot .btn {
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.28rem 0.7rem;
  border-radius: 4px;
  line-height: 1.3;
  min-height: 0;
}
#modal.modal-detail .modal-foot .btn.primary {
  font-weight: 500;
}
#modal.modal-detail .detail-code {
  font-size: 1.05rem;
  line-height: 1.2;
}
#modal.modal-detail .detail-name {
  font-size: 0.9rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}
#modal.modal-detail .detail-en {
  font-size: 0.78rem;
  margin-top: 0.05rem;
  margin-bottom: 0.35rem;
}
#modal.modal-detail .detail-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem 0.4rem;
  margin: 0.35rem 0 0.4rem;
}
#modal.modal-detail .kv {
  border-radius: 6px;
  padding: 0.28rem 0.45rem;
}
#modal.modal-detail .kv .k {
  font-size: 0.68rem;
  margin-bottom: 0.05rem;
  line-height: 1.2;
}
#modal.modal-detail .kv .v {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}
#modal.modal-detail .kv.span2 { grid-column: span 2; }
#modal.modal-detail .kv.full { grid-column: 1 / -1; }
#modal.modal-detail .kv .v.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 720px) {
  #modal.modal-detail .detail-grid { grid-template-columns: 1fr 1fr; }
  #modal.modal-detail .kv.span2 { grid-column: span 2; }
}


/* 编码详情：统一微软雅黑，字距略加、行高更匀称 */
#modal.modal-detail,
#modal.modal-detail .detail-code,
#modal.modal-detail .modal-head,
#modal.modal-detail .modal-head h3,
#modal.modal-detail .modal-foot,
#modal.modal-detail .modal-foot .btn,
.catalog-detail-pane,
.catalog-detail-pane .detail-code,
.catalog-detail-pane .catalog-detail-foot,
.catalog-detail-pane .catalog-detail-foot .btn {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans SC", sans-serif;
}
#modal.modal-detail,
.catalog-detail-pane {
  letter-spacing: 0.04em;
}
#modal.modal-detail .modal-head h3,
.catalog-detail-pane .catalog-detail-head {
  letter-spacing: 0.06em;
}
#modal.modal-detail .detail-code,
.catalog-detail-pane .detail-code {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans SC", sans-serif;
  letter-spacing: 0.08em;
  font-weight: 700;
  line-height: 1.35;
}
#modal.modal-detail .detail-name,
.catalog-detail-pane .detail-name {
  letter-spacing: 0.04em;
  line-height: 1.45;
}
#modal.modal-detail .detail-en,
.catalog-detail-pane .detail-en {
  letter-spacing: 0.03em;
  line-height: 1.5;
}
#modal.modal-detail .kv .k,
.catalog-detail-pane .kv .k {
  letter-spacing: 0.06em;
  line-height: 1.4;
  margin-bottom: 0.12rem;
}
#modal.modal-detail .kv .v,
.catalog-detail-pane .kv .v {
  letter-spacing: 0.04em;
  line-height: 1.45;
  font-weight: 600;
}
#modal.modal-detail .detail-grid,
.catalog-detail-pane .detail-grid {
  gap: 0.45rem 0.5rem;
}
#modal.modal-detail .kv,
.catalog-detail-pane .kv {
  padding: 0.4rem 0.55rem;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 1.1rem 0 0.5rem;
}
div.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
div.examples span {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #16a34a;
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.footer strong { color: var(--ink); }

.stub-note {
  background: #fffbeb;
  border: 1px dashed #fbbf24;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: #92400e;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: 0.6rem; align-items: center; }
  .nav { order: 3; flex: 1 1 100%; width: 100%; max-width: 100%; }
  .header-meta { display: none; }
  .search-box { flex-direction: column; }
  .result-item { grid-template-columns: 1fr; }
  .result-actions { flex-direction: row; justify-content: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .hero { padding: 0.95rem 1rem 0.85rem; }
}

/* —— Aligned IA: panels, tables, modal —— */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel-head .form-actions {
  margin-top: 0;
  justify-content: flex-end;
  flex: 1 1 auto;
}
.panel .sub { margin: 0.35rem 0 0; }
.card.panel { padding: 1.15rem 1.2rem 1.35rem; }

/* Panel toolbars (收藏夹 / 私有云): lock button box to 28px regardless of flex stretch */
.panel-head .form-actions .btn,
[data-view="cloud"] .btn,
[data-view="favs"] .btn {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  padding: 0.28rem 0.7rem !important;
  font-size: 0.82rem !important;
  line-height: 1.3 !important;
  border-radius: 4px !important;
  box-sizing: border-box !important;
}

.placeholder-row td {
  text-align: center;
  color: var(--muted);
  padding: 1.75rem 0.7rem !important;
}

td.code {
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Noto Sans SC", sans-serif;
  font-weight: 400;
  color: var(--brand);
  vertical-align: middle;
  white-space: nowrap;
}
td.code a { color: var(--brand); }
td.code a:hover { color: var(--brand-dark); }
.mono { font-family: var(--mono); font-weight: 600; color: var(--brand-dark); }
td.clamp {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.clamp.desc,
td.clamp.excol {
  /* Keep display:table-cell; overflow must NOT be on <td> (Chromium breaks row borders) */
  max-width: 22rem;
  min-width: 0;
  width: auto;
  white-space: normal;
  overflow: visible;
  vertical-align: middle;
  line-height: 1.4;
  word-break: break-word;
}
td.clamp.desc .clamp-inner,
td.clamp.excol .clamp-inner {
  display: block;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.4;
  max-height: 2.8em; /* ~2 lines; clip on inner only */
}
td.ops {
  white-space: nowrap;
  vertical-align: middle;
}
#home-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}
#home-table th,
#home-table td {
  display: table-cell !important; /* never flex — .examples chip rule used to hit tds */
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}
#home-table tbody td .clamp-inner {
  display: block;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.4;
  max-height: 2.8em;
}
#home-table th:nth-child(1),
#home-table td.code { width: 9.6rem; }
#home-table th:nth-child(4),
#home-table td.rec-cell { width: 7.2rem; }
#home-table th:nth-child(5),
#home-table td.ops { width: 8.2rem; }
#home-table th:nth-child(2),
#home-table td.clamp.desc {
  width: 34%;
  min-width: 0;
  max-width: none;
}
#home-table th:nth-child(3),
#home-table td.clamp.excol {
  width: 24%;
  min-width: 0;
  max-width: none;
}
#home-table td.clamp,
#home-table td.clamp.desc,
#home-table td.clamp.excol {
  overflow: visible;
}

td.rec-cell {
  vertical-align: middle;
  white-space: nowrap;
}
td.ops .linkish {
  margin-right: 0.45rem;
  color: var(--brand);
  font-weight: 400;
}

.linkish {
  border: none;
  background: none;
  color: var(--brand);
  cursor: pointer;
  font-weight: 400;
  font-size: 0.85rem;
  padding: 0;
}
.linkish:hover { text-decoration: underline; }

.rec {
  display: inline-block;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 2.6rem;
  color: #f5a623;
}
.rec .stars-filled { color: #ffb020; }
.rec .star-half {
  position: relative;
  display: inline-block;
  color: #e5e7eb;
  /* keep half overlay aligned despite .rec letter-spacing */
  letter-spacing: 0;
}
.rec .star-half::before {
  content: "★";
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #ffb020;
  pointer-events: none;
}
.rec .stars-empty { color: #e5e7eb; }
.rec-high, .rec-mid { color: #f5a623; }
.rec-low { color: #d97706; }

.badge.mid { background: #e0f2fe; color: #0369a1; }


/* Modal (replaces drawer) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(720px, calc(100vw - 1.5rem));
  max-height: min(88vh, 900px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.modal.open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
/* Closed modals must not intercept clicks: UA [hidden]{display:none} is overridden by .modal{display:flex} */
.modal[hidden],
.modal:not(.open) {
  display: none !important;
  pointer-events: none !important;
  opacity: 0;
}
.modal-backdrop[hidden],
.modal-backdrop:not(.open) {
  display: none !important;
  pointer-events: none !important;
  opacity: 0;
}

/* HS detail (#modal) must stack above deep-search / login / merge when opened from 换税号 */
/* Layering: deep/login/merge backdrop 50 + modal 60 < detail backdrop 70 + modal 80 < toast 100 */
#modal-backdrop {
  z-index: 70;
}
#modal {
  z-index: 80;
}
.modal-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.detail-code {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: 0.03em;
}
.detail-name { font-weight: 600; margin-top: 0.3rem; }
.detail-en { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* Hide legacy drawer if present */
.drawer, .drawer-backdrop { display: none !important; }

@media (max-width: 720px) {
  td.clamp { max-width: 100px; }
  td.clamp.desc, td.clamp.excol { max-width: 220px; }
  .modal { width: calc(100vw - 0.75rem); max-height: 92vh; }
}


a.header-meta {
  text-decoration: none;
  transition: color .15s ease;
}
a.header-meta:hover {
  color: var(--brand);
  text-decoration: none;
}


/* p0 stars */
.rec small { font-weight: 600; margin-left: 4px; color: #64748b; opacity: 0.95; }
.rec { letter-spacing: 0.5px; white-space: nowrap; }

/* —— P1/P2 —— */
.header-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.auth-phone {
  font-size: 0.82rem;
  color: var(--brand-dark);
  font-weight: 600;
  background: var(--brand-soft);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}
.empty-en { color: var(--muted) !important; font-style: italic; font-weight: 500 !important; }
.login-err {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}
.auth-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35rem;
}
.auth-tab {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.35rem;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  position: relative;
}
.auth-tab:hover { color: var(--brand, #1e86fc); background: var(--brand-soft, #eef6ff); }
.auth-tab.active {
  color: var(--brand, #1e86fc);
}
.auth-tab.active::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -0.4rem;
  height: 2px;
  background: var(--brand, #1e86fc);
  border-radius: 2px;
}
.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.auth-remember input { width: auto; margin: 0; accent-color: var(--brand, #1e86fc); }
.auth-links {
  display: flex;
  justify-content: space-between;
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
}
.auth-links a {
  color: var(--brand, #1e86fc);
  text-decoration: none;
  font-weight: 600;
}
.auth-links a:hover { text-decoration: underline; }
.auth-sms-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.auth-sms-field { flex: 1; min-width: 0; }
.auth-sms-row > .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 6.5rem;
}
.auth-hint {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.modal-sm { width: min(420px, calc(100vw - 1.5rem)); }
.modal-wide { width: min(920px, calc(100vw - 1.5rem)); }
#deep-modal .search-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.35rem 0.35rem 0.45rem;
  box-shadow: none;
  align-items: center;
  min-height: 44px;
}
#deep-modal .search-box input {
  background: transparent;
  border: none;
  min-width: 0;
  flex: 1;
}
#deep-modal .search-box input:focus {
  border: none;
  box-shadow: none;
  outline: none;
}
#deep-modal .search-box button.primary {
  flex-shrink: 0;
  height: 36px;
  padding: 0 1rem;
}

.tag-deep {
  display: inline-block;
  font-size: 0.72rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.25rem;
  font-weight: 600;
  vertical-align: middle;
}
.src-tag {
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  color: var(--muted);
}
.field input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rec[title] { cursor: help; }

/* —— P3 体验优化 —— */
.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
}
.panel-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.inline-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}
.inline-filter select {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.5rem;
  font-size: 0.82rem;
  line-height: 1.3;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  box-sizing: border-box;
  background: #fff;
  color: var(--ink);
  max-width: 11rem;
}
.search-history {
  margin-top: 0.5rem;
  text-align: left;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 0.3rem;
}
.history-head .linkish {
  color: rgba(255, 255, 255, 0.92);
}
.history-head .linkish:hover {
  color: #fff;
}
.history-chips {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.4rem;
  /* 最多两行：chip 行高约 1.9rem + gap */
  max-height: calc(2 * 1.9rem + 0.4rem);
  overflow: hidden;
}
.history-chips .chip {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
.history-chips .chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.pager-btns {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.pager-btns button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.pager-btns button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pager-btns button.active-page {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}
.batch-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0.25rem;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 4.5rem;
}
.classify-empty-hint {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.classify-empty-hint[hidden] { display: none !important; }
.table-wrap {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}
#data-loading .load-steps {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 0.35rem;
  text-align: center;
  max-width: 22rem;
  line-height: 1.45;
}
#data-loading .load-bar {
  width: 220px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.65rem;
}
#data-loading .load-bar > i {
  display: block;
  height: 100%;
  width: 35%;
  background: var(--brand, #1e86fc);
  border-radius: 999px;
  animation: loadslide 1.1s ease-in-out infinite;
}
@keyframes loadslide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; align-items: center; order: 2; margin-left: auto; }
  .header-auth { order: 2; }
  .nav {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 0.25rem;
    padding: 0.35rem 0 0.15rem;
    border-top: 1px solid var(--line);
    margin-top: 0.15rem;
  }
  .nav button {
    flex: 1 1 auto;
    white-space: nowrap;
    min-width: calc(33% - 0.25rem);
    text-align: center;
    padding: 0.55rem 0.6rem;
  }
  body.nav-collapsed .nav { display: none; }
  .panel-tools { width: 100%; }
  .inline-filter select { max-width: 8.5rem; }
  td.clamp { max-width: 120px; }
  td.clamp.desc, td.clamp.excol { max-width: 260px; }
}


/* —— 税则目录 / 章节目录 — 左目录 | 右税号+详情 —— */
.main:has(.view[data-view="catalog"].active) {
  max-width: 1280px;
}
.catalog-panel { padding-bottom: 1rem; }
.catalog-head { align-items: flex-start; }
.catalog-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
  min-height: 28rem;
}
.catalog-nav {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 0.55rem;
}
.catalog-nav-mobile {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  font-size: 0.86rem;
}
.catalog-nav-mobile select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #fff;
}
.catalog-sections {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.catalog-sec {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  overflow: hidden;
}
.catalog-sec.open {
  border-color: var(--line);
  background: #fff;
}
.catalog-sec-head {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.55rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: 8px;
}
.catalog-sec-head:hover { background: var(--brand-soft); }
.catalog-sec.open > .catalog-sec-head { background: var(--brand-soft); }
.catalog-sec-badge {
  flex: 0 0 auto;
  min-width: 2.6rem;
  height: 1.45rem;
  line-height: 1.45rem;
  text-align: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0 0.4rem;
}
.catalog-sec-meta { flex: 1; min-width: 0; }
.catalog-sec-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
}
.catalog-sec-sub {
  margin: 0.15rem 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}
.catalog-sec-chev {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.catalog-ch-list {
  display: none;
  padding: 0.15rem 0.35rem 0.45rem;
  gap: 0.15rem;
  flex-direction: column;
}
.catalog-sec.open .catalog-ch-list { display: flex; }
.catalog-ch-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.catalog-ch-card:hover {
  background: #fff;
  border-color: rgba(30, 134, 252, 0.35);
}
.catalog-ch-card.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(30, 134, 252, 0.12);
}
.catalog-ch-no {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 0.82rem;
}
.catalog-ch-name {
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.35;
}
.catalog-ch-stats {
  font-size: 0.7rem;
  color: var(--muted);
}
.catalog-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.catalog-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 2.5rem 1.25rem;
  text-align: center;
}
.catalog-empty p { margin: 0; font-size: 0.95rem; }
.catalog-ch-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  margin: 0 0 0.15rem;
}
.catalog-ch-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.catalog-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.catalog-right-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}
.catalog-right-split.has-detail {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}
.catalog-list-pane { min-width: 0; }
.catalog-detail-pane {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
/* Same pitfall as .modal: author display:flex overrides UA [hidden] without !important */
.catalog-detail-pane[hidden] {
  display: none !important;
}
.catalog-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--brand-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}
.catalog-detail-head h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--brand-dark);
}
.catalog-detail-body {
  padding: 0.65rem 0.75rem 0.4rem;
  flex: 1;
}
.catalog-detail-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem 0.7rem;
  border-top: 1px solid var(--line);
  background: #fafbfd;
}
.catalog-detail-foot .btn {
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.28rem 0.7rem;
  border-radius: 4px;
  line-height: 1.3;
  min-height: 0;
}
.catalog-detail-pane .detail-code {
  font-size: 1.05rem;
  line-height: 1.2;
}
.catalog-detail-pane .detail-name {
  font-size: 0.9rem;
  margin-top: 0.15rem;
  line-height: 1.3;
  font-weight: 600;
}
.catalog-detail-pane .detail-en {
  font-size: 0.78rem;
  margin-top: 0.05rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
}
.catalog-detail-pane .detail-en.empty-en { display: none; }
.catalog-detail-pane .detail-grid {
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.4rem;
  margin: 0.35rem 0 0.4rem;
}
.catalog-detail-pane .kv {
  border-radius: 6px;
  padding: 0.28rem 0.45rem;
}
.catalog-detail-pane .kv .k {
  font-size: 0.68rem;
  margin-bottom: 0.05rem;
  line-height: 1.2;
}
.catalog-detail-pane .kv .v {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}
.catalog-detail-pane .kv.span2,
.catalog-detail-pane .kv.full { grid-column: 1 / -1; }
.catalog-detail-pane .kv .v.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#catalog-tbody tr.catalog-row-active {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
#catalog-tbody tr.catalog-row-active td {
  border-color: rgba(30, 134, 252, 0.2);
  background: var(--brand-soft);
}
#catalog-tbody tr.catalog-row-active td.code,
#catalog-tbody tr.catalog-row-active td.code a {
  color: var(--brand-dark);
}
.catalog-heading-row td {
  background: #f1f5f9;
  font-size: 0.86rem;
  font-weight: 600;
  color: #334155;
  padding: 0.55rem 0.75rem;
}
.catalog-source {
  margin: 1rem 0 0;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.45;
}
@media (max-width: 1100px) {
  .catalog-right-split.has-detail {
    grid-template-columns: 1fr;
  }
  .catalog-detail-pane {
    position: static;
    max-height: none;
  }
}
@media (max-width: 860px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .catalog-nav {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .catalog-nav-mobile { display: flex; }
  .catalog-sections { display: none; }
  .catalog-nav.show-tree .catalog-sections { display: flex; }
}

/* 结构树 icon next to HS codes (24px hit area, 16px glyph) */
.catalog-tree-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 0.2rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  vertical-align: middle;
  flex: 0 0 auto;
  line-height: 0;
}
.catalog-tree-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.catalog-tree-btn:hover {
  color: var(--brand-dark);
  background: var(--brand-soft);
}
.catalog-tree-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* 税则目录 tree modal — large host for the existing #catalog-layout */
#catalog-tree-backdrop {
  z-index: 55;
}
#catalog-tree-modal {
  z-index: 65;
  width: min(92vw, 1440px);
  height: 88vh;
  max-height: 88vh;
  border-radius: 16px;
  font-family: var(--font);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}
#catalog-tree-modal .modal-head {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  gap: 0.75rem;
}
#catalog-tree-modal .modal-head h3 {
  font-size: 1.05rem;
  font-weight: 650;
}
.catalog-tree-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}
#catalog-tree-modal .catalog-tree-body {
  padding: 0.7rem 0.9rem 0.9rem;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#catalog-tree-scale {
  --catalog-tree-scale: 1;
  flex: 1 1 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  zoom: var(--catalog-tree-scale);
}
@supports not (zoom: 1) {
  #catalog-tree-scale {
    transform: scale(var(--catalog-tree-scale));
    transform-origin: top left;
    width: calc(100% / var(--catalog-tree-scale));
  }
}
#catalog-tree-modal .catalog-layout {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}
#catalog-tree-modal .catalog-nav {
  position: sticky;
  top: 0;
  align-self: stretch;
  max-height: 100%;
  height: auto;
  overflow: auto;
}
#catalog-tree-modal .catalog-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#catalog-tree-modal .catalog-chapter:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  height: 100%;
}
#catalog-tree-modal .catalog-right-split {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}
#catalog-tree-modal .catalog-list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
#catalog-tree-modal .catalog-list-pane .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#catalog-tree-modal .catalog-detail-pane {
  position: sticky;
  top: 0;
  align-self: stretch;
  max-height: 100%;
  height: 100%;
}
#catalog-tree-modal .catalog-source {
  margin-top: 0.75rem;
  flex-shrink: 0;
}
#catalog-tree-modal.is-fullscreen,
#catalog-tree-modal.is-fullscreen.open {
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
  transform: none;
}

/* Login must stack above the catalog tree modal when 收藏 requires sign-in */
#login-backdrop { z-index: 86; }
#login-modal { z-index: 90; }

@media (max-width: 720px) {
  #catalog-tree-modal {
    width: calc(100vw - 0.5rem);
    height: 96vh;
    max-height: 96vh;
  }
  #catalog-tree-modal .catalog-tree-tools .btn {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }
}


/* HS 名称查询：接口补足 / 实例库等待 */
tr.home-loading-row td {
  text-align: center;
  color: var(--muted);
  padding: 0.7rem 0.7rem !important;
  font-size: 0.86rem;
}


/* —— 登录/注册/重置弹框（对齐参考稿） —— */
#login-modal.modal-auth {
  width: min(400px, calc(100vw - 1.5rem));
  border-radius: 16px;
  overflow: hidden;
}
#login-modal .auth-head {
  border-bottom: none;
  padding: 1rem 1.25rem 0;
  min-height: 2.4rem;
  position: relative;
}
#login-modal .auth-head.no-title {
  padding: 0.7rem 1.25rem 0;
  min-height: 2.2rem;
}
#login-modal .auth-head.no-title h3 { display: none; }
#login-modal .auth-head h3 {
  width: 100%;
  text-align: center;
  font-size: 1.12rem;
  font-weight: 700;
  color: #1f2937;
}
#login-modal .auth-head .close-btn {
  position: absolute;
  right: 0.65rem;
  top: 0.55rem;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  color: #9ca3af;
}
#login-modal .auth-head .close-btn:hover { color: #374151; background: #f3f4f6; border-radius: 50%; }
#login-modal .modal-body {
  padding: 0.35rem 1.75rem 1.6rem;
}
#login-modal .auth-foot-hidden { display: none; }

#login-modal .auth-mode-tabs {
  display: flex;
  justify-content: center;
  gap: 2.2rem;
  margin: 0.15rem 0 1.35rem;
  padding: 0;
  border-bottom: none;
}
#login-modal .auth-mode-tabs .auth-tab {
  flex: none;
  background: transparent;
  color: #111827;
  font-size: 1.08rem;
  font-weight: 700;
  padding: 0.35rem 0.15rem 0.7rem;
  border-radius: 0;
}
#login-modal .auth-mode-tabs .auth-tab:hover {
  color: var(--brand, #1e86fc);
  background: transparent;
}
#login-modal .auth-mode-tabs .auth-tab.active {
  color: var(--brand, #1e86fc);
}
#login-modal .auth-mode-tabs .auth-tab.active::after {
  left: 18%;
  right: 18%;
  bottom: 0.15rem;
  height: 3px;
  border-radius: 2px;
  background: var(--brand, #1e86fc);
}

#login-modal .auth-panel { display: block; }
#login-modal .auth-panel[hidden],
#login-modal .auth-mode-tabs[hidden] { display: none !important; }
#login-modal .auth-pill {
  display: flex;
  align-items: center;
  background: #f3f5f7;
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 46px;
  padding: 0 0.25rem 0 1.15rem;
  margin-top: 0.85rem;
}
#login-modal .auth-panel .auth-pill:first-child { margin-top: 0; }
#login-modal .auth-pill:focus-within {
  border-color: #cfe3ff;
  background: #f7faff;
  box-shadow: 0 0 0 3px rgba(30, 134, 252, 0.12);
}
#login-modal .auth-pill input {
  flex: 1;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0.7rem 1rem 0.7rem 0;
  border: none;
  background: transparent;
  border-radius: 0;
  font-size: 0.95rem;
  color: #111827;
  font-family: inherit;
  outline: none;
  box-shadow: none;
}
#login-modal .auth-pill input:focus {
  border: none;
  box-shadow: none;
  outline: none;
}
#login-modal .auth-pill input::placeholder { color: #c0c4cc; }

#login-modal .auth-phone-pill { padding-left: 0; }
#login-modal .auth-cc {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex: 0 0 auto;
  padding: 0 0.85rem 0 1.15rem;
  margin-right: 0.15rem;
  border-right: 1px solid #e5e7eb;
  color: #111827;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
}
#login-modal .auth-cc-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #9ca3af;
  display: inline-block;
}
#login-modal .auth-code-pill { padding-right: 0.35rem; }
#login-modal .auth-get-code {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--brand, #1e86fc);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
#login-modal .auth-get-code:hover { color: var(--brand-dark, #1565c0); }
#login-modal .auth-get-code:disabled {
  color: #9ca3af;
  cursor: default;
}

#login-modal .auth-remember {
  margin: 0.85rem 0 0 0.35rem;
  font-size: 0.86rem;
  color: #6b7280;
}
#login-modal .btn.primary.auth-submit {
  display: block;
  width: 100%;
  margin-top: 1.15rem;
  height: 46px;
  border: none;
  border-radius: 999px;
  background: var(--brand, #1e86fc);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
}
#login-modal .btn.primary.auth-submit:hover {
  background: var(--brand-dark, #1565c0);
}
#login-modal .btn.primary.auth-submit:disabled { opacity: 0.65; cursor: default; }

#login-modal .auth-footer-links {
  display: block;
  text-align: center;
  margin: 1.15rem 0 0;
  font-size: 0.88rem;
  color: #9ca3af;
}
#login-modal .auth-footer-links a {
  color: #6b7280;
  font-weight: 500;
  text-decoration: none;
}
#login-modal .auth-footer-links a:hover { color: var(--brand, #1e86fc); }
#login-modal .auth-footer-links .sep {
  margin: 0 0.7rem;
  color: #d1d5db;
}
#login-modal .auth-hint {
  margin: 0.55rem 0 0 0.4rem;
  font-size: 0.76rem;
  color: #9ca3af;
}
#login-modal .login-err {
  text-align: center;
  margin: 0.7rem 0 0;
}
