*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d7e0ec;
  --border-strong: #bdcbdd;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --green: #059669;
  --red: #dc2626;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.045);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 30%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header,
.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  padding: 22px 0 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue) 0%, #4f8cff 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.22);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 16px;
  line-height: 1.25;
}

.brand-copy span {
  color: var(--muted);
  font-size: 13px;
}

.page {
  padding: 24px 0 68px;
  flex: 1;
}

.search-toolbar {
  margin-bottom: 16px;
}

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}

#search-input {
  display: block;
  width: 100%;
  height: 58px;
  padding: 0 112px 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 58px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input::-webkit-search-decoration,
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-results-button,
#search-input::-webkit-search-results-decoration {
  display: none;
}

#search-clear {
  display: none;
  position: absolute;
  top: 50%;
  right: 100px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 13px 11px;
  cursor: pointer;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
}

#search-clear:hover {
  color: #334155;
}

#search-clear.visible {
  display: block;
}

#search-input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px rgba(51, 65, 85, 0.08);
}

#search-input::placeholder {
  color: #9aa7b8;
  font-weight: 400;
}

#search-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 88px;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue) 0%, #4f8cff 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

#search-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.region-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.region-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.region-pill {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(207, 218, 231, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: #5b6779;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.region-pill:hover,
.region-pill.active {
  border-color: rgba(37, 99, 235, 0.3);
  background: linear-gradient(135deg, var(--blue) 0%, #4f8cff 100%);
  color: #fff;
}

.offices-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.offices-label-text {
  color: var(--muted);
  font-size: 14px;
}

#offices-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(207, 218, 231, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #334155;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

#offices-trigger.offices-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.arrow {
  color: var(--muted);
  font-size: 11px;
}

#offices-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

#offices-dropdown.open {
  display: grid;
  grid-template-columns: repeat(var(--office-columns, 1), minmax(0, 1fr));
}

#offices-dropdown.office-cols-1 {
  min-width: 240px;
}

#offices-dropdown.office-cols-2 {
  min-width: 380px;
}

#offices-dropdown.office-cols-3 {
  min-width: 540px;
}

.office-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
}

.office-option:hover {
  background: #f8fafc;
}

.office-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.wechat-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  margin: 18px 0 28px;
  padding: 18px;
  border: 1px solid #c7eadb;
  border-radius: 8px;
  background: linear-gradient(135deg, #f0fdf4 0%, #f0f9ff 100%);
}

.wechat-copy h1 {
  margin: 0 0 8px;
  font-size: 19px;
  letter-spacing: 0;
  line-height: 1.35;
}

.wechat-copy p {
  margin: 0;
  color: #31504a;
  font-size: 14px;
  line-height: 1.65;
}

.wechat-qr {
  display: grid;
  gap: 8px;
  justify-items: center;
  color: #047857;
  font-size: 13px;
  font-weight: 700;
}

.wechat-qr img {
  display: block;
  width: 128px;
  height: 128px;
  border: 8px solid #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.wechat-qr a {
  color: #047857;
  text-decoration: none;
}

.wechat-qr a:hover {
  text-decoration: underline;
}

#searching-msg {
  margin-bottom: 20px;
  padding: 40px;
  border: 1px solid rgba(219, 228, 239, 0.7);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.spinner-ring {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.label-main {
  margin-bottom: 6px;
  color: #334155;
  font-size: 15px;
  font-weight: 700;
}

.label-sub {
  color: #94a3b8;
  font-size: 13px;
}

.search-error-inline {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.search-error-icon {
  color: var(--red);
  font-size: 26px;
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#results-title {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0;
}

#results-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.country-block + .country-block {
  margin-top: 22px;
}

.country-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 2px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.country-name {
  color: var(--muted);
  font-weight: 600;
}

.country-count {
  margin-left: auto;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
}

.tm-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid rgba(219, 228, 239, 0.82);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tm-card img,
.tm-placeholder {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.tm-card img {
  object-fit: contain;
  cursor: pointer;
}

.tm-placeholder {
  display: grid;
  place-items: center;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tm-info {
  min-width: 0;
  flex: 1;
}

.tm-name {
  margin-bottom: 6px;
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.tm-meta span {
  margin-right: 12px;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.tm-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(10, 15, 25, 0.86);
  cursor: pointer;
  z-index: 100;
}

.tm-lightbox.open {
  display: flex;
}

.tm-lightbox-inner {
  position: relative;
  max-width: min(92vw, 900px);
  max-height: 88vh;
  cursor: auto;
}

.tm-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 88vh;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.tm-lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  display: none;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 14px;
  z-index: 110;
}

.record-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 24px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.record-footer a {
  color: var(--muted);
  text-decoration: none;
}

.record-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .site-header,
  .page {
    width: min(100% - 24px, 1180px);
  }

  .wechat-cta {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .region-bar {
    align-items: stretch;
  }

  .offices-wrap {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  #offices-dropdown.open {
    position: static;
    width: 100%;
    min-width: 0;
    flex-basis: 100%;
    grid-template-columns: 1fr;
    margin-top: 8px;
  }

  .wechat-qr {
    justify-items: start;
  }
}
