:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --danger: #dc2626;
  --warning-bg: rgba(220, 38, 38, 0.08);
  --good: #16a34a;
  --good-bg: rgba(22, 163, 74, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --space: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 20% -20%, rgba(37, 99, 235, 0.10), transparent 60%),
    radial-gradient(900px 600px at 90% 0%, rgba(22, 163, 74, 0.10), transparent 55%), var(--bg);
}

a {
  color: inherit;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(246, 247, 251, 0.75);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #22c55e);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}

.brand__text {
  min-width: 0;
}

.brand__title {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app {
  padding: 22px 0 72px;
}

.view {
  animation: fadeIn 180ms ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  padding: 34px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.70));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero__title {
  margin: 0;
  font-size: 40px;
  letter-spacing: -0.4px;
}

.hero__subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.hero__cta {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pagehead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin: 8px 0 16px;
}

.pagehead__title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.2px;
}

.pagehead__desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pagehead__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card__title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 750;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card__body {
  padding: 16px;
}

.highlight {
  border-color: rgba(37, 99, 235, 0.40);
  box-shadow: 0 14px 40px rgba(37, 99, 235, 0.12);
}

.prose {
  color: var(--muted);
  line-height: 1.7;
}

.prose ul {
  margin: 0;
  padding-left: 18px;
}

.muted {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 80ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.20);
}

.btn--primary:hover {
  background: linear-gradient(180deg, var(--primary-600), var(--primary-700));
  border-color: rgba(37, 99, 235, 0.60);
}

.btn--secondary {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.04);
}

.btn--secondary:hover {
  background: rgba(15, 23, 42, 0.06);
}

.btn--ghost {
  background: transparent;
}

.btn--ghost:hover {
  background: rgba(15, 23, 42, 0.05);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field--compact {
  margin-bottom: 10px;
}

.field__label {
  font-size: 13px;
  font-weight: 750;
}

.field__hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: box-shadow 140ms ease, border-color 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 86px;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.03);
  cursor: pointer;
  user-select: none;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.segmented__item input {
  margin: 0;
}

.segmented__item:has(input:checked) {
  background: rgba(37, 99, 235, 0.10);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.segmented__item:has(input:checked) span {
  color: var(--primary-700);
}

.weights {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

.weights__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.weights__title {
  font-size: 13px;
  font-weight: 750;
}

.pill {
  font-size: 12px;
  font-weight: 750;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
  color: var(--primary-700);
}

.weights__grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.weights__normalized {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.03);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.listings {
  display: grid;
  gap: 12px;
}

.listing {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(2, 6, 23, 0.01);
}

.listing__head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #16a34a;
  color: rgba(255, 255, 255, 0.92);
}

.listing__title {
  font-weight: 800;
  letter-spacing: -0.2px;
}

.listing__tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbtn {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  font-weight: 750;
  font-size: 12px;
}

.toolbtn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.toolbtn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.listing__body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.fields-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.details {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

details > summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--muted);
}

.actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: var(--warning-bg);
  color: #7f1d1d;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 12px;
}

.result-best {
  display: grid;
  gap: 10px;
}

.result-best__title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.score {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.6px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.03);
}

.tag--good {
  border-color: rgba(22, 163, 74, 0.28);
  background: var(--good-bg);
  color: #166534;
}

.tag--primary {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary-700);
}

.bars {
  display: grid;
  gap: 10px;
}

.bar {
  display: grid;
  grid-template-columns: 120px 1fr 52px;
  gap: 10px;
  align-items: center;
}

.bar__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.bar__track {
  height: 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #22c55e);
}

.bar__value {
  text-align: right;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.ranklist {
  display: grid;
  gap: 10px;
}

.rankcard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.rankcard--top {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.10);
}

.rankcard__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.rankcard__name {
  font-weight: 850;
}

.rankcard__meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rankcard__score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.rankcard__text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.risk {
  color: #7f1d1d;
  background: var(--warning-bg);
  border: 1px solid rgba(220, 38, 38, 0.20);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.6;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: rgba(15, 23, 42, 0.03);
  font-weight: 850;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 12px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.30);
  font-weight: 750;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 980px) {
  .grid--2 {
    grid-template-columns: 1fr;
  }
  .weights__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fields-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hero {
    padding: 22px;
  }
  .hero__title {
    font-size: 32px;
  }
}

@media (max-width: 520px) {
  .topbar__inner {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar__actions {
    display: flex;
    justify-content: flex-end;
  }
  .fields-grid {
    grid-template-columns: 1fr;
  }
  .pagehead {
    flex-direction: column;
    align-items: stretch;
  }
  .pagehead__actions {
    justify-content: flex-start;
  }
  .pagehead__actions .btn {
    width: 100%;
  }
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .actions .btn {
    width: 100%;
  }
  .segmented__item {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
  .listing__head {
    flex-direction: column;
    align-items: stretch;
  }
  .listing__tools {
    justify-content: flex-end;
  }
  .input,
  select,
  textarea {
    font-size: 16px;
  }
  .bar {
    grid-template-columns: 1fr;
  }
  .bar__value {
    text-align: left;
  }
  .toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}
