:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --brand: #1155cc;
  --brand-dark: #0b3f99;
  --border: #d9e1ef;
  --good-bg: #e9f8ef;
  --good: #087443;
  --warn-bg: #fff4e5;
  --warn: #9a5800;
  --bad-bg: #fff0f0;
  --bad: #b42318;
  --shadow: 0 18px 50px rgba(20, 35, 70, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #e8f0ff 0, transparent 30%), var(--bg);
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 22px;
}

.language-switch {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(20, 35, 70, .08);
}

.lang-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 13px;
  font-weight: 800;
  cursor: pointer;
}

.lang-button.active {
  background: var(--brand);
  color: #fff;
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: stretch;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  letter-spacing: .08em;
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05;
  margin-bottom: 16px;
}

h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.lead {
  max-width: 720px;
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 0;
}

.score-card {
  background: linear-gradient(145deg, var(--brand), #0a7ad8);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  outline: none;
  transition: transform .25s ease, box-shadow .25s ease;
}

.score-card strong {
  font-size: 72px;
  line-height: 1;
  margin: 8px 0;
}

.score-card.highlight {
  transform: translateY(-4px);
  box-shadow: 0 0 0 6px rgba(17, 85, 204, .18), var(--shadow);
}

.score-label,
#thresholdText {
  opacity: .9;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 24px;
}

.panel-heading {
  margin-bottom: 20px;
}

.panel-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

.sticky-panel {
  position: sticky;
  top: 16px;
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcff;
}

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

.field label {
  display: block;
  font-weight: 700;
  font-size: 16px;
}

.helper {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.field-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.points-preview {
  color: var(--brand);
  font-weight: 800;
  background: #edf4ff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.info-button {
  border: 1px solid #b8c4d9;
  background: #fff;
  color: var(--brand);
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.info-button:hover {
  background: #edf4ff;
}

select {
  width: 100%;
  border: 1px solid #b8c4d9;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  font-size: 16px;
  color: var(--text);
  outline: none;
}

select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(17, 85, 204, .12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  color: var(--text);
}

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

.button.primary:hover {
  background: var(--brand-dark);
}

.button.ghost:hover {
  background: #f2f5fb;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  background: var(--bad-bg);
  color: var(--bad);
  margin-bottom: 16px;
}

.status-badge.ok {
  background: var(--good-bg);
  color: var(--good);
}

.breakdown {
  display: grid;
  gap: 10px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.breakdown-row .name {
  color: var(--muted);
}

.breakdown-row .value {
  font-weight: 800;
}

.warnings {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.warning {
  padding: 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
}

.info-panel {
  margin-top: 24px;
  margin-bottom: 32px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.info-grid article {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fbfcff;
}

details {
  margin-top: 18px;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

code {
  background: #f0f3f9;
  border-radius: 6px;
  padding: 2px 5px;
}

.site-footer {
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #101828;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .55);
  padding: 24px;
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
  padding: 28px;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #f2f5fb;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-title {
  font-size: 28px;
  margin: 0 44px 10px 0;
}

.modal-summary {
  color: var(--muted);
  margin-bottom: 18px;
}

.modal-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

.modal-section ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}

.modal-links a {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
  color: var(--brand);
  background: #fbfcff;
}

.modal-links a:hover {
  background: #edf4ff;
}

@media (max-width: 900px) {
  .topbar {
    justify-content: flex-start;
  }

  .header-grid,
  .main-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
  }

  .score-card strong {
    font-size: 56px;
  }
}

@media (max-width: 640px) {
  .field-header {
    flex-direction: column;
  }

  .field-tools {
    flex-wrap: wrap;
  }

  .modal {
    padding: 22px;
  }

  .modal-title {
    font-size: 24px;
  }
}

@media print {
  .actions, .site-footer, .modal-backdrop, .info-button, .language-switch {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .panel, .score-card {
    box-shadow: none;
  }

  .main-grid, .header-grid, .info-grid {
    grid-template-columns: 1fr;
  }
}


.page-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(20, 35, 70, .06);
}

.page-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.reports-panel {
  margin-bottom: 32px;
}

.reports-heading {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.report-controls {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.report-controls label {
  font-weight: 800;
  color: var(--muted);
  font-size: 14px;
}

.report-note {
  padding: 14px 16px;
  border-radius: 14px;
  background: #edf4ff;
  color: #174ea6;
  border: 1px solid #cfe0ff;
  margin-bottom: 18px;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.report-stat {
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.report-stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.report-stat strong {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  margin-top: 4px;
}

.report-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.report-toolbar input {
  flex: 1;
  min-width: 220px;
  border: 1px solid #b8c4d9;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}

.report-toolbar input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(17, 85, 204, .12);
}

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

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.report-table th,
.report-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.report-table th {
  background: #f4f7fc;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.report-table tr:last-child td {
  border-bottom: 0;
}

.score-pill {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf4ff;
  color: var(--brand);
  font-weight: 900;
}

.no-data {
  color: var(--muted);
}

.round-list {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.report-sources {
  margin-top: 18px;
}

@media (max-width: 900px) {
  .reports-heading,
  .report-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .report-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .report-summary-grid {
    grid-template-columns: 1fr;
  }
}


.occupation-cell {
  display: block;
  min-width: 170px;
  max-width: 260px;
  white-space: normal;
  line-height: 1.35;
}

.occupation-zh {
  display: block;
}

.occupation-en {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.report-table td:first-child {
  min-width: 170px;
  max-width: 280px;
}


.shortage-table th:nth-child(1),
.shortage-table td:nth-child(1),
.shortage-table th:nth-child(2),
.shortage-table td:nth-child(2),
.shortage-table th:nth-child(6),
.shortage-table td:nth-child(6),
.shortage-table th:nth-child(7),
.shortage-table td:nth-child(7) {
  text-align: center;
  white-space: nowrap;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2ff;
  color: var(--brand);
  white-space: nowrap;
}

.rating-pill.s {
  background: var(--bad-bg);
  color: var(--bad);
}

.rating-pill.r,
.rating-pill.m {
  background: var(--warn-bg);
  color: var(--warn);
}

.rating-pill.ns {
  background: #f2f4f7;
  color: var(--muted);
}

.state-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 170px;
}

.state-tag {
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
  background: #f2f4f7;
  color: var(--muted);
}

.state-tag.s {
  background: var(--bad-bg);
  color: var(--bad);
}

.state-tag.r,
.state-tag.m {
  background: var(--warn-bg);
  color: var(--warn);
}

.shortage-method {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}


.column-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  margin-left: 6px;
  border: 1px solid #b8c4d9;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
  vertical-align: middle;
}

.column-info-button:hover,
.column-info-button:focus {
  background: #edf4ff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(17, 85, 204, .12);
}

.modal-action-button {
  margin-top: 18px;
}
