:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #d9e0e8;
  --navy: #111827;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #be123c;
  --blue: #2563eb;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 14px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -14px 14px;
  padding: 14px 14px 12px;
  background: rgba(244, 246, 248, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(217, 224, 232, 0.8);
}

.topbar > div {
  flex: 1 1 auto;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

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

h1 {
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

.top-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.icon-link {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

button.icon-link {
  cursor: pointer;
}

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

.summary-card {
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

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

.summary-card strong {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.source-overview,
.priority-section,
.view-section {
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-head.compact {
  padding: 14px;
  margin-bottom: 8px;
}

.section-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.score-pill {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.tabs {
  position: sticky;
  top: 74px;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 -2px 14px;
  padding: 6px 2px;
  background: rgba(244, 246, 248, 0.94);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

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

.card-list {
  display: grid;
  gap: 10px;
}

.candidate-card,
.event-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.candidate-card,
.event-card {
  padding: 14px;
}

.empty-state {
  padding: 22px 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

.stock-title strong,
.event-title {
  display: block;
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stock-title span,
.event-meta,
.meta-line {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.score-box {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #eef6f5;
  color: var(--teal);
  font-weight: 900;
}

.score-box.warn {
  background: #fff7ed;
  color: var(--amber);
}

.score-box.hot {
  background: #fff1f2;
  color: var(--red);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.chip {
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chip.action {
  background: #ecfdf5;
  color: var(--teal);
}

.chip.watch {
  background: #fff7ed;
  color: var(--amber);
}

.chip.pass {
  background: #f1f5f9;
  color: var(--muted);
}

.chip.foreign {
  background: #e0f2fe;
  color: #075985;
}

.chip.domestic {
  background: #f1f5f9;
  color: #475569;
}

.body-text {
  color: #334155;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.evidence-list,
.risk-list,
.source-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.source-list.front {
  margin-top: 0;
}

.evidence-list a,
.event-link {
  color: var(--blue);
  text-decoration: none;
}

.evidence-list li,
.risk-list li,
.source-item {
  padding: 9px 10px;
  border: 1px solid #e6ebf1;
  border-radius: 8px;
  background: #fbfcfe;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.risk-list li {
  border-color: #fde2e2;
  background: #fff7f7;
  color: #9f1239;
}

.source-item {
  display: grid;
  gap: 4px;
}

.source-chips {
  margin: 2px 0 0;
}

.source-item.ok {
  border-color: #b8e3dd;
  background: #f0fdfa;
}

.source-item.error {
  border-color: #fecdd3;
  background: #fff1f2;
}

.source-item.disabled {
  color: var(--muted);
}

.source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.status {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.footer-note {
  margin-top: 18px;
  padding: 14px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.hidden {
  display: none;
}

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

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

@media (min-width: 640px) {
  .summary-band {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    margin-left: -18px;
    margin-right: -18px;
    padding-left: 18px;
    padding-right: 18px;
  }
}
