:root {
  --ink: #14212b;
  --muted: #697986;
  --line: #dbe3e7;
  --paper: #ffffff;
  --canvas: #eef2f4;
  --navy: #0d1b2a;
  --teal: #087f73;
  --teal-soft: #e7f5f2;
  --green: #187a4e;
  --green-soft: #eaf7ef;
  --red: #b43643;
  --red-soft: #ffedf0;
  --amber: #a86414;
  --amber-soft: #fff4df;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
  background: var(--canvas);
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)),
    var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--teal);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(11px + env(safe-area-inset-top)) 14px 11px;
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 6px 20px rgba(13, 27, 42, 0.16);
}

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

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #16897d;
  border-radius: 11px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
  letter-spacing: 0.06em;
}

.brand p {
  margin: 1px 0 0;
  color: #aebdca;
  font-size: 10px;
}

.connection {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #b7c6d2;
  font-size: 9px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.connection.online .dot {
  background: #4bd5a2;
}

.connection.error .dot {
  background: #ff7180;
}

#app {
  width: min(100% - 24px, 760px);
  margin: 0 auto;
  padding: 18px 0 28px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
  background: rgba(13, 27, 42, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  min-height: 55px;
  display: grid;
  place-content: center;
  gap: 1px;
  color: #aebdca;
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-size: 10px;
}

.bottom-nav button span {
  font-family: Georgia, "Songti SC", serif;
  font-size: 18px;
  line-height: 1.1;
}

.bottom-nav button.active {
  color: #ffffff;
  background: rgba(56, 185, 168, 0.18);
}

.footer {
  width: min(100% - 24px, 760px);
  margin: 0 auto;
  padding: 16px 0 8px;
  color: #7a8995;
  border-top: 1px solid #d4dee3;
  font-size: 9px;
}

.page-head {
  margin-bottom: 15px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.page-head h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 29px;
  line-height: 1.25;
}

.page-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.stamp {
  margin-top: 7px;
  color: #82909b;
  font-size: 9px;
}

.card {
  background: var(--paper);
  border: 1px solid #dbe4e8;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(13, 35, 51, 0.055);
}

.pad {
  padding: 16px;
}

.mood {
  position: relative;
  overflow: hidden;
  padding: 18px;
  color: #ffffff;
  background: #15283b;
}

.mood::after {
  content: "";
  position: absolute;
  top: -90px;
  right: -90px;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 40px rgba(255, 255, 255, 0.025);
}

.mood small {
  color: #aab9c6;
}

.mood h3 {
  position: relative;
  z-index: 1;
  margin: 4px 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 26px;
}

.mood p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #c5d1da;
  font-size: 11px;
}

.source-chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px;
}

.source-chip {
  padding: 4px 7px;
  color: #a9b8c5;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  font-size: 8px;
}

.source-chip.ok {
  color: #a5e4cc;
}

.source-chip.fail {
  color: #ffb1ba;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 0 9px;
}

.section-head h3 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

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

.index-card {
  padding: 13px;
}

.index-card .name {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.index-card strong {
  display: block;
  margin-top: 4px;
  font-family: Georgia, serif;
  font-size: 21px;
}

.index-card span {
  font-size: 11px;
  font-weight: 700;
}

.up {
  color: var(--red) !important;
}

.down {
  color: var(--green) !important;
}

.flat {
  color: var(--muted) !important;
}

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

.macro-card {
  padding: 13px;
  border-top: 3px solid var(--amber);
}

.macro-card.good {
  border-top-color: var(--green);
}

.macro-card.bad {
  border-top-color: var(--red);
}

.macro-card span {
  color: var(--muted);
  font-size: 10px;
}

.macro-card strong {
  display: block;
  margin: 3px 0;
  font-family: Georgia, serif;
  font-size: 21px;
}

.macro-card p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.news-list {
  overflow: hidden;
  border-radius: var(--radius);
}

.news-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #ffffff;
  border-bottom: 1px solid #edf1f3;
  text-decoration: none;
}

.news-item:last-child {
  border-bottom: 0;
}

.news-item h4 {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.news-item p {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta {
  margin-top: 4px;
  color: #8795a1;
  font-size: 8px;
}

.sentiment {
  height: 20px;
  padding: 2px 6px;
  border-radius: 99px;
  font-size: 8px;
  white-space: nowrap;
}

.sentiment.good {
  color: var(--green);
  background: var(--green-soft);
}

.sentiment.bad {
  color: var(--red);
  background: var(--red-soft);
}

.sentiment.neutral {
  color: #755b31;
  background: #f4ede1;
}

.button {
  min-height: 42px;
  padding: 9px 13px;
  color: #ffffff;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
}

.button.secondary {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.button:disabled {
  opacity: 0.55;
}

.full {
  width: 100%;
}

.stack {
  display: grid;
  gap: 12px;
}

.form-card {
  padding: 15px;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 4px;
}

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

.field label {
  color: #526473;
  font-size: 10px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 9px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #ccd8df;
  border-radius: 9px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 115, 0.1);
}

.toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #506272;
  font-size: 11px;
}

.toggle input {
  width: 17px;
  height: 17px;
}

.notice {
  padding: 10px 12px;
  color: #74531d;
  background: var(--amber-soft);
  border: 1px solid #ecdbb9;
  border-radius: 10px;
  font-size: 9px;
}

.info {
  padding: 12px;
  color: #506272;
  background: #f4f7f8;
  border: 1px solid #e0e8ec;
  border-radius: 10px;
  font-size: 9px;
}

.loading,
.empty,
.error {
  min-height: 280px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.loading h2,
.empty strong,
.error h3 {
  margin: 12px 0 2px;
  font-size: 19px;
}

.loading p,
.empty span,
.error p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #dbe5e8;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.result-head strong {
  font-size: 15px;
}

.result-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.badge {
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 8px;
  white-space: nowrap;
}

.stock-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

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

.stock-head h3 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
}

