:root {
  color-scheme: light;
  --ink: #18252c;
  --muted: rgba(24, 37, 44, 0.62);
  --faint: rgba(24, 37, 44, 0.42);
  --line: rgba(24, 37, 44, 0.12);
  --line-strong: rgba(24, 37, 44, 0.2);
  --surface: #f3f7f2;
  --paper: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --brand: hsl(175 76% 33%);
  --brand-dark: hsl(175 76% 18%);
  --brand-soft: hsl(175 76% 33% / 0.14);
  --grade-a: var(--brand);
  --grade-b: hsl(172 52% 27%);
  --grade-c: hsl(190 38% 39%);
  --red: #b4282e;
  --gold: #bd9150;
  --green: #176f53;
  --amber: #9f6b18;
  --blue: #275d83;
  --shadow: 0 24px 70px rgba(31, 67, 73, 0.16);
  --soft-shadow: 0 16px 42px rgba(31, 67, 73, 0.1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(243, 247, 242, 0.86), #ffffff 48%),
    #ffffff;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang HK", "Noto Sans CJK TC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(45, 199, 189, 0.85);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(45, 199, 189, 0.12);
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
  position: relative;
  overflow-x: hidden;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.topbar {
  position: relative;
  z-index: 10;
}

.brand-hero {
  overflow: hidden;
  min-height: 216px;
  padding: max(30px, env(safe-area-inset-top)) 24px 24px;
  background: var(--brand);
  color: white;
  border-radius: 0 0 32px 32px;
}

.brand-hero::after {
  content: "DATA";
  position: absolute;
  right: -18px;
  top: 16px;
  color: rgba(255, 255, 255, 0.06);
  font-size: 112px;
  font-weight: 950;
  letter-spacing: 0.06em;
  line-height: 1;
  pointer-events: none;
}

.brand-nav {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-logo-image {
  display: block;
  width: 142px;
  max-width: min(46vw, 142px);
  height: auto;
}

.hero-copy {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  max-width: 340px;
}

.hero-copy .eyebrow {
  color: rgba(255, 255, 255, 0.74);
}

.hero-copy p:last-child {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.56;
}

.detail-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 14px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

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

h1 {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 780;
}

.icon-button,
.back-button {
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--ink);
  min-width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.favorite-button {
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.icon-button:active,
.back-button:active {
  transform: translateY(1px) scale(0.985);
}

.back-button {
  min-width: 40px;
  height: 40px;
  font-size: 32px;
  line-height: 1;
}

.favorite-count {
  position: absolute;
  right: -5px;
  top: -6px;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  background: var(--gold);
  color: white;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.view {
  display: none;
  padding: 16px 18px 30px;
  animation: enter 280ms ease both;
}

.view.active {
  display: block;
}

#listView {
  margin-top: -4px;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overview {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--line);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--soft-shadow);
}

.insights-strip + .overview {
  margin-top: 12px;
}

.overview > div {
  background: var(--glass-strong);
  padding: 16px 12px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.overview strong {
  font-size: 27px;
  line-height: 1;
}

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

.filter-group {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 1px 4px;
  scrollbar-width: none;
}

.filter-group::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  min-height: 38px;
  border-radius: 999px;
  padding: 0 15px;
  white-space: nowrap;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.filter-pill.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 12px 28px rgba(45, 199, 189, 0.2);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 12px;
}

.section-head h2,
.insights-strip h2 {
  font-size: 19px;
  line-height: 1.2;
}

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

.section-head span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.lead-list {
  display: grid;
  gap: 12px;
}

.lead-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  border-radius: 18px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86), 0 14px 34px rgba(31, 67, 73, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.lead-card:active {
  transform: translateY(1px) scale(0.985);
}

.lead-card:hover {
  border-color: rgba(45, 199, 189, 0.34);
  box-shadow: var(--soft-shadow);
}

.lead-main,
.recommend-row,
.script-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lead-main h3 {
  font-size: 17px;
  line-height: 1.25;
}

.lead-main p,
.lead-reason,
.signal-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.lead-main p {
  margin-top: 4px;
}

.grade-badge,
.profile-score span {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  font-weight: 850;
}

.grade-A {
  background: var(--grade-a);
}

.grade-B {
  background: var(--grade-b);
}

.grade-C {
  background: var(--grade-c);
}

.recommend-row {
  margin-top: 14px;
  color: var(--ink);
  font-size: 14px;
}

.recommend-row strong {
  color: var(--brand);
  white-space: nowrap;
}

.lead-reason {
  margin-top: 9px;
}

.signal-line {
  margin-top: 8px;
  color: var(--green);
}

.pagination {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  margin: 16px 0 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 12px 30px rgba(31, 67, 73, 0.06);
}

.page-button,
.page-number {
  border: 0;
  background: transparent;
  color: var(--ink);
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  font-weight: 850;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.page-button {
  display: inline-grid;
  place-items: center;
  background: rgba(24, 37, 44, 0.06);
  font-size: 24px;
  line-height: 1;
}

.page-button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 34px;
}

.page-number {
  min-width: 32px;
  height: 32px;
  font-size: 13px;
}

.page-number.active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: white;
}

.page-gap {
  color: var(--muted);
  font-size: 13px;
  min-width: 8px;
  text-align: center;
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.page-size select {
  border: 0;
  border-radius: 999px;
  background: rgba(24, 37, 44, 0.06);
  color: var(--ink);
  height: 32px;
  padding: 0 9px;
  font-weight: 780;
}

.insights-strip {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(189, 145, 80, 0.28);
  background: linear-gradient(135deg, rgba(255, 250, 240, 0.96), rgba(255, 255, 255, 0.86));
  padding: 16px;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.insights-strip strong {
  color: var(--gold);
  font-size: 24px;
  white-space: nowrap;
}

.detail-view {
  padding-top: 14px;
}

.profile-panel,
.content-section {
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82), 0 12px 32px rgba(31, 67, 73, 0.07);
}

.profile-panel {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 16px;
  align-items: center;
}

.profile-score {
  min-height: 88px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--brand-soft), rgba(255, 255, 255, 0.9));
  border: 1px solid rgba(45, 199, 189, 0.24);
}

.profile-score strong {
  font-size: 20px;
}

.profile-panel h3,
.content-section h3 {
  font-size: 18px;
  line-height: 1.25;
}

.profile-panel p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.tag-row,
.signal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag-row span,
.signal-list span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  min-height: 30px;
  padding: 6px 10px;
  color: var(--ink);
  font-size: 12px;
}

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

