:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2b6cb0; --accent-soft: #e6effa; --up: #d23b3b; --down: #1f8a4c;
  --warn-bg: #fff6e0; --warn: #9a6400; --bad-bg: #fde8e8; --bad: #b42323; --good-bg: #e5f6ec; --good: #1d7a45;
  --tag: #eef0f4; --shadow: 0 1px 2px rgba(20, 30, 50, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2029; --text: #e7eaf0; --muted: #98a1b3; --line: #2b313d;
    --accent: #6ea8ff; --accent-soft: #1d2a40; --up: #ff6b6b; --down: #4cc38a;
    --warn-bg: #3a2f14; --warn: #f2c25c; --bad-bg: #3d1c1c; --bad: #ff8a8a; --good-bg: #163323; --good: #6fdc9f;
    --tag: #262c37; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 8px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
header h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; min-width: 0; }
header .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 420px) { header .date { display: none; } }
.datebar { color: var(--muted); font-size: 12px; margin: -4px 0 8px; }
.icon-btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; }
main { padding: 12px 16px 96px; max-width: 760px; margin: 0 auto; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; min-width: 0; border: 0; background: none; color: var(--muted); padding: 8px 0 10px; font-size: 11px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
nav.tabs button .ico { display: block; font-size: 19px; line-height: 1.2; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.grid2 > * { min-width: 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 18px; font-weight: 600; }
.up { color: var(--up); } .down { color: var(--down); }
.tag { display: inline-block; background: var(--tag); border-radius: 6px; padding: 0 6px; font-size: 12px; color: var(--muted); }
.tag.large { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag.new { background: var(--good-bg); color: var(--good); }
.tag.ok { background: var(--good-bg); color: var(--good); }
.pick { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.pick:first-child { border-top: 0; }
.pick .main { flex: 1; min-width: 0; }
.pick .name { font-weight: 600; }
.pick .why { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pick .right { text-align: right; white-space: nowrap; }
.bar { height: 6px; background: var(--tag); border-radius: 3px; overflow: hidden; margin-top: 4px; width: 64px; margin-left: auto; }
.bar i { display: block; height: 100%; background: var(--accent); }
.note { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad, .note.sell { background: var(--bad-bg); color: var(--bad); }
.note.good { background: var(--good-bg); color: var(--good); }
.note.info { background: var(--accent-soft); color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 15px; cursor: pointer; width: 100%; }
button.primary:disabled { opacity: .5; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
label.field { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
input[type=date] { -webkit-appearance: none; appearance: none; min-height: 40px; text-align: left; }
input, select { width: 100%; min-width: 0; max-width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font-size: 15px; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.scroll-x { overflow-x: auto; }
.tip { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--muted); color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; flex: none; font-style: normal; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; display: none; max-width: 760px; margin: 0 auto; }
.sheet h3 { margin: 0 0 8px; font-size: 17px; }
.sheet .ex { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 14px; }
.show { display: block !important; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: none; padding: 7px; color: var(--text); cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }
svg.chart { width: 100%; height: 180px; display: block; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 12px; }
.legend i { display: inline-block; width: 10px; height: 3px; vertical-align: middle; margin-right: 4px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 1s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
.tour { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .55); display: none; align-items: center; justify-content: center; padding: 16px; }
.tour .box { background: var(--card); border-radius: 14px; padding: 18px; max-width: 420px; width: 100%; }
.tour .steps { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.verdict { font-size: 12px; }
.chartbox { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.chartbox .xh { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); display: none; pointer-events: none; }
.chartbox .dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; border: 2px solid var(--card); display: none; pointer-events: none; }
.chartbox .ctip { position: absolute; top: 4px; display: none; pointer-events: none; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; line-height: 1.5; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 2; }
.chartbox .ctip i { display: inline-block; width: 8px; height: 3px; vertical-align: middle; margin-right: 4px; }
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; margin-top: 2px; display: none; max-height: 280px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.ac-list div { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ac-list div:last-child { border-bottom: 0; }
