:root {
  --bg: #f3f6f1;
  --bg-soft: #e9efe8;
  --card: #ffffff;
  --ink: #17221c;
  --muted: #66756c;
  --line: #dce5dc;
  --green: #126a4f;
  --green-2: #2c946d;
  --green-soft: #e6f3ec;
  --orange: #e4772e;
  --orange-soft: #fff0e4;
  --red: #c94b41;
  --red-soft: #fdecea;
  --blue: #346fa8;
  --shadow: 0 14px 38px rgba(31, 58, 43, .08);
  --shadow-soft: 0 8px 22px rgba(31, 58, 43, .06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(47, 150, 108, .16), transparent 34%),
    radial-gradient(circle at 96% 2%, rgba(234, 139, 69, .12), transparent 30%),
    var(--bg);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--green); }
.hidden { display: none !important; }

.page-shell { max-width: 1220px; margin: 0 auto; padding: 18px clamp(14px, 3vw, 34px) 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 8px 0 20px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, #167855, #47a378);
  box-shadow: 0 9px 22px rgba(18, 106, 79, .2); flex: 0 0 auto;
}
.brand-mark svg { width: 34px; height: 34px; }
.brand h1 { margin: 0; font-size: clamp(20px, 2.2vw, 28px); line-height: 1.1; letter-spacing: -.03em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.button, .icon-button {
  border: 0; border-radius: 13px; cursor: pointer; transition: transform .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.button:active, .icon-button:active { transform: scale(.97); }
.button { padding: 10px 15px; font-weight: 700; font-size: 14px; }
.button.primary { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(18, 106, 79, .18); }
.button.primary:hover { background: #0c5d44; }
.button.secondary { color: var(--ink); background: #edf1ed; }
.button.ghost { color: var(--green); background: rgba(255,255,255,.75); border: 1px solid var(--line); }
.button.ghost:hover { background: white; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; background: rgba(255,255,255,.82); border: 1px solid var(--line); }
.icon-button svg { width: 22px; height: 22px; }

.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.75); border: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.status-pill.live { color: var(--green); background: var(--green-soft); border-color: #cbe6d8; }
.status-pill.muted { color: #7c6a5c; background: #f8f1ea; border-color: #ebded2; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #25a36f; box-shadow: 0 0 0 4px rgba(37,163,111,.12); }

.market-switch {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 7px;
  border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.72); box-shadow: var(--shadow-soft); margin-bottom: 14px;
}
.market-option {
  text-align: left; border: 0; border-radius: 15px; padding: 13px 16px; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.market-option:hover { background: #f5f8f5; }
.market-option.active { color: white; background: linear-gradient(135deg, #126a4f, #318d68); box-shadow: 0 9px 22px rgba(18,106,79,.16); }
.market-name { font-weight: 800; font-size: 15px; }
.market-meta { font-size: 12px; opacity: .72; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 15px 17px; margin: 0 0 14px; border-radius: 18px; color: #78441f; background: var(--orange-soft); border: 1px solid #f2d4ba; line-height: 1.55; }
.notice strong { white-space: nowrap; }
.notice span { color: #8f6547; font-size: 13px; }

.card { background: var(--card); border: 1px solid rgba(213,225,214,.95); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr); gap: 14px; margin-bottom: 14px; }
.hero-card { padding: clamp(20px, 3vw, 30px); min-height: 290px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.hero-card::after { content: ""; position: absolute; width: 210px; height: 210px; right: -70px; bottom: -95px; border-radius: 50%; background: radial-gradient(circle, rgba(44,148,109,.16), transparent 70%); pointer-events: none; }
.hero-topline, .section-heading { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.eyebrow { display: block; color: var(--green); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.hero-card h2, .section-heading h3, .modal-head h2 { margin: 0; letter-spacing: -.025em; }
.hero-card h2 { font-size: clamp(21px, 2.3vw, 28px); }
.quality-badge { display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 800; white-space: nowrap; }
.quality-badge.low { color: #9c4d22; background: var(--orange-soft); }
.hero-price-row { display: flex; align-items: flex-end; gap: 18px; margin: 27px 0 5px; flex-wrap: wrap; }
.hero-price { display: flex; align-items: baseline; gap: 7px; }
.hero-price span { font-size: clamp(42px, 7vw, 72px); font-weight: 900; line-height: .92; letter-spacing: -.055em; color: var(--green); font-variant-numeric: tabular-nums; }
.hero-price small { color: var(--muted); font-size: 15px; font-weight: 700; }
.change-block { display: inline-flex; align-items: center; gap: 5px; padding: 8px 10px; border-radius: 12px; background: #f1f5f1; font-size: 13px; font-weight: 800; }
.change-block.up { color: var(--red); background: var(--red-soft); }
.change-block.down { color: var(--green); background: var(--green-soft); }
.change-block.steady { color: var(--muted); background: #f0f3f0; }
.change-arrow { font-size: 18px; line-height: 1; }
.hero-meta { color: var(--muted); font-size: 13px; line-height: 1.65; max-width: 620px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 22px; }
.tag { padding: 6px 9px; border-radius: 999px; background: #f1f5f1; color: #53675b; font-size: 12px; font-weight: 700; }
.tag.warn { color: #925126; background: var(--orange-soft); }

.forecast-strip-card { padding: 22px; display: flex; flex-direction: column; }
.section-heading h3 { font-size: clamp(18px, 2vw, 23px); }
.section-heading.compact h3 { font-size: 19px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: #eef2ee; }
.segmented button { border: 0; border-radius: 8px; padding: 6px 10px; background: transparent; color: var(--muted); font-weight: 800; font-size: 12px; cursor: pointer; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 3px 8px rgba(32,60,44,.08); }
.forecast-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; margin-top: 21px; }
.forecast-day { padding: 10px 5px; border-radius: 14px; text-align: center; background: #f7f9f7; min-width: 0; }
.forecast-day.today { background: var(--green-soft); }
.forecast-day .day { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.forecast-day .arrow { display: block; font-size: 21px; line-height: 1.05; color: var(--green); }
.forecast-day .arrow.up { color: var(--red); }
.forecast-day .arrow.down { color: var(--green); }
.forecast-day .value { display: block; margin-top: 6px; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.confidence-line { margin-top: auto; padding-top: 21px; }
.confidence-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.confidence-label strong { color: var(--ink); }
.confidence-track { height: 7px; overflow: hidden; border-radius: 99px; background: #e9eeea; }
.confidence-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #e69a49, #2b956b); transition: width .45s ease; }

.chart-card, .list-card, .data-notes { padding: clamp(18px, 3vw, 28px); margin-bottom: 14px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 13px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 20px; height: 3px; border-radius: 2px; background: var(--green); }
.legend-line.forecast { background: var(--orange); }
.legend-band { display: inline-block; width: 20px; height: 10px; border-radius: 4px; background: rgba(228,119,46,.18); }
.chart-stage { position: relative; height: 350px; margin-top: 16px; }
#priceChart { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.chart-tooltip { position: absolute; pointer-events: none; min-width: 150px; max-width: 220px; padding: 10px 12px; border-radius: 13px; background: rgba(22,34,28,.92); color: white; font-size: 12px; line-height: 1.55; box-shadow: 0 12px 30px rgba(0,0,0,.18); transform: translate(-50%, -112%); z-index: 3; }
.chart-tooltip strong { display: block; margin-bottom: 2px; }
.chart-footnote { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 8px; }

.list-heading { align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; width: min(270px, 42vw); padding: 9px 12px; border-radius: 13px; background: #f5f7f5; border: 1px solid transparent; }
.search-box:focus-within { border-color: #b9d8c8; background: white; }
.search-box svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 16px; }
.category-chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: white; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.category-chip.active { color: white; background: var(--green); border-color: var(--green); }
.variety-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.variety-card { position: relative; display: flex; flex-direction: column; min-height: 154px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, #fff, #fbfcfb); text-align: left; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.variety-card:hover { transform: translateY(-2px); border-color: #b7d5c5; box-shadow: var(--shadow-soft); }
.variety-card.active { border-color: var(--green); box-shadow: 0 0 0 3px rgba(18,106,79,.1), var(--shadow-soft); }
.variety-card.stale { opacity: .72; }
.variety-card .variety-name { font-size: 15px; font-weight: 900; }
.variety-card .variety-price { margin-top: 8px; color: var(--green); font-size: 20px; font-weight: 900; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.variety-card .variety-price small { color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 3px; }
.variety-card .variety-delta { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 800; }
.variety-card .variety-delta.up { color: var(--red); }
.variety-card .variety-delta.down { color: var(--green); }
.sparkline { width: 100%; height: 38px; margin-top: auto; }
.sparkline path.line { fill: none; stroke: var(--green); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline path.fill { fill: rgba(44,148,109,.09); stroke: none; }
.variety-status { position: absolute; top: 11px; right: 11px; padding: 4px 6px; border-radius: 8px; background: #f0f4f0; color: var(--muted); font-size: 10px; font-weight: 800; }
.variety-status.active { color: var(--green); background: var(--green-soft); }
.variety-status.reference { color: #97532b; background: var(--orange-soft); }

.empty-state { padding: 40px 10px; text-align: center; color: var(--muted); }
.notes-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.notes-grid > div { padding: 15px; border-radius: 17px; background: #f7f9f7; }
.notes-grid strong { display: block; margin-bottom: 7px; font-size: 14px; }
.notes-grid p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.footer { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); padding: 17px 5px 0; font-size: 12px; }

.modal { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 24px; background: transparent; overflow: visible; }
.modal::backdrop { background: rgba(20,31,25,.48); backdrop-filter: blur(4px); }
.modal-card { max-height: calc(100vh - 30px); overflow: auto; padding: 24px; border-radius: 24px; background: white; box-shadow: 0 28px 90px rgba(13,32,22,.28); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.close-button { font-size: 25px; line-height: 1; }
.form-grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 11px 12px; outline: 0; color: var(--ink); background: #fbfcfb; }
input:focus, select:focus, textarea:focus { border-color: #8ebea5; box-shadow: 0 0 0 3px rgba(44,148,109,.09); }
textarea { resize: vertical; line-height: 1.65; }
.full-label { margin-top: 12px; }
.parse-preview { margin-top: 12px; padding: 13px; border-radius: 14px; color: var(--muted); background: #f4f7f4; font-size: 12px; line-height: 1.65; max-height: 190px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .ghost { margin-right: auto; }

@media (max-width: 980px) {
  .overview-grid { grid-template-columns: 1fr; }
  .variety-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .page-shell { padding: 12px 12px 26px; }
  .topbar { align-items: flex-start; }
  .brand p { display: none; }
  .top-actions .ghost:first-child { display: none; }
  .market-switch { grid-template-columns: 1fr; }
  .market-option { padding: 11px 13px; }
  .status-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  .status-pill { flex: 0 0 auto; }
  .hero-card { min-height: 260px; }
  .hero-price span { font-size: 52px; }
  .forecast-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .forecast-day:nth-child(n+5) { display: none; }
  .chart-stage { height: 300px; }
  .chart-legend { display: none; }
  .list-heading { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .variety-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .variety-card { min-height: 148px; }
  .notes-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
  .form-grid.two { grid-template-columns: 1fr; }
  .modal-card { padding: 20px 16px; }
  .modal-actions .ghost { width: 100%; margin-right: 0; }
}

@media (max-width: 420px) {
  .top-actions .ghost { padding: 9px 11px; font-size: 12px; }
  .hero-price-row { gap: 10px; }
  .hero-price span { font-size: 46px; }
  .forecast-strip-card { padding: 18px; }
  .forecast-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .forecast-day:nth-child(n+4) { display: none; }
}

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: min(520px, calc(100vw - 28px)); padding: 12px 16px; border-radius: 14px; color: white; background: rgba(22,34,28,.94); box-shadow: 0 14px 38px rgba(0,0,0,.2); transform: translateX(-50%); font-size: 13px; line-height: 1.5; }
.toast.hidden { display: none; }
.login-card { max-width: 520px; }
.login-copy { color: var(--muted); font-size: 13px; line-height: 1.7; margin: -4px 0 18px; }
.login-card label + label { margin-top: 12px; }
.login-message { min-height: 22px; margin-top: 12px; color: var(--red); font-size: 12px; line-height: 1.55; }
.login-actions { align-items: center; }
.login-actions .ghost { margin-right: auto; }
.cloud-ok { color: var(--green) !important; background: var(--green-soft) !important; border-color: #cbe6d8 !important; }
.cloud-warn { color: #8c572f !important; background: var(--orange-soft) !important; border-color: #f2d4ba !important; }


