:root {
  --bg: #f6f3ed;
  --surface: #ffffff;
  --surface-2: #ece8df;
  --ink: #1e252b;
  --muted: #69716d;
  --line: #ddd5c8;
  --border: #ddd5c8;
  --china: #177f68;
  --us: #c85b48;
  --accent: #334f8d;
  --shadow: 0 18px 48px rgba(31, 31, 27, 0.14);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
}

.sidebar,
.inspector {
  background: var(--surface);
  border-color: var(--line);
  position: relative;
  z-index: 500;
  min-width: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.inspector {
  border-left: 1px solid var(--line);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.inspector-pane {
  min-height: 0;
}

.inspector-pane[hidden] {
  display: none;
}

.detail-panel.inspector-pane {
  overflow-y: auto;
}

.rank-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
}

.rank-pane .rank-list {
  flex: 1 1 auto;
}

.inspector-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 170px;
}

.inspector-tabs button {
  min-height: 32px;
  font-size: 12.5px;
}

.rank-toolbar {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-filter {
  min-height: 34px;
  font-size: 13px;
}

.detail-acc {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 8px;
}

.detail-acc summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
}

.detail-acc summary::-webkit-details-marker {
  display: none;
}

.detail-acc summary::before {
  content: "▸";
  margin-right: 6px;
  color: rgba(255, 255, 255, 0.5);
}

.detail-acc[open] summary::before {
  content: "▾";
}

.detail-acc summary span {
  flex: 1;
}

.detail-acc summary b {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
}

.detail-acc-body {
  margin-top: 8px;
}


.inspector[hidden] {
  display: none;
}

.app:has(.inspector[hidden]) {
  grid-template-columns: 300px minmax(0, 1fr);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--ink);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-copy {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 780;
}

.brand-copy p,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.control-section {
  display: grid;
  gap: 10px;
}

.control-section[hidden] {
  display: none;
}

.section-title {
  color: #3d4741;
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #414943;
  font-size: 13px;
  font-weight: 680;
  white-space: nowrap;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.search {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 0 11px;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 79, 141, 0.14);
}

.data-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.primary,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 760;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 237, 0.93);
  backdrop-filter: blur(10px);
  padding: 18px 22px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 450;
}

.topbar h2 {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.1;
  font-weight: 820;
  white-space: nowrap;
}

.topbar > div:first-child {
  flex: 0 0 auto;
}

