/* ============================================================
   theme.css — Ecer Freight port pages (replicated from
   scm-en.ecer.com common.css / tool_code.css, 2026-10-20)
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
  /* brand */
  --color-primary: #e2231a;
  --color-primary-light: #f0564e;
  --color-primary-gradient: linear-gradient(225deg, #f0564e 0%, #e2231a 100%);
  --color-hero-gradient: linear-gradient(315deg, #6d100a 0%, #a8170e 100%);
  --color-cta-gradient: linear-gradient(224deg, #c01810 0%, #e2231a 100%);
  --color-primary-soft: #fdecea;
  /* text */
  --color-text: #1c1d1e;
  --color-heading: #0a0a0a;
  --color-muted-text: #555555;
  --color-faint-text: #9c9c9c;
  --color-link: #c51710;
  --color-selected: #b7140d;
  --color-selected-bg: #fdecea;
  /* surface */
  --color-background: #ffffff;
  --color-surface: #ffffff;
  --color-surface-alt: #f7f8fa;
  --color-border: #d6dadf;
  --color-border-soft: #e0e0e0;
  --color-divider: #f0f2f5;
  --color-focus: #e2231a;
  /* radius / shadow */
  --radius-sm: 4px;
  --radius-md: 12px;
  --radius-lg: 1rem;
  --radius-badge: 12px;
  --radius-pill: 20px;
  --shadow-card: 0 0 10px rgba(0, 0, 0, 0.1);
  /* type */
  --font-body: "SourceHanSansCN", "Source Han Sans CN", "PingFang SC",
    "Hiragino Sans GB", "Microsoft Yahei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  --font-display: "SourceHanSansCN", "Source Han Sans CN", "PingFang SC",
    "Hiragino Sans GB", "Microsoft Yahei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  /* layout */
  --space-unit: 0.5rem;
  --heading-rule-gap: 0.625rem;
  --table-note-gap: 0.5rem;
  --content-width: 100%;
  --content-gutter: 12.5vw;
  --header-h: 5rem;
  --tabs-h: 0rem;
}

body[data-page-id="port-home"] { --tabs-h: 3rem; }

/* ---------- responsive root font (original rem system) ---------- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media screen and (min-width: 1200px) { html { font-size: 12px; } }
@media screen and (min-width: 1400px) { html { font-size: 14px; } }
@media screen and (min-width: 1600px) { html { font-size: 16px; } }
@media screen and (min-width: 1800px) { html { font-size: 18px; } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-heading);
  line-height: 1.4;
  margin: 0;
}
p { margin: 0 0 0.75rem; }
a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; }
ul, ol { margin: 0 0 0.75rem; padding-left: 1.25rem; }
li { margin-bottom: 0.375rem; }
img { max-width: 100%; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--color-primary); color: #fff;
  padding: 0.5rem 1rem; border-radius: 0 0 var(--radius-sm) 0; z-index: 10000;
}
.skip-link:focus { left: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0; clip: rect(0 0 0 0);
  white-space: nowrap; overflow: hidden;
}

/* ---------- layout ---------- */
.correct_center { padding-left: var(--content-gutter); padding-right: var(--content-gutter); }
.section {
  margin-left: calc(var(--content-gutter) * -1);
  margin-right: calc(var(--content-gutter) * -1);
  padding-left: var(--content-gutter);
  padding-right: var(--content-gutter);
  padding-top: 3rem;
  padding-bottom: 1.25rem;
  scroll-margin-top: calc(var(--header-h) + var(--tabs-h) + 0.75rem);
}
.section:first-of-type { padding-top: 2.25rem; }
.section:nth-of-type(even) { background: var(--color-surface-alt); }
/* Preserve the directory's existing bands after closing its overview section. */
body[data-page-id="ports-by-country"] .section:nth-of-type(even) { background: transparent; }
body[data-page-id="ports-by-country"] .section:nth-of-type(odd):not(:first-of-type) { background: var(--color-surface-alt); }

/* ---------- hero ---------- */
.port-top {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, var(--color-surface-alt) 100%);
  padding-top: 7rem;
  padding-bottom: 3rem;
}
.port-top > * { position: relative; z-index: 2; }
.port-top::before,
.port-top::after {
  content: "";
  position: absolute;
  inset: -30%;
  z-index: 0;
  pointer-events: none;
  filter: blur(44px);
  will-change: transform;
}
.port-top::before {
  background:
    radial-gradient(38% 50% at 12% 22%, rgba(255, 120, 165, 0.14), transparent 62%),
    radial-gradient(34% 46% at 88% 12%, rgba(255, 165, 70, 0.14), transparent 62%),
    radial-gradient(40% 54% at 74% 88%, rgba(125, 155, 255, 0.12), transparent 62%),
    radial-gradient(28% 38% at 36% 78%, rgba(255, 190, 110, 0.12), transparent 62%);
  animation: heroDriftA 6s ease-in-out infinite alternate;
}
.port-top::after {
  background:
    radial-gradient(36% 48% at 62% 28%, rgba(130, 160, 255, 0.12), transparent 62%),
    radial-gradient(40% 52% at 22% 66%, rgba(255, 135, 180, 0.13), transparent 62%),
    radial-gradient(30% 40% at 92% 66%, rgba(255, 175, 90, 0.12), transparent 62%);
  animation: heroDriftB 8s ease-in-out infinite alternate-reverse;
}
.port-top__crumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem;
  padding: 1rem 0 0; font-size: 0.875rem; color: var(--color-muted-text);
}
.port-top__crumb a { color: var(--color-link); }
.port-top__crumb a:hover { color: var(--color-selected); }
.port-top__crumb .sep { color: var(--color-faint-text); margin: 0 0.25rem; }
.port-top__title {
  font-size: 2rem; font-weight: 700; color: var(--color-heading);
  padding-top: 1.25rem; margin: 0;
}
.port-top__sub {
  font-size: 1.125rem; color: var(--color-muted-text);
  padding-top: 0.75rem; margin: 0; max-width: 60rem;
}
.port-top__sub strong { color: var(--color-heading); font-weight: 700; }
@keyframes heroDriftA {
  0% { transform: translate3d(-3%, -2%, 0) scale(1.02) rotate(0deg); }
  50% { transform: translate3d(1.5%, 2.5%, 0) scale(1.1) rotate(2deg); }
  100% { transform: translate3d(4%, -1%, 0) scale(1.05) rotate(-1.5deg); }
}
@keyframes heroDriftB {
  0% { transform: translate3d(3%, -2.5%, 0) scale(1.08) rotate(0deg); }
  50% { transform: translate3d(-1.5%, 1.5%, 0) scale(1.02) rotate(-2.5deg); }
  100% { transform: translate3d(-4%, 3%, 0) scale(1.12) rotate(1.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .port-top::before,
  .port-top::after { animation: none; }
}
.port-top__list {
  position: relative; z-index: 1;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
/* Keep the country selector above following sections and allow it to extend past the hero. */
.port-top:has(.port-country[data-open="true"]) { z-index: 1001; overflow: visible; }
.port-top__list:has(.port-country[data-open="true"]) { z-index: 1001; }

/* ---------- search form ---------- */
.search-form { display: flex; }
.search-form input[type="text"] {
  flex: 1 1 auto; min-width: 0;
  height: 40px; padding: 0 0.75rem;
  border: 1px solid var(--color-border); border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 0.875rem; font-family: var(--font-body);
  color: var(--color-text); background: #fff;
}
.search-form input[type="text"]::placeholder { color: var(--color-faint-text); }
.search-form input[type="text"]:focus { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.search-form .btn-search {
  flex: 0 0 auto; width: 7.5rem; min-width: 7.5rem; height: 40px;
  border: none; cursor: pointer;
  background: var(--color-cta-gradient);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #fff; font-size: 0.875rem; font-weight: 600;
  font-family: var(--font-body);
}
.search-form .btn-search:hover { filter: brightness(1.05); }

.search-hot {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 0.875rem; font-size: 0.875rem;
}
.search-hot .label { color: var(--color-faint-text); line-height: 1.6rem; margin-right: 0.25rem; }
.search-hot a {
  display: inline-block; padding: 0 0.75rem; height: 1.6rem; line-height: 1.6rem;
  color: var(--color-muted-text);
  border-radius: var(--radius-pill);
  background: var(--color-divider);
}
.search-hot a:hover { color: #fff; background: var(--color-primary-gradient); text-decoration: none; }

/* ---------- country dropdown (search card) ---------- */
.port-country { position: relative; margin-bottom: 0.75rem; }
.port-country__toggle {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; min-height: 40px; padding: 0 0.875rem;
  background: #fff; cursor: pointer; text-align: left;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: var(--font-body); color: var(--color-text);
}
.port-country__toggle #pcLabel { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.port-country__toggle .arrow {
  margin-left: auto; color: var(--color-faint-text);
  transition: transform 0.2s;
}
.port-country__toggle .arrow::after { content: "\25BE"; font-size: 0.75rem; }
.port-country[data-open="true"] .port-country__toggle .arrow { transform: rotate(180deg); }
.port-country__panel {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; z-index: 9999;
  border: 1px solid var(--color-border-soft); border-radius: var(--radius-md);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  padding: 0.75rem;
  height: 360px; flex-direction: column;
}
.port-country[data-open="true"] .port-country__panel { display: flex; }
.port-country__filter {
  flex: 0 0 auto; width: 100%; height: 36px; padding: 0 0.75rem; margin-bottom: 0.625rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: var(--font-body); color: var(--color-text);
}
.port-country__items {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.25rem 0.75rem;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0;
}
.port-country__items li { margin: 0; }
.port-country__items button {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  height: 2.375rem; padding: 0 0.625rem;
  background: none; border: none; cursor: pointer; text-align: left;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-family: var(--font-body); color: var(--color-text);
}
.port-country__items button:hover { background: var(--color-divider); }
.port-country__items button[aria-checked="true"],
.port-country__items button.selected {
  background: var(--color-selected-bg); color: var(--color-selected); font-weight: 600;
}
.pc-empty { padding: 0.75rem 0.25rem; color: var(--color-faint-text); font-size: 0.8125rem; list-style: none; }
.port-country__items .c-count { flex: 0 0 auto; margin-left: auto; color: var(--color-faint-text); font-size: 0.8125rem; white-space: nowrap; text-align: right; }

/* ---------- ISO badge (flag replacement; original flag images 404) ---------- */
.iso-badge {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid rgba(226, 35, 26, 0.25);
}
.iso-badge--lg { width: 2rem; height: 2rem; font-size: 0.75rem; }
.iso-badge--inline { width: auto; border-radius: var(--radius-pill); padding: 0.125rem 0.5rem; }

/* ---------- section headings ---------- */
.wl-m-section { margin-top: 0; }
.wl-m-section h2 {
  position: relative; font-size: 1.375rem; font-weight: 700; color: var(--color-heading);
}
.wl-m-section h2::after {
  content: ""; display: block; width: 2.5rem; height: 4px; margin-top: var(--heading-rule-gap);
  background: var(--color-primary); border-radius: 2px;
}
.wl-m-section .section-desc {
  color: var(--color-muted-text); font-size: 0.9375rem;
  max-width: 62rem; margin-top: 1.25rem;
}
/* Keep the rule equally spaced from the heading and the first content block. */
.section > .wl-m-section { padding-bottom: var(--heading-rule-gap); }
.section > .wl-m-section + * { margin-top: 0; }
h3.sub-title {
  font-size: 1.125rem; font-weight: 600; color: var(--color-heading);
  margin: 1.5rem 0 0.75rem;
}

/* ---------- cards ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-top: 1.25rem;
}
.card--soft { background: var(--color-primary-soft); box-shadow: none; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }

/* ---------- stat strip ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem;
  margin-top: 1.25rem;
}
.stat-grid + .section-desc { margin-top: 1.5rem; }
.stat-item {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 1.25rem 1.5rem; text-align: center;
}
.stat-item .num {
  display: block; font-size: 1.75rem; font-weight: 700;
  color: var(--color-primary); line-height: 1.2;
}
.stat-item .lbl {
  display: block; margin-top: 0.375rem; font-size: 0.875rem; color: var(--color-muted-text);
}
.stat-item .src { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: var(--color-faint-text); }

/* ---------- quick answer cards (GEO) ---------- */
.answer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.answer-card {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 1.25rem 1.5rem;
  border-top: 3px solid var(--color-primary);
}
.answer-card .q { font-size: 0.9375rem; font-weight: 700; color: var(--color-heading); margin-bottom: 0.5rem; }
.answer-card .a { font-size: 0.875rem; color: var(--color-muted-text); line-height: 1.7; margin: 0; }
.answer-card .a strong { color: var(--color-text); }

/* ---------- tables ---------- */
.table-wrap {
  min-width: 0; max-width: 100%; margin-top: 1.25rem;
  border: 1px solid var(--color-border-soft); border-radius: var(--radius-md);
  background: var(--color-surface); overflow: hidden;
}
/* The frame stays fixed while the table scrolls inside all four rounded corners. */
.table-scroll { min-width: 0; max-width: 100%; overflow-x: auto; }
.data-table {
  min-width: 40rem; font-size: 0.875rem;
  background: var(--color-surface);
  border: 0; border-collapse: separate; border-spacing: 0;
}
.table-caption {
  font-size: 0.8125rem; color: var(--color-faint-text);
  margin: 1.25rem 0 var(--table-note-gap);
}
.table-caption + .table-wrap { margin-top: 0; }
.data-table th, .data-table td {
  padding: 0.625rem 0.75rem; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--color-divider);
}
.data-table thead th {
  background: var(--color-surface-alt); color: var(--color-heading);
  font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--color-border-soft);
}
.data-table tbody tr:hover { background: #fdf0ef; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:not([hidden]):has(+ tr[hidden]) td { border-bottom: none; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .rank { color: var(--color-faint-text); font-variant-numeric: tabular-nums; }
.data-table .pos { color: var(--color-primary); font-weight: 700; }
.data-table .neg { color: #cc140e; }
.data-table a { color: var(--color-link); }
.data-table tbody tr[hidden] { display: none; }
.table-toggle {
  display: inline-flex; align-items: center; gap: 0.4375rem;
  margin-top: 0.875rem; padding: 0.4375rem 1.375rem;
  background: #fff; color: var(--color-primary);
  border: 1px solid var(--color-primary); border-radius: var(--radius-pill);
  font-size: 0.875rem; font-weight: 600; font-family: var(--font-body); cursor: pointer;
}
.table-toggle:hover { background: var(--color-primary-soft); }
.table-toggle::after { content: "\25BE"; font-size: 0.75rem; }
.table-toggle[aria-expanded="true"]::after { content: "\25B4"; }
.country-cell { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }

/* mini bar inside table cells */
.bar-cell { min-width: 9rem; }
.bar-track { display: flex; align-items: center; gap: 0.5rem; }
.bar-fill {
  height: 0.5rem; border-radius: 3px; min-width: 2px;
  background: var(--color-primary-gradient);
}
.bar-fill--navy { background: linear-gradient(225deg, #3a4bbd 0%, #0b105f 100%); }
.bar-value { font-variant-numeric: tabular-nums; color: var(--color-muted-text); white-space: nowrap; }

/* ---------- region donut ---------- */
.region-flex { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; }
.donut {
  flex: 0 0 auto; width: 13rem; height: 13rem; border-radius: 50%;
  position: relative;
}
.donut::after {
  content: ""; position: absolute; inset: 3.25rem; border-radius: 50%;
  background: #fff;
}
.donut-center {
  position: absolute; inset: 0; z-index: 1; display: flex;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.donut-center .num { font-size: 1.25rem; font-weight: 700; color: var(--color-heading); }
.donut-center .lbl { font-size: 0.75rem; color: var(--color-faint-text); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 18rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.375rem 1.5rem; }
.legend li { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.875rem; }
.legend .sw { flex: 0 0 auto; width: 0.75rem; height: 0.75rem; border-radius: 2px; }
.legend .lg-name { color: var(--color-text); }
.legend .lg-val { margin-left: auto; color: var(--color-muted-text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- pill nav (on this page / regions) ---------- */
.pill-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.pill-nav a {
  display: inline-block; padding: 0.375rem 0.875rem;
  border-radius: var(--radius-pill); font-size: 0.8125rem;
  background: var(--color-divider); color: var(--color-muted-text);
  border: 1px solid transparent;
}
.pill-nav a:hover { background: var(--color-selected-bg); color: var(--color-selected); text-decoration: none; }

/* ---------- sticky section tabs (port home) ---------- */
.port-tabs {
  position: sticky; top: var(--header-h); z-index: 900;
  margin-left: calc(var(--content-gutter) * -1);
  margin-right: calc(var(--content-gutter) * -1);
  padding-left: var(--content-gutter);
  padding-right: var(--content-gutter);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-divider);
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.05);
}
.port-tabs__track {
  display: flex; gap: 0.25rem; padding: 0.5rem 0;
  overflow-x: auto; scrollbar-width: none;
}
.port-tabs__track::-webkit-scrollbar { display: none; }
.port-tabs a {
  flex: 0 0 auto; padding: 0.4375rem 1rem; border-radius: var(--radius-pill);
  font-size: 0.875rem; font-weight: 600; white-space: nowrap;
  color: var(--color-muted-text); background: transparent;
}
.port-tabs a:hover { background: var(--color-divider); color: var(--color-heading); text-decoration: none; }
.port-tabs a.is-active { background: var(--color-primary); color: #fff; }

/* ---------- badges ---------- */
.badge-main {
  display: inline-block; padding: 0.125rem 0.5rem; border-radius: var(--radius-badge);
  background: var(--color-primary-soft); color: var(--color-primary);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-soft {
  display: inline-block; padding: 0.125rem 0.5rem; border-radius: var(--radius-badge);
  background: var(--color-divider); color: var(--color-muted-text);
  font-size: 0.75rem; white-space: nowrap;
}

/* ---------- country card (page 2) ---------- */
.country-card {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 1.25rem 1.5rem; margin-top: 1.25rem;
}
.country-card__head {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding-bottom: 0.875rem; border-bottom: 1px solid var(--color-divider);
}
.country-card__head h3 { font-size: 1.0625rem; font-weight: 700; color: var(--color-heading); margin: 0; }
.country-card__count { font-size: 0.8125rem; color: var(--color-faint-text); }
.country-card__links { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.8125rem; }
.country-card .data-table { min-width: 34rem; }
.region-note { font-size: 0.875rem; color: var(--color-muted-text); margin-top: 0.75rem; max-width: 62rem; }

/* ---------- buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  height: 2.75rem; padding: 0 2rem; border: none; cursor: pointer;
  background: var(--color-primary-gradient); color: #fff;
  font-size: 0.9375rem; font-weight: 600; font-family: var(--font-body);
  border-radius: var(--radius-pill);
}
.btn-primary:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  height: 2.5rem; padding: 0 1.5rem; cursor: pointer;
  background: #fff; color: var(--color-primary);
  border: 1px solid var(--color-primary);
  font-size: 0.875rem; font-weight: 600; font-family: var(--font-body);
  border-radius: var(--radius-pill);
}
.btn-ghost:hover { background: var(--color-primary-soft); text-decoration: none; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------- knowledge blocks ---------- */
.knowledge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-top: 1.25rem; }
.knowledge-card {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 1.5rem;
}
.knowledge-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.625rem; }
.knowledge-card p, .knowledge-card li { font-size: 0.875rem; color: var(--color-muted-text); line-height: 1.8; }
.code-chip {
  display: inline-block; padding: 0.0625rem 0.375rem; border-radius: var(--radius-sm);
  background: var(--color-divider); color: var(--color-heading);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8125rem;
}

/* ---------- FAQ ---------- */
.faq { margin-top: 1.25rem; }
.faq details {
  background: var(--color-surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); margin-bottom: 0.75rem; overflow: hidden;
}
.faq summary {
  cursor: pointer; list-style: none; position: relative;
  padding: 1rem 2.75rem 1rem 1.25rem;
  font-size: 0.9375rem; font-weight: 600; color: var(--color-heading);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 1.125rem; top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem; font-weight: 400; color: var(--color-primary); line-height: 1;
}
.faq details[open] summary::after { content: "−"; }
.faq .faq-body { padding: 0 1.25rem 1.125rem; font-size: 0.8125rem; color: var(--color-muted-text); line-height: 1.8; }
.faq .faq-body p:last-child { margin-bottom: 0; }

/* ---------- editorial / sources ---------- */
.editorial {
  margin-top: 1.25rem; padding: 1.25rem 1.5rem;
  background: var(--color-primary-soft); border-radius: var(--radius-lg);
  font-size: 0.8125rem; color: var(--color-muted-text); line-height: 1.8;
}
.editorial strong { color: var(--color-heading); }
.sources { margin-top: 1.25rem; }
.sources ol { padding-left: 1.5rem; }
.sources li { font-size: 0.8125rem; color: var(--color-muted-text); line-height: 1.8; margin-bottom: 0.5rem; }

/* ---------- page foot note ---------- */
.page-note {
  margin: 2.5rem 0 3rem; padding-top: 1.25rem;
  border-top: 1px solid var(--color-divider);
  font-size: 0.75rem; color: var(--color-faint-text);
  line-height: 1.8; text-align: left;
}
.page-note a { color: var(--color-link); }

/* ---------- responsive ---------- */
@media screen and (min-width: 769px) and (max-width: 1199px) {
  header.hgj-header { padding-left: 20px; padding-right: 20px; }
  .hgj-header-logo, .hgj-header-userinfo, .hgj-header-lang { flex-shrink: 0; }
  .hgj-header-menu {
    flex: 1; min-width: 0; flex-wrap: wrap; justify-content: center;
    gap: 0.5rem 1rem; margin: 0 1rem;
  }
  .hgj-header-menu > div { margin-right: 0; }
  .hgj-header-userinfo { margin-left: 0.5rem; }
}
@media screen and (max-width: 992px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-grid { grid-template-columns: 1fr; }
  .knowledge-grid { grid-template-columns: 1fr; }
  .port-country__items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .legend { grid-template-columns: 1fr; }
}
@media screen and (max-width: 768px) {
  :root { --content-gutter: 30px; --header-h: 3.625rem; }
  .port-top { padding-top: 1rem; }
  .port-top__title { font-size: 1.625rem; }
  .port-top__sub { font-size: 1rem; }
  .region-flex { flex-direction: column; align-items: flex-start; }
  .region-flex .legend { flex: 0 1 auto; width: 100%; }
  .port-country__items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .country-card__links { margin-left: 0; width: 100%; }
}
@media screen and (max-width: 576px) {
  :root { --content-gutter: 20px; }
  .stat-grid { grid-template-columns: 1fr; }
  .port-top__list, .card, .country-card, .knowledge-card { padding: 1.25rem; }
  .search-form .btn-search { width: 6rem; min-width: 6rem; }
  .port-country__items { grid-template-columns: 1fr; }
  .wl-m-section h2 { font-size: 1.25rem; }
}

/* ---------- additions used by generated pages ---------- */
.src-note { margin-top: 0.75rem; font-size: 0.75rem; color: var(--color-faint-text); line-height: 1.7; }
.table-wrap + .src-note, .table-toggle + .src-note { margin-top: var(--table-note-gap); }
.table-wrap--tall > .table-scroll { max-height: 32rem; overflow-y: auto; }

/* Let prose and flex/grid items shrink without widening the page. */
main p, main h1, main h2, main h3, main li { overflow-wrap: anywhere; }
.stat-grid > *, .answer-grid > *, .knowledge-grid > *,
.region-flex > *, .legend li, .country-card__head > *, .hero-actions > * { min-width: 0; }
.country-card__links a, .editorial a, .sources-list a { overflow-wrap: anywhere; }
.table-toggle { max-width: 100%; }
@media screen and (max-width: 576px) {
  .hero-actions > * { max-width: 100%; height: auto; min-height: 2.5rem; }
  .hero-actions .btn-primary { min-height: 2.75rem; }
}
.donut { max-width: 100%; height: auto; aspect-ratio: 1; }

/* ---------- coexistence with the original site stylesheets ----------
   style.css/common.css reset list-style and body paddings globally; these
   scoped rules restore list rendering inside page content (loaded last). */
main ul { list-style: disc; }
main ol { list-style: decimal; }
main ul li, main ol li { margin-bottom: 0.25rem; }
main .sources-list li { margin-bottom: 0.625rem; }

/* ---------- red brand chrome (site header / footer overrides) ----------
   These pages open on a light hero, so the header keeps its brand-red palette
   (colored logo + dark-state icons) from the first paint; there is no
   white-on-transparent state to wait for. `.gray` is added to the same element
   on scroll, so `header.hgj-header` covers both states. */
.hgj-header-logo img { width: auto; height: 2rem; }
header.hgj-header .hgj-header-logo > a:first-child { display: none; }
header.hgj-header .hgj-header-logo > a:last-child { display: flex; }
header.hgj-header .icon-lang,
header.hgj-header .icon-arrow { display: none; }
header.hgj-header .icon-lang-dark,
header.hgj-header .icon-arrow-dark { display: inline-block; color: var(--color-primary); }
header.hgj-header { color: var(--color-primary); }
header.hgj-header .hgj-header-menu a { color: var(--color-primary); }
header.hgj-header .hgj-header-menu a:hover { color: var(--color-selected); }
header.hgj-header .hgj-header-menu a.active-link { border-bottom-color: var(--color-primary); }
header.hgj-header .userinfo-name,
header.hgj-header .userinfo-name span { color: var(--color-primary); }
header.hgj-header .hgj-header-userinfo:hover .userinfo-name { color: var(--color-selected); }
.wl-dropdown-content a:hover { color: var(--color-primary); }
.footer-links .ecer-logo img { filter: brightness(0) invert(1); width: auto; height: 2.25rem; }

/* ---------- brand-red nav item (Logistics Tools) ---------- */
header.hgj-header .wl-dropdown-title.is-brand,
header.hgj-header .wl-dropdown-title.is-brand span { color: var(--color-primary); }
.hgj-m-menu .wl-m-menu-title.is-brand,
.hgj-m-menu .wl-m-menu-title.is-brand span { color: var(--color-primary); }

/* ---------- back to top ---------- */
.back-top {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 1900;
  width: 2.75rem; height: 2.75rem; border: none; border-radius: 50%;
  background: var(--color-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(120, 10, 5, 0.28);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.back-top.show { opacity: 1; visibility: visible; transform: none; }
.back-top:hover { background: var(--color-selected); }
.back-top svg { width: 1.125rem; height: 1.125rem; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
@media print { .back-top { display: none; } }

/* ---------- brand arrow / mobile chevron ---------- */
.wl-dropdown-title.is-brand .icon-arrow-brand { display: inline-block; width: 1rem; height: 1rem; margin-left: 0.375rem; vertical-align: middle; }
.hgj-m-menu .wl-m-menu-title.is-brand i { border-top-color: var(--color-primary); border-bottom-color: transparent; }
.hgj-m-menu .wl-m-menu-title.is-brand i.active { top: 17px; transform: none; border-top-color: transparent; border-bottom-color: var(--color-primary); }
@media (max-width: 768px) {
  .hgj-m-menu .mobile-tool-link.active-link {
    color: var(--color-primary);
    font-weight: 600;
  }
}

/* ---------- port detail pages (s-*.html): red overrides for tool_code.css ---------- */
body.port-detail-page .top_form .search-form > div > span { color: var(--color-primary); }
body.port-detail-page .port-introduction .port-introduction-top { background: var(--color-primary-gradient); }
body.port-detail-page .port-introduction .port-introduction-bottom .introduction-title::after { background-color: var(--color-primary); }
body.port-detail-page .search-hot_ports > div { border-left: 1px solid var(--color-primary); }
body.port-detail-page .search-hot_ports a { color: var(--color-link); }
body.port-detail-page .search-hot_ports a:hover { color: var(--color-selected); }
body.port-detail-page .catagory_title .search-show { background: var(--color-primary-soft); color: var(--color-primary); }
body.port-detail-page .scroll .catagory_box .catagory_title .tit_code { background: var(--color-primary); }
body.port-detail-page .scroll .catagory_box .catagory_title .ms > span { color: var(--color-primary); }
body.port-detail-page .scroll .port-list-link a { background-color: var(--color-primary); }
body.port-detail-page .scroll .port-list-link a:hover { background-color: var(--color-selected); }
body.port-detail-page .port-list-box-detail > div > div:nth-of-type(2) a { color: var(--color-link); }
body.port-detail-page .port-list-map .container-hide .container-show { background: rgba(226, 35, 26, 0.1); color: var(--color-primary); }
/* hero band: neutralize tool_code's 14rem centered strip, match port.html hero */
body.port-detail-page .port-top {
  height: auto;
  display: block;
  padding: 7.5rem 12.5vw 5rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--color-surface-alt) 100%);
}
body.port-detail-page .port-top .port-top__title {
  width: auto;
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-heading);
  text-align: center;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
body.port-detail-page .port-top .port-top__text {
  margin: 0;
  padding-top: 0.75rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--color-muted-text);
  text-align: center;
}
/* search card: same correct_center inset as the result table below -> flush on both ends */
body.port-detail-page .top_form .search-form { width: 100%; margin: 0; }
/* country / code segments split 50-50 so the boat icon sits at the bar's half point */
@media (min-width: 769px) {
  body.port-detail-page .top_form .search-form > div { flex: 1 1 0; min-width: 0; }
}
/* country selector: pin + label + chevron clustered and vertically centered */
body.port-detail-page .top_form .port-country { margin-bottom: 0; }
body.port-detail-page .top_form .port-country .port-country-select > div { flex: 0 1 auto; }
body.port-detail-page .top_form .port-country .port-country-select .down { margin-left: 0.5rem; line-height: 1; }
/* country dropdown panel: fixed 400px height, list scrolls inside */
body.port-detail-page .top_form .port-country-list { height: 400px; flex-direction: column; }
body.port-detail-page .top_form .port-country.active .port-country-list,
body.port-detail-page .top_form .search-form .search-form-input input:focus + .port-country-list { display: flex; }
body.port-detail-page .top_form .port-country-items { flex: 1 1 auto; min-height: 0; max-height: none; }
/* search card: red submit instead of tool_code yellow-red gradient */
body.port-detail-page .top_form .search-form .search-form-submit { background: var(--color-cta-gradient); }
body.port-detail-page .top_form .search-form .search-form-submit:hover { filter: brightness(1.05); }
@media (max-width: 768px) {
  body.port-detail-page .port-top { height: auto !important; padding-top: 5.5rem !important; padding-bottom: 3.5rem !important; }
  body.port-detail-page .port-top .port-top__title { font-size: 1.5rem; }
  body.port-detail-page .port-top .port-top__text { font-size: 0.9375rem; }
}