.gap-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.56);
}

.gap-item strong,
.gap-item span {
  display: block;
}

.gap-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.gap-item p {
  font-weight: 850;
  white-space: nowrap;
}

.gap-item.missing {
  border-color: rgba(180, 40, 46, 0.28);
  background: rgba(255, 247, 247, 0.88);
}

.gap-item.missing p {
  color: var(--red);
}

.script-section {
  margin-bottom: 30px;
}

.primary-button,
.utility-button {
  border: 0;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 15px;
  font-weight: 780;
}

.primary-button {
  background: var(--brand);
  color: white;
  box-shadow: 0 14px 30px rgba(45, 199, 189, 0.2);
}

.utility-button {
  background: rgba(24, 37, 44, 0.08);
  color: var(--ink);
}

.utility-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.script-output {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  padding: 14px;
}

.script-output.empty {
  color: var(--muted);
  font-size: 14px;
}

.script-output article + article {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.script-output h4 {
  color: var(--brand);
  font-size: 13px;
  margin-bottom: 7px;
}

.script-output p {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.62;
}

.script-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.favorites-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(24, 37, 44, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.favorites-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.favorites-card {
  position: absolute;
  inset: auto 0 0 0;
  max-height: 78vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 18px;
  transform: translateY(20px);
  transition: transform 200ms ease;
  box-shadow: 0 -24px 70px rgba(24, 37, 44, 0.18);
}

.favorites-panel.open .favorites-card {
  transform: translateY(0);
}

.favorites-card > header,
.favorite-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.favorite-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.favorite-item h3 {
  font-size: 16px;
}

.favorite-item header p,
.favorite-item > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.favorite-item > p {
  margin-top: 10px;
  white-space: pre-line;
}

.favorite-item > div {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  z-index: 80;
  opacity: 0;
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 360px) {
  .brand-hero {
    padding-left: 18px;
    padding-right: 18px;
  }

  h1 {
    font-size: 30px;
  }

  .view {
    padding-left: 14px;
    padding-right: 14px;
  }

  .script-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (min-width: 760px) {
  body {
    padding: 24px 0;
  }

  .app-shell {
    min-height: calc(100vh - 48px);
    border-radius: 24px;
    overflow: hidden;
  }

  .favorites-card {
    width: min(430px, 100%);
    left: 50%;
    right: auto;
    transform: translate(-50%, 20px);
  }

  .favorites-panel.open .favorites-card {
    transform: translate(-50%, 0);
  }
}