.stock-head h3 small {
  margin-left: 4px;
  color: var(--muted);
  font-family: sans-serif;
  font-size: 9px;
  font-weight: 400;
}

.price {
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
}

.score {
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 700;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mini-grid > div {
  min-width: 0;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.mini-grid > div:nth-child(2n) {
  border-right: 0;
}

.mini-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.mini-grid span,
.mini-grid small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-grid strong {
  display: block;
  margin: 2px 0;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history {
  padding: 10px;
  background: #f1f8f6;
  border: 1px solid #d4e9e4;
  border-radius: 10px;
}

.history-title {
  display: flex;
  justify-content: space-between;
  color: #35665e;
  font-size: 9px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.history-grid > div {
  padding: 7px;
  background: #ffffff;
  border-radius: 7px;
}

.history-grid span,
.history-grid small {
  display: block;
  color: var(--muted);
  font-size: 7px;
}

.history-grid strong {
  display: block;
  margin: 2px 0;
  font-family: Georgia, serif;
  font-size: 17px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chips span {
  padding: 3px 6px;
  color: #0e7367;
  background: var(--teal-soft);
  border-radius: 5px;
  font-size: 8px;
}

.risk {
  padding: 7px 9px;
  color: #8f3440;
  background: var(--red-soft);
  border-radius: 7px;
  font-size: 8px;
}

.risk.clear {
  color: #37735a;
  background: var(--green-soft);
}

.rule-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.rule-guide div {
  padding: 9px;
  background: #f5f8f8;
  border-radius: 8px;
}

.rule-guide b {
  display: block;
  color: var(--teal);
  font-family: Georgia, serif;
  font-size: 17px;
}

.rule-guide strong {
  display: block;
  font-size: 10px;
}

.rule-guide p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 8px;
}

.rule-list {
  display: grid;
  gap: 5px;
}

.rule {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: start;
  padding: 7px;
  border-radius: 7px;
  background: #f4f7f8;
}

.rule.passed {
  background: var(--green-soft);
}

.rule.failed {
  background: var(--red-soft);
}

.rule b {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #7d919e;
  border-radius: 5px;
  font-family: Georgia, serif;
  font-size: 9px;
}

.rule.passed b {
  background: var(--green);
}

.rule.failed b {
  background: var(--red);
}

.rule strong {
  display: block;
  font-size: 9px;
}

.rule p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 7px;
}

.rule > span {
  color: var(--muted);
  font-size: 7px;
}

.rule.passed > span {
  color: var(--green);
}

.rule.failed > span {
  color: var(--red);
}

.search-row {
  display: flex;
  gap: 7px;
}

.search-row input {
  min-width: 0;
  flex: 1;
  height: 42px;
  padding: 0 10px;
  border: 1px solid #ccd8df;
  border-radius: 9px;
  outline: none;
}

.detail-hero {
  padding: 18px;
  color: #ffffff;
  background: #15283b;
}

.detail-hero h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 28px;
}

.detail-hero .price {
  margin: 8px 0;
  font-size: 32px;
}

.detail-hero .price span {
  margin-left: 8px;
  font-family: sans-serif;
  font-size: 13px;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.detail-stats span {
  padding: 4px 7px;
  color: #c3d0d9;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  font-size: 8px;
}

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

.metric {
  padding: 11px;
}

.metric span {
  color: var(--muted);
  font-size: 9px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 18px;
}

.chart-card {
  padding: 13px;
}

.chart-card h3 {
  margin: 0 0 4px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
}

.chart-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 8px;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid-line {
  stroke: #e8edef;
  stroke-width: 1;
}

.chart .axis {
  fill: #8896a1;
  font-size: 8px;
}

.chart .line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-detail {
  padding: 12px;
  background: #f3faf8;
  border: 1px solid #d4e8e3;
}

.history-detail h3 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 18px;
}

.history-detail .note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 8px;
}

.error {
  color: #7e2832;
  background: #fff0f2;
  border: 1px solid #efc9cf;
  border-radius: var(--radius);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 40px);
  padding: 9px 13px;
  color: #ffffff;
  background: #263b49;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: 0.2s ease;
  font-size: 10px;
}

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