:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e0ea;
  --navy: #0f172a;
  --blue: #2563eb;
  --green: #16835f;
  --amber: #a15c07;
  --red: #b42318;
  --soft-blue: #eaf1ff;
  --soft-green: #e7f6ee;
  --soft-amber: #fff3da;
  --soft-red: #fde7e7;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    Arial,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.eyebrow {
  margin: 0 0 3px;
  color: #b9c6da;
  font-size: 12px;
}

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

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

main {
  display: grid;
  gap: 14px;
  padding: 14px;
  max-width: 980px;
  margin: 0 auto;
}

.icon-button,
.secondary-button,
.primary-button,
.tab,
.bottom-nav button,
.import-button,
.menu-list button,
.menu-list a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.app-header .icon-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.primary-button {
  border: 0;
  background: var(--blue);
  color: #fff;
  min-height: 48px;
  font-size: 16px;
}

.secondary-button {
  color: var(--blue);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.summary-card,
.quick-capture,
.tabs,
.view-section,
.settings-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 12px 10px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 2px;
  font-size: 23px;
}

.summary-card.good strong {
  color: var(--green);
}

.summary-card.watch strong {
  color: var(--blue);
}

.summary-card.risk strong {
  color: var(--amber);
}

.quick-capture {
  padding: 14px;
}

.capture-head,
.score-head,
.tool-row,
.candidate-top,
.candidate-meta,
.candidate-actions,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.capture-head p,
.score-head span,
.candidate-meta,
.candidate-note,
.dialog-note,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

input,
select {
  min-height: 44px;
  padding: 0 11px;
}

textarea {
  min-height: 82px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.wide {
  grid-column: 1 / -1;
}

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

.score-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.score-row {
  display: grid;
  gap: 8px;
}

.score-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #344054;
}

.score-label strong {
  color: var(--blue);
}

input[type="range"] {
  accent-color: var(--blue);
}

.live-verdict {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.live-verdict div {
  border-radius: 8px;
  padding: 12px;
  background: var(--soft-blue);
}

.live-verdict span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.live-verdict strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
}

.tab {
  border: 0;
  background: transparent;
}

.tab.active {
  background: var(--navy);
  color: #fff;
}

.view-section {
  padding: 14px;
}

.hidden {
  display: none;
}

.tool-row {
  align-items: stretch;
  margin-bottom: 12px;
}

.tool-row input {
  flex: 1;
}

.tool-row select {
  width: 138px;
}

.candidate-list,
.review-list {
  display: grid;
  gap: 10px;
}

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

.candidate-title {
  min-width: 0;
}

.candidate-title h3 {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.candidate-title p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.priority {
  background: var(--soft-green);
  color: var(--green);
}

.badge.watch {
  background: var(--soft-blue);
  color: var(--blue);
}

.badge.avoid {
  background: var(--soft-amber);
  color: var(--amber);
}

.badge.pass {
  background: var(--soft-red);
  color: var(--red);
}

.score-line {
  display: grid;
  grid-template-columns: 58px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.score-track {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf1f7;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.candidate-note {
  display: grid;
  gap: 7px;
  line-height: 1.5;
}

.candidate-actions {
  margin-top: 12px;
  justify-content: flex-start;
}

.candidate-actions button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.candidate-actions .danger {
  color: var(--red);
}

.checklist {
  line-height: 1.6;
}

.checklist h2 {
  margin-bottom: 8px;
}

.checklist ol {
  margin: 0;
  padding-left: 22px;
}

.checklist li + li {
  margin-top: 8px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.bottom-nav button,
.import-button {
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
}

.import-button input {
  display: none;
}

.settings-dialog {
  width: min(420px, calc(100vw - 28px));
  border: 0;
  padding: 14px;
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.menu-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.menu-list a,
.menu-list button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-list .danger {
  color: var(--red);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%) translateY(18px);
  max-width: min(420px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--navy);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty-state {
  text-align: center;
  padding: 34px 12px;
}

@media (min-width: 760px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 980px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 520px) {
  main {
    padding: 10px;
    gap: 10px;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .summary-card {
    padding: 10px 8px;
  }

  .summary-card strong {
    font-size: 21px;
  }

  .quick-capture,
  .view-section {
    padding: 12px;
  }

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

  .live-verdict {
    grid-template-columns: 1fr;
  }

  .tool-row {
    flex-direction: column;
  }

  .tool-row select {
    width: 100%;
  }
}