.legend {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.legend > span {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #3f4742;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

/* Countries strip is itself a flex container of chips, not a chip. */
.legend > .legend-countries {
  border: 0;
  background: transparent;
  padding: 0;
  gap: 6px;
  flex-wrap: wrap;
}

.legend .legend-item {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #3f4742;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.dot,
.bubble-scale {
  display: inline-block;
  flex: 0 0 auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.china {
  background: var(--china);
}

.dot.us {
  background: var(--us);
}

.bubble-scale {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(51, 79, 141, 0.23);
  border: 1px solid rgba(51, 79, 141, 0.45);
}

.kpi-strip {
  position: relative;
  z-index: 440;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.kpi {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
}

.kpi b {
  display: block;
  margin-bottom: 6px;
  font-size: 23px;
  line-height: 1;
  font-weight: 820;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-wrap {
  position: relative;
  /* Fill the viewport below the topbar + KPI strip (~300px) instead of a
     fixed 540px that leaves a blank band on tall screens. */
  min-height: max(540px, calc(100vh - 300px));
}

#map {
  width: 100%;
  height: 100%;
  min-height: max(540px, calc(100vh - 300px));
  background: #e8e2d6;
}

.map-notice {
  position: absolute;
  left: 22px;
  bottom: 22px;
  z-index: 460;
  max-width: min(420px, calc(100% - 44px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #3d4741;
  box-shadow: var(--shadow);
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.45;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.city-talent-list {
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  overflow-y: auto;
}

.city-talent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.city-talent-header h3 {
  font-size: 14px;
  font-weight: 680;
}

.city-talent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.city-talent-table th,
.city-talent-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.city-talent-table th {
  background: var(--surface-2);
  font-weight: 680;
  font-size: 12px;
  white-space: nowrap;
}

.city-talent-table tbody tr:hover {
  background: rgba(51, 79, 141, 0.05);
}

.city-talent-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 4px;
  font-size: 13px;
}

.pager-btn {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0 4px;
  font-size: 13px;
}

.table-pager .pager-info {
  color: var(--ink-soft, #555);
}

.talent-tooltip {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  padding: 9px 10px;
}

.talent-tooltip::before {
  border-top-color: var(--ink);
}

.talent-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.talent-tooltip span {
  display: block;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  line-height: 1.45;
}

.city-label {
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #26312c;
  box-shadow: 0 4px 14px rgba(26, 34, 31, 0.16);
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 780;
}

.city-label::before {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading h2 {
  font-size: 17px;
  font-weight: 790;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.detail-panel {
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 16px;
  display: grid;
  gap: 13px;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.detail-top h3 {
  font-size: 22px;
  line-height: 1.14;
}

.detail-top p,
.detail-panel .muted {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
}

.country-pill {
  min-height: 27px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.country-pill.china {
  background: var(--china);
}

.country-pill.us {
  background: var(--us);
}

.country-pill.singapore { background: #d49a2e; }
.country-pill.uk { background: #4f6fa8; }
.country-pill.canada { background: #a6483a; }
.country-pill.switzerland { background: #8d5fb1; }
.country-pill.australia { background: #3a8a78; }
.country-pill.japan { background: #bd5a7a; }
.country-pill.germany { background: #5a6b7a; }
.country-pill.france { background: #3f73a1; }
.country-pill.korea { background: #c87c3e; }
.country-pill.hk { background: #d49a2e; }
.country-pill.other { background: #6b7480; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.detail-stat {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 10px;
}

.detail-stat b {
  display: block;
  margin-bottom: 6px;
  font-size: 24px;
  line-height: 1;
}

.detail-stat span {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 2px;
}

.rank-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.rank-item.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(29, 37, 44, 0.08);
}

.rank-line,
.rank-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rank-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-weight: 760;
}

.rank-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-index {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--surface-2);
  color: #3f4742;
  font-size: 11px;
}

.rank-value {
  color: var(--ink);
  font-weight: 780;
  white-space: nowrap;
}

.rank-meta {
  color: var(--muted);
  font-size: 12px;
}

.mini-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.mini-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

/* Module Navigation Tabs */
.module-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.module-tabs button svg {
  flex: 0 0 auto;
}

/* Module Content Areas */
.module-content {
  display: contents;
}

.module-content[hidden] {
  display: none;
}

/* Map module specific layout */
[data-module="map"] {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  height: 100%;
}

[data-module="map"] .topbar {
  grid-row: 1;
}

[data-module="map"] .map-toolbar {
  grid-row: 2;
}

[data-module="map"] .kpi-strip {
  grid-row: 3;
  padding: 12px 22px;
}

[data-module="map"] .map-hints {
  grid-row: 4;
}

[data-module="map"] .map-wrap {
  grid-row: 5;
}

[data-module="map"] .city-talent-list {
  grid-row: 6;
}

/* Statistics module specific layout */
[data-module="statistics"] {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  height: 100%;
}

[data-module="statistics"] .topbar {
  grid-row: 1;
}

[data-module="statistics"] .kpi-strip {
  grid-row: 2;
  padding: 12px 22px;
}

[data-module="statistics"] .stats-scope-hint {
  grid-row: 3;
  padding: 4px 22px 12px;
}

[data-module="statistics"] .statistics-grid {
  grid-row: 4;
  padding: 0 22px 22px;
  overflow: auto;
}

/* Talent list module specific layout */
[data-module="list"] {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100%;
}

[data-module="list"] .topbar {
  grid-row: 1;
}

[data-module="list"] .filter-panel {
  grid-row: 2;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

[data-module="list"] .table-container {
  grid-row: 3;
  padding: 12px 22px 22px;
  overflow: auto;
}

/* Filter Panel */
.filter-panel {
  display: grid;
  gap: 14px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-group {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.filter-label {
  color: #3d4741;
  font-size: 12px;
  font-weight: 680;
}

.filter-select,
.filter-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 0 10px;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 79, 141, 0.14);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.filter-actions button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 680;
  font-size: 13px;
}

.filter-actions .primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Table Container */
.table-container {
  display: grid;
  gap: 14px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.table-header h3 {
  font-size: 18px;
  font-weight: 780;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
}

.table-scroll {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  background: #fff;
}

.talent-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.talent-table th,
.talent-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  box-sizing: border-box;
  line-height: 1.45;
}

.talent-table th {
  background: var(--surface-2);
  font-weight: 680;
  font-size: 12px;
  color: #3d4741;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.talent-table tbody tr:hover {
  background: rgba(51, 79, 141, 0.05);
}

.talent-table .checkbox-cell {
  width: 40px;
  text-align: center;
}

.talent-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.talent-table .sortable {
  cursor: pointer;
  user-select: none;
}

.talent-table .sortable:hover {
  background: rgba(51, 79, 141, 0.1);
}

.talent-table .sortable::after {
  content: " ↕";
  opacity: 0.3;
  font-size: 10px;
}

.keywords-cell {
  /* Cell itself is a normal table-cell so the row's bottom border aligns with siblings.
     Inner wrapper handles the flex/wrap layout for keyword tags. */
  max-width: 280px;
}

.keywords-cell .keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.keyword-tag {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 2px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.metrics-cell {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.metrics-grid {
  display: grid;
  gap: 2px;
  align-content: center;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell .actions-row {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}

.action-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
}

.action-btn:hover {
  background: var(--surface-2);
}

.action-btn svg {
  width: 14px;
  height: 14px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}

.selection-info {
  color: var(--muted);
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

.bulk-action {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
}

.bulk-action:hover {
  background: var(--surface-2);
}

/* Statistics Module */
.statistics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  padding: 22px;
}

.chart-container {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 14px;
  font-weight: 760;
  margin-bottom: 16px;
}

.stats-scope-hint {
  padding: 8px 22px 0;
}

.d3-chart {
  width: 100%;
  min-height: 300px;
}

.word-cloud {
  min-height: 350px;
}

/* D3 Chart Styles */
.d3-bar {
  fill: var(--china);
  transition: fill 0.2s;
}

.d3-bar:hover {
  fill: #1a6666;
}

.d3-bar-us {
  fill: var(--us);
}

.d3-bar-us:hover {
  fill: #a34536;
}

.d3-axis text {
  font-size: 11px;
  fill: var(--muted);
}

.d3-axis line,
.d3-axis path {
  stroke: var(--line);
}

.d3-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.word-cloud text {
  cursor: pointer;
  transition: opacity 0.2s;
}

.word-cloud text:hover {
  opacity: 0.8;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  .app {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-columns: 330px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 430px);
  }

  .panel-heading {
    grid-column: 1 / -1;
  }

  .rank-list {
    max-height: 430px;
  }
}

@media (max-width: 860px) {
  .app {
    display: block;
  }

  .sidebar,
  .inspector {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar,
  .inspector,
  .topbar {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .legend {
    justify-content: flex-start;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 16px;
  }

  .map-wrap,
  #map {
    min-height: 520px;
  }

  .inspector {
    display: grid;
    gap: 16px;
  }
}

@media (max-width: 520px) {
  .segmented,
  .kpi-strip,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .segmented button {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .segmented button:last-child {
    border-bottom: 0;
  }

}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  margin: 0 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 780;
}

.modal-header .icon-button {
  width: 32px;
  height: 32px;
  background: var(--surface-2);
  color: var(--ink);
  border: 0;
}

.modal-header .icon-button:hover {
  background: var(--line);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: grid;
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-group label {
  font-size: 13px;
  font-weight: 680;
  color: #3d4741;
}

.form-group label .required {
  color: #c85b48;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 0 12px;
  font-size: 14px;
}

.form-group textarea {
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 79, 141, 0.14);
}

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

.form-section {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 680;
  color: var(--ink);
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-footer button {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 680;
  font-size: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.modal-footer button.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-content {
    margin: 0 10px;
  }
}

/* Sync Button Animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning svg {
  animation: spin 1s linear infinite;
}

/* Detail Modal Styles */
.detail-modal-content {
  max-width: 900px;
  max-height: 90vh;
}

.detail-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.detail-section h4 {
  font-size: 14px;
  font-weight: 760;
  color: var(--ink);
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.detail-header-row {
  display: flex;
  gap: 16px;
  align-items: start;
}

.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 780;
  flex-shrink: 0;
}

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

.detail-header-info h3 {
  font-size: 20px;
  font-weight: 780;
  margin: 0 0 4px 0;
}

.detail-header-info small {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
}

.detail-header-info p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 8px 0;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 680;
}

.status-badge.archived {
  background: var(--surface-2);
  color: var(--muted);
}

.status-badge.deleted {
  background: #ffebee;
  color: #c62828;
}

.status-badge.verify-idle {
  background: var(--surface-2);
  color: var(--muted);
}

.status-badge.verify-verifying {
  background: #e3f2fd;
  color: #1565c0;
}

.status-badge.verify-done {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-badge.verify-failed {
  background: #ffebee;
  color: #c62828;
}

.status-badge.verify-pending_approval {
  background: #fff3e0;
  color: #ef6c00;
}

.detail-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 680;
}

.detail-field span {
  font-size: 13px;
  color: var(--ink);
}

.detail-field a {
  color: var(--accent);
  text-decoration: none;
}

.detail-field a:hover {
  text-decoration: underline;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-badge {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
}

.detail-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
  white-space: pre-wrap;
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stat-card b {
  display: block;
  font-size: 20px;
  font-weight: 780;
  color: var(--ink);
  margin-bottom: 4px;
}

.stat-card span {
  font-size: 11px;
  color: var(--muted);
}

.change-history {
  display: grid;
  gap: 8px;
}

.change-item {
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.change-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.change-summary {
  font-size: 12px;
  color: var(--ink);
}

@media (max-width: 520px) {
  .detail-grid-2col {
    grid-template-columns: 1fr;
  }

  .detail-stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-content {
    margin: 0 10px;
  }
}

/* ===== AI Mining Entry Button ===== */
.mining-entry-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 680;
  transition: background 0.15s, border-color 0.15s;
}

.mining-entry-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.mining-entry-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.mining-entry-btn svg {
  flex-shrink: 0;
}

.mining-entry-btn .mining-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ===== AI Mining Module ===== */
.mining-panels {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.mining-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.mining-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--ink);
}

.mining-panel-title svg {
  color: var(--accent);
  flex-shrink: 0;
}

.mining-form .form-row {
  margin-bottom: 12px;
}

.mining-form .filter-actions {
  margin-top: 16px;
}

.mining-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.mining-status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.mining-status-badge.active {
  border-color: var(--accent);
  color: var(--accent);
}

.mining-status-badge.active .status-dot {
  background: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.mining-task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mining-task-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.mining-task-item:last-child {
  border-bottom: none;
}

.mining-task-item .task-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.mining-task-item .task-type {
  font-weight: 500;
  min-width: 40px;
  color: var(--accent);
}

.mining-task-item .task-progress {
  flex: 1;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mining-task-item .task-time {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}

.mining-task-item .task-cancel {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  color: var(--muted);
}

.mining-task-item .task-cancel:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

.mining-task-item.completed .task-progress {
  color: var(--muted);
}

.mining-task-item.failed .task-progress {
  color: #e74c3c;
}

.task-result-list {
  width: 100%;
  margin-top: 4px;
  padding: 8px 0 0;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-soft-delete {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-top: 1px dashed var(--line);
  border-left: 3px solid #c85b48;
  background: rgba(200, 91, 72, 0.06);
  border-radius: 4px;
}

.task-soft-delete strong {
  display: block;
  color: #c85b48;
  font-size: 13px;
  margin-bottom: 4px;
}

.task-soft-delete p {
  margin: 0 0 4px;
  font-size: 12px;
  color: #3d4741;
  line-height: 1.5;
}

.task-soft-delete .hint {
  margin: 4px 0 0;
  color: #6b7480;
  font-size: 11px;
}

.task-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
  padding: 3px 0;
}

.task-result-item .result-name {
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
}

.task-result-item .result-org {
  color: var(--muted);
  font-size: 11px;
}

.task-result-item .result-dir {
  color: var(--accent);
  font-size: 11px;
  margin-left: auto;
  text-align: right;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-result-item .result-check {
  flex-shrink: 0;
}

.verify-discovered-btn {
  margin-top: 8px;
  font-size: 12px;
  padding: 4px 12px;
}

.result-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.select-all-btn {
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

@keyframes spinning {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: spinning 1s linear infinite;
}

/* ===== Field (research domain) switch + badges ===== */
.field-tabs button[data-field="AI"].active {
  background: var(--accent);
}

.field-tabs button[data-field="Physics"].active {
  background: #6a4c93;
}

.field-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
  letter-spacing: 0.02em;
  color: #fff;
  background: #7a8189;
}

.field-badge.field-ai {
  background: var(--accent);
}

.field-badge.field-physics {
  background: #6a4c93;
}

.profile-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: #2e9e6b;
  vertical-align: middle;
}

/* ===== Expert profile (能力画像) ===== */
.profile-section h4 small {
  font-weight: 500;
  margin-left: 8px;
}

.profile-summary {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 10px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.source-links a {
  font-size: 12px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  text-decoration: none;
  background: #fff;
}

.source-links a:hover {
  border-color: var(--accent);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.profile-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.profile-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-block-title small {
  font-weight: 400;
}

.profile-value {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.profile-value small {
  font-weight: 400;
  color: var(--muted);
}

.conf-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e7e3da;
  color: #5a615d;
}

.conf-tag.high { background: #d9efe4; color: #1f6b4e; }
.conf-tag.mid { background: #fbecd0; color: #8a5a10; }
.conf-tag.low { background: #f6dcd7; color: #9a3a2c; }

.evidence-list {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.evidence-list li {
  margin: 2px 0;
}

.metric-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.metric-chips span {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
}

.metric-chips b {
  font-weight: 700;
}

.direction-row {
  margin-bottom: 8px;
}

.direction-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.direction-topic {
  font-weight: 600;
  flex: 1;
}

.direction-weight {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: #e6e1d6;
  overflow: hidden;
  margin: 4px 0;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* ===== Match module (专家匹配) ===== */
.match-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.match-form-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 12px;
}

.mining-form textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
  background: #fff;
  color: var(--ink);
}

.mining-form textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 79, 141, 0.14);
}

.weight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 4px;
}

.weight-grid label {
  display: grid;
  grid-template-columns: 72px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.weight-grid input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.weight-grid b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.match-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.match-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid #b8b2a6;
  border-radius: 10px;
  padding: 16px 18px;
}

.match-card.tier-A { border-left-color: #1f8f5f; }
.match-card.tier-B { border-left-color: #d49a2e; }
.match-card.tier-C { border-left-color: #b8b2a6; }

.match-card-head {
  display: grid;
  grid-template-columns: 44px 1fr 92px;
  gap: 12px;
  align-items: start;
}

.match-rank {
  font-size: 18px;
  font-weight: 800;
  color: var(--muted);
}

.match-who h3 {
  margin: 0 0 2px;
  font-size: 16px;
}

.match-who h3 small {
  font-weight: 400;
  color: var(--muted);
}

.match-who p {
  margin: 2px 0;
  font-size: 13px;
  color: var(--ink);
}

.match-total {
  text-align: right;
}

.match-total b {
  display: block;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
}

.match-total span {
  font-size: 11.5px;
  color: var(--muted);
}

.match-scores {
  margin: 12px 0 8px;
  display: grid;
  gap: 4px;
}

.score-row summary {
  list-style: none;
  display: grid;
  grid-template-columns: 76px 1fr 36px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}

.score-row summary::-webkit-details-marker {
  display: none;
}

.score-row .bar-track {
  margin: 0;
  height: 12px;
  background: #dfe5ef;
}

.score-row .bar-fill {
  background: #1d3f7a;
}

.score-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.score-row[open] summary .score-label {
  color: var(--accent);
}

.score-row .evidence-list {
  margin: 4px 0 6px 86px;
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.difficulty {
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
  background: #e7e3da;
}

.difficulty.高 { background: #f6dcd7; color: #9a3a2c; }
.difficulty.中 { background: #fbecd0; color: #8a5a10; }
.difficulty.低 { background: #d9efe4; color: #1f6b4e; }

.competing {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.match-summary-text {
  font-size: 13px;
  margin: 6px 0 8px;
}

.match-summary .need-parsed {
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.match-summary .summary-row {
  font-size: 12.5px;
  margin-bottom: 8px;
}

.tier-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tier {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: #e7e3da;
}

.tier.A { background: #d9efe4; color: #1f6b4e; }
.tier.B { background: #fbecd0; color: #8a5a10; }
.tier.C { background: #ece8df; color: #5a615d; }

.dist-block {
  margin-top: 10px;
}

.dist-row {
  display: grid;
  grid-template-columns: 120px 1fr 28px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 3px;
}

.dist-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-row .bar-track {
  margin: 0;
}

.keyword-tag.suggest {
  background: #efe6f7;
  color: #5b3d86;
}

.task-build-result {
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: 12px;
}

.task-build-result .result-src {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
}

.task-build-result .result-src.ok { background: #d9efe4; color: #1f6b4e; }
.task-build-result .result-src.miss { background: #f6dcd7; color: #9a3a2c; }

.task-build-result .result-dirs {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bulk-action-accent {
  border-color: var(--accent);
  color: var(--accent);
}

.highlight-row td {
  background: #fff7dc;
}

.match-mark {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e0a100;
  color: #fff;
  margin-left: 4px;
}

@media (max-width: 1100px) {
  .match-layout {
    grid-template-columns: 1fr;
  }

  .match-form-panel {
    position: static;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* Generic keyword-tag rows outside the table (profile / match / summary). */
.profile-block .keyword-tags,
.match-card .keyword-tags,
.match-summary .keyword-tags,
.result-dirs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin: 4px 0;
}

.city-label.selected {
  background: var(--ink);
  color: #fff;
}

/* City detail panel enrichment */
.detail-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-block {
  margin-top: 12px;
}

.detail-block-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 6px;
}

.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.detail-chip b {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

button.detail-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.detail-chip .field-badge {
  margin-left: 0;
  font-style: normal;
}

.detail-open-list {
  margin-top: 14px;
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}

.detail-open-list:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* City talent list (below the map) */
.city-talent-row {
  cursor: pointer;
}

.city-talent-row:hover td {
  background: var(--surface-2);
}

.city-talent-table th.num,
.city-talent-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted-inline {
  color: var(--muted);
  font-weight: 400;
}

/* Map hint strip (unresolved cities / active highlight) */
.map-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 10px;
}

.map-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
}

.map-hint.warn {
  background: #fbecd0;
  color: #8a5a10;
}

.map-hint.info {
  background: #fff3c4;
  color: #6b4d00;
}

.hint-btn {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

.hint-btn:disabled {
  opacity: 0.6;
}

.kpi b small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Ranking mode switch in the inspector */
.rank-tabs button {
  min-height: 32px;
  font-size: 12px;
}

.map-hint.filter {
  background: #e3ebf7;
  color: #24457f;
}

.talent-tooltip .tip-hint {
  opacity: 0.6;
  font-size: 11px;
}

/* Task process log */
.task-log {
  width: 100%;
  margin-top: 6px;
  font-size: 12px;
}

.task-log summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.task-log summary .err {
  color: #9a3a2c;
  font-weight: 600;
}

.task-log ol {
  margin: 6px 0 0;
  padding: 8px 10px;
  list-style: none;
  background: var(--surface-2);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.task-log li {
  display: grid;
  grid-template-columns: 44px 92px 1fr;
  gap: 8px;
  padding: 2px 0;
  line-height: 1.45;
  color: var(--ink);
}

.task-log li.err .log-msg {
  color: #9a3a2c;
  font-weight: 600;
}

.task-log li.warn .log-msg {
  color: #8a5a10;
}

.task-log .log-t {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.task-log .log-stage {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-log .log-msg {
  word-break: break-word;
}

/* ===== Sidebar redesign: field switch, nav list, overview, map toolbar ===== */
.field-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.field-switch button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
}

.field-switch button b {
  font-size: 13px;
  font-weight: 800;
}

.field-switch button small {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.field-switch button.active {
  color: #fff;
  border-color: transparent;
  background: var(--ink);
}

.field-switch button.active small {
  color: rgba(255, 255, 255, 0.75);
}

.field-switch button[data-field="AI"].active {
  background: var(--accent);
}

.field-switch button[data-field="Physics"].active {
  background: #6a4c93;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  position: relative;
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--muted);
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--ink);
  color: #fff;
}

.nav-item.active svg {
  color: #fff;
}

.nav-item .mining-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e0a100;
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.overview-grid div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
}

.overview-grid b {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.overview-grid span {
  font-size: 11px;
  color: var(--muted);
}

.link-button {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

.map-toolbar {
  display: flex;
  gap: 12px;
  padding: 12px 22px 0;
  align-items: end;
  background: #fbfaf7;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  min-width: 160px;
}

.toolbar-field.grow {
  flex: 1 1 auto;
}

.toolbar-field .search,
.toolbar-field .filter-select {
  width: 100%;
  min-height: 36px;
}

.rank-item[hidden] {
  display: none;
}

/* Mining module tabs */
.mining-tabs-bar {
  padding: 16px 20px 0;
}

.mining-tabs {
  max-width: 480px;
}

.mining-tabs button {
  min-height: 36px;
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e0a100;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

.mining-pane[hidden] {
  display: none;
}

.form-row.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-group label small {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.mining-form .filter-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.mining-form .filter-actions .hint {
  margin: 0;
  flex: 1 1 320px;
}

@media (max-width: 1100px) {
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===== Task list cards ===== */
.tasks-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.task-status-filter {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 320px;
}

.task-status-filter button {
  min-height: 32px;
  font-size: 12.5px;
}

.task-filters .filter-select {
  min-height: 32px;
  width: 140px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #b8b2a6;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}

.task-card[hidden] {
  display: none;
}

.task-card.status-running { border-left-color: var(--accent); }
.task-card.status-pending { border-left-color: #c9c2b4; }
.task-card.status-completed { border-left-color: #1f8f5f; }
.task-card.status-failed { border-left-color: #c85b48; }
.task-card.status-cancelled { border-left-color: #8a5a10; }

.task-card-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
}

.task-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ece8df;
  color: #5a615d;
  white-space: nowrap;
}

.task-status.running { background: #e3ebf7; color: #24457f; }
.task-status.completed { background: #d9efe4; color: #1f6b4e; }
.task-status.failed { background: #f6dcd7; color: #9a3a2c; }
.task-status.cancelled { background: #fbecd0; color: #8a5a10; }

.task-card .task-type {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.task-card .task-progress {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.task-card.status-failed .task-progress {
  color: #9a3a2c;
}

.task-card.status-completed .task-progress {
  color: var(--muted);
}

.task-card .task-time {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.task-card .task-cancel {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
}

.task-card .task-log {
  margin-top: 8px;
}

.task-card .task-result-list,
.task-card .task-build-result,
.task-card .task-soft-delete {
  margin-top: 8px;
}

.task-card .task-result-item {
  flex-wrap: wrap;
}

.task-card .verify-discovered-btn {
  align-self: flex-start;
  width: auto;
}

/* Logged-in user box in the sidebar */
.user-box {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.user-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 14px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-meta b {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  font-size: 11px;
  color: var(--muted);
}

.user-line .link-button {
  margin: 0;
}

.estimate-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fbecd0;
  color: #8a5a10;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
}

/* Long, messy employer strings must not blow up the city panel. */
.detail-chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tabbed talent detail — the modal used to be one long scroll.
   The modal body is a grid, so the tab strip needs its own height or the row
   collapses and the buttons overflow a 2px box (unclickable). */
.detail-tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  min-height: 36px;
  align-self: start;
  position: sticky;
  top: 0;
  z-index: 2;
}

.detail-tabs button {
  min-height: 34px;
  font-size: 12.5px;
}

.detail-tabs button small {
  font-weight: 500;
  opacity: 0.7;
}

.detail-tab-pane[hidden] {
  display: none;
}

/* Tabbed statistics charts */
.stats-tabs-bar {
  padding: 0 22px 10px;
}

.stats-tabs {
  max-width: 520px;
}

.stats-tabs button {
  min-height: 34px;
  font-size: 12.5px;
}

.stats-pane[hidden] {
  display: none;
}

.statistics-grid:has(.stats-pane) {
  grid-template-columns: minmax(0, 1fr);
}
